CommandLine::StringType CommandLine::GetSwitchValueNative( const std::string& switch_string) const { SwitchMap::const_iterator result = switches_.end(); result = switches_.find(LowerASCIIOnWindows(switch_string)); return result==switches_.end() ? StringType() : result->second; }
void CommandLine::AppendSwitchNative(const std::string& switch_string, const CommandLine::StringType& value) { std::string switch_key(LowerASCIIOnWindows(switch_string)); #if defined(OS_WIN) StringType combined_switch_string(ASCIIToWide(switch_key)); #elif defined(OS_POSIX) StringType combined_switch_string(switch_string); #endif size_t prefix_length = GetSwitchPrefixLength(combined_switch_string); switches_[switch_key.substr(prefix_length)] = value; // Preserve existing switch prefixes in |argv_|; only append one if necessary. if (prefix_length == 0) combined_switch_string = kSwitchPrefixes[0] + combined_switch_string; if (!value.empty()) combined_switch_string += kSwitchValueSeparator + value; // Append the switch and update the switches/arguments divider |begin_args_|. argv_.insert(argv_.begin() + begin_args_++, combined_switch_string); }
bool CommandLine::HasSwitch(const std::string& switch_string) const { return switches_.find(LowerASCIIOnWindows(switch_string)) != switches_.end(); }