MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / ParseBoolFlag

Function ParseBoolFlag

test/common/gtest/gtest.cpp:6631–6641  ·  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

6629// On success, stores the value of the flag in *value, and returns
6630// true. On failure, returns false without changing *value.
6631bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
6632 // Gets the value of the flag as a string.
6633 const char* const value_str = ParseFlagValue(str, flag, true);
6634
6635 // Aborts if the parsing failed.
6636 if (value_str == NULL) return false;
6637
6638 // Converts the string value to a bool.
6639 *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
6640 return true;
6641}
6642
6643// Parses a string for an Int32 flag, in the form of
6644// "--flag=value".

Callers 1

Calls 1

ParseFlagValueFunction · 0.85

Tested by

no test coverage detected