]> jfr.im git - irc/rizon/znc.git/blame - Buffer.h
Write forceserver and webircpassword to conf
[irc/rizon/znc.git] / Buffer.h
CommitLineData
a09a7e79 1/*
b9b0fd4c 2 * Copyright (C) 2004-2011 See the AUTHORS file for details.
a09a7e79 3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
7 */
6dcacaa7 8
538d3ece 9#ifndef _BUFFER_H
10#define _BUFFER_H
11
3ecbf133 12#include "zncconfig.h"
57f4288c 13#include "ZNCString.h"
901af259 14#include <deque>
e72c4456 15
901af259 16using std::deque;
538d3ece 17
18class CBufLine {
19public:
6a6ae0ed 20 CBufLine(const CString& sPre, const CString& sPost, bool bIncNick);
acd854eb 21 ~CBufLine();
86924339 22 void GetLine(const CString& sTarget, CString& sRet) const;
9d046cc7 23
f601db2c 24 const CString& GetPre() const { return m_sPre; }
25 const CString& GetPost() const { return m_sPost; }
26 bool GetIncNick() const { return m_bIncNick; }
27
28 void SetPre(const CString& s) { m_sPre = s; }
29 void SetPost(const CString& s) { m_sPost = s; }
30 void SetIncNick(bool b) { m_bIncNick = b; }
31
538d3ece 32private:
33protected:
f2d7ae1a 34 CString m_sPre;
35 CString m_sPost;
36 bool m_bIncNick;
538d3ece 37};
38
901af259 39class CBuffer : private deque<CBufLine> {
538d3ece 40public:
41 CBuffer(unsigned int uLineCount = 100);
acd854eb 42 ~CBuffer();
538d3ece 43
6a6ae0ed 44 int AddLine(const CString& sPre, const CString& sPost, bool bIncNick = true);
f601db2c 45 /// Same as AddLine, but if there is already a line with sPre it is replaced.
46 int UpdateLine(const CString& sPre, const CString& sPost, bool bIncNick = true);
94f64333 47 /// Same as UpdateLine, but does nothing if this exact line already exists
48 int UpdateExactLine(const CString& sPre, const CString& sPost, bool bIncNick = true);
beb5b49b 49 bool GetNextLine(const CString& sTarget, CString& sRet);
86924339 50 bool GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) const;
51 bool IsEmpty() const { return empty(); }
538d3ece 52 void Clear() { clear(); }
53
54 // Setters
0ac3466f 55 void SetLineCount(unsigned int u);
538d3ece 56 // !Setters
57
58 // Getters
59 unsigned int GetLineCount() const { return m_uLineCount; }
60 // !Getters
61private:
62protected:
f2d7ae1a 63 unsigned int m_uLineCount;
538d3ece 64};
65
66#endif // !_BUFFER_H