mirror of
https://github.com/znc/znc.git
synced 2026-08-06 08:52:57 +02:00
Make CBufLine hold a CMessage internally
This commit is contained in:
+14
-10
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <znc/zncconfig.h>
|
||||
#include <znc/ZNCString.h>
|
||||
#include <znc/Message.h>
|
||||
#include <sys/time.h>
|
||||
#include <deque>
|
||||
|
||||
@@ -29,31 +30,32 @@ class CClient;
|
||||
class CBufLine {
|
||||
public:
|
||||
CBufLine() : CBufLine("") { throw 0; } // shouldn't be called, but is needed for compilation
|
||||
CBufLine(const CMessage& Format, const CString& sText = "");
|
||||
CBufLine(const CString& sFormat, const CString& sText = "", const timeval* ts = nullptr, const MCString& mssTags = MCString::EmptyMap);
|
||||
~CBufLine();
|
||||
CString GetLine(const CClient& Client, const MCString& msParams) const;
|
||||
CMessage ToMessage(const CClient& Client, const MCString& mssParams) const;
|
||||
/// @deprecated Use ToMessage() instead
|
||||
CString GetLine(const CClient& Client, const MCString& mssParams) const;
|
||||
void UpdateTime();
|
||||
|
||||
// Setters
|
||||
void SetFormat(const CString& sFormat) { m_sFormat = sFormat; }
|
||||
void SetFormat(const CString& sFormat) { m_Message.Parse(sFormat); }
|
||||
void SetText(const CString& sText) { m_sText = sText; }
|
||||
void SetTime(const timeval& ts) { m_time = ts; }
|
||||
void SetTags(const MCString& mssTags) { m_mssTags = mssTags; }
|
||||
void SetTime(const timeval& ts) { m_Message.SetTime(ts); }
|
||||
void SetTags(const MCString& mssTags) { m_Message.SetTags(mssTags); }
|
||||
// !Setters
|
||||
|
||||
// Getters
|
||||
const CString& GetFormat() const { return m_sFormat; }
|
||||
CString GetFormat() const { return m_Message.ToString(CMessage::ExcludeTags); }
|
||||
const CString& GetText() const { return m_sText; }
|
||||
timeval GetTime() const { return m_time; }
|
||||
const MCString& GetTags() const { return m_mssTags; }
|
||||
timeval GetTime() const { return m_Message.GetTime(); }
|
||||
const MCString& GetTags() const { return m_Message.GetTags(); }
|
||||
// !Getters
|
||||
|
||||
private:
|
||||
protected:
|
||||
CString m_sFormat;
|
||||
CMessage m_Message;
|
||||
CString m_sText;
|
||||
timeval m_time;
|
||||
MCString m_mssTags;
|
||||
};
|
||||
|
||||
class CBuffer : private std::deque<CBufLine> {
|
||||
@@ -61,6 +63,8 @@ public:
|
||||
CBuffer(unsigned int uLineCount = 100);
|
||||
~CBuffer();
|
||||
|
||||
// TODO: CMessage-based API
|
||||
|
||||
size_type AddLine(const CString& sFormat, const CString& sText = "", const timeval* ts = nullptr, const MCString& mssTags = MCString::EmptyMap);
|
||||
/// Same as AddLine, but replaces a line whose format string starts with sMatch if there is one.
|
||||
size_type UpdateLine(const CString& sMatch, const CString& sFormat, const CString& sText = "");
|
||||
|
||||
Reference in New Issue
Block a user