| Index: base/command_line.h
|
| diff --git a/base/command_line.h b/base/command_line.h
|
| index ed46c4f0d13c34778d390e86827b8e6db307d186..8be7523bd62bc405e131cc98f95274305e32255b 100644
|
| --- a/base/command_line.h
|
| +++ b/base/command_line.h
|
| @@ -16,6 +16,7 @@
|
| #define BASE_COMMAND_LINE_H_
|
|
|
| #include <stddef.h>
|
| +#include <stdint.h>
|
| #include <map>
|
| #include <string>
|
| #include <vector>
|
| @@ -40,6 +41,11 @@ class BASE_EXPORT CommandLine {
|
| typedef std::vector<StringType> StringVector;
|
| typedef std::map<std::string, StringType> SwitchMap;
|
|
|
| + struct ExplicitStdString {
|
| + ExplicitStdString(const std::string& str) : s(str) {}
|
| + const std::string& s;
|
| + };
|
| +
|
| // A constructor for CommandLines that only carry switches and arguments.
|
| enum NoProgram { NO_PROGRAM };
|
| explicit CommandLine(NoProgram no_program);
|
| @@ -102,7 +108,23 @@ class BASE_EXPORT CommandLine {
|
|
|
| // Returns true if this command line contains the given switch.
|
| // (Switch names are case-insensitive).
|
| - bool HasSwitch(const std::string& switch_string) const;
|
| + bool HasStringSwitch(const std::string& switch_string) const;
|
| + bool HasSwitch(const ExplicitStdString& switch_string) const {
|
| + return HasStringSwitch(switch_string.s);
|
| + }
|
| + bool HasSwitch(const char* switch_string, size_t string_length) const;
|
| +
|
| + template <size_t N>
|
| + bool HasSwitch(const char (&constant_switch_string)[N]) const {
|
| + // Note that N includes a null terminator, so this will generate a compile
|
| + // error if called with an empty string constant.
|
| + if (N <= 65 &&
|
| + (switch_lengths_mask_ & (static_cast<uint64_t>(1) << (N - 2))) == 0) {
|
| + return false;
|
| + }
|
| +
|
| + return HasSwitch(constant_switch_string, N - 1);
|
| + }
|
|
|
| // Returns the value associated with the given switch. If the switch has no
|
| // value or isn't present, this method returns the empty string.
|
| @@ -173,6 +195,10 @@ class BASE_EXPORT CommandLine {
|
|
|
| // The index after the program and switches, any arguments start here.
|
| size_t begin_args_;
|
| +
|
| + // A bitset, with a 1 at bit postion |i| indicating that the command line
|
| + // includes a switch of string length |i| + 1 ascii characters.
|
| + uint64_t switch_lengths_mask_;
|
| };
|
|
|
| #endif // BASE_COMMAND_LINE_H_
|
|
|