|
// Buffer.h: interface for the CBuffer class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BUFFER_H__03034B81_B719_11D4_BFE2_D3E1AB54CD44__INCLUDED_)
#define AFX_BUFFER_H__03034B81_B719_11D4_BFE2_D3E1AB54CD44__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/**
* Buffer class.
*/
class CBuffer
{
public:
CBuffer()
{
m_buffer = NULL;
m_size = 0;
}
CBuffer(DWORD theSize)
{
m_size = theSize;
m_buffer = ( theSize > 0 ) ? new char[theSize] : NULL;
}
virtual ~CBuffer()
{
if ( m_buffer != NULL )
delete[] m_buffer;
}
inline DWORD getSize(void)
{
return m_size;
}
inline void allocate(DWORD theSize)
{
if ( m_buffer != NULL )
{
delete[] m_buffer;
}
m_size = theSize;
m_buffer = ( theSize > 0 ) ? new char[theSize] : NULL;
}
inline bool isAllocated(void)
{
return (m_buffer != NULL);
}
inline operator char*()
{
return m_buffer;
}
inline void setByte(int aPosition, char aValue)
{
if ( isAllocated()
&& aPosition >= 0
&& aPosition < m_size )
{
m_buffer[aPosition] = aValue;
}
}
private:
char *m_buffer;
DWORD m_size;
};
#endif // !defined(AFX_BUFFER_H__03034B81_B719_11D4_BFE2_D3E1AB54CD44__INCLUDED_)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here