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

Unified Diff: base/command_line.cc

Issue 3068004: base/ header cleanup. Forward declaration instead of including. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: chrome_launcher_unittest.cc Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/command_line.h ('k') | base/command_line_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/command_line.cc
diff --git a/base/command_line.cc b/base/command_line.cc
index c046125b5e624d4cf2c4630c8b294440c32fd653..b11902bc11f055de77429c26b4a2bc0988bcaf5c 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -104,6 +104,13 @@ void CommandLine::ParseFromString(const std::wstring& command_line) {
LocalFree(args);
}
+// static
+CommandLine CommandLine::FromString(const std::wstring& command_line) {
+ CommandLine cmd;
+ cmd.ParseFromString(command_line);
+ return cmd;
+}
+
CommandLine::CommandLine(const FilePath& program) {
if (!program.empty()) {
program_ = program.value();
@@ -117,6 +124,14 @@ CommandLine::CommandLine(ArgumentsOnly args_only) {
argv_.push_back("");
}
+CommandLine::CommandLine(int argc, const char* const* argv) {
+ InitFromArgv(argc, argv);
+}
+
+CommandLine::CommandLine(const std::vector<std::string>& argv) {
+ InitFromArgv(argv);
+}
+
void CommandLine::InitFromArgv(int argc, const char* const* argv) {
for (int i = 0; i < argc; ++i)
argv_.push_back(argv[i]);
@@ -265,6 +280,20 @@ bool CommandLine::HasSwitch(const std::string& switch_string) const {
return switches_.find(lowercased_switch) != switches_.end();
}
+bool CommandLine::HasSwitch(const std::wstring& switch_string) const {
+ return HasSwitch(WideToASCII(switch_string));
+}
+
+std::string CommandLine::GetSwitchValueASCII(
+ const std::string& switch_string) const {
+ return WideToASCII(GetSwitchValue(switch_string));
+}
+
+FilePath CommandLine::GetSwitchValuePath(
+ const std::string& switch_string) const {
+ return FilePath::FromWStringHack(GetSwitchValue(switch_string));
+}
+
std::wstring CommandLine::GetSwitchValue(
const std::string& switch_string) const {
std::string lowercased_switch(switch_string);
@@ -286,6 +315,15 @@ std::wstring CommandLine::GetSwitchValue(
}
}
+std::wstring CommandLine::GetSwitchValue(
+ const std::wstring& switch_string) const {
+ return GetSwitchValue(WideToASCII(switch_string));
+}
+
+FilePath CommandLine::GetProgram() const {
+ return FilePath::FromWStringHack(program());
+}
+
#if defined(OS_WIN)
std::wstring CommandLine::program() const {
return program_;
@@ -432,6 +470,11 @@ void CommandLine::PrependWrapper(const std::wstring& wrapper_wide) {
#endif
+void CommandLine::AppendSwitchWithValue(const std::string& switch_string,
+ const std::string& value_string) {
+ AppendSwitchWithValue(switch_string, ASCIIToWide(value_string));
+}
+
// private
CommandLine::CommandLine() {
}
« no previous file with comments | « base/command_line.h ('k') | base/command_line_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698