MCPcopy Create free account
hub / github.com/chromium/crashpad / StringToIntegerInternal

Function StringToIntegerInternal

util/stdlib/string_number_conversion.cc:137–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135
136template <typename Traits>
137bool StringToIntegerInternal(const std::string& string,
138 typename Traits::IntType* number) {
139 using IntType = typename Traits::IntType;
140 using LongType = typename Traits::LongType;
141
142 Traits::TypeCheck();
143
144 if (string.empty() || base::IsAsciiWhitespace(string[0])) {
145 return false;
146 }
147
148 errno = 0;
149 char* end;
150 LongType result = Traits::Convert(string.data(), &end, 0);
151 if (Traits::IsNegativeOverflow(result) ||
152 result > std::numeric_limits<IntType>::max() ||
153 errno == ERANGE ||
154 end != string.data() + string.length()) {
155 return false;
156 }
157 *number = static_cast<IntType>(result);
158 return true;
159}
160
161} // namespace
162

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected