| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
| 73 static CommandLine FromString(const std::wstring& command_line); | 73 static CommandLine FromString(const std::wstring& command_line); |
| 74 #endif | 74 #endif |
| 75 | 75 |
| 76 // Initialize from an argv vector. | 76 // Initialize from an argv vector. |
| 77 void InitFromArgv(int argc, const CharType* const* argv); | 77 void InitFromArgv(int argc, const CharType* const* argv); |
| 78 void InitFromArgv(const StringVector& argv); | 78 void InitFromArgv(const StringVector& argv); |
| 79 | 79 |
| 80 // Constructs and returns the represented command line string. | 80 // Constructs and returns the represented command line string. |
| 81 // CAUTION! This should be avoided because quoting behavior is unclear. | 81 // CAUTION! This should be avoided because quoting behavior is unclear. |
| 82 // TODO(msw): Rename GetCommandLineString. | 82 StringType GetCommandLineString() const; |
| 83 StringType command_line_string() const; | |
| 84 | 83 |
| 85 // Returns the original command line string as a vector of strings. | 84 // Returns the original command line string as a vector of strings. |
| 86 const StringVector& argv() const { return argv_; } | 85 const StringVector& argv() const { return argv_; } |
| 87 | 86 |
| 88 // Get and Set the program part of the command line string (the first item). | 87 // Get and Set the program part of the command line string (the first item). |
| 89 FilePath GetProgram() const; | 88 FilePath GetProgram() const; |
| 90 void SetProgram(const FilePath& program); | 89 void SetProgram(const FilePath& program); |
| 91 | 90 |
| 92 // Returns true if this command line contains the given switch. | 91 // Returns true if this command line contains the given switch. |
| 93 // (Switch names are case-insensitive). | 92 // (Switch names are case-insensitive). |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 StringVector argv_; | 156 StringVector argv_; |
| 158 | 157 |
| 159 // Parsed-out switch keys and values. | 158 // Parsed-out switch keys and values. |
| 160 SwitchMap switches_; | 159 SwitchMap switches_; |
| 161 | 160 |
| 162 // The index after the program and switches, any arguments start here. | 161 // The index after the program and switches, any arguments start here. |
| 163 size_t begin_args_; | 162 size_t begin_args_; |
| 164 }; | 163 }; |
| 165 | 164 |
| 166 #endif // BASE_COMMAND_LINE_H_ | 165 #endif // BASE_COMMAND_LINE_H_ |
| OLD | NEW |