Loads a 16, 32 or 64 bit value with no byte swapping. More...
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. | |
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.
Does nothing.
Native endian value do not need to be endian swapped, so this function will do nothing.
T | Pointer to a value to not endian swap. |
pOutput | Pointer to the variable |
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.
T | Pointer to a value to not endian swap. |
pOutput | Pointer to the variable |
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.
T | arithmetic type or pointer to arithmetic type. |
Input | The value to load from pointer or return as is. |
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.
T | arithmetic type. |
pInput | Pointer to a value. |
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.
T | arithmetic type. |
pOutput | Pointer to an arithmetic value. |
Input | The arithmetic value. |
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.
T | arithmetic type. |
pOutput | Volatile pointer to an arithmetic value. |
Input | The arithmetic value. |
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.
T | arithmetic type. |
pOutput | Pointer to a 16 bit value. |
Input | The 16 bit unsigned value. |