blob: e20068b66dcb14ab3082f28fd9d53de3107dc282 [file] [log] [blame]
John Bauman89401822014-05-06 15:04:28 -04001//
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 Hetu3ef0c0a2015-06-09 11:37:45 -04007#include <limits>
John Bauman89401822014-05-06 15:04:28 -04008
9#include "util.h"
Alexis Hetu3ef0c0a2015-06-09 11:37:45 -040010#include "preprocessor/numeric_lex.h"
John Bauman89401822014-05-06 15:04:28 -040011
Alexis Hetu3ef0c0a2015-06-09 11:37:45 -040012bool atof_clamp(const char *str, float *value)
John Bauman89401822014-05-06 15:04:28 -040013{
Alexis Hetu3ef0c0a2015-06-09 11:37:45 -040014 bool success = pp::numeric_lex_float(str, value);
15 if(!success)
16 *value = std::numeric_limits<float>::max();
17 return success;
18}
19
20bool 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 Bauman89401822014-05-06 15:04:28 -040026}