From 2287a4753ce50fcfb1849cff2d60f8bbefd09db5 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 21 Apr 2019 13:50:17 +0200 Subject: [PATCH] Fixed operator << warnings. --- src/easy/types_easy.cpp | 66 ++++++++++++++++++++------------------ src/return_types.cpp | 71 +++++++++++++++++++++-------------------- 2 files changed, 71 insertions(+), 66 deletions(-) diff --git a/src/easy/types_easy.cpp b/src/easy/types_easy.cpp index 835d883..dbb022d 100644 --- a/src/easy/types_easy.cpp +++ b/src/easy/types_easy.cpp @@ -16,42 +16,46 @@ #include "types_easy.hpp" -using namespace Mastodon; - -Easy::time::operator const system_clock::time_point() const +namespace Mastodon { - return timepoint; -} - -Easy::time::operator const string() const +namespace Easy { - return strtime("%FT%T%z", true); -} - -const string Easy::time::strtime(const string &format, const bool &local) const -{ - constexpr std::uint16_t bufsize = 1024; - std::time_t time = system_clock::to_time_t(timepoint); - std::tm *tm; - if (local) + time::operator const system_clock::time_point() const { - tm = std::localtime(&time); - } - else - { - tm = std::gmtime(&time); + return timepoint; } - char buffer[bufsize]; - std::strftime(buffer, bufsize, format.c_str(), tm); + time::operator const string() const + { + return strtime("%FT%T%z", true); + } - return static_cast(buffer); -} + const string time::strtime(const string &format, const bool &local) const + { + constexpr std::uint16_t bufsize = 1024; + std::time_t time = system_clock::to_time_t(timepoint); + std::tm *tm; + if (local) + { + tm = std::localtime(&time); + } + else + { + tm = std::gmtime(&time); + } -std::ostream &Mastodon::Easy::operator <<(std::ostream &out, - const Easy::time &t) -{ - const string s = t; // Converts using operator const string(). - out << s; - return out; + char buffer[bufsize]; + std::strftime(buffer, bufsize, format.c_str(), tm); + + return static_cast(buffer); + } + + std::ostream &operator <<(std::ostream &out, + const time &t) + { + const string s = t; // Converts using operator const string(). + out << s; + return out; + } +} } diff --git a/src/return_types.cpp b/src/return_types.cpp index ea4e977..e84087e 100644 --- a/src/return_types.cpp +++ b/src/return_types.cpp @@ -16,44 +16,45 @@ #include "return_types.hpp" -using namespace Mastodon; - -return_base::operator bool() +namespace Mastodon { - if (error_code == 0) + return_base::operator bool() { - return true; + if (error_code == 0) + { + return true; + } + else + { + return false; + } } - else + + return_base::operator uint8_t() { - return false; + return error_code; + } + + return_call::operator const string() const + { + return answer; + } + + std::ostream &operator <<(std::ostream &out, const return_call &ret) + { + out << ret.answer; + return out; + } + + return_call::return_call() + {} + + return_call::return_call(const uint8_t ec, const string &em, + const uint16_t hec, const string &a) + : answer(a) + { + error_code = ec; + error_message = em; + http_error_code = hec; } } - -return_base::operator uint8_t() -{ - return error_code; -} - -return_call::operator const string() const -{ - return answer; -} - -std::ostream &Mastodon::operator <<(std::ostream &out, const return_call &ret) -{ - out << ret.answer; - return out; -} - -return_call::return_call() -{} - -return_call::return_call(const uint8_t ec, const string &em, - const uint16_t hec, const string &a) - : answer(a) -{ - error_code = ec; - error_message = em; - http_error_code = hec; -}