OLD | NEW |
| (Empty) |
1 // Copyright 2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 #ifndef OMAHA_BASE_COMMAND_LINE_PARSER_INTERNAL_H_ | |
17 #define OMAHA_BASE_COMMAND_LINE_PARSER_INTERNAL_H_ | |
18 | |
19 #include <windows.h> | |
20 #include <map> | |
21 #include <vector> | |
22 | |
23 namespace omaha { | |
24 | |
25 namespace internal { | |
26 | |
27 // Repository for switches and corresponding switch arguments for a command | |
28 // line. | |
29 class CommandLineParserArgs { | |
30 public: | |
31 CommandLineParserArgs() {} | |
32 ~CommandLineParserArgs() {} | |
33 | |
34 typedef std::vector<CString> StringVector; | |
35 typedef StringVector::const_iterator StringVectorIter; | |
36 typedef std::map<CString, StringVector > SwitchAndArgumentsMap; | |
37 typedef SwitchAndArgumentsMap::const_iterator SwitchAndArgumentsMapIter; | |
38 | |
39 // Gets the number of switches in the parsed command line. Will return 0 for | |
40 // count if a parse has not occurred. | |
41 int GetSwitchCount() const; | |
42 | |
43 // Returns the switch at a particular index. | |
44 // This is meant for iteration only and is not guaranteed to be in the order | |
45 // of the switches in the parsed command line. | |
46 HRESULT GetSwitchNameAtIndex(int index, CString* switch_name) const; | |
47 | |
48 // Returns true if a switch with the name switch_name is found. | |
49 bool HasSwitch(const CString& switch_name) const; | |
50 | |
51 // Returns the number of arguments for switch_name. Will fail if switch_name | |
52 // is not a valid switch. | |
53 HRESULT GetSwitchArgumentCount(const CString& switch_name, int* count) const; | |
54 | |
55 // Returns the value of a switch argument at the specified offset. | |
56 // Fails if switch_name is not a valid switch. | |
57 HRESULT GetSwitchArgumentValue(const CString& switch_name, | |
58 int argument_index, | |
59 CString* argument_value) const; | |
60 | |
61 void Reset(); | |
62 HRESULT AddSwitch(const CString& switch_name); | |
63 HRESULT AddSwitchArgument(const CString& switch_name, | |
64 const CString& argument_value); | |
65 | |
66 private: | |
67 SwitchAndArgumentsMap switch_arguments_; | |
68 | |
69 DISALLOW_EVIL_CONSTRUCTORS(CommandLineParserArgs); | |
70 }; | |
71 | |
72 } // namespace internal | |
73 | |
74 } // namespace omaha | |
75 | |
76 #endif // OMAHA_BASE_COMMAND_LINE_PARSER_INTERNAL_H_ | |
77 | |
OLD | NEW |