[DEV] continue removing stl
This commit is contained in:
parent
d4b240ac1f
commit
278a5ef865
@ -9,6 +9,7 @@
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <echrono/Duration.hpp>
|
||||
#include <echrono/debug.hpp>
|
||||
#include <etk/UString.hpp>
|
||||
|
||||
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<std::chrono::nanoseconds>(_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<echrono::Clock>(const echrono::Clock& _obj) {
|
||||
template<> etk::String toString<echrono::Clock>(const echrono::Clock& _obj) {
|
||||
std::chrono::nanoseconds ns = std::chrono::duration_cast<std::chrono::nanoseconds>(_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<echrono::Clock>(const echrono::Clock& _obj) {
|
||||
template<> etk::UString toUString<echrono::Clock>(const echrono::Clock& _obj) {
|
||||
std::chrono::nanoseconds ns = std::chrono::duration_cast<std::chrono::nanoseconds>(_obj.get().time_since_epoch());
|
||||
return etk::to_u32string(ns.count());
|
||||
return etk::toUString(ns.count());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <chrono>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <echrono/Time.hpp>
|
||||
#include <echrono/Duration.hpp>
|
||||
#include <echrono/debug.hpp>
|
||||
#include <etk/UString.hpp>
|
||||
|
||||
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<echrono::Duration>(const echrono::Duration& _obj) {
|
||||
return etk::to_string(_obj.count());
|
||||
template<> etk::String toString<echrono::Duration>(const echrono::Duration& _obj) {
|
||||
return etk::toString(_obj.count());
|
||||
}
|
||||
#if __CPP_VERSION__ >= 2011
|
||||
template<> std::u32string to_u32string<echrono::Duration>(const echrono::Duration& _obj) {
|
||||
return etk::to_u32string(_obj.count());
|
||||
template<> etk::UString toUString<echrono::Duration>(const echrono::Duration& _obj) {
|
||||
return etk::toUString(_obj.count());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <echrono/Duration.hpp>
|
||||
#include <echrono/debug.hpp>
|
||||
#include <etk/UString.hpp>
|
||||
|
||||
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<std::chrono::nanoseconds>(_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<echrono::Steady>(const echrono::Steady& _obj) {
|
||||
template<> etk::String toString<echrono::Steady>(const echrono::Steady& _obj) {
|
||||
std::chrono::nanoseconds ns = std::chrono::duration_cast<std::chrono::nanoseconds>(_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<echrono::Steady>(const echrono::Steady& _obj) {
|
||||
template<> etk::UString toUString<echrono::Steady>(const echrono::Steady& _obj) {
|
||||
std::chrono::nanoseconds ns = std::chrono::duration_cast<std::chrono::nanoseconds>(_obj.get().time_since_epoch());
|
||||
return etk::to_u32string(ns.count());
|
||||
return etk::toUString(ns.count());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <chrono>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <echrono/Time.hpp>
|
||||
#include <echrono/Duration.hpp>
|
||||
#include <echrono/debug.hpp>
|
||||
#include <etk/UString.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
|
||||
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<std::chrono::nanoseconds>(_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<std::chrono::nanoseconds>(_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<echrono::Time>(const echrono::Time& _obj) {
|
||||
template<> etk::String toString<echrono::Time>(const echrono::Time& _obj) {
|
||||
std::chrono::nanoseconds ns = std::chrono::duration_cast<std::chrono::nanoseconds>(_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<echrono::Time>(const echrono::Time& _obj) {
|
||||
template<> etk::UString toUString<echrono::Time>(const echrono::Time& _obj) {
|
||||
std::chrono::nanoseconds ns = std::chrono::duration_cast<std::chrono::nanoseconds>(_obj.get().time_since_epoch());
|
||||
return etk::to_u32string(ns.count());
|
||||
return etk::toUString(ns.count());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <chrono>
|
||||
|
||||
@ -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 <echrono/Duration.hpp>
|
||||
|
@ -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 : ");
|
||||
|
Loading…
x
Reference in New Issue
Block a user