Lines Matching +full:has +full:- +full:flag
7 // http://www.apache.org/licenses/LICENSE-2.0
31 // Parses 'str' for a 32-bit signed integer. If successful, writes
39 // Has strtol() consumed all characters in the string? in ParseInt32()
41 // No - an invalid character was encountered. in ParseInt32()
42 std::cerr << src_text << " is expected to be a 32-bit integer, " in ParseInt32()
43 << "but actually has value \"" << str << "\".\n"; in ParseInt32()
56 std::cerr << src_text << " is expected to be a 32-bit integer, " in ParseInt32()
57 << "but actually has value \"" << str << "\", " in ParseInt32()
73 // Has strtol() consumed all characters in the string? in ParseDouble()
75 // No - an invalid character was encountered. in ParseDouble()
77 << "but actually has value \"" << str << "\".\n"; in ParseDouble()
93 std::cerr << src_text << " is expected to be a comma-separated list of " in ParseKvPairs()
94 << "<key>=<value> strings, but actually has value \"" << str in ParseKvPairs()
110 // given flag. For example, FlagToEnvVar("foo") will return
111 // "BENCHMARK_FOO" in the open-source version.
112 static std::string FlagToEnvVar(const char* flag) { in FlagToEnvVar() argument
113 const std::string flag_str(flag); in FlagToEnvVar()
125 bool BoolFromEnv(const char* flag, bool default_val) { in BoolFromEnv() argument
126 const std::string env_var = FlagToEnvVar(flag); in BoolFromEnv()
132 int32_t Int32FromEnv(const char* flag, int32_t default_val) { in Int32FromEnv() argument
133 const std::string env_var = FlagToEnvVar(flag); in Int32FromEnv()
145 double DoubleFromEnv(const char* flag, double default_val) { in DoubleFromEnv() argument
146 const std::string env_var = FlagToEnvVar(flag); in DoubleFromEnv()
158 const char* StringFromEnv(const char* flag, const char* default_val) { in StringFromEnv() argument
159 const std::string env_var = FlagToEnvVar(flag); in StringFromEnv()
166 const char* flag, std::map<std::string, std::string> default_val) { in KvPairsFromEnv() argument
167 const std::string env_var = FlagToEnvVar(flag); in KvPairsFromEnv()
179 // Parses a string as a command line flag. The string should have
180 // the format "--flag=value". When def_optional is true, the "=value"
183 // Returns the value of the flag, or nullptr if the parsing failed.
184 const char* ParseFlagValue(const char* str, const char* flag, in ParseFlagValue() argument
186 // str and flag must not be nullptr. in ParseFlagValue()
187 if (str == nullptr || flag == nullptr) return nullptr; in ParseFlagValue()
189 // The flag must start with "--". in ParseFlagValue()
190 const std::string flag_str = std::string("--") + std::string(flag); in ParseFlagValue()
194 // Skips the flag name. in ParseFlagValue()
201 // flag name, or if def_optional is false, there must be a '=' after in ParseFlagValue()
202 // the flag name. in ParseFlagValue()
210 bool ParseBoolFlag(const char* str, const char* flag, bool* value) { in ParseBoolFlag() argument
211 // Gets the value of the flag as a string. in ParseBoolFlag()
212 const char* const value_str = ParseFlagValue(str, flag, true); in ParseBoolFlag()
223 bool ParseInt32Flag(const char* str, const char* flag, int32_t* value) { in ParseInt32Flag() argument
224 // Gets the value of the flag as a string. in ParseInt32Flag()
225 const char* const value_str = ParseFlagValue(str, flag, false); in ParseInt32Flag()
230 // Sets *value to the value of the flag. in ParseInt32Flag()
231 return ParseInt32(std::string("The value of flag --") + flag, value_str, in ParseInt32Flag()
236 bool ParseDoubleFlag(const char* str, const char* flag, double* value) { in ParseDoubleFlag() argument
237 // Gets the value of the flag as a string. in ParseDoubleFlag()
238 const char* const value_str = ParseFlagValue(str, flag, false); in ParseDoubleFlag()
243 // Sets *value to the value of the flag. in ParseDoubleFlag()
244 return ParseDouble(std::string("The value of flag --") + flag, value_str, in ParseDoubleFlag()
249 bool ParseStringFlag(const char* str, const char* flag, std::string* value) { in ParseStringFlag() argument
250 // Gets the value of the flag as a string. in ParseStringFlag()
251 const char* const value_str = ParseFlagValue(str, flag, false); in ParseStringFlag()
261 bool ParseKeyValueFlag(const char* str, const char* flag, in ParseKeyValueFlag() argument
263 const char* const value_str = ParseFlagValue(str, flag, false); in ParseKeyValueFlag()
270 value->emplace(kv[0], kv[1]); in ParseKeyValueFlag()
277 bool IsFlag(const char* str, const char* flag) { in IsFlag() argument
278 return (ParseFlagValue(str, flag, true) != nullptr); in IsFlag()