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

Side by Side Diff: base/command_line.h

Issue 329017: Remove deprecated CommandLine(std::wstring) ctor. (Closed)
Patch Set: Created 11 years, 2 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 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 14 matching lines...) Expand all
25 25
26 #include "base/basictypes.h" 26 #include "base/basictypes.h"
27 #include "base/file_path.h" 27 #include "base/file_path.h"
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.
36 enum ArgumentsOnly { ARGUMENTS_ONLY };
37 explicit CommandLine(ArgumentsOnly args_only);
38
35 #if defined(OS_WIN) 39 #if defined(OS_WIN)
36 // Initialize by parsing the given command-line string. 40 // Initialize by parsing the given command-line string.
37 // The program name is assumed to be the first item in the string. 41 // The program name is assumed to be the first item in the string.
38 void ParseFromString(const std::wstring& command_line); 42 void ParseFromString(const std::wstring& command_line);
43 static CommandLine FromString(const std::wstring& command_line) {
44 CommandLine cmd;
45 cmd.ParseFromString(command_line);
46 return cmd;
47 }
39 #elif defined(OS_POSIX) 48 #elif defined(OS_POSIX)
40 // Initialize from an argv vector. 49 // Initialize from an argv vector.
41 void InitFromArgv(int argc, const char* const* argv); 50 void InitFromArgv(int argc, const char* const* argv);
42 void InitFromArgv(const std::vector<std::string>& argv); 51 void InitFromArgv(const std::vector<std::string>& argv);
43 52
44 CommandLine(int argc, const char* const* argv) { 53 CommandLine(int argc, const char* const* argv) {
45 InitFromArgv(argc, argv); 54 InitFromArgv(argc, argv);
46 } 55 }
47 explicit CommandLine(const std::vector<std::string>& argv) { 56 explicit CommandLine(const std::vector<std::string>& argv) {
48 InitFromArgv(argv); 57 InitFromArgv(argv);
49 } 58 }
50 #endif 59 #endif
51 60
52 // Construct a new, empty command line. 61 // Construct a new, empty command line.
53 // |program| is the name of the program to run (aka argv[0]). 62 // |program| is the name of the program to run (aka argv[0]).
54 explicit CommandLine(const FilePath& program); 63 explicit CommandLine(const FilePath& program);
55 64
56 // Deprecated in favor of FilePath version.
57 explicit CommandLine(const std::wstring& program);
58
59 // Initialize the current process CommandLine singleton. On Windows, 65 // Initialize the current process CommandLine singleton. On Windows,
60 // ignores its arguments (we instead parse GetCommandLineW() 66 // ignores its arguments (we instead parse GetCommandLineW()
61 // directly) because we don't trust the CRT's parsing of the command 67 // directly) because we don't trust the CRT's parsing of the command
62 // line, but it still must be called to set up the command line. 68 // line, but it still must be called to set up the command line.
63 static void Init(int argc, const char* const* argv); 69 static void Init(int argc, const char* const* argv);
64 70
65 #if defined(OS_LINUX) || defined(OS_FREEBSD) 71 #if defined(OS_LINUX) || defined(OS_FREEBSD)
66 // Sets the current process' arguments that show in "ps" etc. to those 72 // Sets the current process' arguments that show in "ps" etc. to those
67 // in |current_process_commandline_|. Used by the zygote host so that 73 // in |current_process_commandline_|. Used by the zygote host so that
68 // renderers show up with --type=renderer. 74 // renderers show up with --type=renderer.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 std::vector<StringType> loose_values_; 232 std::vector<StringType> loose_values_;
227 233
228 // We allow copy constructors, because a common pattern is to grab a 234 // We allow copy constructors, because a common pattern is to grab a
229 // copy of the current process's command line and then add some 235 // copy of the current process's command line and then add some
230 // flags to it. E.g.: 236 // flags to it. E.g.:
231 // CommandLine cl(*CommandLine::ForCurrentProcess()); 237 // CommandLine cl(*CommandLine::ForCurrentProcess());
232 // cl.AppendSwitch(...); 238 // cl.AppendSwitch(...);
233 }; 239 };
234 240
235 #endif // BASE_COMMAND_LINE_H_ 241 #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