Ocean
Loading...
Searching...
No Matches
Ocean::IO::ScopedInputBitstream Class Reference

This class implements a scoped input bitstream that allows to read content from a bitstream while the stream position is restored if this object is disposed. More...

#include <Bitstream.h>

Inheritance diagram for Ocean::IO::ScopedInputBitstream:

Public Member Functions

 ScopedInputBitstream (InputBitstream &stream)
 Creates a new scoped input bitstream object from a given input bitstream object and stores the current stream position of the given stream object.
 
 ~ScopedInputBitstream ()
 Destructs this scoped object and restores the stream position of the original input bitstream object.
 
- Public Member Functions inherited from Ocean::IO::InputBitstream
 InputBitstream (std::istream &stream)
 Creates a new bitstream object.
 
template<typename T >
bool read (T &value)
 Reads a value from the bitstream and moves the internal position inside the bitstream accordingly.
 
template<typename T >
readDefault (const T &defaultValue)
 Reads a value from the bitstream and moves the internal position inside the bitstream accordingly.
 
bool read (void *data, const size_t size)
 Reads a defined memory block from the stream into a given buffer and moves the internal position inside the bitstream accordingly.
 
template<typename T >
bool look (T &value)
 Reads a value from the bitstream but does not move the internal position inside the bitstream.
 
uint64_t position () const
 Returns the current position inside the bitstream, in bytes counting from the beginning of the stream.
 
uint64_t size () const
 Returns the current size of the bitstream, in bytes.
 
bool setPosition (const uint64_t position)
 Sets the current position inside the bitstream explicitly.
 
bool skip (const uint64_t bytes)
 Skips a specified number of bytes in the bitstream by moving the position forward.
 
bool isEndOfFile () const
 Returns whether the previous read attempt failed because the end of the stream has been reached.
 
bool reset ()
 Resets the stream after the stream has reached the end of the stream.
 
 operator bool () const
 Returns whether this bitstream object is valid and can be used.
 

Protected Member Functions

 ScopedInputBitstream (const ScopedInputBitstream &)=delete
 Deleted copy constructor.
 
 ScopedInputBitstream (ScopedInputBitstream &&)=delete
 Deleted move constructor.
 
ScopedInputBitstreamoperator= (const ScopedInputBitstream &)=delete
 Deleted copy operator.
 
ScopedInputBitstreamoperator= (ScopedInputBitstream &&)=delete
 Deleted move operator.
 

Protected Attributes

uint64_t streamStartPosition_ = uint64_t(-1)
 The original stream position of the original bitstream object.
 
- Protected Attributes inherited from Ocean::IO::InputBitstream
std::istream & inputStream_
 The internal input stream object that this object encapsulates.
 

Detailed Description

This class implements a scoped input bitstream that allows to read content from a bitstream while the stream position is restored if this object is disposed.

The implementation of this scoped input bitstream object is not thread-safe.

See also
InputBitstream

Constructor & Destructor Documentation

◆ ScopedInputBitstream() [1/3]

Ocean::IO::ScopedInputBitstream::ScopedInputBitstream ( InputBitstream stream)
inline

Creates a new scoped input bitstream object from a given input bitstream object and stores the current stream position of the given stream object.

Parameters
streamThe input bitstream object that is encapsulated by this object

◆ ~ScopedInputBitstream()

Ocean::IO::ScopedInputBitstream::~ScopedInputBitstream ( )
inline

Destructs this scoped object and restores the stream position of the original input bitstream object.

◆ ScopedInputBitstream() [2/3]

Ocean::IO::ScopedInputBitstream::ScopedInputBitstream ( const ScopedInputBitstream )
protecteddelete

Deleted copy constructor.

◆ ScopedInputBitstream() [3/3]

Ocean::IO::ScopedInputBitstream::ScopedInputBitstream ( ScopedInputBitstream &&  )
inlineprotecteddelete

Deleted move constructor.

Member Function Documentation

◆ operator=() [1/2]

ScopedInputBitstream & Ocean::IO::ScopedInputBitstream::operator= ( const ScopedInputBitstream )
protecteddelete

Deleted copy operator.

Returns
Reference to this object

◆ operator=() [2/2]

ScopedInputBitstream & Ocean::IO::ScopedInputBitstream::operator= ( ScopedInputBitstream &&  )
protecteddelete

Deleted move operator.

Returns
Reference to this object

Field Documentation

◆ streamStartPosition_

uint64_t Ocean::IO::ScopedInputBitstream::streamStartPosition_ = uint64_t(-1)
protected

The original stream position of the original bitstream object.


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