Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qendian.h File Reference

(7a829eaf51853e0852db28b8b8223e1a62a3db0c)

#include <QtCore/qfloat16.h>
#include <QtCore/qglobal.h>
#include <limits>
#include <stdlib.h>
#include <string.h>
Include dependency graph for qendian.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  QSpecialInteger< S >
class  QLittleEndianStorageType< T >
class  QBigEndianStorageType< T >
class  QTypeInfo< QLEInteger< T > >
class  QTypeInfo< QBEInteger< T > >

Typedefs

template<typename T>
using QLEInteger = QSpecialInteger<QLittleEndianStorageType<T>>
 Constructs a QLEInteger with the given value.
template<typename T>
using QBEInteger = QSpecialInteger<QBigEndianStorageType<T>>
 Constructs a QBEInteger with the given value.
typedef QLEInteger< qint16qint16_le
typedef QLEInteger< qint32qint32_le
typedef QLEInteger< qint64qint64_le
typedef QLEInteger< quint16quint16_le
typedef QLEInteger< quint32quint32_le
typedef QLEInteger< quint64quint64_le
typedef QBEInteger< qint16qint16_be
typedef QBEInteger< qint32qint32_be
typedef QBEInteger< qint64qint64_be
typedef QBEInteger< quint16quint16_be
typedef QBEInteger< quint32quint32_be
typedef QBEInteger< quint64quint64_be

Functions

template<typename T>
QT_BEGIN_NAMESPACE Q_ALWAYS_INLINE void qToUnaligned (const T src, void *dest)
template<typename T>
Q_ALWAYS_INLINEqFromUnaligned (const void *src)
 \inmodule QtCore \title Endian Conversion Functions
constexpr quint64 qbswap_helper (quint64 source)
constexpr quint32 qbswap_helper (quint32 source)
constexpr quint16 qbswap_helper (quint16 source)
constexpr quint8 qbswap_helper (quint8 source)
template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
constexpr T qbswap (T source)
template<typename Float>
Float qbswapFloatHelper (Float source)
qfloat16 qbswap (qfloat16 source)
float qbswap (float source)
double qbswap (double source)
template<typename T>
void qbswap (const T src, void *dest)
template<int Size>
voidqbswap (const void *source, qsizetype count, void *dest) noexcept
template<>
voidqbswap< 1 > (const void *source, qsizetype count, void *dest) noexcept
template<>
Q_CORE_EXPORT voidqbswap< 2 > (const void *source, qsizetype count, void *dest) noexcept
template<>
Q_CORE_EXPORT voidqbswap< 4 > (const void *source, qsizetype count, void *dest) noexcept
template<>
Q_CORE_EXPORT voidqbswap< 8 > (const void *source, qsizetype count, void *dest) noexcept
template<typename T>
constexpr T qToBigEndian (T source)
template<typename T>
constexpr T qFromBigEndian (T source)
template<typename T>
constexpr T qToLittleEndian (T source)
template<typename T>
constexpr T qFromLittleEndian (T source)
template<typename T>
void qToBigEndian (T src, void *dest)
template<typename T>
void qToLittleEndian (T src, void *dest)
template<typename T>
void qToBigEndian (const void *source, qsizetype count, void *dest)
template<typename T>
void qToLittleEndian (const void *source, qsizetype count, void *dest)
template<typename T>
void qFromBigEndian (const void *source, qsizetype count, void *dest)
template<typename T>
void qFromLittleEndian (const void *source, qsizetype count, void *dest)
template<typename T>
qFromLittleEndian (const void *src)
template<>
quint8 qFromLittleEndian< quint8 > (const void *src)
template<>
qint8 qFromLittleEndian< qint8 > (const void *src)
template<class T>
qFromBigEndian (const void *src)
template<>
quint8 qFromBigEndian< quint8 > (const void *src)
template<>
qint8 qFromBigEndian< qint8 > (const void *src)

Typedef Documentation

◆ QBEInteger

template<typename T>
using QBEInteger = QSpecialInteger<QBigEndianStorageType<T>>

Constructs a QBEInteger with the given value.

Definition at line 382 of file qendian.h.

◆ qint16_be

Definition at line 399 of file qendian.h.

◆ qint16_le

Definition at line 392 of file qendian.h.

◆ qint32_be

Definition at line 400 of file qendian.h.

◆ qint32_le

Definition at line 393 of file qendian.h.

◆ qint64_be

Definition at line 401 of file qendian.h.

◆ qint64_le

Definition at line 394 of file qendian.h.

◆ QLEInteger

template<typename T>
using QLEInteger = QSpecialInteger<QLittleEndianStorageType<T>>

Constructs a QLEInteger with the given value.

Definition at line 379 of file qendian.h.

◆ quint16_be

Definition at line 402 of file qendian.h.

◆ quint16_le

Definition at line 395 of file qendian.h.

◆ quint32_be

Definition at line 403 of file qendian.h.

◆ quint32_le

Definition at line 396 of file qendian.h.

◆ quint64_be

Definition at line 404 of file qendian.h.

◆ quint64_le

Definition at line 397 of file qendian.h.

Function Documentation

◆ qbswap() [1/6]

template<typename T>
void qbswap ( const T src,
void * dest )
inline

Definition at line 156 of file qendian.h.

◆ qbswap() [2/6]

template<int Size>
void * qbswap ( const void * source,
qsizetype count,
void * dest )
noexcept

◆ qbswap() [3/6]

double qbswap ( double source)
inline

Definition at line 145 of file qendian.h.

◆ qbswap() [4/6]

float qbswap ( float source)
inline

Definition at line 140 of file qendian.h.

◆ qbswap() [5/6]

qfloat16 qbswap ( qfloat16 source)
inline

Definition at line 135 of file qendian.h.

◆ qbswap() [6/6]

template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
T qbswap ( T source)
inlineconstexpr

Definition at line 103 of file qendian.h.

◆ qbswap< 1 >()

template<>
void * qbswap< 1 > ( const void * source,
qsizetype count,
void * dest )
inlinenoexcept

Definition at line 162 of file qendian.h.

◆ qbswap< 2 >()

template<>
Q_CORE_EXPORT void * qbswap< 2 > ( const void * source,
qsizetype count,
void * dest )
noexcept

Definition at line 860 of file qendian.cpp.

◆ qbswap< 4 >()

template<>
Q_CORE_EXPORT void * qbswap< 4 > ( const void * source,
qsizetype count,
void * dest )
noexcept

Definition at line 869 of file qendian.cpp.

◆ qbswap< 8 >()

template<>
Q_CORE_EXPORT void * qbswap< 8 > ( const void * source,
qsizetype count,
void * dest )
noexcept

Definition at line 878 of file qendian.cpp.

◆ qbswap_helper() [1/4]

quint16 qbswap_helper ( quint16 source)
inlineconstexpr

Definition at line 84 of file qendian.h.

◆ qbswap_helper() [2/4]

quint32 qbswap_helper ( quint32 source)
inlineconstexpr

Definition at line 75 of file qendian.h.

◆ qbswap_helper() [3/4]

quint64 qbswap_helper ( quint64 source)
inlineconstexpr

Definition at line 62 of file qendian.h.

◆ qbswap_helper() [4/4]

quint8 qbswap_helper ( quint8 source)
inlineconstexpr

Definition at line 91 of file qendian.h.

◆ qbswapFloatHelper()

template<typename Float>
Float qbswapFloatHelper ( Float source)

Definition at line 127 of file qendian.h.

◆ qFromBigEndian() [1/3]

template<typename T>
void qFromBigEndian ( const void * source,
qsizetype count,
void * dest )
inline

Definition at line 189 of file qendian.h.

◆ qFromBigEndian() [2/3]

template<class T>
T qFromBigEndian ( const void * src)
inline

Definition at line 238 of file qendian.h.

◆ qFromBigEndian() [3/3]

template<typename T>
T qFromBigEndian ( T source)
inlineconstexpr

Definition at line 174 of file qendian.h.

◆ qFromBigEndian< qint8 >()

template<>
qint8 qFromBigEndian< qint8 > ( const void * src)
inline

Definition at line 245 of file qendian.h.

◆ qFromBigEndian< quint8 >()

template<>
quint8 qFromBigEndian< quint8 > ( const void * src)
inline

Definition at line 243 of file qendian.h.

◆ qFromLittleEndian() [1/3]

template<typename T>
void qFromLittleEndian ( const void * source,
qsizetype count,
void * dest )
inline

Definition at line 191 of file qendian.h.

◆ qFromLittleEndian() [2/3]

template<typename T>
T qFromLittleEndian ( const void * src)
inline

Definition at line 224 of file qendian.h.

◆ qFromLittleEndian() [3/3]

template<typename T>
T qFromLittleEndian ( T source)
inlineconstexpr

Definition at line 178 of file qendian.h.

◆ qFromLittleEndian< qint8 >()

template<>
qint8 qFromLittleEndian< qint8 > ( const void * src)
inline

Definition at line 231 of file qendian.h.

◆ qFromLittleEndian< quint8 >()

template<>
quint8 qFromLittleEndian< quint8 > ( const void * src)
inline

Definition at line 229 of file qendian.h.

◆ qFromUnaligned()

template<typename T>
Q_ALWAYS_INLINE T qFromUnaligned ( const void * ptr)

\inmodule QtCore \title Endian Conversion Functions

The <QtEndian> header provides functions to convert between little and big endian representations of numbers.

Since
5.5

Loads a {T} from address ptr, which may be misaligned.

Use of this function avoids the undefined behavior that the C++ standard otherwise attributes to unaligned loads.

Definition at line 47 of file qendian.h.

◆ qToBigEndian() [1/3]

template<typename T>
void qToBigEndian ( const void * source,
qsizetype count,
void * dest )
inline

Definition at line 185 of file qendian.h.

◆ qToBigEndian() [2/3]

template<typename T>
T qToBigEndian ( T source)
inlineconstexpr

Definition at line 172 of file qendian.h.

◆ qToBigEndian() [3/3]

template<typename T>
void qToBigEndian ( T src,
void * dest )
inline

Definition at line 180 of file qendian.h.

◆ qToLittleEndian() [1/3]

template<typename T>
void qToLittleEndian ( const void * source,
qsizetype count,
void * dest )
inline

Definition at line 187 of file qendian.h.

◆ qToLittleEndian() [2/3]

template<typename T>
T qToLittleEndian ( T source)
inlineconstexpr

Definition at line 176 of file qendian.h.

◆ qToLittleEndian() [3/3]

template<typename T>
void qToLittleEndian ( T src,
void * dest )
inline

Definition at line 182 of file qendian.h.

◆ qToUnaligned()

template<typename T>
QT_BEGIN_NAMESPACE Q_ALWAYS_INLINE void qToUnaligned ( const T t,
void * ptr )
Since
4.5

Stores t to address ptr, which may be misaligned.

Use of this function avoids the undefined behavior that the C++ standard otherwise attributes to unaligned stores.

Definition at line 34 of file qendian.h.