Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: base/command_line.h

Issue 3138001: CommandLine: remove PrefixedSwitchString(). (Closed)
Patch Set: works Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/command_line.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // renderers show up with --type=renderer. 72 // renderers show up with --type=renderer.
73 static void SetProcTitle(); 73 static void SetProcTitle();
74 #endif 74 #endif
75 75
76 // Destroys the current process CommandLine singleton. This is necessary if 76 // Destroys the current process CommandLine singleton. This is necessary if
77 // you want to reset the base library to its initial state (for example in an 77 // you want to reset the base library to its initial state (for example in an
78 // outer library that needs to be able to terminate, and be re-initialized). 78 // outer library that needs to be able to terminate, and be re-initialized).
79 // If Init is called only once, e.g. in main(), calling Reset() is not 79 // If Init is called only once, e.g. in main(), calling Reset() is not
80 // necessary. 80 // necessary.
81 static void Reset(); 81 static void Reset();
82 // The same function snuck into this class under two different names;
83 // this one remains for backwards compat with the older o3d build.
84 static void Terminate() { Reset(); }
85 82
86 // Get the singleton CommandLine representing the current process's 83 // Get the singleton CommandLine representing the current process's
87 // command line. Note: returned value is mutable, but not thread safe; 84 // command line. Note: returned value is mutable, but not thread safe;
88 // only mutate if you know what you're doing! 85 // only mutate if you know what you're doing!
89 static CommandLine* ForCurrentProcess() { 86 static CommandLine* ForCurrentProcess() {
90 DCHECK(current_process_commandline_); 87 DCHECK(current_process_commandline_);
91 return current_process_commandline_; 88 return current_process_commandline_;
92 } 89 }
93 90
94 // Returns true if this command line contains the given switch. 91 // Returns true if this command line contains the given switch.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return argv_; 124 return argv_;
128 } 125 }
129 // Try to match the same result as command_line_string() would get you 126 // Try to match the same result as command_line_string() would get you
130 // on windows. 127 // on windows.
131 std::string command_line_string() const; 128 std::string command_line_string() const;
132 #endif 129 #endif
133 130
134 // Returns the program part of the command line string (the first item). 131 // Returns the program part of the command line string (the first item).
135 FilePath GetProgram() const; 132 FilePath GetProgram() const;
136 133
137 // Return a copy of the string prefixed with a switch prefix.
138 // Used internally.
139 static std::wstring PrefixedSwitchString(const std::string& switch_string);
140
141 // Return a copy of the string prefixed with a switch prefix,
142 // and appended with the given value. Used internally.
143 static std::wstring PrefixedSwitchStringWithValue(
144 const std::string& switch_string,
145 const std::wstring& value_string);
146
147 // Append a switch to the command line. 134 // Append a switch to the command line.
148 void AppendSwitch(const std::string& switch_string); 135 void AppendSwitch(const std::string& switch_string);
149 136
150 // Append a switch and value to the command line. 137 // Append a switch and value to the command line.
151 void AppendSwitchPath(const std::string& switch_string, const FilePath& path); 138 void AppendSwitchPath(const std::string& switch_string, const FilePath& path);
152 void AppendSwitchNative(const std::string& switch_string, 139 void AppendSwitchNative(const std::string& switch_string,
153 const StringType& value); 140 const StringType& value);
154 void AppendSwitchASCII(const std::string& switch_string, 141 void AppendSwitchASCII(const std::string& switch_string,
155 const std::string& value); 142 const std::string& value);
156 143
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 std::vector<StringType> args_; 209 std::vector<StringType> args_;
223 210
224 // We allow copy constructors, because a common pattern is to grab a 211 // We allow copy constructors, because a common pattern is to grab a
225 // copy of the current process's command line and then add some 212 // copy of the current process's command line and then add some
226 // flags to it. E.g.: 213 // flags to it. E.g.:
227 // CommandLine cl(*CommandLine::ForCurrentProcess()); 214 // CommandLine cl(*CommandLine::ForCurrentProcess());
228 // cl.AppendSwitch(...); 215 // cl.AppendSwitch(...);
229 }; 216 };
230 217
231 #endif // BASE_COMMAND_LINE_H_ 218 #endif // BASE_COMMAND_LINE_H_
OLDNEW
« no previous file with comments | « no previous file | base/command_line.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698