MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / ParseBoolFlag

Function ParseBoolFlag

tests/gtest/gtest-all.cc:7199–7209  ·  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

7197// On success, stores the value of the flag in *value, and returns
7198// true. On failure, returns false without changing *value.
7199static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
7200 // Gets the value of the flag as a string.
7201 const char* const value_str = ParseFlagValue(str, flag, true);
7202
7203 // Aborts if the parsing failed.
7204 if (value_str == nullptr) return false;
7205
7206 // Converts the string value to a bool.
7207 *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
7208 return true;
7209}
7210
7211// Parses a string for an Int32 flag, in the form of
7212// "--flag=value".

Callers 1

ParseGoogleTestFlagFunction · 0.85

Calls 1

ParseFlagValueFunction · 0.85

Tested by

no test coverage detected