M5Utility 0.0.12 git rev:13bfbd6
Loading...
Searching...
No Matches
m5::types::EndianInt< T, DataIsLittle > Struct Template Reference

Endian-compliant integer type. More...

#include <types.hpp>

Public Member Functions

template<bool HostIsLittle = m5::endian::little>
void set (const T v)
 Set value with specified endianness.
 
template<bool HostIsLittle = m5::endian::little>
get () const
 Gets value with specified endianness.
 
uint8_t high () const
 Gets the high byte (u8[0])
 
uint8_t low () const
 Gets the low byte (u8[sizeof(T)-1])
 
const uint8_t * data () const
 Gets the const pointer.
 
uint8_t * data ()
 Gets the pointer.
 
size_t size () const
 Gets size in uint8_t units.
 
Constructor
constexpr EndianInt ()
 default constructor
 
template<bool HostIsLittle = m5::endian::little>
 EndianInt (const T v)
 from T
 
template<typename U = T, typename std::enable_if< sizeof(U)==2, int >::type = 0>
constexpr EndianInt (const uint8_t b0, const uint8_t b1)
 Stored in order of bytes (2-byte types)
 
template<typename U = T, typename std::enable_if< sizeof(U)==4, int >::type = 0>
constexpr EndianInt (const uint8_t b0, const uint8_t b1, const uint8_t b2, const uint8_t b3)
 Stored in order of bytes (4-byte types)
 
template<typename U = T, typename std::enable_if< sizeof(U)==8, int >::type = 0>
constexpr EndianInt (const uint8_t b0, const uint8_t b1, const uint8_t b2, const uint8_t b3, const uint8_t b4, const uint8_t b5, const uint8_t b6, const uint8_t b7)
 Stored in order of bytes (8-byte types)
 
constexpr EndianInt (const EndianInt &)=default
 default constructor
 
constexpr EndianInt (EndianInt &&o) noexcept=default
 default constructor
 
Assignment
EndianIntoperator= (const EndianInt &)=default
 
EndianIntoperator= (EndianInt &&) noexcept=default
 
template<bool HostIsLittle = m5::endian::little>
EndianIntoperator= (const T v)
 
template<typename H , typename L , typename U = T, typename std::enable_if< sizeof(U)==2, int >::type = 0>
EndianIntoperator= (const std::pair< H, L > &o)
 
Cast
 operator bool () const
 To boolean.
 
 operator const uint8_t * () const
 To const uint8_t*.
 
 operator uint8_t * ()
 To uint8_t*.
 
 operator T () const
 To T on processor endianness.
 

Public Attributes

value {}
 Raw value.
 
uint8_t u8 [sizeof(T)]
 Raw value according to uint8_t.
 

Related Symbols

(Note that these are not member symbols.)

Compare
template<typename T , bool DL1, bool DL2>
bool operator== (const EndianInt< T, DL1 > &a, const EndianInt< T, DL2 > &b)
 
template<typename T , bool DL1, bool DL2>
bool operator!= (const EndianInt< T, DL1 > &a, const EndianInt< T, DL2 > &b)
 
template<typename T , bool DL1, bool DL2>
bool operator< (const EndianInt< T, DL1 > &a, const EndianInt< T, DL2 > &b)
 
template<typename T , bool DL1, bool DL2>
bool operator> (const EndianInt< T, DL1 > &a, const EndianInt< T, DL2 > &b)
 
template<typename T , bool DL1, bool DL2>
bool operator<= (const EndianInt< T, DL1 > &a, const EndianInt< T, DL2 > &b)
 
template<typename T , bool DL1, bool DL2>
bool operator>= (const EndianInt< T, DL1 > &a, const EndianInt< T, DL2 > &b)
 

Detailed Description

template<typename T, bool DataIsLittle>
struct m5::types::EndianInt< T, DataIsLittle >

Endian-compliant integer type.

Template Parameters
TUnderlying integer type (uint16_t, int16_t, uint32_t, int32_t, etc.)
DataIsLittleData endianness
true: Little false: Big

Member Function Documentation

◆ get()

template<typename T , bool DataIsLittle>
template<bool HostIsLittle = m5::endian::little>
T m5::types::EndianInt< T, DataIsLittle >::get ( ) const
inline

Gets value with specified endianness.

Template Parameters
HostIsLittleHost endianness (default as processor endianness)

◆ set()

template<typename T , bool DataIsLittle>
template<bool HostIsLittle = m5::endian::little>
void m5::types::EndianInt< T, DataIsLittle >::set ( const T v)
inline

Set value with specified endianness.

Template Parameters
HostIsLittleHost endianness (default as processor endianness)