#ifndef __byteBuffer_h__
#define __byteBuffer_h__

#include <vector>
#include <ctype.h>
#include <string.h>

using namespace std;

typedef unsigned char	byte;
typedef unsigned short	ushort;
typedef unsigned long	ulong;

class byteBuffer : public vector<byte>
{
public:
//	explicit byteBuffer( byteBuffer & bb ){};
	byteBuffer( size_type n ) : vector<byte>(n)	{};
	byteBuffer() : vector<byte>() {};
	byteBuffer( const char * hex );
	byteBuffer( byte * data, size_type len );

	void append( const byteBuffer & data );
	void append( byte data ) { push_back(data); };

	void assign( byte * data, size_t size );

	byteBuffer substr( int offset, size_t len );

	operator void * () { return &at(0); };
//	operator byte * () { return &at(0); };

	byteBuffer & operator += (const byteBuffer & right) { append(right); return *this; };
	byteBuffer operator + (const byteBuffer & right);
	byteBuffer operator ^ (const byteBuffer & right);


	byte * hex2bin( const char * hex, byteBuffer & bin );

	void zeroClear( void );

	inline unsigned long size() const
	{
		return (unsigned long)vector<byte>::size();
	}
};

#endif // __byteBuffer_h__
