Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
Burger::NativeEndian Struct Reference

Loads a 16, 32 or 64 bit value with no byte swapping. More...

Inheritance diagram for Burger::NativeEndian:
Inheritance graph
[legend]

Static Public Member Functions

template<typename T >
static constexpr remove_pointer< T >::type load (T Input) noexcept
 Load an arithmetic value.
 
template<typename T >
static void store (T *pOutput, T Input) noexcept
 Store an arithmetic value.
 
template<typename T >
static void store (volatile T *pOutput, T Input) noexcept
 Store an arithmetic value to a volatile variable.
 
template<typename T >
static T load_unaligned (T *pInput) noexcept
 Fetch a value from memory with byte alignment.
 
template<typename T >
static void store_unaligned (T *pOutput, T Input) noexcept
 Store a 16 bit unsigned value to memory with byte alignment.
 
template<typename T >
static void fixup (T *) noexcept
 Does nothing.
 
template<typename T >
static void fixup_unaligned (T *) noexcept
 Does nothing.
 

Detailed Description

Loads a 16, 32 or 64 bit value with no byte swapping.


The classes LittleEndian and BigEndian either map to NativeEndian or SwapEndian. If the machine's endian matches the class, then it maps to this class.

This class does nothing for most functions by design. It is meant to vanish when the program is asking for no endian swapping since the data being read is the same endian as the machine.

The only functions that do not disappear are the load_unaligned(T*) or store_unaligned(T*, T) group of calls since they have the ability to fetch a 16, 32 or 64 bit value regardless of the alignment of the data pointer. These are useful in grabbing data from a byte stream and won't trigger an alignment access fault.

Under most circumstances, you will not call this class directly.

See also
SwapEndian, LittleEndian and BigEndian

Member Function Documentation

◆ fixup()

template<typename T >
Burger::NativeEndian::fixup ( T * pOutput)
inlinestaticnoexcept

Does nothing.


Native endian value do not need to be endian swapped, so this function will do nothing.

Template Parameters
TPointer to a value to not endian swap.
Parameters
pOutputPointer to the variable
See also
SwapEndian::fixup(T*)

◆ fixup_unaligned()

template<typename T >
Burger::NativeEndian::fixup_unaligned ( T * pOutput)
inlinestaticnoexcept

Does nothing.


The SwapEndian class would swap the endian of a non aligned variable, but this class performs no operation since the endian is already a match for what the machine expects.

Template Parameters
TPointer to a value to not endian swap.
Parameters
pOutputPointer to the variable
See also
SwapEndian::fixup_unaligned(T*)

◆ load()

template<typename T >
Burger::NativeEndian::load ( T Input)
inlinestaticconstexprnoexcept

Load an arithmetic value.


Given either an arithmetic type, or a pointer to an arithmetic type, load the value and return it without modification.

If a non-arithmetic or pointer to non-arithmetic type is used, this template will throw a static assert.

Note
If a pointer is passed to this template, the pointer is assumed to be aligned to the data type's granularity.
Template Parameters
Tarithmetic type or pointer to arithmetic type.
Parameters
InputThe value to load from pointer or return as is.
Returns
The input value or the loaded value from pointer.
See also
SwapEndian::load(T)

◆ load_unaligned()

template<typename T >
Burger::NativeEndian::load_unaligned ( T * pInput)
inlinestaticnoexcept

Fetch a value from memory with byte alignment.


Assuming the data is unaligned, it will grab data a byte at a time and reconstruct it into a value in native endian.

Template Parameters
Tarithmetic type.
Parameters
pInputPointer to a value.
Returns
The loaded value
See also
store_unaligned(T*, T), or SwapEndian::load_unaligned(T*)

◆ store() [1/2]

template<typename T >
Burger::NativeEndian::store ( T * pOutput,
T Input )
inlinestaticnoexcept

Store an arithmetic value.


Given either an arithmetic type and its pointer, store the value without modification.

If a non-arithmetic or pointer to non-arithmetic type is used, this template will throw a static assert.

Note
If a pointer is assumed to be aligned to the data type's granularity.
nullptr is illegal and will page fault.
Template Parameters
Tarithmetic type.
Parameters
pOutputPointer to an arithmetic value.
InputThe arithmetic value.
See also
store(volatile T*,T), load(T), SwapEndian::store(T*, T)

◆ store() [2/2]

template<typename T >
Burger::NativeEndian::store ( volatile T * pOutput,
T Input )
inlinestaticnoexcept

Store an arithmetic value to a volatile variable.


Given either an arithmetic type and its pointer, store the value without modification.

If a non-arithmetic or pointer to non-arithmetic type is used, this template will throw a static assert.

Note
If a pointer is assumed to be aligned to the data type's granularity.
nullptr is illegal and will page fault.
Template Parameters
Tarithmetic type.
Parameters
pOutputVolatile pointer to an arithmetic value.
InputThe arithmetic value.
See also
store(T*, T), load(T), SwapEndian::store(T*, T)

◆ store_unaligned()

template<typename T >
Burger::NativeEndian::store_unaligned ( T * pOutput,
T Input )
inlinestaticnoexcept

Store a 16 bit unsigned value to memory with byte alignment.


Assuming the output pointer is unaligned, it will store data a byte at a time into a 16 bit value in native endian.

Template Parameters
Tarithmetic type.
Parameters
pOutputPointer to a 16 bit value.
InputThe 16 bit unsigned value.
See also
load_unaligned(T*), or SwapEndian::store_unaligned(T*, T)