1
/****************************************************************************
3
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
** All rights reserved.
5
** Contact: Nokia Corporation (qt-info@nokia.com)
7
** This file is part of the documentation of the Qt Toolkit.
9
** $QT_BEGIN_LICENSE:LGPL$
10
** No Commercial Usage
11
** This file contains pre-release code and may not be distributed.
12
** You may use this file in accordance with the terms and conditions
13
** contained in the Technology Preview License Agreement accompanying
16
** GNU Lesser General Public License Usage
17
** Alternatively, this file may be used under the terms of the GNU Lesser
18
** General Public License version 2.1 as published by the Free Software
19
** Foundation and appearing in the file LICENSE.LGPL included in the
20
** packaging of this file. Please review the following information to
21
** ensure the GNU Lesser General Public License version 2.1 requirements
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
** In addition, as a special exception, Nokia gives you certain additional
25
** rights. These rights are described in the Nokia Qt LGPL Exception
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
40
****************************************************************************/
43
\headerfile <QtEndian>
44
\title Endian Conversion Functions
46
\brief The <QtEndian> header provides functions to convert between
47
little and big endian representations of numbers.
51
\fn T qFromBigEndian(const uchar *src)
55
Reads a big-endian number from memory location \a src and returns the number in the
56
host byte order representation.
57
On CPU architectures where the host byte order is little-endian (such as x86) this
58
will swap the byte order; otherwise it will just read from \a src.
60
\note Template type \c{T} can either be a qint16, qint32 or qint64. Other types of
61
integers, e.g., qlong, are not applicable.
63
There are no data alignment constraints for \a src.
65
\sa qFromLittleEndian()
70
\fn T qFromBigEndian(T src)
75
Converts \a src from big-endian byte order and returns the number in host byte order
76
representation of that number.
77
On CPU architectures where the host byte order is little-endian (such as x86) this
78
will return \a src with the byte order swapped; otherwise it will return \a src
82
\fn T qFromLittleEndian(const uchar *src)
86
Reads a little-endian number from memory location \a src and returns the number in
87
the host byte order representation.
88
On CPU architectures where the host byte order is big-endian (such as PowerPC) this
89
will swap the byte order; otherwise it will just read from \a src.
91
\note Template type \c{T} can either be a qint16, qint32 or qint64. Other types of
92
integers, e.g., qlong, are not applicable.
94
There are no data alignment constraints for \a src.
101
\fn T qFromLittleEndian(T src)
106
Converts \a src from little-endian byte order and returns the number in host byte
107
order representation of that number.
108
On CPU architectures where the host byte order is big-endian (such as PowerPC) this
109
will return \a src with the byte order swapped; otherwise it will return \a src
113
\fn void qToBigEndian(T src, uchar *dest)
117
Writes the number \a src with template type \c{T} to the memory location at \a dest
118
in big-endian byte order.
120
Note that template type \c{T} can only be an integer data type (signed or unsigned).
122
There are no data alignment constraints for \a dest.
125
\sa qFromLittleEndian()
126
\sa qToLittleEndian()
129
\fn T qToBigEndian(T src)
134
Converts \a src from host byte order and returns the number in big-endian byte order
135
representation of that number.
136
On CPU architectures where the host byte order is little-endian (such as x86) this
137
will return \a src with the byte order swapped; otherwise it will return \a src
141
\fn void qToLittleEndian(T src, uchar *dest)
145
Writes the number \a src with template type \c{T} to the memory location at \a dest
146
in little-endian byte order.
148
Note that template type \c{T} can only be an integer data type (signed or unsigned).
150
There are no data alignment constraints for \a dest.
153
\sa qFromLittleEndian()
157
\fn T qToLittleEndian(T src)
162
Converts \a src from host byte order and returns the number in little-endian byte
163
order representation of that number.
164
On CPU architectures where the host byte order is big-endian (such as PowerPC) this
165
will return \a src with the byte order swapped; otherwise it will return \a src