MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / ParseBoolFlag

Function ParseBoolFlag

rtpose_wrapper/src/gtest/gtest-all.cpp:5901–5911  ·  view source on GitHub ↗

Parses a string for a bool flag, in the form of either "--flag=value" or "--flag". In the former case, the value is taken as true as long as it does not start with '0', 'f', or 'F'. In the latter case, the value is taken as true. On success, stores the value of the flag in *value, and returns true. On failure, returns false without changing *value.

Source from the content-addressed store, hash-verified

5899// On success, stores the value of the flag in *value, and returns
5900// true. On failure, returns false without changing *value.
5901bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
5902 // Gets the value of the flag as a string.
5903 const char* const value_str = ParseFlagValue(str, flag, true);
5904
5905 // Aborts if the parsing failed.
5906 if (value_str == NULL) return false;
5907
5908 // Converts the string value to a bool.
5909 *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
5910 return true;
5911}
5912
5913// Parses a string for an Int32 flag, in the form of
5914// "--flag=value".

Callers 1

Calls 1

ParseFlagValueFunction · 0.85

Tested by

no test coverage detected