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:
authorSergey Yershov <syershov@maps.me>2016-12-20 16:12:52 +0300
committerSergey Yershov <syershov@maps.me>2016-12-28 15:24:52 +0300
commit63b6375f7c8649d3fd0577264abb8ea1b51959cb (patch)
tree29cfe3eccc40fc1e9e0039f9526643865ee7b103 /base
parent20c0eb77e37e8148e37ca50edb3b6c5bab160198 (diff)
Fix issues while build on Linux
Diffstat (limited to 'base')
-rw-r--r--base/buffer_vector.hpp2
-rw-r--r--base/stl_add.hpp1
-rw-r--r--base/string_utils.cpp4
-rw-r--r--base/timer.cpp63
4 files changed, 65 insertions, 5 deletions
diff --git a/base/buffer_vector.hpp b/base/buffer_vector.hpp
index f807cf18c7..d9df450959 100644
--- a/base/buffer_vector.hpp
+++ b/base/buffer_vector.hpp
@@ -46,7 +46,7 @@ private:
MoveStatic(buffer_vector<T, N> & rhs)
{
for (size_t i = 0; i < rhs.m_size; ++i)
- Swap(m_static[i], rhs.m_static[i]);
+ std::swap(m_static[i], rhs.m_static[i]);
}
#endif
diff --git a/base/stl_add.hpp b/base/stl_add.hpp
index d30c16d2b8..5df723ee69 100644
--- a/base/stl_add.hpp
+++ b/base/stl_add.hpp
@@ -3,6 +3,7 @@
#include <algorithm>
#include <functional>
#include <iterator>
+#include <memory>
namespace my
{
diff --git a/base/string_utils.cpp b/base/string_utils.cpp
index 6379deab9e..d1ac84b24a 100644
--- a/base/string_utils.cpp
+++ b/base/string_utils.cpp
@@ -101,14 +101,14 @@ bool to_float(char const * s, float & f)
{
char * stop;
f = strtof(s, &stop);
- return *stop == 0 && s != stop && isfinite(f);
+ return *stop == 0 && s != stop && std::isfinite(f);
}
bool to_double(char const * s, double & d)
{
char * stop;
d = strtod(s, &stop);
- return *stop == 0 && s != stop && isfinite(d);
+ return *stop == 0 && s != stop && std::isfinite(d);
}
UniString MakeLowerCase(UniString const & s)
diff --git a/base/timer.cpp b/base/timer.cpp
index f8796b0479..07ca601f6a 100644
--- a/base/timer.cpp
+++ b/base/timer.cpp
@@ -12,6 +12,65 @@
#include <iomanip>
#include <sstream>
+#ifndef OMIM_OS_LINUX
+using std::get_time;
+using std::put_time;
+
+#else
+#include <cassert>
+
+namespace detail
+{
+ template <class _CharT> struct get_time_manip
+ {
+ tm* __tm_;
+ const _CharT* __fmt_;
+
+ get_time_manip(tm* __tm, const _CharT* __fmt)
+ : __tm_(__tm), __fmt_(__fmt) {}
+ };
+
+ template <class _CharT, class _Traits>
+ class stream_buf_impl : public std::basic_streambuf<_CharT, _Traits>
+ {
+ typedef std::basic_streambuf<_CharT, _Traits> base_t;
+ public:
+ bool parse(const get_time_manip<_CharT>& __x)
+ {
+ // Workaround works only for a stream buffer under null-terminated string.
+ assert(*base_t::egptr() == 0);
+
+ char * res = ::strptime(base_t::gptr(), __x.__fmt_, __x.__tm_);
+ if (res == 0)
+ return false;
+ else
+ {
+ base_t::setg(base_t::eback(), res, base_t::egptr());
+ return true;
+ }
+ }
+ };
+
+ template <class _CharT, class _Traits>
+ std::basic_istream<_CharT, _Traits>&
+ operator>>(std::basic_istream<_CharT, _Traits>& __is, const get_time_manip<_CharT>& __x)
+ {
+ if (!reinterpret_cast<stream_buf_impl<_CharT, _Traits>*>(__is.rdbuf())->parse(__x))
+ __is.setstate(std::ios_base::failbit);
+ return __is;
+ }
+}
+
+template <class _CharT>
+detail::get_time_manip<_CharT> get_time(tm* __tm, const _CharT* __fmt)
+{
+ return detail::get_time_manip<_CharT>(__tm, __fmt);
+}
+
+#endif
+
+
+
namespace my
{
@@ -103,7 +162,7 @@ time_t StringToTimestamp(std::string const & s)
// Parse UTC format: 1970-01-01T00:00:00Z
tm t{};
std::istringstream ss(s);
- ss >> std::get_time(&t, "%Y-%m-%dT%H:%M:%SZ");
+ ss >> get_time(&t, "%Y-%m-%dT%H:%M:%SZ");
if (!ss.fail() && IsValid(t))
res = base::TimeGM(t);
@@ -114,7 +173,7 @@ time_t StringToTimestamp(std::string const & s)
tm t1{}, t2{};
char sign;
std::istringstream ss(s);
- ss >> std::get_time(&t1, "%Y-%m-%dT%H:%M:%S") >> sign >> std::get_time(&t2, "%H:%M");
+ ss >> get_time(&t1, "%Y-%m-%dT%H:%M:%S") >> sign >> get_time(&t2, "%H:%M");
if (!ss.fail() && IsValid(t1))
{