MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / ParseDouble

Function ParseDouble

deps/google-benchmark/src/commandlineflags.cc:68–83  ·  view source on GitHub ↗

Parses 'str' for a double. If successful, writes the result to *value and returns true; otherwise leaves *value unchanged and returns false.

Source from the content-addressed store, hash-verified

66// Parses 'str' for a double. If successful, writes the result to *value and
67// returns true; otherwise leaves *value unchanged and returns false.
68bool ParseDouble(const std::string& src_text, const char* str, double* value) {
69 // Parses the environment variable as a decimal integer.
70 char* end = nullptr;
71 const double double_value = strtod(str, &end); // NOLINT
72
73 // Has strtol() consumed all characters in the string?
74 if (*end != '\0') {
75 // No - an invalid character was encountered.
76 std::cerr << src_text << " is expected to be a double, "
77 << "but actually has value \"" << str << "\".\n";
78 return false;
79 }
80
81 *value = double_value;
82 return true;
83}
84
85// Parses 'str' into KV pairs. If successful, writes the result to *value and
86// returns true; otherwise leaves *value unchanged and returns false.

Callers 2

DoubleFromEnvFunction · 0.85
ParseDoubleFlagFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected