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, | 6 // Switches can optionally have a value attached using an equals sign, |
7 // as in "-switch=value". Arguments that aren't prefixed with a | 7 // as in "-switch=value". Arguments that aren't prefixed with a |
8 // switch prefix are saved as extra arguments. An argument of "--" | 8 // switch prefix are saved as extra arguments. An argument of "--" |
9 // will terminate switch parsing, causing everything after to be | 9 // will terminate switch parsing, causing everything after to be |
10 // considered as extra arguments. | 10 // considered as extra arguments. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 std::string command_line_string() const; | 122 std::string command_line_string() const; |
123 #endif | 123 #endif |
124 | 124 |
125 // Returns the program part of the command line string (the first item). | 125 // Returns the program part of the command line string (the first item). |
126 FilePath GetProgram() const; | 126 FilePath GetProgram() const; |
127 | 127 |
128 // Append a switch to the command line. | 128 // Append a switch to the command line. |
129 void AppendSwitch(const std::string& switch_string); | 129 void AppendSwitch(const std::string& switch_string); |
130 | 130 |
131 // Append a switch and value to the command line. | 131 // Append a switch and value to the command line. |
| 132 // CAUTION! Appending a switch after the "--" kSwitchTerminator is futile! |
132 void AppendSwitchPath(const std::string& switch_string, const FilePath& path); | 133 void AppendSwitchPath(const std::string& switch_string, const FilePath& path); |
133 void AppendSwitchNative(const std::string& switch_string, | 134 void AppendSwitchNative(const std::string& switch_string, |
134 const StringType& value); | 135 const StringType& value); |
135 void AppendSwitchASCII(const std::string& switch_string, | 136 void AppendSwitchASCII(const std::string& switch_string, |
136 const std::string& value); | 137 const std::string& value); |
| 138 void AppendSwitches(const CommandLine& other); |
137 | 139 |
138 // Append an argument to the command line. | 140 // Append an argument to the command line. |
139 // Note on quoting: the argument will be quoted properly such that it is | 141 // Note on quoting: the argument will be quoted properly such that it is |
140 // interpreted as one argument to the target command. | 142 // interpreted as one argument to the target command. |
141 // AppendArg is primarily for ASCII; non-ASCII input will be | 143 // AppendArg is primarily for ASCII; non-ASCII input will be |
142 // interpreted as UTF-8. | 144 // interpreted as UTF-8. |
143 void AppendArg(const std::string& value); | 145 void AppendArg(const std::string& value); |
144 void AppendArgPath(const FilePath& value); | 146 void AppendArgPath(const FilePath& value); |
145 void AppendArgNative(const StringType& value); | 147 void AppendArgNative(const StringType& value); |
| 148 void AppendArgs(const CommandLine& other); |
146 | 149 |
147 // Append the arguments from another command line to this one. | 150 // Append the arguments from another command line to this one. |
148 // If |include_program| is true, include |other|'s program as well. | 151 // If |include_program| is true, include |other|'s program as well. |
149 void AppendArguments(const CommandLine& other, | 152 void AppendArguments(const CommandLine& other, |
150 bool include_program); | 153 bool include_program); |
151 | 154 |
152 // Insert a command before the current command. Common for debuggers, | 155 // Insert a command before the current command. Common for debuggers, |
153 // like "valgrind" or "gdb --args". | 156 // like "valgrind" or "gdb --args". |
154 void PrependWrapper(const StringType& wrapper); | 157 void PrependWrapper(const StringType& wrapper); |
155 | 158 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 std::vector<StringType> args_; | 199 std::vector<StringType> args_; |
197 | 200 |
198 // We allow copy constructors, because a common pattern is to grab a | 201 // We allow copy constructors, because a common pattern is to grab a |
199 // copy of the current process's command line and then add some | 202 // copy of the current process's command line and then add some |
200 // flags to it. E.g.: | 203 // flags to it. E.g.: |
201 // CommandLine cl(*CommandLine::ForCurrentProcess()); | 204 // CommandLine cl(*CommandLine::ForCurrentProcess()); |
202 // cl.AppendSwitch(...); | 205 // cl.AppendSwitch(...); |
203 }; | 206 }; |
204 | 207 |
205 #endif // BASE_COMMAND_LINE_H_ | 208 #endif // BASE_COMMAND_LINE_H_ |
OLD | NEW |