Member Typedef Documentation

The asio library expects a const_iterator (the const-ness refers to the fact that the underlying avro of buffers will not be modified, even though the data in those buffers is being modified).

The iterator provides the list of addresses an operation can write to.

Constructor & Destructor Documentation

avro::OutputBuffer::OutputBuffer

(

size_type

reserveSize = 0

)

[inline]

Default constructor.

Will pre-allocate at least the requested size, but can grow larger on demand.

Destructor uses the default, which resets a shared pointer, deleting the underlying data if no other copies of exist.

Copy and assignment operators are not explicitly provided because the default ones work fine. The default makes only a shallow copy, so the copies will refer to the same memory. This is required by asio functions, which will implicitly make copies for asynchronous operations. Therefore, the user must be careful that if they create multiple copies of the same OutputBuffer, only one is being modified otherwise undefined behavior may occur.

When using writeTo(), the buffer will grow dynamically as needed. But when using the iterator to write (followed by wroteTo()), data may only be written to the space available, so this ensures there is enough room in the buffer before the write operation.

Update the state of the buffer after writing through the iterator interface.

This function exists primarily for the boost:asio which writes directly to the buffer using its iterator. In this case, the internal state of the buffer does not reflect that the data was written This informs the buffer how much data was written.

The buffer does not automatically resize in this case, the bytes written cannot exceed the amount of free space. Attempting to write more will throw a std::length_error exception.