Hi
I need to serialize to a buffer and after failing by using streams and the
private OutputStream derived classes as the padding was included in the
buffer I implemented something like:
class BufferedOutputStream : public avro::OutputStream {
public:
std::vector<uint8_t> m_buf;
BufferedOutputStream():
m_buf()
{
m_buf.reserve(4096);
}
~BufferedOutputStream()
{
}
bool next(uint8_t** data, size_t* len);
void backup(size_t len)
{
assert(m_buf.size() >= len);
m_buf.resize(m_buf.size() - len);
}
uint64_t byteCount() const
{
return m_buf.size();
}
void flush() {}
};
Any comments on this? I think the C++ code should have something similar,
or maybe I wasn't able to find it.
Pedro.