0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 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: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
|
|
14 |
** this package.
|
|
15 |
**
|
|
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.
|
|
23 |
**
|
|
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.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
/*!
|
|
43 |
\headerfile <QtEndian>
|
|
44 |
\title Endian Conversion Functions
|
|
45 |
\ingroup funclists
|
|
46 |
\brief The <QtEndian> header provides functions to convert between
|
|
47 |
little and big endian representations of numbers.
|
|
48 |
*/
|
|
49 |
|
|
50 |
/*!
|
|
51 |
\fn T qFromBigEndian(const uchar *src)
|
|
52 |
\since 4.3
|
|
53 |
\relates <QtEndian>
|
|
54 |
|
|
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.
|
|
59 |
|
|
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.
|
|
62 |
|
|
63 |
There are no data alignment constraints for \a src.
|
|
64 |
|
|
65 |
\sa qFromLittleEndian()
|
|
66 |
\sa qToBigEndian()
|
|
67 |
\sa qToLittleEndian()
|
|
68 |
*/
|
|
69 |
/*!
|
|
70 |
\fn T qFromBigEndian(T src)
|
|
71 |
\since 4.3
|
|
72 |
\relates <QtEndian>
|
|
73 |
\overload
|
|
74 |
|
|
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
|
|
79 |
unmodified.
|
|
80 |
*/
|
|
81 |
/*!
|
|
82 |
\fn T qFromLittleEndian(const uchar *src)
|
|
83 |
\since 4.3
|
|
84 |
\relates <QtEndian>
|
|
85 |
|
|
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.
|
|
90 |
|
|
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.
|
|
93 |
|
|
94 |
There are no data alignment constraints for \a src.
|
|
95 |
|
|
96 |
\sa qFromBigEndian()
|
|
97 |
\sa qToBigEndian()
|
|
98 |
\sa qToLittleEndian()
|
|
99 |
*/
|
|
100 |
/*!
|
|
101 |
\fn T qFromLittleEndian(T src)
|
|
102 |
\since 4.3
|
|
103 |
\relates <QtEndian>
|
|
104 |
\overload
|
|
105 |
|
|
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
|
|
110 |
unmodified.
|
|
111 |
*/
|
|
112 |
/*!
|
|
113 |
\fn void qToBigEndian(T src, uchar *dest)
|
|
114 |
\since 4.3
|
|
115 |
\relates <QtEndian>
|
|
116 |
|
|
117 |
Writes the number \a src with template type \c{T} to the memory location at \a dest
|
|
118 |
in big-endian byte order.
|
|
119 |
|
|
120 |
Note that template type \c{T} can only be an integer data type (signed or unsigned).
|
|
121 |
|
|
122 |
There are no data alignment constraints for \a dest.
|
|
123 |
|
|
124 |
\sa qFromBigEndian()
|
|
125 |
\sa qFromLittleEndian()
|
|
126 |
\sa qToLittleEndian()
|
|
127 |
*/
|
|
128 |
/*!
|
|
129 |
\fn T qToBigEndian(T src)
|
|
130 |
\since 4.3
|
|
131 |
\relates <QtEndian>
|
|
132 |
\overload
|
|
133 |
|
|
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
|
|
138 |
unmodified.
|
|
139 |
*/
|
|
140 |
/*!
|
|
141 |
\fn void qToLittleEndian(T src, uchar *dest)
|
|
142 |
\since 4.3
|
|
143 |
\relates <QtEndian>
|
|
144 |
|
|
145 |
Writes the number \a src with template type \c{T} to the memory location at \a dest
|
|
146 |
in little-endian byte order.
|
|
147 |
|
|
148 |
Note that template type \c{T} can only be an integer data type (signed or unsigned).
|
|
149 |
|
|
150 |
There are no data alignment constraints for \a dest.
|
|
151 |
|
|
152 |
\sa qFromBigEndian()
|
|
153 |
\sa qFromLittleEndian()
|
|
154 |
\sa qToBigEndian()
|
|
155 |
*/
|
|
156 |
/*!
|
|
157 |
\fn T qToLittleEndian(T src)
|
|
158 |
\since 4.3
|
|
159 |
\relates <QtEndian>
|
|
160 |
\overload
|
|
161 |
|
|
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
|
|
166 |
unmodified.
|
|
167 |
*/
|
|
168 |
|