Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::MemoryOutputStream Class Reference

A concrete implementation of OutputStream that performs output operations to an in-memory buffer. More...

#include <bond/io/memoryoutputstream.h>

Inheritance diagram for Bond::MemoryOutputStream:
Bond::OutputStream Bond::Stream

Public Member Functions

 MemoryOutputStream (void *buffer, pos_t size)
 Constructs a MemoryOutputStream object.
virtual ~MemoryOutputStream ()
virtual void VPrint (const char *format, va_list argList) override
 Writes formatted output to the stream using a variable argument list.
virtual void Write (const uint8_t *bytes, size_t numBytes) override
 Writes a sequence of bytes to the stream.
virtual void Write (uint8_t c) override
 Writes a single byte to the stream.
virtual pos_t GetPosition () const override
 Returns the current position within the stream.
virtual pos_t GetEndPosition () const override
 Returns the end position of the stream.
virtual void SetPosition (off_t offset) override
 Sets the current position within the stream.
virtual void SetPositionFromEnd (off_t offset) override
 Sets the current position relative to the end of the stream.
virtual void AddOffset (off_t offset) override
 Advances the current position by the given offset.
virtual bool IsEof () const override
 Tests whether the current position is at or beyond the end of the stream.
virtual bool HasError () const override
 Tests whether the stream is currently in an error state.
virtual void ClearError () override
 Clears the current error state of the stream.
Public Member Functions inherited from Bond::OutputStream
virtual ~OutputStream ()
 Destroys an OutputStream object.
virtual void Flush ()
 Flushes any buffered output.
virtual void Print (const char *format,...)
 Writes formatted output to the stream.
Public Member Functions inherited from Bond::Stream
virtual ~Stream ()
 Destroys a Stream object.
virtual void Close ()
 Closes the stream.

Additional Inherited Members

Public Types inherited from Bond::Stream
typedef long pos_t
 A type used to represent absolute positions within a stream.
typedef long off_t
 A type used to represent relative offsets within a stream.
Static Public Attributes inherited from Bond::Stream
static const int Eof = -1
 A special value returned by single-byte input functions to indicate end of stream.

Detailed Description

A concrete implementation of OutputStream that performs output operations to an in-memory buffer.

MemoryOutputStream provides a non-owning view over a writable memory buffer and writes data to that buffer without reallocating it.

See also
MemoryInputStream, OutputStream

Constructor & Destructor Documentation

◆ MemoryOutputStream()

Bond::MemoryOutputStream::MemoryOutputStream ( void * buffer,
pos_t size )

Constructs a MemoryOutputStream object.

Parameters
bufferA pointer to the memory buffer to which bytes will be written. The buffer is not copied and must remain valid for the lifetime of the MemoryOutputStream.
sizeThe size of the memory buffer, in bytes.

◆ ~MemoryOutputStream()

virtual Bond::MemoryOutputStream::~MemoryOutputStream ( )
inlinevirtual

Member Function Documentation

◆ AddOffset()

virtual void Bond::MemoryOutputStream::AddOffset ( off_t offset)
overridevirtual

Advances the current position by the given offset.

Parameters
offsetThe signed amount by which the current position should be adjusted.

Implements Bond::Stream.

◆ ClearError()

virtual void Bond::MemoryOutputStream::ClearError ( )
inlineoverridevirtual

Clears the current error state of the stream.

Implements Bond::Stream.

◆ GetEndPosition()

virtual pos_t Bond::MemoryOutputStream::GetEndPosition ( ) const
inlineoverridevirtual

Returns the end position of the stream.

Returns
The absolute position one past the last byte in the stream.

Implements Bond::Stream.

◆ GetPosition()

virtual pos_t Bond::MemoryOutputStream::GetPosition ( ) const
inlineoverridevirtual

Returns the current position within the stream.

Returns
The current absolute stream position.

Implements Bond::Stream.

◆ HasError()

virtual bool Bond::MemoryOutputStream::HasError ( ) const
inlineoverridevirtual

Tests whether the stream is currently in an error state.

Returns
True if an error has occurred on the underlying stream.

Implements Bond::Stream.

◆ IsEof()

virtual bool Bond::MemoryOutputStream::IsEof ( ) const
inlineoverridevirtual

Tests whether the current position is at or beyond the end of the stream.

Returns
True if no more data can be read or written at the current position.

Implements Bond::Stream.

◆ SetPosition()

virtual void Bond::MemoryOutputStream::SetPosition ( off_t offset)
overridevirtual

Sets the current position within the stream.

Parameters
offsetThe absolute position to which the stream should be moved.

Implements Bond::Stream.

◆ SetPositionFromEnd()

virtual void Bond::MemoryOutputStream::SetPositionFromEnd ( off_t offset)
overridevirtual

Sets the current position relative to the end of the stream.

Parameters
offsetThe offset from the end position to which the stream should be moved.

Implements Bond::Stream.

◆ VPrint()

virtual void Bond::MemoryOutputStream::VPrint ( const char * format,
va_list argList )
overridevirtual

Writes formatted output to the stream using a variable argument list.

Parameters
formatA printf-style format string describing the text to be written.
argListA variable argument list containing the values to be formatted.

Implements Bond::OutputStream.

◆ Write() [1/2]

virtual void Bond::MemoryOutputStream::Write ( const uint8_t * bytes,
size_t numBytes )
overridevirtual

Writes a sequence of bytes to the stream.

Parameters
bytesThe buffer containing the bytes to be written.
numBytesThe number of bytes to write.

Reimplemented from Bond::OutputStream.

◆ Write() [2/2]

virtual void Bond::MemoryOutputStream::Write ( uint8_t byte)
overridevirtual

Writes a single byte to the stream.

Parameters
byteThe byte to write.

Implements Bond::OutputStream.


The documentation for this class was generated from the following file:
  • include/bond/io/memoryoutputstream.h