RAVENNAKIT
Loading...
Searching...
No Matches
rav::VectorBuffer< T > Class Template Reference

Simple buffer around a vector that allows for easy reading and writing of values. More...

#include <vector_buffer.hpp>

Public Member Functions

 VectorBuffer ()=default
 VectorBuffer (size_t size)
 VectorBuffer (std::initializer_list< T > values)
 VectorBuffer (const VectorBuffer &other)=default
 VectorBuffer (VectorBuffer &&other) noexcept=default
VectorBuffer & operator= (const VectorBuffer &other)=default
VectorBuffer & operator= (VectorBuffer &&other) noexcept=default
bool operator== (const std::vector< T > &other) const
void push_back (T value)
 Writes the given value to the buffer in native byte order.
void push_back (std::initializer_list< T > values)
 Writes the given values to the buffer in native byte order.
void push_back_be (T value)
 Writes the given value to the buffer in big endian byte order.
void push_back_be (std::initializer_list< T > values)
 Writes the given value to the buffer in big endian byte order.
void push_back_le (T value)
 Writes the given value to the buffer in little endian byte order.
void push_back_le (std::initializer_list< T > values)
 Writes the given value to the buffer in little endian byte order.
T read ()
 Reads a value from the buffer in native byte order.
T read_be ()
 Reads a value from the buffer in big endian byte order.
T read_le ()
 Reads a value from the buffer in little endian byte order.
const T * data () const
T * data ()
size_t size () const
bool empty () const
void resize (size_t size)
 Resizes the stream to the given size.
void reset ()
 Resets the stream to its initial state.

Detailed Description

template<class T>
class rav::VectorBuffer< T >

Simple buffer around a vector that allows for easy reading and writing of values.

Definition at line 40 of file vector_buffer.hpp.

Constructor & Destructor Documentation

◆ VectorBuffer() [1/5]

template<class T>
rav::VectorBuffer< T >::VectorBuffer ( )
default

◆ VectorBuffer() [2/5]

template<class T>
rav::VectorBuffer< T >::VectorBuffer ( size_t size)
inlineexplicit

Definition at line 44 of file vector_buffer.hpp.

◆ VectorBuffer() [3/5]

template<class T>
rav::VectorBuffer< T >::VectorBuffer ( std::initializer_list< T > values)
inline

Definition at line 46 of file vector_buffer.hpp.

◆ VectorBuffer() [4/5]

template<class T>
rav::VectorBuffer< T >::VectorBuffer ( const VectorBuffer< T > & other)
default

◆ VectorBuffer() [5/5]

template<class T>
rav::VectorBuffer< T >::VectorBuffer ( VectorBuffer< T > && other)
defaultnoexcept

Member Function Documentation

◆ data() [1/2]

template<class T>
T * rav::VectorBuffer< T >::data ( )
inlinenodiscard
Returns
Returns a pointer to the data in the buffer.

Definition at line 156 of file vector_buffer.hpp.

◆ data() [2/2]

template<class T>
const T * rav::VectorBuffer< T >::data ( ) const
inlinenodiscard
Returns
Returns a pointer to the data in the buffer.

Definition at line 149 of file vector_buffer.hpp.

◆ empty()

template<class T>
bool rav::VectorBuffer< T >::empty ( ) const
inlinenodiscard
Returns
True if the stream is empty, false otherwise.

Definition at line 171 of file vector_buffer.hpp.

◆ operator=() [1/2]

template<class T>
VectorBuffer & rav::VectorBuffer< T >::operator= ( const VectorBuffer< T > & other)
default

◆ operator=() [2/2]

template<class T>
VectorBuffer & rav::VectorBuffer< T >::operator= ( VectorBuffer< T > && other)
defaultnoexcept

◆ operator==()

template<class T>
bool rav::VectorBuffer< T >::operator== ( const std::vector< T > & other) const
inline

Definition at line 53 of file vector_buffer.hpp.

◆ push_back() [1/2]

template<class T>
void rav::VectorBuffer< T >::push_back ( std::initializer_list< T > values)
inline

Writes the given values to the buffer in native byte order.

Parameters
valuesThe values to write.

Definition at line 69 of file vector_buffer.hpp.

◆ push_back() [2/2]

template<class T>
void rav::VectorBuffer< T >::push_back ( T value)
inline

Writes the given value to the buffer in native byte order.

Parameters
valueThe value to write.

Definition at line 61 of file vector_buffer.hpp.

◆ push_back_be() [1/2]

template<class T>
void rav::VectorBuffer< T >::push_back_be ( std::initializer_list< T > values)
inline

Writes the given value to the buffer in big endian byte order.

Template Parameters
TThe type of the value to write.
Parameters
valuesThe values to write.

Definition at line 89 of file vector_buffer.hpp.

◆ push_back_be() [2/2]

template<class T>
void rav::VectorBuffer< T >::push_back_be ( T value)
inline

Writes the given value to the buffer in big endian byte order.

Template Parameters
TThe type of the value to write.
Parameters
valueThe value to write.

Definition at line 80 of file vector_buffer.hpp.

◆ push_back_le() [1/2]

template<class T>
void rav::VectorBuffer< T >::push_back_le ( std::initializer_list< T > values)
inline

Writes the given value to the buffer in little endian byte order.

Template Parameters
TThe type of the value to write.
Parameters
valuesThe values to write.

Definition at line 110 of file vector_buffer.hpp.

◆ push_back_le() [2/2]

template<class T>
void rav::VectorBuffer< T >::push_back_le ( T value)
inline

Writes the given value to the buffer in little endian byte order.

Template Parameters
TThe type of the value to write.
Parameters
valueThe value to write.
Returns
True if the value was written successfully, false otherwise.

Definition at line 101 of file vector_buffer.hpp.

◆ read()

template<class T>
T rav::VectorBuffer< T >::read ( )
inline

Reads a value from the buffer in native byte order.

Template Parameters
TThe type of the value to read.
Returns
The value read from the stream, or a default-constructed value if the read failed.

Definition at line 121 of file vector_buffer.hpp.

◆ read_be()

template<class T>
T rav::VectorBuffer< T >::read_be ( )
inline

Reads a value from the buffer in big endian byte order.

Template Parameters
TThe type of the value to read.
Returns
The value read from the stream, or a default-constructed value if the read failed.

Definition at line 133 of file vector_buffer.hpp.

◆ read_le()

template<class T>
T rav::VectorBuffer< T >::read_le ( )
inline

Reads a value from the buffer in little endian byte order.

Template Parameters
TThe type of the value to read.
Returns
The value read from the stream, or a default-constructed value if the read failed.

Definition at line 142 of file vector_buffer.hpp.

◆ reset()

template<class T>
void rav::VectorBuffer< T >::reset ( )
inline

Resets the stream to its initial state.

Definition at line 189 of file vector_buffer.hpp.

◆ resize()

template<class T>
void rav::VectorBuffer< T >::resize ( size_t size)
inline

Resizes the stream to the given size.

Parameters
sizeThe new size of the stream.

Definition at line 179 of file vector_buffer.hpp.

◆ size()

template<class T>
size_t rav::VectorBuffer< T >::size ( ) const
inlinenodiscard
Returns
Returns the size of the data in the buffer.

Definition at line 163 of file vector_buffer.hpp.


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