Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorYuri Gorshenin <y@maps.me>2016-10-06 22:25:34 +0300
committerYuri Gorshenin <y@maps.me>2016-10-11 17:58:27 +0300
commitda69d602c568846235657a843b30c17a672320e1 (patch)
treeab172257367d683031241c75e6f95aeb3813e7f4 /base
parent09566c5ca7aa761a40b0e769e4e44b85c5c3f429 (diff)
[search] Implemented hotels filter.
Diffstat (limited to 'base')
-rw-r--r--base/string_utils.cpp7
-rw-r--r--base/string_utils.hpp2
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 179a5d560b..03c11fb61f 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); }
//@}