OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This class works with command lines: building and parsing. | 5 // This class works with command lines: building and parsing. |
6 // Switches can optionally have a value attached using an equals sign, as in | 6 // Switches can optionally have a value attached using an equals sign, as in |
7 // "-switch=value". Arguments that aren't prefixed with a switch prefix are | 7 // "-switch=value". Arguments that aren't prefixed with a switch prefix are |
8 // saved as extra arguments. An argument of "--" will terminate switch parsing, | 8 // saved as extra arguments. An argument of "--" will terminate switch parsing, |
9 // causing everything after to be considered as extra arguments. | 9 // causing everything after to be considered as extra arguments. |
10 | 10 |
11 // There is a singleton read-only CommandLine that represents the command line | 11 // There is a singleton read-only CommandLine that represents the command line |
12 // that the current process was started with. It must be initialized in main(). | 12 // that the current process was started with. It must be initialized in main(). |
13 | 13 |
14 #ifndef BASE_COMMAND_LINE_H_ | 14 #ifndef BASE_COMMAND_LINE_H_ |
15 #define BASE_COMMAND_LINE_H_ | 15 #define BASE_COMMAND_LINE_H_ |
16 #pragma once | 16 #pragma once |
17 | 17 |
18 #include <map> | 18 #include <map> |
19 #include <string> | 19 #include <string> |
20 #include <vector> | 20 #include <vector> |
21 | 21 |
| 22 #include "base/base_api.h" |
22 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
24 | 25 |
25 class FilePath; | 26 class FilePath; |
26 | 27 |
27 class CommandLine { | 28 class BASE_API CommandLine { |
28 public: | 29 public: |
29 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
30 // The native command line string type. | 31 // The native command line string type. |
31 typedef std::wstring StringType; | 32 typedef std::wstring StringType; |
32 #elif defined(OS_POSIX) | 33 #elif defined(OS_POSIX) |
33 typedef std::string StringType; | 34 typedef std::string StringType; |
34 #endif | 35 #endif |
35 | 36 |
36 typedef std::vector<StringType> StringVector; | 37 typedef std::vector<StringType> StringVector; |
37 // The type of map for parsed-out switch key and values. | 38 // The type of map for parsed-out switch key and values. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // Non-switch command line arguments. | 174 // Non-switch command line arguments. |
174 StringVector args_; | 175 StringVector args_; |
175 | 176 |
176 // Allow the copy constructor. A common pattern is to copy the current | 177 // Allow the copy constructor. A common pattern is to copy the current |
177 // process's command line and then add some flags to it. For example: | 178 // process's command line and then add some flags to it. For example: |
178 // CommandLine cl(*CommandLine::ForCurrentProcess()); | 179 // CommandLine cl(*CommandLine::ForCurrentProcess()); |
179 // cl.AppendSwitch(...); | 180 // cl.AppendSwitch(...); |
180 }; | 181 }; |
181 | 182 |
182 #endif // BASE_COMMAND_LINE_H_ | 183 #endif // BASE_COMMAND_LINE_H_ |
OLD | NEW |