|
1 // Copyright (c) 2009 - 2010 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 "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 * @file commontypes.h |
|
17 * |
|
18 * @internalComponent |
|
19 * @released |
|
20 */ |
|
21 #ifndef COMMONTYPES_H |
|
22 #define COMMONTYPES_H |
|
23 |
|
24 #include "symbiantypes.h" |
|
25 #include "uidtype.h" |
|
26 #include <vector> |
|
27 using namespace std; |
|
28 using namespace rscparser; |
|
29 |
|
30 /** |
|
31 Returns the smaller of two values. |
|
32 |
|
33 @param aLeft The first value to be compared. |
|
34 @param aRight The second value to be compared. |
|
35 |
|
36 @return The smaller value. |
|
37 */ |
|
38 template <class T> |
|
39 inline T Min(T aLeft,T aRight) |
|
40 {return(aLeft<aRight ? aLeft : aRight);} |
|
41 |
|
42 /** |
|
43 Returns the smaller of two objects, where the right hand object is a treated |
|
44 as a TInt for the purpose of comparison. |
|
45 |
|
46 @param aLeft The first value to be compared. |
|
47 @param aRight The second value to be compared. |
|
48 |
|
49 @return The smaller value. |
|
50 */ |
|
51 template <class T> |
|
52 inline T Min(T aLeft,TUint aRight) |
|
53 {return(aLeft<(TInt)aRight ? aLeft : (T)aRight);} |
|
54 |
|
55 /** |
|
56 Returns the larger of two values. |
|
57 |
|
58 @param aLeft The first value to be compared. |
|
59 @param aRight The second value to be compared. |
|
60 |
|
61 @return The larger value. |
|
62 */ |
|
63 template <class T> |
|
64 inline T Max(T aLeft,T aRight) |
|
65 {return(aLeft<aRight ? aRight : aLeft);} |
|
66 |
|
67 /** |
|
68 Returns the larger of two objects, where the right hand object is a treated |
|
69 as a TInt for the purpose of comparison. |
|
70 |
|
71 @param aLeft The first value to be compared. |
|
72 @param aRight The second value to be compared. |
|
73 |
|
74 @return The larger value. |
|
75 */ |
|
76 template <class T> |
|
77 inline T Max(T aLeft,TUint aRight) |
|
78 {return(aLeft<(TInt)aRight ? (TInt)aRight : aLeft);} |
|
79 |
|
80 /** |
|
81 Class to allocate heap memory and store a pointer to it |
|
82 for unicode data. |
|
83 The maximun allocated length and current length would also |
|
84 be maintained. |
|
85 */ |
|
86 class Ptr8 |
|
87 { |
|
88 |
|
89 public: |
|
90 /** |
|
91 Allocate heap of the specified size and |
|
92 store the pointer to it. |
|
93 @param aSize Size of the heap to be allocated. |
|
94 */ |
|
95 Ptr8(const TUint32& aSize); |
|
96 |
|
97 /** |
|
98 Free the allocated heap |
|
99 */ |
|
100 ~Ptr8(); |
|
101 |
|
102 /** |
|
103 Get the pointer to the allocated heap |
|
104 */ |
|
105 TUint8* GetPtr() const; |
|
106 /** |
|
107 Set the pointer |
|
108 */ |
|
109 void SetPtr(TUint8* aPtr); |
|
110 |
|
111 /** |
|
112 Set the length |
|
113 */ |
|
114 void SetLength(const TUint32& aLength); |
|
115 void ForceLength(const TUint32& aLength); |
|
116 |
|
117 /** |
|
118 Update the length of the current pointer |
|
119 with the length provided |
|
120 @param aLength Length to be updated |
|
121 */ |
|
122 TBool UpdateLength(const TUint32& aLength); |
|
123 |
|
124 /** |
|
125 To fetch the current length |
|
126 */ |
|
127 TUint32 GetLength() const; |
|
128 |
|
129 /** |
|
130 To fetch the Max length |
|
131 */ |
|
132 TUint32 GetMaxLength() const; |
|
133 |
|
134 TUint8 operator[](TInt anIndex) const; |
|
135 |
|
136 void Append(TUint8* aBuffer, TInt aLen); |
|
137 |
|
138 private: |
|
139 TUint8* iPtr; |
|
140 TUint32 iLength; |
|
141 const TUint32 iMaxLength; |
|
142 }; |
|
143 |
|
144 |
|
145 /** |
|
146 Class to allocate heap memory and store a pointer to it |
|
147 for non-unicode data. |
|
148 The maximun allocated length and current length would also |
|
149 be maintained. |
|
150 */ |
|
151 class Ptr16 |
|
152 { |
|
153 |
|
154 public: |
|
155 /** |
|
156 Allocate heap of the specified size and |
|
157 store the pointer to it. |
|
158 @param aSize Size of the heap to be allocated. |
|
159 */ |
|
160 Ptr16(const TUint32& aSize); |
|
161 |
|
162 /** |
|
163 Free the allocated heap |
|
164 */ |
|
165 ~Ptr16(); |
|
166 |
|
167 /** |
|
168 Get the pointer to the allocated heap |
|
169 */ |
|
170 TUint16* GetPtr() const; |
|
171 |
|
172 /** |
|
173 Set the pointer |
|
174 */ |
|
175 void SetPtr(TUint16* aPtr); |
|
176 |
|
177 /** |
|
178 Update the length of the current pointer |
|
179 with the length provided |
|
180 @param aLength Length to be updated |
|
181 */ |
|
182 TBool UpdateLength(const TUint32& aLength); |
|
183 |
|
184 /** |
|
185 To fetch the current length |
|
186 */ |
|
187 TUint32 GetLength() const; |
|
188 |
|
189 TUint16 operator[](TInt anIndex) const; |
|
190 |
|
191 private: |
|
192 TUint16* iPtr; |
|
193 TUint32 iLength; |
|
194 const TUint32 iMaxLength; |
|
195 }; |
|
196 |
|
197 |
|
198 /** |
|
199 Structure to represent TPtrC8 from symbian data type |
|
200 */ |
|
201 struct PtrC8 |
|
202 { |
|
203 PtrC8(); |
|
204 ~PtrC8(); |
|
205 const TUint8* iPtr; |
|
206 TUint32 iMaxLength; |
|
207 }; |
|
208 |
|
209 |
|
210 /** |
|
211 Structure to represent TPtrC16 from symbian data type |
|
212 */ |
|
213 struct PtrC16 |
|
214 { |
|
215 PtrC16(); |
|
216 ~PtrC16(); |
|
217 TUint16* iPtr; |
|
218 TUint32 iMaxLength; |
|
219 }; |
|
220 |
|
221 |
|
222 /** |
|
223 Structure to hold the UIDs of the RSC file |
|
224 */ |
|
225 |
|
226 struct sTUid |
|
227 { |
|
228 sTUid(); |
|
229 TUint32 iUid1; |
|
230 TUint32 iUid2; |
|
231 TUint32 iUid3; |
|
232 }; |
|
233 |
|
234 /** |
|
235 System wide error code -1 : item not found. |
|
236 |
|
237 A system wide error code indicates an error in the environment, or in |
|
238 user input from which a program may recover. |
|
239 */ |
|
240 const TInt KErrNotFound=(-1); // Must remain set to -1 |
|
241 |
|
242 /** |
|
243 System wide error code 0 : this represents the no-error condition. |
|
244 |
|
245 A system wide error code indicates an error in the environment, or in |
|
246 user input from which a program may recover. |
|
247 */ |
|
248 const TInt KErrNone=0; |
|
249 |
|
250 /** |
|
251 System wide error code -25 : indicates that end of file has been reached. |
|
252 |
|
253 A system wide error code indicates an error in the environment, or in |
|
254 user input from which a program may recover. |
|
255 |
|
256 Note that RFile::Read() is a higher-level interface. When the end of |
|
257 the file is reached, it returns zero bytes in the destination descriptor, and |
|
258 a KErrNone return value. KErrEof is not used for this purpose; other error |
|
259 conditions are returned only if some other error condition was indicated on |
|
260 the file. |
|
261 */ |
|
262 const TInt KErrEof=(-25); |
|
263 |
|
264 |
|
265 const TInt KExecutableImageUidValue=0x1000007a; |
|
266 |
|
267 const TUid KExecutableImageUidVal={KExecutableImageUidValue}; |
|
268 |
|
269 /** The hexadecimal value of the 2nd UID that defines a DLL as being a Unicode |
|
270 UI application. In .mmp files, the hexadecimal number is explicitly inserted |
|
271 as the first value following the UID keyword. |
|
272 |
|
273 @publishedAll |
|
274 @released |
|
275 @see KAppUidValue */ |
|
276 const TInt KAppUidValue16 = 0x100039CE; |
|
277 |
|
278 /** The 2nd UID that defines a DLL as being a Unicode UI application. |
|
279 |
|
280 @publishedAll |
|
281 @released |
|
282 @see KUidApp */ |
|
283 const TUid KUidApp16={KAppUidValue16}; |
|
284 |
|
285 /** The type-independent 2nd UID that identifies a DLL as being a UI application. |
|
286 |
|
287 @publishedAll |
|
288 @released |
|
289 @see KUidApp16 */ |
|
290 #define KUidApp KUidApp16 |
|
291 |
|
292 /** |
|
293 The uid for the Open service. |
|
294 |
|
295 @publishedPartner |
|
296 @released |
|
297 */ |
|
298 const TUid KOpenServiceUid = { 0x10208DCA }; |
|
299 |
|
300 /** An application group name. |
|
301 |
|
302 This is a name that allows applications to be categorized, for instance "Games" |
|
303 or "Utilities". |
|
304 |
|
305 @publishedAll |
|
306 @released */ |
|
307 typedef Ptr16* TAppGroupName; |
|
308 #endif /* COMMONTYPES_H */ |