Rewrite Buffer to store a format string.

Will use this to allow more parameters to be inserted at the time the
buffers are flushed to the client.
This commit is contained in:
Stéphan Kochen
2011-10-16 17:31:43 +02:00
parent 2fdf54d43d
commit 948ae2510c
8 changed files with 70 additions and 75 deletions
+12 -20
View File
@@ -17,23 +17,15 @@ using std::deque;
class CBufLine {
public:
CBufLine(const CString& sPre, const CString& sPost, bool bIncNick);
CBufLine(const CString& sFormat);
~CBufLine();
void GetLine(const CString& sTarget, CString& sRet) const;
const CString& GetPre() const { return m_sPre; }
const CString& GetPost() const { return m_sPost; }
bool GetIncNick() const { return m_bIncNick; }
void SetPre(const CString& s) { m_sPre = s; }
void SetPost(const CString& s) { m_sPost = s; }
void SetIncNick(bool b) { m_bIncNick = b; }
const CString& GetFormat() const { return m_sFormat; }
void SetFormat(const CString& sFormat) { m_sFormat = sFormat; }
void GetLine(CString& sRet, const MCString& msParams) const;
private:
protected:
CString m_sPre;
CString m_sPost;
bool m_bIncNick;
CString m_sFormat;
};
class CBuffer : private deque<CBufLine> {
@@ -41,13 +33,13 @@ public:
CBuffer(unsigned int uLineCount = 100);
~CBuffer();
int AddLine(const CString& sPre, const CString& sPost, bool bIncNick = true);
/// Same as AddLine, but if there is already a line with sPre it is replaced.
int UpdateLine(const CString& sPre, const CString& sPost, bool bIncNick = true);
/// Same as UpdateLine, but does nothing if this exact line already exists
int UpdateExactLine(const CString& sPre, const CString& sPost, bool bIncNick = true);
bool GetNextLine(const CString& sTarget, CString& sRet);
bool GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) const;
int AddLine(const CString& sFormat);
/// Same as AddLine, but replaces a line that starts with sMatch if there is one.
int UpdateLine(const CString& sMatch, const CString& sFormat);
/// Same as UpdateLine, but does nothing if this exact line already exists.
int UpdateExactLine(const CString& sFormat);
bool GetNextLine(CString& sRet, const MCString& msParams = MCString::EmptyMap);
bool GetLine(unsigned int uIdx, CString& sRet, const MCString& msParams = MCString::EmptyMap) const;
bool IsEmpty() const { return empty(); }
void Clear() { clear(); }
+7 -7
View File
@@ -107,17 +107,17 @@ public:
bool PutIRC(const CString& sLine);
// Buffers
void AddRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.AddLine(sPre, sPost, bIncNick); }
void UpdateRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.UpdateLine(sPre, sPost, bIncNick); }
void UpdateExactRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.UpdateExactLine(sPre, sPost, bIncNick); }
void AddRawBuffer(const CString& sFormat) { m_RawBuffer.AddLine(sFormat); }
void UpdateRawBuffer(const CString& sMatch, const CString& sFormat) { m_RawBuffer.UpdateLine(sMatch, sFormat); }
void UpdateExactRawBuffer(const CString& sFormat) { m_RawBuffer.UpdateExactLine(sFormat); }
void ClearRawBuffer() { m_RawBuffer.Clear(); }
void AddMotdBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_MotdBuffer.AddLine(sPre, sPost, bIncNick); }
void UpdateMotdBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_MotdBuffer.UpdateLine(sPre, sPost, bIncNick); }
void AddMotdBuffer(const CString& sFormat) { m_MotdBuffer.AddLine(sFormat); }
void UpdateMotdBuffer(const CString& sMatch, const CString& sFormat) { m_MotdBuffer.UpdateLine(sMatch, sFormat); }
void ClearMotdBuffer() { m_MotdBuffer.Clear(); }
void AddQueryBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_QueryBuffer.AddLine(sPre, sPost, bIncNick); }
void UpdateQueryBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_QueryBuffer.UpdateLine(sPre, sPost, bIncNick); }
void AddQueryBuffer(const CString& sFormat) { m_QueryBuffer.AddLine(sFormat); }
void UpdateQueryBuffer(const CString& sMatch, const CString& sFormat) { m_QueryBuffer.UpdateLine(sMatch, sFormat); }
void ClearQueryBuffer() { m_QueryBuffer.Clear(); }
// !Buffers
+3
View File
@@ -482,6 +482,9 @@ public:
/** Destruct this MCString. */
virtual ~MCString() { clear(); }
/** A static instance of an empty map. */
static const MCString EmptyMap;
/** Status codes that can be returned by WriteToDisk() and
* ReadFromDisk(). */
enum status_t