John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Alexis Hetu | 3ef0c0a | 2015-06-09 11:37:45 -0400 | [diff] [blame] | 7 | #include <limits> |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 8 | |
| 9 | #include "util.h" |
Alexis Hetu | 3ef0c0a | 2015-06-09 11:37:45 -0400 | [diff] [blame] | 10 | #include "preprocessor/numeric_lex.h" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 11 | |
Alexis Hetu | 3ef0c0a | 2015-06-09 11:37:45 -0400 | [diff] [blame] | 12 | bool atof_clamp(const char *str, float *value) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 13 | { |
Alexis Hetu | 3ef0c0a | 2015-06-09 11:37:45 -0400 | [diff] [blame] | 14 | bool success = pp::numeric_lex_float(str, value); |
| 15 | if(!success) |
| 16 | *value = std::numeric_limits<float>::max(); |
| 17 | return success; |
| 18 | } |
| 19 | |
| 20 | bool atoi_clamp(const char *str, int *value) |
| 21 | { |
| 22 | bool success = pp::numeric_lex_int(str, value); |
| 23 | if(!success) |
| 24 | *value = std::numeric_limits<int>::max(); |
| 25 | return success; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 26 | } |