Files
znc/Buffer.h
psychon 3ecbf13390 Use autoheader
This commit adds a zncconfig.h to ZNC that is automatically generated by
configure. This is done because the -DPACKAGE_STRING=\"znc\ 0.097\" that
configure adds to CXXFLAGS breaks znc-buildmod.

This means that we have to include zncconfig.h as the very first header in every
C++ file that is compiled. This commit kinda cheats and instead adds this
include as the very first thing to all header files we have. This should
hopefully mean that modules don't have to include this.

Because Csocket includes defines.h too late, this commit causes znc to divert
from upstream Csocket once again. :(


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2250 726aef4b-f618-498e-8847-2d620e286838
2011-01-07 15:01:08 +00:00

67 lines
1.8 KiB
C++

/*
* Copyright (C) 2004-2010 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