#ifndef REMOTE_TRAN_UTIL #define REMOTE_TRAN_UTIL #include #include #include constexpr int MAX_BUFFER_SIZE = 1024 * 1024 * 10; class TranUtil { public: TranUtil(); }; class MLogFormatter : public wxLogFormatter { public: wxString Format(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info) const override { wxDateTime time(info.timestampMS / 1000); time.SetMillisecond(info.timestampMS % 1000); auto timeStr = time.Format(wxT("%H:%M:%S.%l")); wxString levelStr; switch (level) { case wxLOG_FatalError: levelStr = "FATAL"; break; case wxLOG_Error: levelStr = "ERROR"; break; case wxLOG_Warning: levelStr = "WARN"; break; case wxLOG_Message: levelStr = "INFO"; break; case wxLOG_Status: levelStr = "STATUS"; break; case wxLOG_Info: levelStr = "INFO"; break; case wxLOG_Debug: levelStr = "DEBUG"; break; case wxLOG_Trace: levelStr = "TRACE"; break; default: levelStr = "OTHER"; break; } return wxString::Format("[%s][%s] %s", timeStr, levelStr, msg); } }; class MutBuffer { public: MutBuffer() = default; public: void Push(const char* data, int len); int IndexOf(const char* data, int len, int start_pos = 0); const char* GetData() const; int Length() const; void RemoveOf(int start_pos, int len); void Clear(); private: std::vector buffer_; }; class wxUtil { public: static wxString GetConfigDir(); static bool CreateConfigDir(const wxString& dir, const wxString& name, wxString& fullPath); }; #endif // REMOTE_TRAN_UTIL