7 #include <boost/scoped_array.hpp>
15 size_t l = data.size();
16 if (l > UCHAR_MAX) l = UCHAR_MAX;
18 unsigned char length =
static_cast<unsigned char>(l);
19 outputStream.write(reinterpret_cast<const char*>(&length),
sizeof(length));
24 outputStream.write(data.c_str(), length);
34 inputStream.read(reinterpret_cast<char*>(&length),
sizeof(length));
39 boost::scoped_array<char> buffer(
new char[length]);
40 char* bufferPtr = buffer.get();
42 inputStream.read(bufferPtr, length);
45 data.assign(bufferPtr, length);