-
Notifications
You must be signed in to change notification settings - Fork 1
/
Buffer.h
66 lines (54 loc) · 1.81 KB
/
Buffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (C) 2004-2011 See the AUTHORS file for details.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/
#ifndef _BUFFER_H
#define _BUFFER_H
#include "zncconfig.h"
#include "ZNCString.h"
#include <deque>
using std::deque;
class CBufLine {
public:
CBufLine(const CString& sPre, const CString& sPost, bool bIncNick);
~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; }
private:
protected:
CString m_sPre;
CString m_sPost;
bool m_bIncNick;
};
class CBuffer : private deque<CBufLine> {
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;
bool IsEmpty() const { return empty(); }
void Clear() { clear(); }
// Setters
void SetLineCount(unsigned int u);
// !Setters
// Getters
unsigned int GetLineCount() const { return m_uLineCount; }
// !Getters
private:
protected:
unsigned int m_uLineCount;
};
#endif // !_BUFFER_H