| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
** All rights reserved. |
| 5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
| 6 |
** |
| 7 |
** This file is part of the documentation of the Qt Toolkit. |
| 8 |
** |
| 9 |
** $QT_BEGIN_LICENSE:FDL$ |
| 10 |
** GNU Free Documentation License |
| 11 |
** Alternatively, this file may be used under the terms of the GNU Free |
| 12 |
** Documentation License version 1.3 as published by the Free Software |
| 13 |
** Foundation and appearing in the file included in the packaging of |
| 14 |
** this file. |
| 15 |
** |
| 16 |
** Other Usage |
| 17 |
** Alternatively, this file may be used in accordance with the terms |
| 18 |
** and conditions contained in a signed written agreement between you |
| 19 |
** and Nokia. |
| 20 |
** |
| 21 |
** |
| 22 |
** |
| 23 |
** |
| 24 |
** $QT_END_LICENSE$ |
| 25 |
** |
| 26 |
****************************************************************************/ |
| 27 |
|
| 28 |
/*! |
| 29 |
\headerfile <QtEndian> |
| 30 |
\title Endian Conversion Functions |
| 31 |
\ingroup funclists |
| 32 |
\brief The <QtEndian> header provides functions to convert between |
| 33 |
little and big endian representations of numbers. |
| 34 |
*/ |
| 35 |
|
| 36 |
/*! |
| 37 |
\fn T qFromBigEndian(const uchar *src) |
| 38 |
\since 4.3 |
| 39 |
\relates <QtEndian> |
| 40 |
|
| 41 |
Reads a big-endian number from memory location \a src and returns the number in the |
| 42 |
host byte order representation. |
| 43 |
On CPU architectures where the host byte order is little-endian (such as x86) this |
| 44 |
will swap the byte order; otherwise it will just read from \a src. |
| 45 |
|
| 46 |
\note Template type \c{T} can either be a qint16, qint32 or qint64. Other types of |
| 47 |
integers, e.g., qlong, are not applicable. |
| 48 |
|
| 49 |
There are no data alignment constraints for \a src. |
| 50 |
|
| 51 |
\sa qFromLittleEndian() |
| 52 |
\sa qToBigEndian() |
| 53 |
\sa qToLittleEndian() |
| 54 |
*/ |
| 55 |
/*! |
| 56 |
\fn T qFromBigEndian(T src) |
| 57 |
\since 4.3 |
| 58 |
\relates <QtEndian> |
| 59 |
\overload |
| 60 |
|
| 61 |
Converts \a src from big-endian byte order and returns the number in host byte order |
| 62 |
representation of that number. |
| 63 |
On CPU architectures where the host byte order is little-endian (such as x86) this |
| 64 |
will return \a src with the byte order swapped; otherwise it will return \a src |
| 65 |
unmodified. |
| 66 |
*/ |
| 67 |
/*! |
| 68 |
\fn T qFromLittleEndian(const uchar *src) |
| 69 |
\since 4.3 |
| 70 |
\relates <QtEndian> |
| 71 |
|
| 72 |
Reads a little-endian number from memory location \a src and returns the number in |
| 73 |
the host byte order representation. |
| 74 |
On CPU architectures where the host byte order is big-endian (such as PowerPC) this |
| 75 |
will swap the byte order; otherwise it will just read from \a src. |
| 76 |
|
| 77 |
\note Template type \c{T} can either be a qint16, qint32 or qint64. Other types of |
| 78 |
integers, e.g., qlong, are not applicable. |
| 79 |
|
| 80 |
There are no data alignment constraints for \a src. |
| 81 |
|
| 82 |
\sa qFromBigEndian() |
| 83 |
\sa qToBigEndian() |
| 84 |
\sa qToLittleEndian() |
| 85 |
*/ |
| 86 |
/*! |
| 87 |
\fn T qFromLittleEndian(T src) |
| 88 |
\since 4.3 |
| 89 |
\relates <QtEndian> |
| 90 |
\overload |
| 91 |
|
| 92 |
Converts \a src from little-endian byte order and returns the number in host byte |
| 93 |
order representation of that number. |
| 94 |
On CPU architectures where the host byte order is big-endian (such as PowerPC) this |
| 95 |
will return \a src with the byte order swapped; otherwise it will return \a src |
| 96 |
unmodified. |
| 97 |
*/ |
| 98 |
/*! |
| 99 |
\fn void qToBigEndian(T src, uchar *dest) |
| 100 |
\since 4.3 |
| 101 |
\relates <QtEndian> |
| 102 |
|
| 103 |
Writes the number \a src with template type \c{T} to the memory location at \a dest |
| 104 |
in big-endian byte order. |
| 105 |
|
| 106 |
Note that template type \c{T} can only be an integer data type (signed or unsigned). |
| 107 |
|
| 108 |
There are no data alignment constraints for \a dest. |
| 109 |
|
| 110 |
\sa qFromBigEndian() |
| 111 |
\sa qFromLittleEndian() |
| 112 |
\sa qToLittleEndian() |
| 113 |
*/ |
| 114 |
/*! |
| 115 |
\fn T qToBigEndian(T src) |
| 116 |
\since 4.3 |
| 117 |
\relates <QtEndian> |
| 118 |
\overload |
| 119 |
|
| 120 |
Converts \a src from host byte order and returns the number in big-endian byte order |
| 121 |
representation of that number. |
| 122 |
On CPU architectures where the host byte order is little-endian (such as x86) this |
| 123 |
will return \a src with the byte order swapped; otherwise it will return \a src |
| 124 |
unmodified. |
| 125 |
*/ |
| 126 |
/*! |
| 127 |
\fn void qToLittleEndian(T src, uchar *dest) |
| 128 |
\since 4.3 |
| 129 |
\relates <QtEndian> |
| 130 |
|
| 131 |
Writes the number \a src with template type \c{T} to the memory location at \a dest |
| 132 |
in little-endian byte order. |
| 133 |
|
| 134 |
Note that template type \c{T} can only be an integer data type (signed or unsigned). |
| 135 |
|
| 136 |
There are no data alignment constraints for \a dest. |
| 137 |
|
| 138 |
\sa qFromBigEndian() |
| 139 |
\sa qFromLittleEndian() |
| 140 |
\sa qToBigEndian() |
| 141 |
*/ |
| 142 |
/*! |
| 143 |
\fn T qToLittleEndian(T src) |
| 144 |
\since 4.3 |
| 145 |
\relates <QtEndian> |
| 146 |
\overload |
| 147 |
|
| 148 |
Converts \a src from host byte order and returns the number in little-endian byte |
| 149 |
order representation of that number. |
| 150 |
On CPU architectures where the host byte order is big-endian (such as PowerPC) this |
| 151 |
will return \a src with the byte order swapped; otherwise it will return \a src |
| 152 |
unmodified. |
| 153 |
*/ |