- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

Functions

# qendian.h File Reference

`#include <QtCore/qglobal.h>`

Go to the source code of this file.

## Functions
QT_BEGIN_HEADER QT_BEGIN_NAMESPACE void | qbswap_helper (const uchar *src, uchar *dest, int size)
template<typename T >
void | qbswap (const T src, uchar *dest)
template<typename T >
void | qToUnaligned (const T src, uchar *dest)
template<typename T >
T | qFromLittleEndian (const uchar *src)
template<>
quint64 | qFromLittleEndian< quint64 > (const uchar *src)
template<>
quint32 | qFromLittleEndian< quint32 > (const uchar *src)
template<>
quint16 | qFromLittleEndian< quint16 > (const uchar *src)
template<>
qint64 | qFromLittleEndian< qint64 > (const uchar *src)
template<>
qint32 | qFromLittleEndian< qint32 > (const uchar *src)
template<>
qint16 | qFromLittleEndian< qint16 > (const uchar *src)
template<class T >
T | qFromBigEndian (const uchar *src)
template<>
quint64 | qFromBigEndian< quint64 > (const uchar *src)
template<>
quint32 | qFromBigEndian< quint32 > (const uchar *src)
template<>
quint16 | qFromBigEndian< quint16 > (const uchar *src)
template<>
qint64 | qFromBigEndian< qint64 > (const uchar *src)
template<>
qint32 | qFromBigEndian< qint32 > (const uchar *src)
template<>
qint16 | qFromBigEndian< qint16 > (const uchar *src)
template<typename T >
T | qbswap (T source)
template<>
quint64 | qbswap< quint64 > (quint64 source)
template<>
quint32 | qbswap< quint32 > (quint32 source)
template<>
quint16 | qbswap< quint16 > (quint16 source)
template<>
qint64 | qbswap< qint64 > (qint64 source)
template<>
qint32 | qbswap< qint32 > (qint32 source)
template<>
qint16 | qbswap< qint16 > (qint16 source)
template<typename T >
T | qToBigEndian (T source)
template<typename T >
T | qFromBigEndian (T source)
template<typename T >
T | qToLittleEndian (T source)
template<typename T >
T | qFromLittleEndian (T source)
template<typename T >
void | qToBigEndian (T src, uchar *dest)
template<typename T >
void | qToLittleEndian (T src, uchar *dest)

## Function Documentation

QT_BEGIN_HEADER QT_BEGIN_NAMESPACE void qbswap_helper | ( | const uchar * | src,
|  | uchar * | dest,
|  | int | size
| ) |  | `[inline]`

Search for all occurrences

Definition at line 64 of file qendian.h.

    {
        for (int i = 0; i < size ; ++i) dest[i] = src[size - 1 - i];
    }

void qbswap | ( | const T | src,
|  | uchar * | dest
| ) |  | `[inline]`

Search for all occurrences

Definition at line 75 of file qendian.h.

    {
        qbswap_helper(reinterpret_cast<const uchar *>(&src), dest, sizeof(T));
    }

void qToUnaligned | ( | const T | src,
|  | uchar * | dest
| ) |  | `[inline]`

Search for all occurrences

Definition at line 82 of file qendian.h.

    {
        qMemCopy(dest, &src, sizeof(T));
    }

T qFromLittleEndian | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

quint64 qFromLittleEndian< quint64 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 136 of file qendian.h.

    {
        return 0
            | src[0]
            | src[1] * Q_UINT64_C(0x0000000000000100)
            | src[2] * Q_UINT64_C(0x0000000000010000)
            | src[3] * Q_UINT64_C(0x0000000001000000)
            | src[4] * Q_UINT64_C(0x0000000100000000)
            | src[5] * Q_UINT64_C(0x0000010000000000)
            | src[6] * Q_UINT64_C(0x0001000000000000)
            | src[7] * Q_UINT64_C(0x0100000000000000);
    }

quint32 qFromLittleEndian< quint32 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 149 of file qendian.h.

    {
        return 0
            | src[0]
            | src[1] * quint32(0x00000100)
            | src[2] * quint32(0x00010000)
            | src[3] * quint32(0x01000000);
    }

quint16 qFromLittleEndian< quint16 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 158 of file qendian.h.

    {
        return quint16(0
                       | src[0]
                       | src[1] * 0x0100);
    }

qint64 qFromLittleEndian< qint64 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 166 of file qendian.h.

    { return static_cast<qint64>(qFromLittleEndian<quint64>(src)); }

qint32 qFromLittleEndian< qint32 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 169 of file qendian.h.

    { return static_cast<qint32>(qFromLittleEndian<quint32>(src)); }

qint16 qFromLittleEndian< qint16 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 172 of file qendian.h.

    { return static_cast<qint16>(qFromLittleEndian<quint16>(src)); }

T qFromBigEndian | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

quint64 qFromBigEndian< quint64 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 226 of file qendian.h.

    {
        return 0
            | src[7]
            | src[6] * Q_UINT64_C(0x0000000000000100)
            | src[5] * Q_UINT64_C(0x0000000000010000)
            | src[4] * Q_UINT64_C(0x0000000001000000)
            | src[3] * Q_UINT64_C(0x0000000100000000)
            | src[2] * Q_UINT64_C(0x0000010000000000)
            | src[1] * Q_UINT64_C(0x0001000000000000)
            | src[0] * Q_UINT64_C(0x0100000000000000);
    }

quint32 qFromBigEndian< quint32 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 240 of file qendian.h.

    {
        return 0
            | src[3]
            | src[2] * quint32(0x00000100)
            | src[1] * quint32(0x00010000)
            | src[0] * quint32(0x01000000);
    }

quint16 qFromBigEndian< quint16 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 250 of file qendian.h.

    {
        return quint16( 0
                        | src[1]
                        | src[0] * quint16(0x0100));
    }

qint64 qFromBigEndian< qint64 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 259 of file qendian.h.

    { return static_cast<qint64>(qFromBigEndian<quint64>(src)); }

qint32 qFromBigEndian< qint32 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 262 of file qendian.h.

    { return static_cast<qint32>(qFromBigEndian<quint32>(src)); }

qint16 qFromBigEndian< qint16 > | ( | const uchar * | src | ) | `[inline]`

Search for all occurrences

Definition at line 265 of file qendian.h.

    { return static_cast<qint16>(qFromBigEndian<quint16>(src)); }

T qbswap | ( | T | source | ) |

Search for all occurrences

quint64 qbswap< quint64 > | ( | quint64 | source | ) | `[inline]`

Search for all occurrences

Definition at line 290 of file qendian.h.

    {
        return 0
            | ((source & Q_UINT64_C(0x00000000000000ff)) << 56)
            | ((source & Q_UINT64_C(0x000000000000ff00)) << 40)
            | ((source & Q_UINT64_C(0x0000000000ff0000)) << 24)
            | ((source & Q_UINT64_C(0x00000000ff000000)) << 8)
            | ((source & Q_UINT64_C(0x000000ff00000000)) >> 8)
            | ((source & Q_UINT64_C(0x0000ff0000000000)) >> 24)
            | ((source & Q_UINT64_C(0x00ff000000000000)) >> 40)
            | ((source & Q_UINT64_C(0xff00000000000000)) >> 56);
    }

quint32 qbswap< quint32 > | ( | quint32 | source | ) | `[inline]`

Search for all occurrences

Definition at line 303 of file qendian.h.

    {
        return 0
            | ((source & 0x000000ff) << 24)
            | ((source & 0x0000ff00) << 8)
            | ((source & 0x00ff0000) >> 8)
            | ((source & 0xff000000) >> 24);
    }

quint16 qbswap< quint16 > | ( | quint16 | source | ) | `[inline]`

Search for all occurrences

Definition at line 312 of file qendian.h.

    {
        return quint16( 0
                        | ((source & 0x00ff) << 8)
                        | ((source & 0xff00) >> 8) );
    }

qint64 qbswap< qint64 > | ( | qint64 | source | ) | `[inline]`

Search for all occurrences

Definition at line 321 of file qendian.h.

    {
        return qbswap<quint64>(quint64(source));
    }

qint32 qbswap< qint32 > | ( | qint32 | source | ) | `[inline]`

Search for all occurrences

Definition at line 326 of file qendian.h.

    {
        return qbswap<quint32>(quint32(source));
    }

qint16 qbswap< qint16 > | ( | qint16 | source | ) | `[inline]`

Search for all occurrences

Definition at line 331 of file qendian.h.

    {
        return qbswap<quint16>(quint16(source));
    }

T qToBigEndian | ( | T | source | ) | `[inline]`

Search for all occurrences

Definition at line 338 of file qendian.h.

    { return source; }

T qFromBigEndian | ( | T | source | ) | `[inline]`

Search for all occurrences

Definition at line 340 of file qendian.h.

    { return source; }

T qToLittleEndian | ( | T | source | ) | `[inline]`

Search for all occurrences

Definition at line 342 of file qendian.h.

    { return qbswap<T>(source); }

T qFromLittleEndian | ( | T | source | ) | `[inline]`

Search for all occurrences

Definition at line 344 of file qendian.h.

    { return qbswap<T>(source); }

void qToBigEndian | ( | T | src,
|  | uchar * | dest
| ) |  | `[inline]`

Search for all occurrences

Definition at line 346 of file qendian.h.

    { qToUnaligned<T>(src, dest); }

void qToLittleEndian | ( | T | src,
|  | uchar * | dest
| ) |  | `[inline]`

Search for all occurrences

Definition at line 348 of file qendian.h.

    { qbswap<T>(src, dest); }