OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Arguments with prefixes ('--', '-', and on Windows, '/') are switches. | 6 // Arguments with prefixes ('--', '-', and on Windows, '/') are switches. |
7 // Switches will precede all other arguments without switch prefixes. | 7 // Switches will precede all other arguments without switch prefixes. |
8 // Switches can optionally have values, delimited by '=', e.g., "-switch=value". | 8 // Switches can optionally have values, delimited by '=', e.g., "-switch=value". |
9 // An argument of "--" will terminate switch parsing during initialization, | 9 // An argument of "--" will terminate switch parsing during initialization, |
10 // interpreting subsequent tokens as non-switch arguments, regardless of prefix. | 10 // interpreting subsequent tokens as non-switch arguments, regardless of prefix. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // you want to reset the base library to its initial state (for example, in an | 65 // you want to reset the base library to its initial state (for example, in an |
66 // outer library that needs to be able to terminate, and be re-initialized). | 66 // outer library that needs to be able to terminate, and be re-initialized). |
67 // If Init is called only once, as in main(), Reset() is not necessary. | 67 // If Init is called only once, as in main(), Reset() is not necessary. |
68 static void Reset(); | 68 static void Reset(); |
69 | 69 |
70 // Get the singleton CommandLine representing the current process's | 70 // Get the singleton CommandLine representing the current process's |
71 // command line. Note: returned value is mutable, but not thread safe; | 71 // command line. Note: returned value is mutable, but not thread safe; |
72 // only mutate if you know what you're doing! | 72 // only mutate if you know what you're doing! |
73 static CommandLine* ForCurrentProcess(); | 73 static CommandLine* ForCurrentProcess(); |
74 | 74 |
| 75 // Returns true if the CommandLine has been initialized for the given process. |
| 76 static bool InitializedForCurrentProcess(); |
| 77 |
75 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
76 static CommandLine FromString(const std::wstring& command_line); | 79 static CommandLine FromString(const std::wstring& command_line); |
77 #endif | 80 #endif |
78 | 81 |
79 // Initialize from an argv vector. | 82 // Initialize from an argv vector. |
80 void InitFromArgv(int argc, const CharType* const* argv); | 83 void InitFromArgv(int argc, const CharType* const* argv); |
81 void InitFromArgv(const StringVector& argv); | 84 void InitFromArgv(const StringVector& argv); |
82 | 85 |
83 // Constructs and returns the represented command line string. | 86 // Constructs and returns the represented command line string. |
84 // CAUTION! This should be avoided on POSIX because quoting behavior is | 87 // CAUTION! This should be avoided on POSIX because quoting behavior is |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 StringVector argv_; | 169 StringVector argv_; |
167 | 170 |
168 // Parsed-out switch keys and values. | 171 // Parsed-out switch keys and values. |
169 SwitchMap switches_; | 172 SwitchMap switches_; |
170 | 173 |
171 // The index after the program and switches, any arguments start here. | 174 // The index after the program and switches, any arguments start here. |
172 size_t begin_args_; | 175 size_t begin_args_; |
173 }; | 176 }; |
174 | 177 |
175 #endif // BASE_COMMAND_LINE_H_ | 178 #endif // BASE_COMMAND_LINE_H_ |
OLD | NEW |