mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-26 20:38:45 +08:00
62 lines
2.2 KiB
Plaintext
62 lines
2.2 KiB
Plaintext
Endian
|
|
Constants & utilities for endianess
|
|
|
|
For endian specific integral types, see unaligned_type.
|
|
|
|
The values for endianness are dependant on the platform setup.
|
|
|
|
If ETL_ENDIAN_NATIVE is defined by the user, then
|
|
etl::endian::little = 0
|
|
etl::endian::big = 1
|
|
|
|
If ETL_ENDIAN_NATIVE is not defined by the user, then the ETL selects an appropriate definition.
|
|
If ETL_CPP20_SUPPORTED == 1 and ETL_USING_STL == 1 then
|
|
etl::endian::little = std::endian::little
|
|
etl::endian::big = std::endian::big
|
|
etl::endian::native = std::endian::native
|
|
|
|
else, if __BYTE_ORDER__ is defined then
|
|
If __ORDER_LITTLE_ENDIAN__ is defined then
|
|
etl::endian::little = __ORDER_LITTLE_ENDIAN__
|
|
etl::endian::big = __ORDER_BIG_ENDIAN__
|
|
etl::endian::native = __BYTE_ORDER__
|
|
|
|
else if __LITTLE_ENDIAN__ is defined
|
|
etl::endian::little = __LITTLE_ENDIAN__
|
|
etl::endian::big = __BIG_ENDIAN__
|
|
etl::endian::native = __BYTE_ORDER__
|
|
|
|
else
|
|
The user needs to define ETL_ENDIAN_NATIVE either as 0 for little endian or 1 for big endian.
|
|
____________________________________________________________________________________________________
|
|
endian
|
|
|
|
A smart enumeration defining little and big members.
|
|
|
|
etl::endian::little;
|
|
etl::endian::big;
|
|
____________________________________________________________________________________________________
|
|
endianness
|
|
|
|
Interrogates the endianness of the platform.
|
|
|
|
etl::endian operator ()() const
|
|
constexpr if ETL_CPP11_SUPPORTED == 1 and ETL_ENDIAN_NATIVE is defined.
|
|
____________________________________________________________________________________________________
|
|
operator etl::endian() const
|
|
constexpr if ETL_CPP11_SUPPORTED == 1 and ETL_ENDIAN_NATIVE is defined.
|
|
____________________________________________________________________________________________________
|
|
static etl::endian value()
|
|
constexpr if ETL_CPP11_SUPPORTED == 1 and ETL_ENDIAN_NATIVE is defined.
|
|
____________________________________________________________________________________________________
|
|
Host to network
|
|
|
|
template <typename T>
|
|
T hton(T value)
|
|
____________________________________________________________________________________________________
|
|
Network to host
|
|
|
|
template <typename T>
|
|
T ntoh(T value)
|
|
|