class ByteBuffer : public std::vector<unsigned char>
{
public:
ByteBuffer(void) {}
ByteBuffer(size_t size):std::vector<unsigned char>(size) {}
ByteBuffer(const void* ptr, size_t len)
{
append(ptr, len);
}
template<class T> void append(const T& b)
{
insert(this->end(), (const unsigned char*)&b, (const unsigned char*)&b+sizeof(T));
}
void append(const void* ptr, size_t len)
{
insert(this->end(), (const unsigned char*)ptr, (const unsigned char*)ptr+len);
}
void* ptr(void)
{
return &*begin();
}
};