1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | /*!
|
---|
43 | \headerfile <QtEndian>
|
---|
44 | \title Endian Conversion Functions
|
---|
45 | \ingroup architecture
|
---|
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 |
|
---|