| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 358 |
| 359 void CommandLine::AppendSwitchASCII(const std::string& switch_string, | 359 void CommandLine::AppendSwitchASCII(const std::string& switch_string, |
| 360 const std::string& value_string) { | 360 const std::string& value_string) { |
| 361 #if defined(OS_WIN) | 361 #if defined(OS_WIN) |
| 362 AppendSwitchNative(switch_string, ASCIIToUTF16(value_string)); | 362 AppendSwitchNative(switch_string, ASCIIToUTF16(value_string)); |
| 363 #elif defined(OS_POSIX) | 363 #elif defined(OS_POSIX) |
| 364 AppendSwitchNative(switch_string, value_string); | 364 AppendSwitchNative(switch_string, value_string); |
| 365 #endif | 365 #endif |
| 366 } | 366 } |
| 367 | 367 |
| 368 void CommandLine::ReplaceSwitchASCIIForTest(const std::string& switch_string, |
| 369 const std::string& value) { |
| 370 #if defined(OS_WIN) |
| 371 const std::string switch_key = ToLowerASCII(switch_string); |
| 372 StringType combined_switch_string(ASCIIToUTF16(switch_key)); |
| 373 #elif defined(OS_POSIX) |
| 374 const std::string& switch_key = switch_string; |
| 375 StringType combined_switch_string(switch_key); |
| 376 #endif |
| 377 size_t prefix_length = GetSwitchPrefixLength(combined_switch_string); |
| 378 switches_by_stringpiece_.erase(switch_key.substr(prefix_length)); |
| 379 switches_.erase(switch_string.substr(prefix_length)); |
| 380 |
| 381 AppendSwitchASCII(switch_string, value); |
| 382 } |
| 383 |
| 368 void CommandLine::CopySwitchesFrom(const CommandLine& source, | 384 void CommandLine::CopySwitchesFrom(const CommandLine& source, |
| 369 const char* const switches[], | 385 const char* const switches[], |
| 370 size_t count) { | 386 size_t count) { |
| 371 for (size_t i = 0; i < count; ++i) { | 387 for (size_t i = 0; i < count; ++i) { |
| 372 if (source.HasSwitch(switches[i])) | 388 if (source.HasSwitch(switches[i])) |
| 373 AppendSwitchNative(switches[i], source.GetSwitchValueNative(switches[i])); | 389 AppendSwitchNative(switches[i], source.GetSwitchValueNative(switches[i])); |
| 374 } | 390 } |
| 375 } | 391 } |
| 376 | 392 |
| 377 CommandLine::StringVector CommandLine::GetArgs() const { | 393 CommandLine::StringVector CommandLine::GetArgs() const { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 return params; | 505 return params; |
| 490 } | 506 } |
| 491 | 507 |
| 492 void CommandLine::ResetStringPieces() { | 508 void CommandLine::ResetStringPieces() { |
| 493 switches_by_stringpiece_.clear(); | 509 switches_by_stringpiece_.clear(); |
| 494 for (const auto& entry : switches_) | 510 for (const auto& entry : switches_) |
| 495 switches_by_stringpiece_[entry.first] = &(entry.second); | 511 switches_by_stringpiece_[entry.first] = &(entry.second); |
| 496 } | 512 } |
| 497 | 513 |
| 498 } // namespace base | 514 } // namespace base |
| OLD | NEW |