OpenTTD Source  20240919-master-gdf0233f4c2
EndianBufferReader Class Reference

Endian-aware buffer adapter that always reads values in little endian order. More...

#include <endian_buffer.hpp>

Public Member Functions

 EndianBufferReader (std::span< const uint8_t > buffer)
 
void rewind ()
 
EndianBufferReaderoperator>> (std::string &data)
 
EndianBufferReaderoperator>> (bool &data)
 
template<typename T >
EndianBufferReaderoperator>> (OverflowSafeInt< T > &data)
 
template<typename... Targs>
EndianBufferReaderoperator>> (std::tuple< Targs... > &data)
 
template<class T , std::enable_if_t< std::disjunction_v< std::negation< std::is_class< T >>, std::is_base_of< StrongTypedefBase, T >>, int > = 0>
EndianBufferReaderoperator>> (T &data)
 

Static Public Member Functions

template<typename Tvalue >
static Tvalue ToValue (std::span< const uint8_t > buffer)
 

Private Member Functions

template<class Ttuple , size_t... Tindices>
void ReadTuple (Ttuple &values, std::index_sequence< Tindices... >)
 Helper function to read a tuple from the buffer.
 
std::string ReadStr ()
 Read overload for string data.
 
template<class T >
Read ()
 Fundamental read function.
 

Private Attributes

std::span< const uint8_t > buffer
 Reference to storage buffer.
 
size_t read_pos = 0
 Current read position.
 

Detailed Description

Endian-aware buffer adapter that always reads values in little endian order.

Note
This class uses operator overloading (>>, just like streams) for reading as this allows providing custom operator overloads for more complex types like e.g. structs without needing to modify this class.

Definition at line 119 of file endian_buffer.hpp.


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