//------------------------ CSPBuffer.h ------------------------

//*************************************************************
//*****       Copyright ©2002 - 2004 Micronovae Ltd       *****
//*****                All rights reserved                *****
//*************************************************************


#ifndef _CSPBUFFER
#define _CSPBUFFER

#include "CSPConf.h"
#include "CSPLib.h"
#include "CSPString.h"
#include "CSPWString.h"
#pragma warning( disable : 4251 )

class CSPLIB_CLASS_EXPORT CSPBuffer : public CSPObject
{
	public:
		CSPBuffer();
		CSPBuffer( unsigned long ulSize );
		CSPBuffer( const CSPBuffer& Buffer );
		virtual ~CSPBuffer();

		void SetSize( unsigned long ulSize );
		void Resize( unsigned long ulSize );
		void Grow( unsigned long ulSize );
		void Shrink( unsigned long ulSize );
		unsigned long GetSize() const;
		void Empty();

		unsigned char* GetPtr() const;
		CSPBuffer& operator = ( const CSPBuffer& Buffer );
		CSPBuffer& operator = ( const CSPString& strText );
		CSPBuffer& operator = ( const CSPWString& wstrText );
		CSPBuffer& operator += ( const CSPBuffer& Buffer );
		CSPBuffer& operator += ( const CSPString& strText );
		CSPBuffer& operator += ( const CSPWString& wstrText );
		bool operator == ( const CSPBuffer& Buffer ) const;
		bool operator != ( const CSPBuffer& Buffer ) const;
		unsigned char& operator [] ( unsigned long x ) const;

		unsigned char* Detach();
		void Attach( CSPBuffer& Buffer );
		void Attach( unsigned char* pData, unsigned long ulSize );
		void Copy( const CSPBuffer& Buffer );
		void Copy( const CSPString& strText );
		void Copy( const CSPWString& wstrText );
		void Copy( const unsigned char* pData, unsigned long ulSize );
		void Add( const CSPBuffer& Buffer );
		void Add( const CSPString& strText );
		void Add( const CSPWString& wstrText );
		void Add( const unsigned char* pData, unsigned long ulSize );
		unsigned char& Get( unsigned long ulIndex ) const;
		void Set( unsigned long ulIndex, unsigned char uchValue );


	protected:
		CSPScalarArray< unsigned char > aArray;
};



#endif
