Files
znc/Buffer.cpp
prozacx 6dcacaa79e Added contact info
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@752 726aef4b-f618-498e-8847-2d620e286838
2006-09-13 07:39:48 +00:00

55 lines
959 B
C++

//! @author prozac@rottenboy.com
#include "Buffer.h"
CBufLine::CBufLine(const CString& sPre, const CString& sPost) {
m_sPre = sPre;
m_sPost = sPost;
}
CBufLine::~CBufLine() {}
void CBufLine::GetLine(const CString& sTarget, CString& sRet) {
sRet = m_sPre + sTarget + m_sPost;
}
CBuffer::CBuffer(unsigned int uLineCount) {
m_uLineCount = uLineCount;
}
CBuffer::~CBuffer() {}
int CBuffer::AddLine(const CString& sPre, const CString& sPost) {
if (!m_uLineCount) {
return 0;
}
if (size() >= m_uLineCount) {
erase(begin());
}
push_back(CBufLine(sPre, sPost));
return size();
}
bool CBuffer::GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) {
if (uIdx >= size()) {
return false;
}
(*this)[uIdx].GetLine(sTarget, sRet);
return true;
}
bool CBuffer::GetNextLine(const CString& sTarget, CString& sRet) {
sRet = "";
if (!size()) {
return false;
}
begin()->GetLine(sTarget, sRet);
erase(begin());
return true;
}