pabigot
0.1.1
C++ support classes
|
Functionality related to byte order and endianness. More...
Data Structures | |
class | octets_helper |
Infrastructure to fill an octet buffer with data. More... | |
Enumerations | |
enum | byte_order_enum : uint32_t { byte_order_enum::little_endian = 0x01020304U, byte_order_enum::big_endian = 0x04030201U, byte_order_enum::network = big_endian, byte_order_enum::pdp_endian = 0x03040102U } |
Enumeration of constants representing various known byte orders. More... | |
Functions | |
constexpr byte_order_enum | host_byte_order () |
Return the byte_order_enum value for the host. More... | |
template<typename T > | |
constexpr std::enable_if< details::is_constexpr_swappable_v< T >, T >::type | byteswap (const T &t) |
Byte-swap values at compile-time. More... | |
template<typename T > | |
std::enable_if< details::is_alias_swappable_v< T >, T >::type | byteswap (const T &t) |
Byte-swap values by aliasing a copy of the value to a uint8_t sequence. | |
template<typename T > | |
std::enable_if< details::is_other_swappable_v< T >, T >::type | byteswap (const T &t) |
Byte-swap values by creating a copy and using std::reverse . More... | |
template<typename T , byte_order_enum endian> | |
constexpr std::enable_if< details::is_constexpr_swappable_v< T > &&(host_byte_order()==endian), T >::type | hostswap (const T &t) |
constexpr-selected byte swap between host and endian. More... | |
template<typename T , byte_order_enum endian> | |
std::enable_if<!details::is_constexpr_swappable_v< T > &&(host_byte_order()==endian), T >::type | hostswap (const T &t) |
constexpr-selected byte swap between host and endian. More... | |
template<typename T , byte_order_enum endian> | |
constexpr std::enable_if< details::is_constexpr_swappable_v< T > &&(host_byte_order() !=endian), T >::type | hostswap (const T &t) |
constexpr-selected byte swap between host and endian. More... | |
template<typename T , byte_order_enum endian> | |
std::enable_if<!details::is_constexpr_swappable_v< T > &&(host_byte_order() !=endian), T >::type | hostswap (const T &t) |
constexpr-selected byte swap between host and endian. More... | |
template<typename T > | |
constexpr std::enable_if< details::is_constexpr_swappable_v< T >, T >::type | host_x_le (const T &v) |
Convert between host and little-endian byte order. More... | |
template<typename T > | |
std::enable_if<!details::is_constexpr_swappable_v< T >, T >::type | host_x_le (const T &v) |
Convert between host and little-endian byte order. | |
template<typename T > | |
constexpr std::enable_if< details::is_constexpr_swappable_v< T >, T >::type | host_x_be (const T &v) |
Convert between host and big-endian byte order. More... | |
template<typename T > | |
std::enable_if<!details::is_constexpr_swappable_v< T >, T >::type | host_x_be (const T &v) |
Convert between host and big-endian byte order. | |
template<typename T > | |
constexpr std::enable_if< details::is_constexpr_swappable_v< T >, T >::type | be_x_le (const T &v) |
Convert between big-endian and little-endian byte order. More... | |
template<typename T > | |
std::enable_if<!details::is_constexpr_swappable_v< T >, T >::type | be_x_le (const T &v) |
Convert between big-endian and little-endian byte order. | |
template<typename T > | |
constexpr std::enable_if< details::is_constexpr_swappable_v< T >, T >::type | host_x_network (const T &v) |
Convert between host and network byte order. More... | |
template<typename T > | |
std::enable_if<!details::is_constexpr_swappable_v< T >, T >::type | host_x_network (const T &v) |
Convert between host and network byte order. | |
Variables | |
static constexpr wchar_t | BOM = u'\uFFFE' |
The Unicode byte order marker. | |
Functionality related to byte order and endianness.
|
strong |
Enumeration of constants representing various known byte orders.
The constants are the host interpretation of a 4-byte sequence {4, 3, 2, 1} as a 32-bit unsigned integer.
|
constexpr |
Convert between big-endian and little-endian byte order.
constexpr
overload is only available for types where a constexpr byte swap is supported, i.e. integral scalars.
|
constexpr |
Byte-swap values at compile-time.
constexpr
overload is only available for types where a compile-time byte swap is supported, i.e. integral scalars. std::enable_if<details::is_other_swappable_v<T>, T>::type pabigot::byteorder::byteswap | ( | const T & | t | ) |
Byte-swap values by creating a copy and using std::reverse
.
std::array<uint8_t, 6>
. It happens to work on std::vector<uint8_t>
, but it'll fail to compile with some types, including ones acceptable to details::is_other_swappable_v().
|
constexpr |
Return the byte_order_enum value for the host.
The implementation of this relies on compiler support, as there is no portable C++17 solution to determining runtime byte order at compile-time.
|
constexpr |
Convert between host and big-endian byte order.
constexpr
overload is only available for types where a constexpr byte swap is supported, i.e. integral scalars.
|
constexpr |
Convert between host and little-endian byte order.
constexpr
overload is only available for types where a constexpr byte swap is supported, i.e. integral scalars.
|
constexpr |
Convert between host and network byte order.
constexpr
overload is only available for types where a constexpr byte swap is supported, i.e. integral scalars.
|
constexpr |
constexpr-selected byte swap between host and endian.
This variant is available when host uses the desired endian and constexpr byte swap is supported for the type.
std::enable_if<!details::is_constexpr_swappable_v<T> && (host_byte_order() == endian), T>::type pabigot::byteorder::hostswap | ( | const T & | t | ) |
constexpr-selected byte swap between host and endian.
This variant is available when host uses the desired endian and constexpr byte swap is not supported for the type.
|
constexpr |
constexpr-selected byte swap between host and endian.
This variant is available when host does not use the desired endian and constexpr byte swap is supported for the type.
std::enable_if<!details::is_constexpr_swappable_v<T> && (host_byte_order() != endian), T>::type pabigot::byteorder::hostswap | ( | const T & | t | ) |
constexpr-selected byte swap between host and endian.
This variant is available when host does not use the desired endian and constexpr byte swap is not supported for the type.