OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 considered "loose parameters". Switch names are | 8 // switch prefix are considered "loose parameters". Switch names are |
9 // case-insensitive. An argument of "--" will terminate switch | 9 // case-insensitive. An argument of "--" will terminate switch |
10 // parsing, causing everything after to be considered as loose | 10 // parsing, causing everything after to be considered as loose |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "base/logging.h" | 28 #include "base/logging.h" |
29 #include "base/string_util.h" | 29 #include "base/string_util.h" |
30 | 30 |
31 class InProcessBrowserTest; | 31 class InProcessBrowserTest; |
32 | 32 |
33 class CommandLine { | 33 class CommandLine { |
34 public: | 34 public: |
35 // A constructor for CommandLines that are used only to carry arguments. | 35 // A constructor for CommandLines that are used only to carry arguments. |
36 enum ArgumentsOnly { ARGUMENTS_ONLY }; | 36 enum ArgumentsOnly { ARGUMENTS_ONLY }; |
37 explicit CommandLine(ArgumentsOnly args_only); | 37 explicit CommandLine(ArgumentsOnly args_only); |
| 38 ~CommandLine(); |
38 | 39 |
39 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
40 // The type of native command line arguments. | 41 // The type of native command line arguments. |
41 typedef std::wstring StringType; | 42 typedef std::wstring StringType; |
42 | 43 |
43 // Initialize by parsing the given command-line string. | 44 // Initialize by parsing the given command-line string. |
44 // The program name is assumed to be the first item in the string. | 45 // The program name is assumed to be the first item in the string. |
45 void ParseFromString(const std::wstring& command_line); | 46 void ParseFromString(const std::wstring& command_line); |
46 static CommandLine FromString(const std::wstring& command_line) { | 47 static CommandLine FromString(const std::wstring& command_line) { |
47 CommandLine cmd; | 48 CommandLine cmd; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 void AppendArguments(const CommandLine& other, | 197 void AppendArguments(const CommandLine& other, |
197 bool include_program); | 198 bool include_program); |
198 | 199 |
199 // On POSIX systems it's common to run processes via a wrapper (like | 200 // On POSIX systems it's common to run processes via a wrapper (like |
200 // "valgrind" or "gdb --args"). | 201 // "valgrind" or "gdb --args"). |
201 void PrependWrapper(const std::wstring& wrapper); | 202 void PrependWrapper(const std::wstring& wrapper); |
202 | 203 |
203 private: | 204 private: |
204 friend class InProcessBrowserTest; | 205 friend class InProcessBrowserTest; |
205 | 206 |
206 CommandLine() {} | 207 CommandLine(); |
207 | 208 |
208 // Used by InProcessBrowserTest. | 209 // Used by InProcessBrowserTest. |
209 static CommandLine* ForCurrentProcessMutable() { | 210 static CommandLine* ForCurrentProcessMutable() { |
210 DCHECK(current_process_commandline_); | 211 DCHECK(current_process_commandline_); |
211 return current_process_commandline_; | 212 return current_process_commandline_; |
212 } | 213 } |
213 | 214 |
214 // The singleton CommandLine instance representing the current process's | 215 // The singleton CommandLine instance representing the current process's |
215 // command line. | 216 // command line. |
216 static CommandLine* current_process_commandline_; | 217 static CommandLine* current_process_commandline_; |
(...skipping 24 matching lines...) Expand all Loading... |
241 std::vector<StringType> loose_values_; | 242 std::vector<StringType> loose_values_; |
242 | 243 |
243 // We allow copy constructors, because a common pattern is to grab a | 244 // We allow copy constructors, because a common pattern is to grab a |
244 // copy of the current process's command line and then add some | 245 // copy of the current process's command line and then add some |
245 // flags to it. E.g.: | 246 // flags to it. E.g.: |
246 // CommandLine cl(*CommandLine::ForCurrentProcess()); | 247 // CommandLine cl(*CommandLine::ForCurrentProcess()); |
247 // cl.AppendSwitch(...); | 248 // cl.AppendSwitch(...); |
248 }; | 249 }; |
249 | 250 |
250 #endif // BASE_COMMAND_LINE_H_ | 251 #endif // BASE_COMMAND_LINE_H_ |
OLD | NEW |