ReXGlue SDK
Loading...
Searching...
No Matches
rex::memory::ByteStream Class Reference

#include <rex/memory/stream.h>

Inheritance diagram for rex::memory::ByteStream:
[legend]

Public Member Functions

 ByteStream (u8 *data, size_t data_length, size_t offset=0)
void Advance (size_t num_bytes)
void Read (std::span< u8 > buf)
void Write (std::span< const u8 > buf)
void Read (void *buf, size_t len)
void Write (const void *buf, size_t len)
const u8 * GetData () const
u8 * GetData ()
size_t GetSize () const
size_t GetOffset () const
void SetOffset (size_t offset)
template<typename T>
T Read ()
template<typename T>
void Write (T data)
void Write (const std::string_view str)
void Write (const std::u16string_view str)
template<>
std::string Read ()
template<>
std::u16string Read ()

Detailed Description

Byte cursor over a buffer the caller owns. Values are copied in host byte order.

Constructor & Destructor Documentation

◆ ByteStream()

rex::memory::ByteStream::ByteStream ( u8 * data,
size_t data_length,
size_t offset = 0 )

Wraps a buffer.

Parameters
offsetInitial cursor position in bytes.

Member Function Documentation

◆ Read() [1/5]

template<>
std::u16string rex::memory::ByteStream::Read ( )

Reads a u32 code unit count followed by the code units.

◆ Read() [2/5]

template<>
std::string rex::memory::ByteStream::Read ( )

Reads a u32 character count followed by the characters.

◆ Read() [3/5]

template<typename T>
T rex::memory::ByteStream::Read ( )
inline

Reads a value at the cursor and moves past it.

Template Parameters
TTrivially copyable value type, or std::string or std::u16string.

◆ Read() [4/5]

void rex::memory::ByteStream::Read ( std::span< u8 > buf)

Copies bytes from the cursor into a buffer and moves past them.

Parameters
bufDestination. Its size is the byte count.

◆ Read() [5/5]

void rex::memory::ByteStream::Read ( void * buf,
size_t len )
inline

Copies bytes from the cursor into a buffer and moves past them.

◆ Write() [1/5]

void rex::memory::ByteStream::Write ( const std::string_view str)
inline

Writes a u32 character count followed by the characters.

◆ Write() [2/5]

void rex::memory::ByteStream::Write ( const std::u16string_view str)
inline

Writes a u32 code unit count followed by the code units.

◆ Write() [3/5]

void rex::memory::ByteStream::Write ( const void * buf,
size_t len )
inline

Copies bytes from a buffer to the cursor and moves past them.

◆ Write() [4/5]

void rex::memory::ByteStream::Write ( std::span< const u8 > buf)

Copies bytes from a buffer to the cursor and moves past them.

Parameters
bufSource. Its size is the byte count.

◆ Write() [5/5]

template<typename T>
void rex::memory::ByteStream::Write ( T data)
inline

Writes a value at the cursor and moves past it.


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