MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ParseBoolFlag

Function ParseBoolFlag

tensorflow/core/util/command_line_flags.cc:85–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85bool ParseBoolFlag(tensorflow::StringPiece arg, tensorflow::StringPiece flag,
86 const std::function<bool(bool)>& hook,
87 bool* value_parsing_ok) {
88 *value_parsing_ok = true;
89 if (absl::ConsumePrefix(&arg, "--") && absl::ConsumePrefix(&arg, flag)) {
90 if (arg.empty()) {
91 *value_parsing_ok = hook(true);
92 return true;
93 }
94
95 if (arg == "=true") {
96 *value_parsing_ok = hook(true);
97 return true;
98 } else if (arg == "=false") {
99 *value_parsing_ok = hook(false);
100 return true;
101 } else {
102 LOG(ERROR) << "Couldn't interpret value " << arg << " for flag " << flag
103 << ".";
104 *value_parsing_ok = false;
105 return true;
106 }
107 }
108
109 return false;
110}
111
112bool ParseFloatFlag(tensorflow::StringPiece arg, tensorflow::StringPiece flag,
113 const std::function<bool(float)>& hook,

Callers 1

ParseMethod · 0.70

Calls 2

ConsumePrefixFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected