diff options
author | mpimenov <mpimenov@users.noreply.github.com> | 2016-10-12 18:41:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 18:41:38 +0300 |
commit | 8500a3e178c5d2093a959303d2b9b4c4c1f83835 (patch) | |
tree | ff15e3692bc62d592f0fd790c265e4c3ff8e0373 /base | |
parent | ee9e97e2f97701974290502f0e88043cc1c2fe08 (diff) | |
parent | da69d602c568846235657a843b30c17a672320e1 (diff) |
Merge pull request #4481 from ygorshenin/hotel-filters
[search] Implemented hotels filter.
Diffstat (limited to 'base')
-rw-r--r-- | base/string_utils.cpp | 7 | ||||
-rw-r--r-- | base/string_utils.hpp | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/base/string_utils.cpp b/base/string_utils.cpp index 6d017e2405..67eed2cb12 100644 --- a/base/string_utils.cpp +++ b/base/string_utils.cpp @@ -96,6 +96,13 @@ bool to_int64(char const * s, int64_t & i) return *stop == 0 && s != stop; } +bool to_float(char const * s, float & f) +{ + char * stop; + f = strtof(s, &stop); + return *stop == 0 && s != stop && isfinite(f); +} + bool to_double(char const * s, double & d) { char * stop; diff --git a/base/string_utils.hpp b/base/string_utils.hpp index 0d5a77754f..114ce0f5d8 100644 --- a/base/string_utils.hpp +++ b/base/string_utils.hpp @@ -341,6 +341,7 @@ bool to_int(char const * s, int & i, int base = 10); bool to_uint(char const * s, unsigned int & i, int base = 10); bool to_uint64(char const * s, uint64_t & i); bool to_int64(char const * s, int64_t & i); +bool to_float(char const * s, float & f); bool to_double(char const * s, double & d); inline bool is_number(string const & s) @@ -356,6 +357,7 @@ inline bool to_uint(string const & s, unsigned int & i, int base = 10) } inline bool to_uint64(string const & s, uint64_t & i) { return to_uint64(s.c_str(), i); } inline bool to_int64(string const & s, int64_t & i) { return to_int64(s.c_str(), i); } +inline bool to_float(string const & s, float & f) { return to_float(s.c_str(), f); } inline bool to_double(string const & s, double & d) { return to_double(s.c_str(), d); } //@} |