10#ifndef SEMF_UTILS_PROCESSING_ENDIAN_LITTLEENDIANINTEGER_H_
11#define SEMF_UTILS_PROCESSING_ENDIAN_LITTLEENDIANINTEGER_H_
13#include <semf/utils/processing/stdworkarounds/algorithm>
14#include <semf/utils/processing/stdworkarounds/bit>
19#if __cplusplus >= 201703L
20#define IF_CONSTEXPR if constexpr
22#define IF_CONSTEXPR if
165 void setValue(T value);
172: m_value{std::endian::big == std::endian::native ? reverse<T>(reinterpret_cast<uint8_t*>(&value), reinterpret_cast<uint8_t*>(&value) + sizeof(T)) : value}
179 return std::numeric_limits<T>::max();
185 return std::numeric_limits<T>::min();
194 std::reverse(
reinterpret_cast<uint8_t*
>(&value),
reinterpret_cast<uint8_t*
>(&value) +
sizeof(T));
202 return m_value != other.m_value;
245 return this->operator++();
270 return this->operator--();
321 return m_value == other.m_value;
347 std::reverse(
reinterpret_cast<uint8_t*
>(&value),
reinterpret_cast<uint8_t*
>(&value) +
sizeof(T));
Class for representing little-endian numbers.
LittleEndianInteger< T > & operator>>=(T i)
Shift i bits right.
T native() const
Returns a native representation of the stored number.
LittleEndianInteger< T > & operator/=(T i)
Performs a division.
LittleEndianInteger< T > & operator=(T i)
Assigns this with the value i.
bool operator!=(LittleEndianInteger< T > other) const
Checks if this and other are unequal.
constexpr LittleEndianInteger(T value)
Constructor.
static LittleEndianInteger< T > max()
Returns the maximum (finite) value representable by the numeric type T.
LittleEndianInteger< T > & operator--()
Decrements this (prefix) and returns a reference to this.
LittleEndianInteger< T > & operator|=(T i)
Performs a bitwise OR.
bool operator==(LittleEndianInteger< T > other) const
Checks for equality between this and other.
LittleEndianInteger< T > & operator^=(T i)
Performs a bitwise XOR.
LittleEndianInteger< T > & operator+=(T i)
Performs an addition.
LittleEndianInteger< T > & operator++()
Increments this (prefix) and returns a reference to this.
virtual ~LittleEndianInteger()=default
LittleEndianInteger< T > & operator%=(T i)
Calculates the modulo.
LittleEndianInteger< T > & operator&=(T i)
Performs a bitwise AND.
static LittleEndianInteger< T > min()
Returns the minimum (finite) value representable by the numeric type T.
LittleEndianInteger< T > & operator-=(T i)
Performs a subtraction.
LittleEndianInteger< T > & operator<<=(T i)
Shift i bits left.
LittleEndianInteger< T > & operator*=(T i)
Performs a multiplication.