| 313 | } |
| 314 | |
| 315 | bool safe_strtou32(StringPiece str, uint32* value) { |
| 316 | SkipSpaces(&str); |
| 317 | if (!isdigit(SafeFirstChar(str))) return false; |
| 318 | |
| 319 | int64 result = 0; |
| 320 | do { |
| 321 | result = result * 10 + SafeFirstChar(str) - '0'; |
| 322 | if (result > kuint32max) { |
| 323 | return false; |
| 324 | } |
| 325 | str.remove_prefix(1); |
| 326 | } while (isdigit(SafeFirstChar(str))); |
| 327 | |
| 328 | SkipSpaces(&str); |
| 329 | if (!str.empty()) return false; |
| 330 | |
| 331 | *value = static_cast<uint32>(result); |
| 332 | return true; |
| 333 | } |
| 334 | |
| 335 | bool safe_strtof(StringPiece str, float* value) { |
| 336 | int processed_characters_count = -1; |