Parses a string for a string flag, in the form of "--flag=value". On success, stores the value of the flag in *value, and returns true. On failure, returns false without changing *value.
| 6231 | // On success, stores the value of the flag in *value, and returns |
| 6232 | // true. On failure, returns false without changing *value. |
| 6233 | bool ParseStringFlag(const char* str, const char* flag, std::string* value) { |
| 6234 | // Gets the value of the flag as a string. |
| 6235 | const char* const value_str = ParseFlagValue(str, flag, false); |
| 6236 | |
| 6237 | // Aborts if the parsing failed. |
| 6238 | if (value_str == NULL) return false; |
| 6239 | |
| 6240 | // Sets *value to the value of the flag. |
| 6241 | *value = value_str; |
| 6242 | return true; |
| 6243 | } |
| 6244 | |
| 6245 | // Determines whether a string has a prefix that Google Test uses for its |
| 6246 | // flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_. |
no test coverage detected