X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/46b0747592074017ff0ea4b33d4a7194235886e5..0907aa4037b12b6b88ee24495d4577a064d4f8db:/stargazer/plugins/configuration/sgconfig/dumphelpers.h?ds=sidebyside diff --git a/stargazer/plugins/configuration/sgconfig/dumphelpers.h b/stargazer/plugins/configuration/sgconfig/dumphelpers.h deleted file mode 100644 index cc02d14d..00000000 --- a/stargazer/plugins/configuration/sgconfig/dumphelpers.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef __STG_DUMP_HELPERS_H__ -#define __STG_DUMP_HELPERS_H__ - -#include "stg/common.h" - -#include -#include -#include -#include - -#include -#include - -namespace STG -{ - -class Dumper -{ - public: - explicit Dumper(const std::string& tag) - : m_stream(getName(tag).c_str()) - { - } - ~Dumper() {} - - void write(const void* data, size_t size) - { - writePrefix(); - m_stream << " "; - writeHEX(data, size); - } - - private: - std::ofstream m_stream; - - tm getTime() const - { - time_t now = time(NULL); - tm localTime; - localtime_r(&now, &localTime); - return localTime; - } - - std::string getName(const std::string& tag) const - { - tm localTime = getTime(); - - std::ostringstream res; - res << tag - << "-" << (localTime.tm_year + 1900) << twoDigit(localTime.tm_mon + 1) << twoDigit(localTime.tm_mday) - << "-" << twoDigit(localTime.tm_hour) << twoDigit(localTime.tm_min) << twoDigit(localTime.tm_sec) - << ".data"; - - return res.str(); - } - - void writePrefix() - { - tm localTime = getTime(); - m_stream << "[" << (localTime.tm_year + 1900) << "-" << twoDigit(localTime.tm_mon + 1) << "-" << twoDigit(localTime.tm_mday) - << " " << twoDigit(localTime.tm_hour) << ":" << twoDigit(localTime.tm_min) << ":" << twoDigit(localTime.tm_sec) - << "]"; - } - - void writeHEX(const void* data, size_t size) - { - m_stream << "(" << std::setw(4) << std::setfill(' ') << size << ") "; - const unsigned char* pos = static_cast(data); - for (size_t i = 0; i < size; ++i) - m_stream << std::hex << std::setw(2) << std::setfill('0') << static_cast(*pos++); - m_stream << std::dec << "\n"; - } - - std::string twoDigit(int value) const - { - std::string res = x2str(value); - if (res.length() < 2) - res = "0" + res; - return res; - } -}; - -} // namespace Caster - -#endif