Ocean
Ocean::IO::OutputBitstream Class Reference

This class implements an output bitstream. More...

Public Member Functions

 OutputBitstream (std::ostream &stream)
 Creates a new output bitstream object. More...
 
template<typename T >
bool write (const T &value)
 Writes a data object to the stream and moves the internal position inside the bitstream accordingly. More...
 
bool write (const void *data, const size_t size)
 Writes a defined memory block from a given buffer into the stream and moves the internal position inside the bitstream accordingly. More...
 
unsigned long long size () const
 Returns the current size of the bitstream, in bytes. More...
 
 operator bool () const
 Returns whether this bitstream object is valid and can be used. More...
 

Protected Attributes

std::ostream & outputStream
 The internal output stream object that this object encapsulates. More...
 

Detailed Description

This class implements an output bitstream.

The implementation of the input bitstream is not thread-safe, thus ensure that the internal input stream object is not used within several threads concurrently.
The bitstream support specific data type, see InputBitstream for detailed information.

Constructor & Destructor Documentation

◆ OutputBitstream()

Ocean::IO::OutputBitstream::OutputBitstream ( std::ostream &  stream)

Creates a new output bitstream object.

Parameters
streamThe output stream object that is encapsulated by this object

Member Function Documentation

◆ operator bool()

Ocean::IO::OutputBitstream::operator bool ( ) const
inlineexplicit

Returns whether this bitstream object is valid and can be used.

Returns
True, if so

◆ size()

unsigned long long Ocean::IO::OutputBitstream::size ( ) const

Returns the current size of the bitstream, in bytes.

Returns
The current stream size in bytes, -1 if the current size cannot be determined

◆ write() [1/2]

template<typename T >
bool Ocean::IO::OutputBitstream::write ( const T &  value)

Writes a data object to the stream and moves the internal position inside the bitstream accordingly.

If the write process fails, the new position of the bitstream may be arbitrary.
Beware: It's recommended to provide the template argument explicitly to avoid type ambiguities.

Parameters
valueThe value that will be written
Returns
True, if the value could be written successfully
Template Parameters
Tthe data type that is written, ensure that only supported data types are applied

◆ write() [2/2]

bool Ocean::IO::OutputBitstream::write ( const void *  data,
const size_t  size 
)

Writes a defined memory block from a given buffer into the stream and moves the internal position inside the bitstream accordingly.

If the write process fails, the new position of the bitstream may be arbitrary.

Parameters
dataThe buffer that will be written, may be nullptr if size is 0
sizeThe number of bytes that will be written, with range [0, infinity
Returns
True, if succeeded

Field Documentation

◆ outputStream

std::ostream& Ocean::IO::OutputBitstream::outputStream
protected

The internal output stream object that this object encapsulates.


The documentation for this class was generated from the following file: