1 #ifndef __STG_DUMP_HELPERS_H__
2 #define __STG_DUMP_HELPERS_H__
4 #include "stg/common.h"
20 explicit Dumper(const std::string& tag)
21 : m_stream(getName(tag).c_str())
26 void write(const void* data, size_t size)
34 std::ofstream m_stream;
38 time_t now = time(NULL);
40 localtime_r(&now, &localTime);
44 std::string getName(const std::string& tag) const
46 tm localTime = getTime();
48 std::ostringstream res;
50 << "-" << (localTime.tm_year + 1900) << twoDigit(localTime.tm_mon + 1) << twoDigit(localTime.tm_mday)
51 << "-" << twoDigit(localTime.tm_hour) << twoDigit(localTime.tm_min) << twoDigit(localTime.tm_sec)
59 tm localTime = getTime();
60 m_stream << "[" << (localTime.tm_year + 1900) << "-" << twoDigit(localTime.tm_mon + 1) << "-" << twoDigit(localTime.tm_mday)
61 << " " << twoDigit(localTime.tm_hour) << ":" << twoDigit(localTime.tm_min) << ":" << twoDigit(localTime.tm_sec)
65 void writeHEX(const void* data, size_t size)
67 m_stream << "(" << std::setw(4) << std::setfill(' ') << size << ") ";
68 const unsigned char* pos = static_cast<const unsigned char*>(data);
69 for (size_t i = 0; i < size; ++i)
70 m_stream << std::hex << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(*pos++);
71 m_stream << std::dec << "\n";
74 std::string twoDigit(int value) const
76 std::string res = x2str(value);