Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qendian.h File Reference
#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)
 
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 >
template< typename T > QBEInteger::QBEInteger

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 >
template< typename T > QLEInteger::QLEInteger

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.

References qbswap().

+ Here is the call graph for this function:

◆ 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.

References qbswapFloatHelper().

+ Here is the call graph for this function:

◆ qbswap() [4/6]

float qbswap ( float  source)
inline

Definition at line 140 of file qendian.h.

References qbswapFloatHelper().

+ Here is the call graph for this function:

◆ qbswap() [5/6]

qfloat16 qbswap ( qfloat16  source)
inline

Definition at line 135 of file qendian.h.

References qbswapFloatHelper().

+ Here is the call graph for this function:

◆ qbswap() [6/6]

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

Definition at line 103 of file qendian.h.

References qbswap_helper().

Referenced by bswapLoop(), QFontEngineFT::loadGlyph(), QDataStream::operator<<(), QDataStream::operator<<(), QDataStream::operator<<(), QDataStream::operator<<(), QDataStream::operator<<(), QDataStream::operator>>(), QDataStream::operator>>(), QDataStream::operator>>(), QDataStream::operator>>(), QDataStream::operator>>(), qbswap(), qbswapFloatHelper(), qFromLittleEndian(), qt_xcb_imageFormatForVisual(), and qToLittleEndian().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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]

constexpr quint16 qbswap_helper ( quint16  source)
inlineconstexpr

Definition at line 84 of file qendian.h.

◆ qbswap_helper() [2/4]

constexpr quint32 qbswap_helper ( quint32  source)
inlineconstexpr

Definition at line 75 of file qendian.h.

◆ qbswap_helper() [3/4]

constexpr quint64 qbswap_helper ( quint64  source)
inlineconstexpr

Definition at line 62 of file qendian.h.

References Q_UINT64_C.

Referenced by qbswap().

+ Here is the caller graph for this function:

◆ qbswap_helper() [4/4]

constexpr 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.

References qbswap().

Referenced by qbswap(), qbswap(), and qbswap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

References qFromBigEndian().

+ Here is the call graph for this function:

◆ qFromBigEndian() [3/3]

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

◆ qFromBigEndian< qint8 >()

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

Definition at line 245 of file qendian.h.

References qint8.

◆ qFromBigEndian< quint8 >()

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

Definition at line 243 of file qendian.h.

Referenced by read8().

+ Here is the caller graph for this function:

◆ 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.

References qFromLittleEndian().

+ Here is the call graph for this function:

◆ qFromLittleEndian() [3/3]

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

Definition at line 178 of file qendian.h.

References qbswap().

Referenced by QLittleEndianStorageType< T >::fromSpecial(), qFromLittleEndian(), and qStringFromUcs2Le().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qFromLittleEndian< qint8 >()

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

Definition at line 231 of file qendian.h.

References qint8.

◆ 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 src)

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]

◆ qToBigEndian() [3/3]

template<typename T >
void qToBigEndian ( 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 >
constexpr T qToLittleEndian ( source)
inlineconstexpr

Definition at line 176 of file qendian.h.

References qbswap().

Referenced by connectionUpdateData(), QUtf16::convertFromUnicode(), QUtf32::convertFromUnicode(), QStringConverter::encodingForData(), QV4::DataViewPrototype::method_setFloat(), QWinRTLowEnergyServiceHandler::obtainCharList(), QUuid::operator<<(), putBtData(), qStringAsUcs2Le(), QPacketProtocol::send(), HciManager::sendConnectionParameterUpdateRequest(), HciManager::sendConnectionUpdateCommand(), and QLittleEndianStorageType< T >::toSpecial().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qToLittleEndian() [3/3]

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

Definition at line 182 of file qendian.h.

◆ qToUnaligned()

template<typename T >
template< typename T > 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.

Referenced by QNfcTagType4NdefFsm::getCommand(), and qt_to_latin1_internal().

+ Here is the caller graph for this function: