CBuffer is an expandable buffer class which can expand when needed and allows insertion of data and many operation on buffer Using the CBuffer Class In order to use the class, simply do the following. (Remember that if any of this is unclear, I have included a demo application that will hopefully clear up any […]
CodeGuru content and product recommendations are
editorially independent. We may make money when you click on links
to our partners.
Learn More
CBuffer is an expandable buffer class which can expand when needed and
allows insertion of data and many operation on buffer
Using the CBuffer Class
In order to use the class, simply do the following. (Remember that if any of this is
unclear, I have included a demo application that will hopefully clear up any
misunderstandings.
- Instantiate the CBuffer object
- Call the CBuffer Init method
CBuffer:Init(int nSizeOfBuffer, int nNbrOfElements,
int nIncrementalGrowthValue)
- Insert data into the buffer by using any of the following mechanisms:
int CBuffer::PutData(BYTE *pBuff)
void CBuffer::operator+=(BYTE *pBuff)
int CBuffer::InserData(BYTE * pBuff,int nOffset)
- Retrieve data from the buffer by calling any of the following methods:
int CBuffer::GetData(BYTE * pBuff,int nIndex)
BYTE *CBuffer::GetPointer(int nIndex) const
- Use any of the following helper methods
m_Buffer.GetSize()
m_Buffer.GetTotalElements()
m_Buffer.GetStructureSize()
m_Buffer.GetFreeSp()
m_Buffer.GetFreeStSp()
#pragma once
class CBuffer
{
public:
CBuffer();
virtual ~CBuffer();
int Init(int,int,int);
int PutData(BYTE*);
void operator+=(BYTE *);
int InserData(BYTE*,int);
int GetData(BYTE*,int);
int ExpandBuff(int);
int GetSize();
int GetTotalElements();
int GetStructureSize();
int GetFreeSp();
int GetFreeStSp();
BYTE *GetPointer(int nIndex)const;
BYTE *CBuffer::operator[](int nIndex)const;
private:
BYTE *m_pBuff;
int m_nStructSize;
int m_nTotal;
int m_nOffset;
int m_nSize;
int m_nStructOffset;
int m_nIncerment;
};
Downloads
Download demo project – 14 Kb