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! | |
133 void AppendSwitchPath(const std::string& switch_string, const FilePath& path); | 132 void AppendSwitchPath(const std::string& switch_string, const FilePath& path); |
134 void AppendSwitchNative(const std::string& switch_string, | 133 void AppendSwitchNative(const std::string& switch_string, |
135 const StringType& value); | 134 const StringType& value); |
136 void AppendSwitchASCII(const std::string& switch_string, | 135 void AppendSwitchASCII(const std::string& switch_string, |
137 const std::string& value); | 136 const std::string& value); |
138 void AppendSwitches(const CommandLine& other); | |
139 | 137 |
140 // Append an argument to the command line. | 138 // Append an argument to the command line. |
141 // Note on quoting: the argument will be quoted properly such that it is | 139 // Note on quoting: the argument will be quoted properly such that it is |
142 // interpreted as one argument to the target command. | 140 // interpreted as one argument to the target command. |
143 // AppendArg is primarily for ASCII; non-ASCII input will be | 141 // AppendArg is primarily for ASCII; non-ASCII input will be |
144 // interpreted as UTF-8. | 142 // interpreted as UTF-8. |
145 void AppendArg(const std::string& value); | 143 void AppendArg(const std::string& value); |
146 void AppendArgPath(const FilePath& value); | 144 void AppendArgPath(const FilePath& value); |
147 void AppendArgNative(const StringType& value); | 145 void AppendArgNative(const StringType& value); |
148 void AppendArgs(const CommandLine& other); | |
149 | 146 |
150 // Append the arguments from another command line to this one. | 147 // Append the arguments from another command line to this one. |
151 // If |include_program| is true, include |other|'s program as well. | 148 // If |include_program| is true, include |other|'s program as well. |
152 void AppendArguments(const CommandLine& other, | 149 void AppendArguments(const CommandLine& other, |
153 bool include_program); | 150 bool include_program); |
154 | 151 |
155 // Insert a command before the current command. Common for debuggers, | 152 // Insert a command before the current command. Common for debuggers, |
156 // like "valgrind" or "gdb --args". | 153 // like "valgrind" or "gdb --args". |
157 void PrependWrapper(const StringType& wrapper); | 154 void PrependWrapper(const StringType& wrapper); |
158 | 155 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 std::vector<StringType> args_; | 196 std::vector<StringType> args_; |
200 | 197 |
201 // We allow copy constructors, because a common pattern is to grab a | 198 // We allow copy constructors, because a common pattern is to grab a |
202 // copy of the current process's command line and then add some | 199 // copy of the current process's command line and then add some |
203 // flags to it. E.g.: | 200 // flags to it. E.g.: |
204 // CommandLine cl(*CommandLine::ForCurrentProcess()); | 201 // CommandLine cl(*CommandLine::ForCurrentProcess()); |
205 // cl.AppendSwitch(...); | 202 // cl.AppendSwitch(...); |
206 }; | 203 }; |
207 | 204 |
208 #endif // BASE_COMMAND_LINE_H_ | 205 #endif // BASE_COMMAND_LINE_H_ |
OLD | NEW |