8#ifndef META_OCEAN_IO_SERIALIZATION_VECTOR_OUTPUT_STREAM_H
9#define META_OCEAN_IO_SERIALIZATION_VECTOR_OUTPUT_STREAM_H
21namespace Serialization
68 int_type
overflow(int_type character)
override;
76 std::streamsize
xsputn(
const char* data, std::streamsize size)
override;
85 pos_type
seekoff(off_type offset, std::ios_base::seekdir direction, std::ios_base::openmode mode = std::ios_base::out)
override;
93 pos_type
seekpos(pos_type position, std::ios_base::openmode mode = std::ios_base::out)
override;
105 void reserve(
const size_t capacity);
111 const Buffer& buffer()
const;
130 size_t currentPosition_ = 0;
150 const void* data()
const;
170 buffer_(std::move(buffer))
177 buffer_.reserve(capacity);
182 return buffer_.size();
187 buffer_.reserve(capacity);
203 currentPosition_ = 0;
213 std::ostream(&streamBuffer_)
This class implements a custom stream buffer that stores data in a vector.
Definition VectorOutputStream.h:38
pos_type seekoff(off_type offset, std::ios_base::seekdir direction, std::ios_base::openmode mode=std::ios_base::out) override
Repositions the stream position indicator using relative offsets.
int_type overflow(int_type character) override
Writes a single character to the buffer when the put area is full.
void reserve(const size_t capacity)
Reserves memory for the buffer to avoid reallocations during writing.
Definition VectorOutputStream.h:185
size_t size() const
Returns the current size of the buffer.
Definition VectorOutputStream.h:180
const Buffer & buffer() const
Returns a const reference to the internal buffer.
Definition VectorOutputStream.h:190
void clear()
Clears the buffer content.
Definition VectorOutputStream.h:200
std::vector< char > Buffer
Definition of the buffer type storing the stream data.
Definition VectorOutputStream.h:42
Buffer buffer_
The internal vector storing the stream data.
Definition VectorOutputStream.h:127
VectorStreamBuffer()=default
Creates a new vector stream buffer with an empty buffer.
std::streamsize xsputn(const char *data, std::streamsize size) override
Writes a sequence of characters to the buffer.
pos_type seekpos(pos_type position, std::ios_base::openmode mode=std::ios_base::out) override
Repositions the stream position indicator to an absolute position.
This class implements an output stream that writes to an internal vector buffer.
Definition VectorOutputStream.h:31
VectorStreamBuffer streamBuffer_
The internal stream buffer storing the data.
Definition VectorOutputStream.h:166
size_t size() const
Returns the current size of the stream.
Definition VectorOutputStream.h:223
VectorOutputStream()
Creates a new vector output stream with an empty buffer.
Definition VectorOutputStream.h:206
void clear()
Clears the stream content.
Definition VectorOutputStream.h:228
const void * data() const
Returns a pointer to the stream data.
Definition VectorOutputStream.h:218
The namespace covering the entire Ocean framework.
Definition Accessor.h:15