From 15855fa84a09fd1fd486d357c38db0f2bd181e74 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 4 Mar 2014 23:23:45 +0000 Subject: HistoryStats compiles ok now git-svn-id: http://svn.miranda-ng.org/main/trunk@8399 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HistoryStats/src/message.h | 121 +++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 plugins/HistoryStats/src/message.h (limited to 'plugins/HistoryStats/src/message.h') diff --git a/plugins/HistoryStats/src/message.h b/plugins/HistoryStats/src/message.h new file mode 100644 index 0000000000..fe239c5be4 --- /dev/null +++ b/plugins/HistoryStats/src/message.h @@ -0,0 +1,121 @@ +#if !defined(HISTORYSTATS_GUARD_MESSAGE_H) +#define HISTORYSTATS_GUARD_MESSAGE_H + +#include "_globals.h" +#include "_consts.h" + +#include "utils.h" + +/* + * Message + */ + +class Message + : private pattern::NotCopyable +{ +private: + enum Flags { + // internal + Raw = 0x01, + WithoutLinks = 0x02, + + // very internal + PtrIsNonT = 0x10, + PtrIsUTF8 = 0x20, + }; + +private: + bool m_bOutgoing; + DWORD m_Timestamp; + ext::string::size_type m_nLength; + const void* m_RawSource; + int m_Available; + ext::string m_Raw; + ext::string m_WithoutLinks; + bool m_bStripRawRTF; + bool m_bStripBBCodes; + +private: + void makeRawAvailable(); + void stripRawRTF(); + void stripBBCodes(); + void filterLinks(); + +public: + explicit Message(bool bStripRawRTF, bool bStripBBCodes) + : m_RawSource(NULL) + , m_Available(0) + , m_bStripRawRTF(bStripRawRTF) + , m_bStripBBCodes(bStripBBCodes) + { + } + + // assigning data + void assignInfo(bool bOutgoing, DWORD localTimestamp) + { + m_bOutgoing = bOutgoing; + m_Timestamp = localTimestamp; + } + + void assignText(const mu_text* msg, ext::string::size_type len) + { + m_RawSource = msg; + m_nLength = len; + m_Available = 0; + } + +#if defined(MU_WIDE) + void assignText(const mu_ansi* msg, ext::string::size_type len) + { + m_RawSource = msg; + m_nLength = len; + m_Available = PtrIsNonT; + } +#endif // MU_WIDE + + void assignTextFromUTF8(const mu_ansi* msg, ext::string::size_type len) + { + m_RawSource = msg; + m_nLength = len; + m_Available = PtrIsUTF8; + } + + // retrieving always available data + bool isOutgoing() + { + return m_bOutgoing; + } + + DWORD getTimestamp() + { + return m_Timestamp; + } + + // retrieving on-demand data + ext::string::size_type getLength() + { + return (!m_bStripBBCodes && !m_bStripRawRTF) ? m_nLength : getRaw().length(); + } + + const ext::string& getRaw() + { + if (!(m_Available & Raw)) + { + makeRawAvailable(); + } + + return m_Raw; + } + + const ext::string& getWithoutLinks() + { + if (!(m_Available & WithoutLinks)) + { + filterLinks(); + } + + return m_WithoutLinks; + } +}; + +#endif // HISTORYSTATS_GUARD_MESSAGE_H -- cgit v1.2.3