| 262 | } |
| 263 | |
| 264 | bool safe_strtou64(StringPiece str, uint64* value) { |
| 265 | SkipSpaces(&str); |
| 266 | if (!isdigit(SafeFirstChar(str))) return false; |
| 267 | |
| 268 | uint64 result = 0; |
| 269 | do { |
| 270 | int digit = SafeFirstChar(str) - '0'; |
| 271 | if ((kuint64max - digit) / 10 < result) { |
| 272 | return false; |
| 273 | } |
| 274 | result = result * 10 + digit; |
| 275 | str.remove_prefix(1); |
| 276 | } while (isdigit(SafeFirstChar(str))); |
| 277 | |
| 278 | SkipSpaces(&str); |
| 279 | if (!str.empty()) return false; |
| 280 | |
| 281 | *value = result; |
| 282 | return true; |
| 283 | } |
| 284 | |
| 285 | bool safe_strto32(StringPiece str, int32* value) { |
| 286 | SkipSpaces(&str); |