0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
/**
|
|
17 |
@file
|
|
18 |
@internalTechnology
|
|
19 |
|
|
20 |
Gets a 32-bit integer value which is in big-endian format from a byte stream.
|
|
21 |
|
|
22 |
@param aPtr A pointer to a byte stream.
|
|
23 |
@return A 32-bit long integer value in native machine format.
|
|
24 |
|
|
25 |
*/
|
|
26 |
inline TUint32 BigEndian::Get32(const TUint8 *aPtr)
|
|
27 |
{
|
|
28 |
return (aPtr[0]<<24) | (aPtr[1]<<16) | (aPtr[2]<<8) | aPtr[3];
|
|
29 |
}
|
|
30 |
|
|
31 |
/**
|
|
32 |
Inserts a 32-bit value into a byte stream in big-endian format.
|
|
33 |
|
|
34 |
@param aPtr A pointer to a byte stream.
|
|
35 |
@param aVal A 32-bit long integer value in native machine format.
|
|
36 |
*/
|
|
37 |
inline void BigEndian::Put32(TUint8 *aPtr, TUint32 aVal)
|
|
38 |
{
|
|
39 |
aPtr[0] = aVal >> 24;
|
|
40 |
aPtr[1] = (aVal >> 16) & 0xff;
|
|
41 |
aPtr[2] = (aVal >> 8) & 0xff;
|
|
42 |
aPtr[3] = aVal & 0xff;
|
|
43 |
}
|
|
44 |
/**
|
|
45 |
Gets a 16-bit value integer which is in big-endian format from a byte stream.
|
|
46 |
|
|
47 |
@param aPtr A pointer to a byte stream.
|
|
48 |
@return A 16-bit long integer value in native machine format.
|
|
49 |
*/
|
|
50 |
inline TUint16 BigEndian::Get16(const TUint8 *aPtr)
|
|
51 |
{
|
|
52 |
return (aPtr[0]<<8) | aPtr[1];
|
|
53 |
}
|
|
54 |
/**
|
|
55 |
Inserts a 16-bit value into a byte stream in big-endian format.
|
|
56 |
|
|
57 |
@param aPtr A pointer to a byte stream.
|
|
58 |
@param aVal A 16-bit long integer value in native machine format.
|
|
59 |
*/
|
|
60 |
inline void BigEndian::Put16(TUint8 *aPtr, TUint16 aVal)
|
|
61 |
{
|
|
62 |
aPtr[0] = aVal >> 8;
|
|
63 |
aPtr[1] = aVal & 0xff;
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
/**
|
|
69 |
Gets a 32-bit integer value which is in little-endian format from a byte
|
|
70 |
stream.
|
|
71 |
|
|
72 |
@param aPtr A pointer to a byte stream.
|
|
73 |
@return A 32-bit long integer value in native machine format.
|
|
74 |
*/
|
|
75 |
inline TUint32 LittleEndian::Get32(const TUint8 *aPtr)
|
|
76 |
{
|
|
77 |
return (aPtr[3]<<24) | (aPtr[2]<<16) | (aPtr[1]<<8) | aPtr[0];
|
|
78 |
}
|
|
79 |
|
|
80 |
/**
|
|
81 |
Inserts a 32-bit value into a byte stream in little-endian format.
|
|
82 |
|
|
83 |
@param aPtr A pointer to a byte stream.
|
|
84 |
@param aVal A 32-bit long integer value in native machine format.
|
|
85 |
*/
|
|
86 |
inline void LittleEndian::Put32(TUint8 *aPtr, TUint32 aVal)
|
|
87 |
{
|
|
88 |
aPtr[3] = aVal >> 24;
|
|
89 |
aPtr[2] = (aVal >> 16) & 0xff;
|
|
90 |
aPtr[1] = (aVal >> 8) & 0xff;
|
|
91 |
aPtr[0] = aVal & 0xff;
|
|
92 |
}
|
|
93 |
/**
|
|
94 |
Gets a 16-bit value integer which is in little-endian format from a byte
|
|
95 |
stream.
|
|
96 |
|
|
97 |
@param aPtr A pointer to a byte stream.
|
|
98 |
@return A 16-bit long integer value in native machine format.
|
|
99 |
*/
|
|
100 |
inline TUint16 LittleEndian::Get16(const TUint8 *aPtr)
|
|
101 |
{
|
|
102 |
return (aPtr[1]<<8) | aPtr[0];
|
|
103 |
}
|
|
104 |
/**
|
|
105 |
Inserts a 16-bit value into a byte stream in little-endian format.
|
|
106 |
|
|
107 |
@param aPtr A pointer to a byte stream.
|
|
108 |
@param aVal A 16-bit long integer value in native machine format.
|
|
109 |
*/
|
|
110 |
inline void LittleEndian::Put16(TUint8 *aPtr, TUint16 aVal)
|
|
111 |
{
|
|
112 |
aPtr[1] = aVal >> 8;
|
|
113 |
aPtr[0] = aVal & 0xff;
|
|
114 |
}
|
|
115 |
|
|
116 |
|
|
117 |
|