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

Side by Side Diff: base/command_line.h

Issue 11305010: Extract arguments reconstruction logic out of GetCommandLineString() into GetArgumentsString(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/command_line.cc » ('j') | base/command_line_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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
72 72
73 #if defined(OS_WIN) 73 #if defined(OS_WIN)
74 static CommandLine FromString(const std::wstring& command_line); 74 static CommandLine FromString(const std::wstring& command_line);
75 #endif 75 #endif
76 76
77 // Initialize from an argv vector. 77 // Initialize from an argv vector.
78 void InitFromArgv(int argc, const CharType* const* argv); 78 void InitFromArgv(int argc, const CharType* const* argv);
79 void InitFromArgv(const StringVector& argv); 79 void InitFromArgv(const StringVector& argv);
80 80
81 // Constructs and returns the represented command line string. 81 // Constructs and returns the represented command line string.
82 // CAUTION! This should be avoided because quoting behavior is unclear. 82 // CAUTION! This should be avoided on POSIX because quoting behavior is
gab 2012/10/26 18:57:59 This CAUTION message was inserted a whillleee back
robertshield 2012/10/29 02:04:43 I believe the comment is still valid for POSIX sys
83 // unclear.
83 StringType GetCommandLineString() const; 84 StringType GetCommandLineString() const;
84 85
86 // Constructs and returns the represented arguments string.
87 // CAUTION! This should be avoided on POSIX because quoting behavior is
88 // unclear.
89 StringType GetArgumentsString() const;
90
85 // Returns the original command line string as a vector of strings. 91 // Returns the original command line string as a vector of strings.
86 const StringVector& argv() const { return argv_; } 92 const StringVector& argv() const { return argv_; }
87 93
88 // Get and Set the program part of the command line string (the first item). 94 // Get and Set the program part of the command line string (the first item).
89 FilePath GetProgram() const; 95 FilePath GetProgram() const;
90 void SetProgram(const FilePath& program); 96 void SetProgram(const FilePath& program);
91 97
92 // Returns true if this command line contains the given switch. 98 // Returns true if this command line contains the given switch.
93 // (Switch names are case-insensitive). 99 // (Switch names are case-insensitive).
94 bool HasSwitch(const std::string& switch_string) const; 100 bool HasSwitch(const std::string& switch_string) const;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 StringVector argv_; 163 StringVector argv_;
158 164
159 // Parsed-out switch keys and values. 165 // Parsed-out switch keys and values.
160 SwitchMap switches_; 166 SwitchMap switches_;
161 167
162 // The index after the program and switches, any arguments start here. 168 // The index after the program and switches, any arguments start here.
163 size_t begin_args_; 169 size_t begin_args_;
164 }; 170 };
165 171
166 #endif // BASE_COMMAND_LINE_H_ 172 #endif // BASE_COMMAND_LINE_H_
OLDNEW
« no previous file with comments | « no previous file | base/command_line.cc » ('j') | base/command_line_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698