<QtEndian> - Endian Conversion Functions

<QtEndian> 头提供在数字的小端、大端表示之间转换的函数。 更多...

头: #include <QtEndian>

类型

qint16_be
qint16_le
qint32_be
qint32_le
qint64_be
qint64_le
quint16_be
quint16_le
quint32_be
quint32_le
quint64_be
quint64_le

函数

T qFromBigEndian (const void * src )
T qFromBigEndian (T src )
void qFromBigEndian (const void * src , qsizetype count , void * dest )
T qFromLittleEndian (const void * src )
T qFromLittleEndian (T src )
void qFromLittleEndian (const void * src , qsizetype count , void * dest )
void qToBigEndian (T src , void * dest )
T qToBigEndian (T src )
void qToBigEndian (const void * src , qsizetype count , void * dest )
void qToLittleEndian (T src , void * dest )
T qToLittleEndian (T src )
void qToLittleEndian (const void * src , qsizetype count , void * dest )

详细描述

类型文档编制

qint16_be

typedef 对于 QBEInteger <qint16>。在所有 Qt 支持平台,保证将此类型按 16 位大端在前有符号整数存储在内存中。

另请参阅 qint16 .

qint16_le

typedef 对于 QLEInteger <qint16>. This type is guaranteed to be stored in memory as a 16-bit little-endian signed integer on all platforms supported by Qt.

另请参阅 qint16 .

qint32_be

typedef 对于 QBEInteger <qint32>. This type is guaranteed to be stored in memory as a 32-bit big-endian signed integer on all platforms supported by Qt.

另请参阅 qint32 .

qint32_le

typedef 对于 QLEInteger <qint32>. This type is guaranteed to be stored in memory as a 32-bit little-endian signed integer on all platforms supported by Qt.

另请参阅 qint32 .

qint64_be

typedef 对于 QBEInteger <qint64>. This type is guaranteed to be stored in memory as a 64-bit big-endian signed integer on all platforms supported by Qt.

另请参阅 qint64 .

qint64_le

typedef 对于 QLEInteger <qint64>. This type is guaranteed to be stored in memory as a 64-bit little-endian signed integer on all platforms supported by Qt.

另请参阅 qint64 .

quint16_be

typedef 对于 QBEInteger <quint16>. This type is guaranteed to be stored in memory as a 16-bit big-endian unsigned integer on all platforms supported by Qt.

另请参阅 quint16 .

quint16_le

typedef 对于 QLEInteger <quint16>. This type is guaranteed to be stored in memory as a 16-bit little-endian unsigned integer on all platforms supported by Qt.

另请参阅 quint16 .

quint32_be

typedef 对于 QBEInteger <quint32>. This type is guaranteed to be stored in memory as a 32-bit big-endian unsigned integer on all platforms supported by Qt.

另请参阅 quint32 .

quint32_le

typedef 对于 QLEInteger <quint32>. This type is guaranteed to be stored in memory as a 32-bit little-endian unsigned integer on all platforms supported by Qt.

另请参阅 quint32 .

quint64_be

typedef 对于 QBEInteger <quint64>. This type is guaranteed to be stored in memory as a 64-bit big-endian unsigned integer on all platforms supported by Qt.

另请参阅 quint64 .

quint64_le

typedef 对于 QLEInteger <quint64>. This type is guaranteed to be stored in memory as a 64-bit little-endian unsigned integer on all platforms supported by Qt.

另请参阅 quint64 .

函数文档编制

template <typename T> T qFromBigEndian (const void * src )

Reads a big-endian number from memory location src and returns the number in the host byte order representation. On CPU architectures where the host byte order is little-endian (such as x86) this will swap the byte order; otherwise it will just read from src .

注意: 模板类型 T can either be a quint16, qint16, quint32, qint32, quint64, or qint64. Other types of integers, e.g., qlong, are not applicable.

注意: 从 Qt 5.7 起,类型的 src 参数是 void 指针。

没有数据对齐约束对于 src .

另请参阅 qFromLittleEndian (), qToBigEndian (),和 qToLittleEndian ().

[constexpr] template <typename T> T qFromBigEndian ( T src )

这是重载函数。

转换 src from big-endian byte order and returns the number in host byte order representation of that number. On CPU architectures where the host byte order is little-endian (such as x86) this will return src with the byte order swapped; otherwise it will return src 未经修改。

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

读取 count big-endian numbers from memory location src and stores them in the host byte order representation at dest . On CPU architectures where the host byte order is little-endian (such as x86) this will swap the byte order; otherwise it will just perform a memcpy from src to dest .

注意: 模板类型 T can either be a quint16, qint16, quint32, qint32, quint64, or qint64. Other types of integers, e.g., qlong, are not applicable.

没有数据对齐约束对于 src . However, dest is expected to be naturally aligned for type T .

src and dest can be the same pointer, this function will perform an in-place swap (if necessary). If they are not the same, the memory regions must not overlap.

另请参阅 qFromLittleEndian (), qToBigEndian (),和 qToLittleEndian ().

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

Reads a little-endian number from memory location src and returns the number in the host byte order representation. On CPU architectures where the host byte order is big-endian (such as PowerPC) this will swap the byte order; otherwise it will just read from src .

注意: 模板类型 T can either be a quint16, qint16, quint32, qint32, quint64, or qint64. Other types of integers, e.g., qlong, are not applicable.

注意: 从 Qt 5.7 起,类型的 src 参数是 void 指针。

没有数据对齐约束对于 src .

另请参阅 qFromBigEndian (), qToBigEndian (),和 qToLittleEndian ().

[constexpr] template <typename T> T qFromLittleEndian ( T src )

这是重载函数。

转换 src from little-endian byte order and returns the number in host byte order representation of that number. On CPU architectures where the host byte order is big-endian (such as PowerPC) this will return src with the byte order swapped; otherwise it will return src 未经修改。

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

读取 count little-endian numbers from memory location src and stores them in the host byte order representation at dest . On CPU architectures where the host byte order is big-endian (such as PowerPC) this will swap the byte order; otherwise it will just perform a memcpy from src to dest .

注意: 模板类型 T can either be a quint16, qint16, quint32, qint32, quint64, or qint64. Other types of integers, e.g., qlong, are not applicable.

没有数据对齐约束对于 src . However, dest is expected to be naturally aligned for type T .

src and dest can be the same pointer, this function will perform an in-place swap (if necessary). If they are not the same, the memory regions must not overlap.

另请参阅 qToBigEndian () 和 qToLittleEndian ().

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

Writes the number src with template type T to the memory location at dest in big-endian byte order.

注意: 模板类型 T can either be a quint16, qint16, quint32, qint32, quint64, or qint64. Other types of integers, e.g., qlong, are not applicable.

没有数据对齐约束对于 dest .

注意: 从 Qt 5.7 起,类型的 dest 参数是 void 指针。

另请参阅 qFromBigEndian (), qFromLittleEndian (),和 qToLittleEndian ().

[constexpr] template <typename T> T qToBigEndian ( T src )

这是重载函数。

转换 src from host byte order and returns the number in big-endian byte order representation of that number. On CPU architectures where the host byte order is little-endian (such as x86) this will return src with the byte order swapped; otherwise it will return src 未经修改。

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

读取 count numbers from memory location src in the host byte order and stores them in big-endian representation at dest . On CPU architectures where the host byte order is little-endian (such as x86) this will swap the byte order; otherwise it will just perform a memcpy from src to dest .

注意: 模板类型 T can either be a quint16, qint16, quint32, qint32, quint64, or qint64. Other types of integers, e.g., qlong, are not applicable.

没有数据对齐约束对于 dest . However, src is expected to be naturally aligned for type T .

src and dest can be the same pointer, this function will perform an in-place swap (if necessary). If they are not the same, the memory regions must not overlap.

另请参阅 qFromLittleEndian (), qToBigEndian (),和 qToLittleEndian ().

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

Writes the number src with template type T to the memory location at dest in little-endian byte order.

注意: 模板类型 T can either be a quint16, qint16, quint32, qint32, quint64, or qint64. Other types of integers, e.g., qlong, are not applicable.

没有数据对齐约束对于 dest .

注意: 从 Qt 5.7 起,类型的 dest 参数是 void 指针。

另请参阅 qFromBigEndian (), qFromLittleEndian (),和 qToBigEndian ().

[constexpr] template <typename T> T qToLittleEndian ( T src )

这是重载函数。

转换 src from host byte order and returns the number in little-endian byte order representation of that number. On CPU architectures where the host byte order is big-endian (such as PowerPC) this will return src with the byte order swapped; otherwise it will return src 未经修改。

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

读取 count numbers from memory location src in the host byte order and stores them in little-endian representation at dest . On CPU architectures where the host byte order is big-endian (such as PowerPC) this will swap the byte order; otherwise it will just perform a memcpy from src to dest .

注意: 模板类型 T can either be a quint16, qint16, quint32, qint32, quint64, or qint64. Other types of integers, e.g., qlong, are not applicable.

没有数据对齐约束对于 dest . However, src is expected to be naturally aligned for type T .

src and dest can be the same pointer, this function will perform an in-place swap (if necessary). If they are not the same, the memory regions must not overlap.

另请参阅 qFromLittleEndian (), qToBigEndian (),和 qToLittleEndian ().