| 333 | } |
| 334 | |
| 335 | bool safe_strtof(StringPiece str, float* value) { |
| 336 | int processed_characters_count = -1; |
| 337 | auto len = str.size(); |
| 338 | |
| 339 | // If string length exceeds buffer size or int max, fail. |
| 340 | if (len >= kFastToBufferSize) return false; |
| 341 | if (len > std::numeric_limits<int>::max()) return false; |
| 342 | |
| 343 | *value = StringToFloatConverter().StringToFloat( |
| 344 | str.data(), static_cast<int>(len), &processed_characters_count); |
| 345 | return processed_characters_count > 0; |
| 346 | } |
| 347 | |
| 348 | bool safe_strtod(StringPiece str, double* value) { |
| 349 | int processed_characters_count = -1; |