
Originally Posted by
ovidiucucu
Right.
A possible better approach is to write your own "buffer" class like for example:
Code:
class CBuffer
{
unsigned char* buffer;
unsigned int length;
public:
CBuffer() : buffer(NULL), length(0) {};
SetBuffer(unsigned char* src, unsigned int length);
unsigned int GetLength() {return length;}
// and so on, and so on... all you need
};
What is wrong with std::string???
Try this
Code:
void DoSomethingWithBinaryData(char* szData, unsigned int nLen)
{
std::string BinaryData;
BinaryData.assign(szData, nLen);
// Now you have access to all those handy functions of std::string and what not
// And to get the data back
DoSomethingElseWithThisBinaryData(BinaryData.data(), BinaryData.size());
}
Now why would you need a buffer class with managing memory yourself???
Regards,
Usman.