|
1 /* |
|
2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: NVG Decoder header file |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef NVGICONDATA_INL_ |
|
19 #define NVGICONDATA_INL_ |
|
20 |
|
21 inline void CNVGIconData::CheckOutOfBoundL(TInt aLength) |
|
22 { |
|
23 if (iTotalRead + aLength > iDataLength || |
|
24 iTotalRead + aLength < 0) |
|
25 { |
|
26 User::Leave(KErrEof); |
|
27 } |
|
28 } |
|
29 |
|
30 inline TInt CNVGIconData::ReadPos() |
|
31 { |
|
32 return iTotalRead; |
|
33 } |
|
34 |
|
35 inline TInt CNVGIconData::DataLength() |
|
36 { |
|
37 return iDataLength; |
|
38 } |
|
39 |
|
40 |
|
41 inline const HBufC8 * CNVGIconData::GetNVGData() |
|
42 { |
|
43 return iNVGData; |
|
44 } |
|
45 |
|
46 inline TBool CNVGIconData::EOF() |
|
47 { |
|
48 return (iTotalRead >= iDataLength); |
|
49 } |
|
50 |
|
51 inline TInt CNVGIconData::EncodeInt8(TUint8 aVal) |
|
52 { |
|
53 return EncodeData(&aVal, sizeof(aVal)); |
|
54 } |
|
55 |
|
56 inline TInt CNVGIconData::EncodeInt16(TUint16 aVal) |
|
57 { |
|
58 return EncodeData(&aVal, sizeof(aVal)); |
|
59 } |
|
60 |
|
61 inline TInt CNVGIconData::EncodeInt32(TUint32 aVal) |
|
62 { |
|
63 return EncodeData(&aVal, sizeof(aVal)); |
|
64 } |
|
65 |
|
66 inline TInt CNVGIconData::EncodeReal32(TReal32 aVal) |
|
67 { |
|
68 return EncodeData(&aVal, sizeof(aVal)); |
|
69 } |
|
70 |
|
71 inline TInt CNVGIconData::EncodeReal64(TReal64 aVal) |
|
72 { |
|
73 return EncodeData(&aVal, sizeof(aVal)); |
|
74 } |
|
75 |
|
76 inline void CNVGIconData::EncodeInt8L(TUint8 aVal) |
|
77 { |
|
78 return EncodeDataL(&aVal, sizeof(aVal)); |
|
79 } |
|
80 |
|
81 inline void CNVGIconData::EncodeInt16L(TUint16 aVal) |
|
82 { |
|
83 return EncodeDataL(&aVal, sizeof(aVal)); |
|
84 } |
|
85 |
|
86 inline void CNVGIconData::EncodeInt32L(TUint32 aVal) |
|
87 { |
|
88 return EncodeDataL(&aVal, sizeof(aVal)); |
|
89 } |
|
90 |
|
91 inline void CNVGIconData::EncodeReal32L(TReal32 aVal) |
|
92 { |
|
93 return EncodeDataL(&aVal, sizeof(aVal)); |
|
94 } |
|
95 |
|
96 inline void CNVGIconData::EncodeReal64L(TReal64 aVal) |
|
97 { |
|
98 return EncodeDataL(&aVal, sizeof(aVal)); |
|
99 } |
|
100 |
|
101 inline const HBufC8 * CNVGIconData::GetNVGData() const |
|
102 { |
|
103 return iNVGData; |
|
104 } |
|
105 |
|
106 inline void CNVGIconData::Set(const TDesC8& aBuf) |
|
107 { |
|
108 iNVGDataPtr.Set((TUint8 *)aBuf.Ptr(), aBuf.Length(), aBuf.Length()); |
|
109 } |
|
110 |
|
111 inline void CNVGIconData::Set(TUint8 * aBuf, TInt aLength) |
|
112 { |
|
113 iNVGDataPtr.Set(aBuf, aLength, aLength); |
|
114 } |
|
115 |
|
116 inline TDereferencer::TDereferencer(TUint8 * aBuf, TInt aLength) |
|
117 : iTotalRead(0), |
|
118 iDataLength(aLength), |
|
119 iReadStream(aBuf) |
|
120 { |
|
121 |
|
122 } |
|
123 |
|
124 inline TDereferencer::TDereferencer(const TDesC8& aBuf) |
|
125 : iTotalRead(0), |
|
126 iDataLength(aBuf.Length()), |
|
127 iReadStream((unsigned char *)aBuf.Ptr()) |
|
128 { |
|
129 } |
|
130 |
|
131 inline void TDereferencer::CheckOutOfBoundL(TInt aLength) |
|
132 { |
|
133 if (iTotalRead + aLength > iDataLength || |
|
134 iTotalRead + aLength < 0) |
|
135 { |
|
136 User::Leave(KErrEof); |
|
137 } |
|
138 } |
|
139 |
|
140 inline void TDereferencer::SkipL(TInt aLength) |
|
141 { |
|
142 CheckOutOfBoundL(aLength); |
|
143 iTotalRead += aLength; |
|
144 } |
|
145 |
|
146 #define DEREF_PTR(TOTYPE, Offset, Size) do {\ |
|
147 CheckOutOfBoundL(Offset + Size); \ |
|
148 return * (TOTYPE *)&iReadStream[iTotalRead + Offset];\ |
|
149 } while (0) |
|
150 |
|
151 inline TReal64 TDereferencer::DerefReal64L(TInt aAt) |
|
152 { |
|
153 DEREF_PTR(TReal64, aAt, sizeof(TReal64)); |
|
154 } |
|
155 |
|
156 inline TReal32 TDereferencer::DerefReal32L(TInt aAt) |
|
157 { |
|
158 DEREF_PTR(TReal32, aAt, sizeof(TReal32)); |
|
159 } |
|
160 |
|
161 inline TUint8 * TDereferencer::DerefInt8ArrayL(TInt aLength, TInt aAt) |
|
162 { |
|
163 CheckOutOfBoundL(aAt + aLength); |
|
164 return (TUint8 *)&iReadStream[iTotalRead + aAt]; |
|
165 } |
|
166 |
|
167 inline void TDereferencer::IsSafeL(TInt aLength, TInt aAt) |
|
168 { |
|
169 CheckOutOfBoundL(aAt + aLength); |
|
170 } |
|
171 |
|
172 inline TInt8 TDereferencer::DerefInt8L(TInt aAt) |
|
173 { |
|
174 DEREF_PTR(TInt8, aAt, sizeof(TInt8)); |
|
175 } |
|
176 |
|
177 inline TInt32 TDereferencer::DerefInt32L(TInt aAt) |
|
178 { |
|
179 DEREF_PTR(TInt32, aAt, sizeof(TInt32)); |
|
180 } |
|
181 |
|
182 inline TInt16 TDereferencer::DerefInt16L(TInt aAt) |
|
183 { |
|
184 DEREF_PTR(TInt16, aAt, sizeof(TInt16)); |
|
185 } |
|
186 |
|
187 inline TDereferencer::operator TReal64() |
|
188 { |
|
189 return DerefReal64L(); |
|
190 } |
|
191 |
|
192 inline TDereferencer::operator TReal32() |
|
193 { |
|
194 return DerefReal32L(); |
|
195 } |
|
196 |
|
197 inline TDereferencer::operator TInt8() |
|
198 { |
|
199 return DerefInt8L(); |
|
200 } |
|
201 |
|
202 inline TDereferencer::operator TInt32() |
|
203 { |
|
204 return DerefInt32L(); |
|
205 } |
|
206 |
|
207 inline TDereferencer::operator TInt16() |
|
208 { |
|
209 return DerefInt16L(); |
|
210 } |
|
211 |
|
212 inline TPtr8 TDereferencer::GetPtr() |
|
213 { |
|
214 return TPtr8(iReadStream, iDataLength, iDataLength); |
|
215 } |
|
216 |
|
217 inline TInt TDereferencer::GetLength() |
|
218 { |
|
219 return iDataLength; |
|
220 } |
|
221 |
|
222 inline TInt TDereferencer::GetReadingPos() |
|
223 { |
|
224 return iTotalRead; |
|
225 } |
|
226 |
|
227 #endif |