Corrade::Utility::Endianness namespace

Endianness-related functions.

Contents

This library is built if WITH_UTILITY is enabled when building Corrade. To use this library with CMake, request the Utility component of the Corrade package and link to the Corrade::Utility target:

find_package(Corrade REQUIRED Utility)

# ...
target_link_libraries(your-app PRIVATE Corrade::Utility)

See also Downloading and building Corrade and Using Corrade with CMake for more information.

Functions

template<class T>
auto swap(T value) -> T
Endian-swap bytes of given value.
template<class ... T>
void swapInPlace(T&... values) new in 2020.06
Endian-swap bytes of each argument in-place.
auto isBigEndian() -> bool constexpr
Whether actual system is Big-Endian.
template<class T>
auto bigEndian(T value) -> T
Convert number from or to Big-Endian.
template<class ... T>
void bigEndianInPlace(T&... values)
Convert values from or to Big-Endian in-place.
template<class T>
auto littleEndian(T value) -> T
Convert value from or to Little-Endian.
template<class ... T>
void littleEndianInPlace(T&... values)
Convert values from or to Little-Endian in-place.
auto fourCC(char a, char b, char c, char d) -> std::uint32_t constexpr new in 2020.06
Create a FourCC code.
template<class T>
void swapInPlace(const Containers::StridedArrayView1D<T>& values) new in 2020.06
Endian-swap bytes of each argument in-place.
template<class T>
void swapInPlace(const Containers::ArrayView<T>& values) new in 2020.06
template<class T>
void littleEndianInPlace(const Containers::StridedArrayView1D<T>& values) new in 2020.06
Convert values from or to Little-Endian in-place.
template<class T>
void littleEndianInPlace(const Containers::ArrayView<T>& values) new in 2020.06
template<class T>
void bigEndianInPlace(const Containers::StridedArrayView1D<T>& values) new in 2020.06
Convert values from or to Big-Endian in-place.
template<class T>
void bigEndianInPlace(const Containers::ArrayView<T>& values) new in 2020.06

Function documentation

template<class T>
T Corrade::Utility::Endianness::swap(T value)

Endian-swap bytes of given value.

template<class ... T>
void Corrade::Utility::Endianness::swapInPlace(T&... values) new in 2020.06

Endian-swap bytes of each argument in-place.

Calls swap() on each value.

bool Corrade::Utility::Endianness::isBigEndian() constexpr

Whether actual system is Big-Endian.

template<class T>
T Corrade::Utility::Endianness::bigEndian(T value)

Convert number from or to Big-Endian.

On Little-Endian systems calls swap(), on Big-Endian systems returns the value unchanged.

template<class ... T>
void Corrade::Utility::Endianness::bigEndianInPlace(T&... values)

Convert values from or to Big-Endian in-place.

On Little-Endian systems calls swapInPlace(T&... values), on Big-Endian systems does nothing.

template<class T>
T Corrade::Utility::Endianness::littleEndian(T value)

Convert value from or to Little-Endian.

On Big-Endian systems calls swap(), on Little-Endian systems returns the value unchanged.

template<class ... T>
void Corrade::Utility::Endianness::littleEndianInPlace(T&... values)

Convert values from or to Little-Endian in-place.

On Big-Endian systems calls swapInPlace(T&... values), on Little-Endian systems does nothing.

std::uint32_t Corrade::Utility::Endianness::fourCC(char a, char b, char c, char d) constexpr new in 2020.06

Create a FourCC code.

Creates a FourCC code from given four characters. The characters are always stored in a Big-Endian order. Usable as a portable alternative to multi-character literals:

std::uint32_t a = 'WAVE';
std::uint32_t b = Utility::Endianness::fourCC('W', 'A', 'V', 'E');

template<class T>
void Corrade::Utility::Endianness::swapInPlace(const Containers::StridedArrayView1D<T>& values) new in 2020.06

Endian-swap bytes of each argument in-place.

Equivalent to calling swap() on each value.

template<class T>
void Corrade::Utility::Endianness::swapInPlace(const Containers::ArrayView<T>& values) new in 2020.06

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
void Corrade::Utility::Endianness::littleEndianInPlace(const Containers::StridedArrayView1D<T>& values) new in 2020.06

Convert values from or to Little-Endian in-place.

On Big-Endian systems calls swapInPlace(const Containers::StridedArrayView1D<T>&), on Little-Endian systems does nothing.

template<class T>
void Corrade::Utility::Endianness::littleEndianInPlace(const Containers::ArrayView<T>& values) new in 2020.06

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
void Corrade::Utility::Endianness::bigEndianInPlace(const Containers::StridedArrayView1D<T>& values) new in 2020.06

Convert values from or to Big-Endian in-place.

On Little-Endian systems calls swapInPlace(const Containers::StridedArrayView1D<T>&), on Big-Endian systems does nothing.

template<class T>
void Corrade::Utility::Endianness::bigEndianInPlace(const Containers::ArrayView<T>& values) new in 2020.06

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.