diff --git a/echrono/Clock.cpp b/echrono/Clock.cpp index e31af28..c1e679d 100644 --- a/echrono/Clock.cpp +++ b/echrono/Clock.cpp @@ -9,6 +9,7 @@ #include #include #include +#include echrono::Clock::Clock() { m_data = std::chrono::steady_clock::time_point(std::chrono::seconds(0)); @@ -112,7 +113,7 @@ int64_t echrono::Clock::count() { return ns.count()/1000; } -std::ostream& echrono::operator <<(std::ostream& _os, const echrono::Clock& _obj) { +etk::Stream& echrono::operator <<(etk::Stream& _os, const echrono::Clock& _obj) { std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); int64_t totalSecond = ns.count()/1000000000; int64_t millisecond = (ns.count()%1000000000)/1000000; @@ -159,14 +160,14 @@ std::ostream& echrono::operator <<(std::ostream& _os, const echrono::Clock& _obj namespace etk { - template<> std::string to_string(const echrono::Clock& _obj) { + template<> etk::String toString(const echrono::Clock& _obj) { std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); - return etk::to_string(ns.count()); + return etk::toString(ns.count()); } #if __CPP_VERSION__ >= 2011 - template<> std::u32string to_u32string(const echrono::Clock& _obj) { + template<> etk::UString toUString(const echrono::Clock& _obj) { std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); - return etk::to_u32string(ns.count()); + return etk::toUString(ns.count()); } #endif } diff --git a/echrono/Clock.hpp b/echrono/Clock.hpp index e9f5a3c..0d72f8e 100644 --- a/echrono/Clock.hpp +++ b/echrono/Clock.hpp @@ -5,7 +5,7 @@ */ #pragma once -#include +#include #include #include @@ -49,7 +49,7 @@ namespace echrono { Duration operator- (const echrono::Clock& _obj) const; void reset(); }; - std::ostream& operator <<(std::ostream& _os, const echrono::Clock& _obj); + etk::Stream& operator <<(etk::Stream& _os, const echrono::Clock& _obj); } diff --git a/echrono/Duration.cpp b/echrono/Duration.cpp index 2920e98..c7f32c2 100644 --- a/echrono/Duration.cpp +++ b/echrono/Duration.cpp @@ -8,6 +8,7 @@ #include #include #include +#include echrono::Duration::Duration() { m_data = std::chrono::nanoseconds(0); @@ -140,7 +141,7 @@ void echrono::Duration::reset() { m_data = std::chrono::nanoseconds(0); } -std::ostream& echrono::operator <<(std::ostream& _os, const echrono::Duration& _obj) { +etk::Stream& echrono::operator <<(etk::Stream& _os, const echrono::Duration& _obj) { int64_t totalSecond = _obj.count()/1000000000; int64_t millisecond = (_obj.count()%1000000000)/1000000; int64_t microsecond = (_obj.count()%1000000)/1000; @@ -185,12 +186,12 @@ std::ostream& echrono::operator <<(std::ostream& _os, const echrono::Duration& _ } namespace etk { - template<> std::string to_string(const echrono::Duration& _obj) { - return etk::to_string(_obj.count()); + template<> etk::String toString(const echrono::Duration& _obj) { + return etk::toString(_obj.count()); } #if __CPP_VERSION__ >= 2011 - template<> std::u32string to_u32string(const echrono::Duration& _obj) { - return etk::to_u32string(_obj.count()); + template<> etk::UString toUString(const echrono::Duration& _obj) { + return etk::toUString(_obj.count()); } #endif } diff --git a/echrono/Duration.hpp b/echrono/Duration.hpp index fa5f46d..e65cd3f 100644 --- a/echrono/Duration.hpp +++ b/echrono/Duration.hpp @@ -54,6 +54,6 @@ namespace echrono { double toSeconds() const; void reset(); }; - std::ostream& operator <<(std::ostream& _os, const echrono::Duration& _obj); + etk::Stream& operator <<(etk::Stream& _os, const echrono::Duration& _obj); } diff --git a/echrono/Steady.cpp b/echrono/Steady.cpp index 1ef92e0..824b56d 100644 --- a/echrono/Steady.cpp +++ b/echrono/Steady.cpp @@ -8,6 +8,7 @@ #include #include #include +#include echrono::Steady::Steady() { m_data = std::chrono::steady_clock::time_point(std::chrono::seconds(0)); @@ -108,7 +109,7 @@ int64_t echrono::Steady::count() { return ns.count()/1000; } -std::ostream& echrono::operator <<(std::ostream& _os, const echrono::Steady& _obj) { +etk::Stream& echrono::operator <<(etk::Stream& _os, const echrono::Steady& _obj) { std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); int64_t totalSecond = ns.count()/1000000000; int64_t millisecond = (ns.count()%1000000000)/1000000; @@ -154,14 +155,14 @@ std::ostream& echrono::operator <<(std::ostream& _os, const echrono::Steady& _ob } namespace etk { - template<> std::string to_string(const echrono::Steady& _obj) { + template<> etk::String toString(const echrono::Steady& _obj) { std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); - return etk::to_string(ns.count()); + return etk::toString(ns.count()); } #if __CPP_VERSION__ >= 2011 - template<> std::u32string to_u32string(const echrono::Steady& _obj) { + template<> etk::UString toUString(const echrono::Steady& _obj) { std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); - return etk::to_u32string(ns.count()); + return etk::toUString(ns.count()); } #endif } diff --git a/echrono/Steady.hpp b/echrono/Steady.hpp index d62782d..e7f097e 100644 --- a/echrono/Steady.hpp +++ b/echrono/Steady.hpp @@ -5,7 +5,7 @@ */ #pragma once -#include +#include #include #include @@ -47,7 +47,7 @@ namespace echrono { Duration operator- (const echrono::Steady& _obj) const; void reset(); }; - std::ostream& operator <<(std::ostream& _os, const echrono::Steady& _obj); + etk::Stream& operator <<(etk::Stream& _os, const echrono::Steady& _obj); } diff --git a/echrono/Time.cpp b/echrono/Time.cpp index 0a9ce3f..d6aed8a 100644 --- a/echrono/Time.cpp +++ b/echrono/Time.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include echrono::Time::Time() { m_data = std::chrono::system_clock::time_point(std::chrono::seconds(0)); @@ -124,66 +126,61 @@ int64_t echrono::Time::count() { return ns.count()/1000; } -std::ostream& echrono::operator <<(std::ostream& _os, const echrono::Time& _obj) { - #ifdef __TARGET_OS__Android - std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); - int64_t totalSecond = ns.count()/1000000000; - int64_t millisecond = (ns.count()%1000000000)/1000000; - int64_t microsecond = (ns.count()%1000000)/1000; - int64_t nanosecond = ns.count()%1000; - //_os << totalSecond << "s " << millisecond << "ms " << microsecond << "µs " << nanosecond << "ns"; - int32_t second = totalSecond % 60; - int32_t minute = (totalSecond/60)%60; - int32_t hour = (totalSecond/3600)%24; - int32_t day = (totalSecond/(24*3600))%365; - int32_t year = totalSecond/(24*3600*365) + 1970; - bool start = false; - if (year != 0) { - start = true; - _os << year << "y "; - } - if (day != 0 || start == true) { - start = true; - _os << day << "d "; - } - if (hour != 0 || start == true) { - start = true; - _os << hour << "h "; - } - if (minute != 0 || start == true) { - start = true; - _os << minute << ":"; - } - if (second != 0 || start == true) { - start = true; - _os << second << "s "; - } - if (millisecond != 0 || start == true) { - start = true; - _os << millisecond << "ms "; - } - if (microsecond != 0 || start == true) { - start = true; - _os << microsecond << "us "; - } - _os << nanosecond << "ns "; - # else - std::time_t now_c = std::chrono::system_clock::to_time_t(_obj.get()); - _os << std::put_time(std::localtime(&now_c), "%F %T"); - # endif +etk::Stream& echrono::operator <<(etk::Stream& _os, const echrono::Time& _obj) { + std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); + int64_t totalSecond = ns.count()/1000000000; + int64_t millisecond = (ns.count()%1000000000)/1000000; + int64_t microsecond = (ns.count()%1000000)/1000; + int64_t nanosecond = ns.count()%1000; + //_os << totalSecond << "s " << millisecond << "ms " << microsecond << "µs " << nanosecond << "ns"; + int32_t second = totalSecond % 60; + int32_t minute = (totalSecond/60)%60; + int32_t hour = (totalSecond/3600)%24; + int32_t day = (totalSecond/(24*3600))%365; + int32_t year = totalSecond/(24*3600*365) + 1970; + bool start = false; + if (year != 0) { + start = true; + _os << year << "y "; + } + if (day != 0 || start == true) { + start = true; + _os << day << "d "; + } + if (hour != 0 || start == true) { + start = true; + _os << hour << "h "; + } + if (minute != 0 || start == true) { + start = true; + _os << minute << ":"; + } + if (second != 0 || start == true) { + start = true; + _os << second << "s "; + } + if (millisecond != 0 || start == true) { + start = true; + _os << millisecond << "ms "; + } + if (microsecond != 0 || start == true) { + start = true; + _os << microsecond << "us "; + } + _os << nanosecond << "ns "; return _os; } namespace etk { - template<> std::string to_string(const echrono::Time& _obj) { + template<> etk::String toString(const echrono::Time& _obj) { std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); - return etk::to_string(ns.count()); + return etk::toString(ns.count()); } #if __CPP_VERSION__ >= 2011 - template<> std::u32string to_u32string(const echrono::Time& _obj) { + template<> etk::UString toUString(const echrono::Time& _obj) { std::chrono::nanoseconds ns = std::chrono::duration_cast(_obj.get().time_since_epoch()); - return etk::to_u32string(ns.count()); + return etk::toUString(ns.count()); } #endif } diff --git a/echrono/Time.hpp b/echrono/Time.hpp index 17f7067..657f3ce 100644 --- a/echrono/Time.hpp +++ b/echrono/Time.hpp @@ -5,7 +5,7 @@ */ #pragma once -#include +#include #include #include @@ -50,7 +50,7 @@ namespace echrono { Duration operator- (const echrono::Time& _obj) const; void reset(); }; - std::ostream& operator <<(std::ostream& _os, const echrono::Time& _obj); + etk::Stream& operator <<(etk::Stream& _os, const echrono::Time& _obj); } #include diff --git a/echrono/echrono.cpp b/echrono/echrono.cpp index 974b465..1bd4101 100644 --- a/echrono/echrono.cpp +++ b/echrono/echrono.cpp @@ -17,7 +17,7 @@ void echrono::init(int _argc, const char** _argv) { } ECHRONO_INFO("E-chrono system init"); for (int32_t iii=0; iii<_argc ; ++iii) { - std::string data = _argv[iii]; + etk::String data = _argv[iii]; if ( data == "-h" || data == "--help") { ECHRONO_PRINT("e-chrono - help : ");