10#ifndef SEMF_UTILS_PROCESSING_ENDIAN_BIGENDIANINTEGER_H_
11#define SEMF_UTILS_PROCESSING_ENDIAN_BIGENDIANINTEGER_H_
13#include <semf/utils/processing/stdworkarounds/algorithm>
14#include <semf/utils/processing/stdworkarounds/bit>
20#if __cplusplus >= 201703L
21#define IF_CONSTEXPR if constexpr
23#define IF_CONSTEXPR if
166 void setValue(T value);
173: m_value{std::endian::little == std::endian::native ? reverse<T>(reinterpret_cast<uint8_t*>(&value), reinterpret_cast<uint8_t*>(&value) + sizeof(T)) : value}
195 IF_CONSTEXPR(std::endian::little == std::endian::native)
197 std::reverse(
reinterpret_cast<uint8_t*
>(&native),
reinterpret_cast<uint8_t*
>(&native) +
sizeof(T));
205 return m_value != other.m_value;
211 T nativeValue = native();
213 setValue(nativeValue);
221 IF_CONSTEXPR(std::endian::little == std::endian::native)
223 std::reverse(
reinterpret_cast<uint8_t*
>(&m_value),
reinterpret_cast<uint8_t*
>(&m_value) +
sizeof(T));
230 T nativeValue = native();
232 setValue(nativeValue);
239 T nativeValue = native();
241 setValue(nativeValue);
248 T nativeValue = native();
250 setValue(nativeValue);
258 return this->operator++();
264 T nativeValue = native();
266 setValue(nativeValue);
273 T nativeValue = native();
275 setValue(nativeValue);
283 return this->operator--();
289 T nativeValue = native();
291 setValue(nativeValue);
298 T nativeValue = native();
300 setValue(nativeValue);
307 T nativeValue = native();
309 setValue(nativeValue);
323 return m_value == other.m_value;
329 T nativeValue = native();
331 setValue(nativeValue);
338 T nativeValue = native();
340 setValue(nativeValue);
347 T nativeValue = native();
349 setValue(nativeValue);
Class for representing big-endian numbers.
BigEndianInteger< T > & operator<<=(T i)
Shift i bits left.
bool operator!=(BigEndianInteger< T > other) const
Check if this and other are unequal.
BigEndianInteger< T > & operator^=(T i)
Performs a bitwise XOR.
BigEndianInteger< T > & operator%=(T i)
Calculates the modulo.
BigEndianInteger< T > & operator--()
Decrements this (prefix) and returns a reference to this.
T native() const
Returns a native representation of the stored number.
bool operator==(BigEndianInteger< T > other) const
Checks for equality between this and other.
BigEndianInteger< T > & operator>>=(T i)
Shift i bits right.
BigEndianInteger< T > & operator+=(T i)
Performs an addition.
BigEndianInteger< T > & operator|=(T i)
Performs a bitwise OR.
BigEndianInteger< T > & operator&=(T i)
Performs a bitwise AND.
virtual ~BigEndianInteger()=default
BigEndianInteger< T > & operator/=(T i)
Performs a division.
BigEndianInteger< T > & operator++()
Increments this (prefix) and returns a reference to this.
static BigEndianInteger< T > min()
Returns the minimum (finite) value representable by the numeric type T.
static BigEndianInteger< T > max()
Returns the maximum (finite) value representable by the numeric type T.
BigEndianInteger< T > & operator*=(T i)
Performs a multiplication.
constexpr BigEndianInteger(T value)
Constructor.
BigEndianInteger< T > & operator-=(T i)
Performs a subtraction.
BigEndianInteger< T > & operator=(T i)
Assigns this with the value i.