| 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 // 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 // Construct a new command line from an argument list. | 49 // Construct a new command line from an argument list. |
| 50 CommandLine(int argc, const CharType* const* argv); | 50 CommandLine(int argc, const CharType* const* argv); |
| 51 explicit CommandLine(const StringVector& argv); | 51 explicit CommandLine(const StringVector& argv); |
| 52 | 52 |
| 53 ~CommandLine(); | 53 ~CommandLine(); |
| 54 | 54 |
| 55 // Initialize the current process CommandLine singleton. On Windows, ignores | 55 // Initialize the current process CommandLine singleton. On Windows, ignores |
| 56 // its arguments (we instead parse GetCommandLineW() directly) because we | 56 // its arguments (we instead parse GetCommandLineW() directly) because we |
| 57 // don't trust the CRT's parsing of the command line, but it still must be | 57 // don't trust the CRT's parsing of the command line, but it still must be |
| 58 // called to set up the command line. | 58 // called to set up the command line. Returns false if initialization has |
| 59 static void Init(int argc, const char* const* argv); | 59 // already occurred, and true otherwise. Only the caller receiving a 'true' |
| 60 // return value should take responsibility for calling Reset. |
| 61 static bool Init(int argc, const char* const* argv); |
| 60 | 62 |
| 61 // Destroys the current process CommandLine singleton. This is necessary if | 63 // Destroys the current process CommandLine singleton. This is necessary if |
| 62 // you want to reset the base library to its initial state (for example, in an | 64 // you want to reset the base library to its initial state (for example, in an |
| 63 // outer library that needs to be able to terminate, and be re-initialized). | 65 // outer library that needs to be able to terminate, and be re-initialized). |
| 64 // If Init is called only once, as in main(), Reset() is not necessary. | 66 // If Init is called only once, as in main(), Reset() is not necessary. |
| 65 static void Reset(); | 67 static void Reset(); |
| 66 | 68 |
| 67 // Get the singleton CommandLine representing the current process's | 69 // Get the singleton CommandLine representing the current process's |
| 68 // command line. Note: returned value is mutable, but not thread safe; | 70 // command line. Note: returned value is mutable, but not thread safe; |
| 69 // only mutate if you know what you're doing! | 71 // only mutate if you know what you're doing! |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 StringVector argv_; | 158 StringVector argv_; |
| 157 | 159 |
| 158 // Parsed-out switch keys and values. | 160 // Parsed-out switch keys and values. |
| 159 SwitchMap switches_; | 161 SwitchMap switches_; |
| 160 | 162 |
| 161 // The index after the program and switches, any arguments start here. | 163 // The index after the program and switches, any arguments start here. |
| 162 size_t begin_args_; | 164 size_t begin_args_; |
| 163 }; | 165 }; |
| 164 | 166 |
| 165 #endif // BASE_COMMAND_LINE_H_ | 167 #endif // BASE_COMMAND_LINE_H_ |
| OLD | NEW |