OLD | NEW |
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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 } | 143 } |
144 out.push_back('"'); | 144 out.push_back('"'); |
145 | 145 |
146 return out; | 146 return out; |
147 } | 147 } |
148 #endif | 148 #endif |
149 | 149 |
150 } // namespace | 150 } // namespace |
151 | 151 |
152 CommandLine::CommandLine(NoProgram no_program) | 152 CommandLine::CommandLine(NoProgram) : argv_(1), begin_args_(1) {} |
153 : argv_(1), | |
154 begin_args_(1) { | |
155 } | |
156 | 153 |
157 CommandLine::CommandLine(const FilePath& program) | 154 CommandLine::CommandLine(const FilePath& program) |
158 : argv_(1), | 155 : argv_(1), |
159 begin_args_(1) { | 156 begin_args_(1) { |
160 SetProgram(program); | 157 SetProgram(program); |
161 } | 158 } |
162 | 159 |
163 CommandLine::CommandLine(int argc, const CommandLine::CharType* const* argv) | 160 CommandLine::CommandLine(int argc, const CommandLine::CharType* const* argv) |
164 : argv_(1), | 161 : argv_(1), |
165 begin_args_(1) { | 162 begin_args_(1) { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 StringType params(GetArgumentsStringInternal(quote_placeholders)); | 434 StringType params(GetArgumentsStringInternal(quote_placeholders)); |
438 if (!params.empty()) { | 435 if (!params.empty()) { |
439 string.append(StringType(FILE_PATH_LITERAL(" "))); | 436 string.append(StringType(FILE_PATH_LITERAL(" "))); |
440 string.append(params); | 437 string.append(params); |
441 } | 438 } |
442 return string; | 439 return string; |
443 } | 440 } |
444 | 441 |
445 CommandLine::StringType CommandLine::GetArgumentsStringInternal( | 442 CommandLine::StringType CommandLine::GetArgumentsStringInternal( |
446 bool quote_placeholders) const { | 443 bool quote_placeholders) const { |
| 444 #if !defined(OS_WIN) |
| 445 (void)quote_placeholders; // Avoid an unused warning. |
| 446 #endif |
447 StringType params; | 447 StringType params; |
448 // Append switches and arguments. | 448 // Append switches and arguments. |
449 bool parse_switches = true; | 449 bool parse_switches = true; |
450 for (size_t i = 1; i < argv_.size(); ++i) { | 450 for (size_t i = 1; i < argv_.size(); ++i) { |
451 StringType arg = argv_[i]; | 451 StringType arg = argv_[i]; |
452 StringType switch_string; | 452 StringType switch_string; |
453 StringType switch_value; | 453 StringType switch_value; |
454 parse_switches &= arg != kSwitchTerminator; | 454 parse_switches &= arg != kSwitchTerminator; |
455 if (i > 1) | 455 if (i > 1) |
456 params.append(StringType(FILE_PATH_LITERAL(" "))); | 456 params.append(StringType(FILE_PATH_LITERAL(" "))); |
(...skipping 16 matching lines...) Expand all Loading... |
473 return params; | 473 return params; |
474 } | 474 } |
475 | 475 |
476 void CommandLine::ResetStringPieces() { | 476 void CommandLine::ResetStringPieces() { |
477 switches_by_stringpiece_.clear(); | 477 switches_by_stringpiece_.clear(); |
478 for (const auto& entry : switches_) | 478 for (const auto& entry : switches_) |
479 switches_by_stringpiece_[entry.first] = &(entry.second); | 479 switches_by_stringpiece_[entry.first] = &(entry.second); |
480 } | 480 } |
481 | 481 |
482 } // namespace base | 482 } // namespace base |
OLD | NEW |