RLLib
0.1
|
This class represents a data stream containing a variable number of bytes. More...
#include <ByteStream.hpp>
Public Member Functions | |
ByteStream ()=default | |
Creates an empty data stream. | |
ByteStream (std::size_t size) | |
Creates a data stream containing a specific number of bytes. More... | |
std::size_t | size () const noexcept |
Returns the number of bytes in the data stream. More... | |
void | resize (std::size_t size) |
Sets the number of bytes in the data stream. More... | |
Byte * | data () noexcept |
Returns a raw pointer to the first byte. More... | |
const Byte * | data () const noexcept |
Returns a raw pointer to the first byte (const). More... | |
std::vector< Byte >::iterator | begin () noexcept |
std::vector< Byte >::const_iterator | cbegin () const noexcept |
std::vector< Byte >::iterator | end () noexcept |
std::vector< Byte >::const_iterator | cend () const noexcept |
std::size_t | tell () const noexcept |
Returns the position of the stream cursor. More... | |
void | seek (std::size_t pos) noexcept |
Sets the position of the stream cursor. More... | |
template<typename T , EnableIfNumeric< T > * = nullptr> | |
T | get () |
Reads an numeric value from the stream. More... | |
template<typename T , EnableIfSerializable< T > * = nullptr> | |
T | get () |
Extracts an serializable object from the stream. More... | |
template<typename T , EnableIfArray< T > * = nullptr> | |
T | get () |
Reads an array from the stream. More... | |
template<typename T , EnableIfByteStream< T > * = nullptr> | |
T | get () |
Reads raw data from the stream. More... | |
template<typename T > | |
T | get (std::size_t pos) |
Reads a value from a specific position in the stream. More... | |
template<typename T > | |
ByteStream & | operator>> (T &value) |
Reads a value from the stream and stores it into a variable. More... | |
template<typename T , EnableIfNumeric< T > * = nullptr> | |
void | put (const T &value) |
Writes an arithmetic value into the stream. More... | |
template<typename T , EnableIfSerializable< T > * = nullptr> | |
void | put (const T &value) |
Serializes an object into the stream. More... | |
template<typename T , EnableIfArray< T > * = nullptr> | |
void | put (const T &value) |
Writes a array into the stream. More... | |
void | put (const char *value) |
Writes a string into the stream. More... | |
void | put (const ByteStream &value) |
Writes raw data into the stream. More... | |
template<typename T > | |
void | put (const T &value, std::size_t pos) |
Writes a value into a specific position in the stream. More... | |
template<typename T > | |
ByteStream & | operator<< (const T &value) |
Writes a value into the stream. More... | |
This class represents a data stream containing a variable number of bytes.
It provides features to extract and write values from and into the stream.
|
explicit |
Creates a data stream containing a specific number of bytes.
size | The initial number of bytes in the data stream |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Returns a raw pointer to the first byte.
|
noexcept |
Returns a raw pointer to the first byte (const).
|
noexcept |
T rl::ByteStream::get | ( | ) |
Reads an numeric value from the stream.
If the data to read is out of bound, the behavior is undefined.
T | The type of the numeric value |
T rl::ByteStream::get | ( | ) |
Extracts an serializable object from the stream.
If the data to read is out of bound, the behavior is undefined.
T | The type of the serializable object |
T rl::ByteStream::get | ( | ) |
Reads an array from the stream.
If the data to read is out of bound, the behavior is undefined.
T | The type of the array |
T rl::ByteStream::get | ( | ) |
Reads raw data from the stream.
If the data to read is out of bound, the behavior is undefined.
T | The type of the raw data |
T rl::ByteStream::get | ( | std::size_t | pos | ) |
Reads a value from a specific position in the stream.
If the data to read is out of bound, the behavior is undefined.
T | The type of the value that is to be read |
pos | The position of the stream cursor |
ByteStream & rl::ByteStream::operator<< | ( | const T & | value | ) |
Writes a value into the stream.
T |
value |
ByteStream & rl::ByteStream::operator>> | ( | T & | value | ) |
Reads a value from the stream and stores it into a variable.
If the data to read is out of bound, the behavior is undefined.
T | The type of the value that is to be read |
value | A reference to the variable where the result will be stored |
void rl::ByteStream::put | ( | const T & | value | ) |
Writes an arithmetic value into the stream.
value | The value that is to be written |
void rl::ByteStream::put | ( | const T & | value | ) |
Serializes an object into the stream.
value | The serializable object that is to be written |
void rl::ByteStream::put | ( | const T & | value | ) |
Writes a array into the stream.
value | The array that is to be written |
void rl::ByteStream::put | ( | const char * | value | ) |
Writes a string into the stream.
value | The string that is to be written |
void rl::ByteStream::put | ( | const ByteStream & | value | ) |
Writes raw data into the stream.
value | A byte stream containing the data |
void rl::ByteStream::put | ( | const T & | value, |
std::size_t | pos | ||
) |
Writes a value into a specific position in the stream.
T | The type of the value that is to be written |
value | The value that is to be written |
pos | The position of the stream cursor |
void rl::ByteStream::resize | ( | std::size_t | size | ) |
Sets the number of bytes in the data stream.
size | The number of bytes |
|
noexcept |
Sets the position of the stream cursor.
pos | The new stream position |
|
noexcept |
Returns the number of bytes in the data stream.
|
noexcept |
Returns the position of the stream cursor.