OpenTTD Source  20241108-master-g80f628063a
EndianBufferWriter< Tcont, Titer > Class Template Reference

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

#include <endian_buffer.hpp>

Public Member Functions

 EndianBufferWriter (Titer buffer)
 
 EndianBufferWriter (typename Titer::container_type &container)
 
EndianBufferWriteroperator<< (const std::string &data)
 
EndianBufferWriteroperator<< (const char *data)
 
EndianBufferWriteroperator<< (std::string_view data)
 
EndianBufferWriteroperator<< (bool data)
 
template<typename T >
EndianBufferWriteroperator<< (const OverflowSafeInt< T > &data)
 
template<typename... Targs>
EndianBufferWriteroperator<< (const 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>
EndianBufferWriteroperator<< (const T data)
 

Static Public Member Functions

template<typename Tvalue , typename Tbuf = std::vector<uint8_t>>
static Tbuf FromValue (const Tvalue &data)
 

Private Member Functions

template<class Ttuple , size_t... Tindices>
void WriteTuple (const Ttuple &values, std::index_sequence< Tindices... >)
 Helper function to write a tuple to the buffer.
 
void Write (std::string_view value)
 Write overload for string values.
 
template<class T >
void Write (T value)
 Fundamental write function.
 

Private Attributes

Titer buffer
 Output iterator for the destination buffer.
 

Detailed Description

template<typename Tcont = typename std::vector<uint8_t>, typename Titer = typename std::back_insert_iterator<Tcont>>
class EndianBufferWriter< Tcont, Titer >

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

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

Definition at line 26 of file endian_buffer.hpp.


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