|
1 // Copyright (c) 1995-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 // e32\include\e32des16.h |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __E32DES16_H__ |
|
19 #define __E32DES16_H__ |
|
20 |
|
21 /** |
|
22 @internalComponent |
|
23 */ |
|
24 const TUint KMaskDesLength16=0xfffffff; |
|
25 |
|
26 class TBufCBase16; |
|
27 class TDes16; |
|
28 class TPtrC16; |
|
29 class TPtr16; |
|
30 struct TCollationMethod; |
|
31 class HBufC16; |
|
32 class HBufC8; |
|
33 |
|
34 class TDesC16 |
|
35 /** |
|
36 @publishedAll |
|
37 @released |
|
38 |
|
39 Abstract base class for 16-bit descriptors. |
|
40 |
|
41 The class encapsulates the data member containing the length of data |
|
42 represented by a 16-bit descriptor. It also provides member functions through |
|
43 which the data can be accessed, but not modified. |
|
44 |
|
45 Data represented by this class is treated as a contiguous set of 16-bit (i.e. |
|
46 double byte) values or data items. |
|
47 |
|
48 This class cannot be instantiated as it is intended to form part of a class |
|
49 hierarchy; it provides a well defined part of descriptor behaviour. It can, |
|
50 however, be passed as an argument type for functions which want access to |
|
51 descriptor data but do not need to modify that data. |
|
52 |
|
53 @see TDesC |
|
54 @see TPtrC16 |
|
55 */ |
|
56 { |
|
57 public: |
|
58 /** |
|
59 A value returned by a call to HasPrefixC(). |
|
60 |
|
61 @see TDesC16::HasPrefixC |
|
62 */ |
|
63 enum TPrefix { |
|
64 /** |
|
65 Indicates that a supplied prefix can be extended to |
|
66 be equivalent to the text at the start of a descriptor. |
|
67 */ |
|
68 EIsPrefix = 0, |
|
69 /** |
|
70 Indicates that a supplied prefix does not seem to be a |
|
71 prefix, but it is possible that it could be extended to |
|
72 become equivalent to text at the start of this descriptor. |
|
73 */ |
|
74 EMightBePrefix = 1, |
|
75 /** |
|
76 Indicates that a supplied prefix cannot be extended to be |
|
77 equivalent to the text at the start of a descriptor. |
|
78 */ |
|
79 EIsNotPrefix = 2 |
|
80 }; |
|
81 public: |
|
82 inline TBool operator<(const TDesC16 &aDes) const; |
|
83 inline TBool operator<=(const TDesC16 &aDes) const; |
|
84 inline TBool operator>(const TDesC16 &aDes) const; |
|
85 inline TBool operator>=(const TDesC16 &aDes) const; |
|
86 inline TBool operator==(const TDesC16 &aDes) const; |
|
87 inline TBool operator!=(const TDesC16 &aDes) const; |
|
88 inline const TUint16 &operator[](TInt anIndex) const; |
|
89 inline TInt Length() const; |
|
90 inline TInt Size() const; |
|
91 IMPORT_C const TUint16 *Ptr() const; |
|
92 IMPORT_C TInt Compare(const TDesC16 &aDes) const; |
|
93 IMPORT_C TInt CompareF(const TDesC16 &aDes) const; |
|
94 IMPORT_C TInt CompareC(const TDesC16 &aDes) const; |
|
95 IMPORT_C TInt CompareC(const TDesC16& aDes,TInt aMaxLevel,const TCollationMethod* aCollationMethod) const; |
|
96 /** |
|
97 @internalComponent |
|
98 */ |
|
99 IMPORT_C HBufC16* GetNormalizedDecomposedFormL() const; |
|
100 /** |
|
101 @internalComponent |
|
102 */ |
|
103 IMPORT_C HBufC16* GetFoldedDecomposedFormL() const; |
|
104 /** |
|
105 @internalComponent |
|
106 */ |
|
107 IMPORT_C HBufC8* GetCollationKeysL(TInt aMaxLevel,const TCollationMethod* aCollationMethod) const; |
|
108 IMPORT_C TInt Match(const TDesC16 &aDes) const; |
|
109 IMPORT_C TInt MatchF(const TDesC16 &aDes) const; |
|
110 IMPORT_C TInt MatchC(const TDesC16 &aDes) const; |
|
111 IMPORT_C TInt MatchC(const TDesC16 &aPattern, TInt aWildChar, TInt aWildSequenceChar, |
|
112 TInt aEscapeChar, TInt aMaxLevel = 3, const TCollationMethod* aCollationMethod = NULL) const; |
|
113 IMPORT_C TInt MatchC(const TDesC16 &aPattern, const TCollationMethod* aCollationMethod, |
|
114 TInt aMaxLevel = 3, TInt aWildChar = '?', TInt aWildSequenceChar = '*', TInt aEscapeChar = 0) const; |
|
115 IMPORT_C TInt Locate(TChar aChar) const; |
|
116 IMPORT_C TInt LocateReverse(TChar aChar) const; |
|
117 IMPORT_C TInt Find(const TDesC16 &aDes) const; |
|
118 IMPORT_C TInt Find(const TUint16 *aBuf,TInt aLen) const; |
|
119 IMPORT_C TPrefix HasPrefixC(const TDesC16& aPossiblePrefix, TInt aLevel, const TCollationMethod* aCollationMethod) const; |
|
120 IMPORT_C TPtrC16 Left(TInt aLength) const; |
|
121 IMPORT_C TPtrC16 Right(TInt aLength) const; |
|
122 IMPORT_C TPtrC16 Mid(TInt aPos) const; |
|
123 IMPORT_C TPtrC16 Mid(TInt aPos,TInt aLength) const; |
|
124 IMPORT_C TInt LocateF(TChar aChar) const; |
|
125 IMPORT_C TInt LocateReverseF(TChar aChar) const; |
|
126 IMPORT_C TInt FindF(const TDesC16 &aDes) const; |
|
127 IMPORT_C TInt FindF(const TUint16 *aBuf,TInt aLen) const; |
|
128 IMPORT_C TInt FindC(const TDesC16 &aDes) const; |
|
129 IMPORT_C TInt FindC(const TUint16 *aBuf,TInt aLen) const; |
|
130 IMPORT_C TInt FindC(const TUint16 *aText,TInt aLength, TInt aMaxLevel) const; |
|
131 IMPORT_C TInt FindC(const TDesC16 &aDes,TInt &aLengthFound, const TCollationMethod &aMethod,TInt aMaxLevel) const; |
|
132 IMPORT_C HBufC16 *Alloc() const; |
|
133 IMPORT_C HBufC16 *AllocL() const; |
|
134 IMPORT_C HBufC16 *AllocLC() const; |
|
135 protected: |
|
136 inline TDesC16() {} |
|
137 inline TDesC16(TInt aType,TInt aLength); |
|
138 // delay this for a while |
|
139 #ifdef SYMBIAN_FIX_TDESC_CONSTRUCTORS |
|
140 inline TDesC16( const TDesC16& aOther) : iLength(aOther.iLength) {} |
|
141 #endif |
|
142 // inline ~TDesC16() {} Commented out for the moment since it breaks code |
|
143 inline TInt Type() const; |
|
144 inline void DoSetLength(TInt aLength); |
|
145 IMPORT_C const TUint16 &AtC(TInt anIndex) const; |
|
146 private: |
|
147 TUint iLength; |
|
148 __DECLARE_TEST; |
|
149 }; |
|
150 // |
|
151 class TPtrC16 : public TDesC16 |
|
152 /** |
|
153 @publishedAll |
|
154 @released |
|
155 |
|
156 16-bit non-modifiable pointer descriptor. |
|
157 |
|
158 This is a descriptor class intended for instantiation and encapsulates a |
|
159 pointer to the 16-bit data that it represents. The data can live in ROM or RAM |
|
160 and this location is separate from the descriptor object itself. |
|
161 |
|
162 The data is intended to be accessed, but not changed, through this descriptor. |
|
163 The base class provides the functions through which data is accessed. |
|
164 |
|
165 @see TPtr16 |
|
166 @see TDesC16 |
|
167 @see TDes16 |
|
168 @see TBufC16 |
|
169 @see TBuf16 |
|
170 @see HBufC16 |
|
171 */ |
|
172 { |
|
173 public: |
|
174 IMPORT_C TPtrC16(); |
|
175 IMPORT_C TPtrC16(const TDesC16 &aDes); |
|
176 IMPORT_C TPtrC16(const TUint16 *aString); |
|
177 IMPORT_C TPtrC16(const TUint16 *aBuf,TInt aLength); |
|
178 inline void Set(const TUint16 *aBuf,TInt aLength); |
|
179 inline void Set(const TDesC16 &aDes); |
|
180 inline void Set(const TPtrC16 &aPtr); |
|
181 private: |
|
182 TPtrC16& operator=(const TPtrC16 &aDes); |
|
183 protected: |
|
184 const TUint16 *iPtr; |
|
185 private: |
|
186 __DECLARE_TEST; |
|
187 }; |
|
188 // |
|
189 class TDes16Overflow |
|
190 /** |
|
191 @publishedAll |
|
192 @released |
|
193 |
|
194 An interface that defines an overflow handler for a 16-bit descriptor. |
|
195 |
|
196 The interface encapsulates a function that is called when an attempt to append |
|
197 formatted text fails because the descriptor is already at its maximum length. |
|
198 |
|
199 A derived class must provide an implementation for the Overflow() member function. |
|
200 |
|
201 @see TDes16::AppendFormat |
|
202 */ |
|
203 { |
|
204 public: |
|
205 /** |
|
206 Handles the overflow. |
|
207 |
|
208 This function is called when the TDes16::AppendFormat() |
|
209 variant that takes an overflow handler argument, fails. |
|
210 |
|
211 @param aDes The 16-bit modifiable descriptor whose overflow results in the |
|
212 call to this overflow handler. |
|
213 */ |
|
214 virtual void Overflow(TDes16 &aDes)=0; |
|
215 }; |
|
216 // |
|
217 class TDes16IgnoreOverflow : public TDes16Overflow |
|
218 /** |
|
219 @publishedAll |
|
220 @released |
|
221 |
|
222 A derived class which provides an implementation for the Overflow() member function |
|
223 where truncation is required. |
|
224 |
|
225 @see TDes16::AppendFormat |
|
226 */ |
|
227 { |
|
228 public: |
|
229 /** |
|
230 Handles the overflow. |
|
231 |
|
232 This function is called when the TDes16::AppendFormat() |
|
233 variant that takes an overflow handler argument, fails. |
|
234 |
|
235 @param aDes The 16-bit modifiable descriptor whose overflow results in the |
|
236 call to this overflow handler. |
|
237 */ |
|
238 IMPORT_C virtual void Overflow(TDes16 &aDes); |
|
239 }; |
|
240 // |
|
241 class TRealFormat; |
|
242 class TDes16 : public TDesC16 |
|
243 /** |
|
244 @publishedAll |
|
245 @released |
|
246 |
|
247 Abstract base class for 16-bit modifiable descriptors. |
|
248 |
|
249 The class encapsulates the data member containing the maximum length of data |
|
250 represented by a 16-bit descriptor. It also provides member functions through |
|
251 which the data can be modified. |
|
252 |
|
253 The class adds to the behaviour provided by TDesC16. |
|
254 |
|
255 This class cannot be instantiated as it is intended to form part of a class |
|
256 hierarchy; it provides a well defined part of descriptor behaviour. It can, |
|
257 however, be passed as an argument type for functions which need to both modify |
|
258 and access descriptor data. |
|
259 |
|
260 @see TDes |
|
261 @see TDesC8 |
|
262 @see TDesC16 |
|
263 */ |
|
264 { |
|
265 public: |
|
266 inline TDes16& operator=(const TUint16 *aString); |
|
267 inline TDes16& operator=(const TDesC16 &aDes); |
|
268 inline TDes16& operator=(const TDes16 &aDes); |
|
269 inline TInt MaxLength() const; |
|
270 inline TInt MaxSize() const; |
|
271 inline const TUint16 &operator[](TInt anIndex) const; |
|
272 inline TUint16 &operator[](TInt anIndex); |
|
273 inline TDes16 &operator+=(const TDesC16 &aDes); |
|
274 IMPORT_C void Zero(); |
|
275 IMPORT_C void SetLength(TInt aLength); |
|
276 IMPORT_C void SetMax(); |
|
277 IMPORT_C void Copy(const TDesC8 &aDes); |
|
278 IMPORT_C void Copy(const TDesC16 &aDes); |
|
279 IMPORT_C void Copy(const TUint16 *aBuf,TInt aLength); |
|
280 IMPORT_C void Copy(const TUint16 *aString); |
|
281 IMPORT_C void Append(TChar aChar); |
|
282 IMPORT_C void Append(const TDesC16 &aDes); |
|
283 IMPORT_C void Append(const TUint16 *aBuf,TInt aLength); |
|
284 IMPORT_C void Fill(TChar aChar); |
|
285 IMPORT_C void Fill(TChar aChar,TInt aLength); |
|
286 IMPORT_C void FillZ(); |
|
287 IMPORT_C void FillZ(TInt aLength); |
|
288 IMPORT_C void NumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth); |
|
289 IMPORT_C void AppendNumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth); |
|
290 IMPORT_C TPtr16 LeftTPtr(TInt aLength) const; |
|
291 IMPORT_C TPtr16 RightTPtr(TInt aLength) const; |
|
292 IMPORT_C TPtr16 MidTPtr(TInt aPos) const; |
|
293 IMPORT_C TPtr16 MidTPtr(TInt aPos,TInt aLength) const; |
|
294 IMPORT_C const TUint16 *PtrZ(); |
|
295 IMPORT_C void CopyF(const TDesC16 &aDes); |
|
296 IMPORT_C void CopyC(const TDesC16 &aDes); |
|
297 IMPORT_C void CopyLC(const TDesC16 &aDes); |
|
298 IMPORT_C void CopyUC(const TDesC16 &aDes); |
|
299 IMPORT_C void CopyCP(const TDesC16 &aDes); |
|
300 IMPORT_C void AppendFill(TChar aChar,TInt aLength); |
|
301 IMPORT_C void ZeroTerminate(); |
|
302 IMPORT_C void Swap(TDes16 &aDes); |
|
303 IMPORT_C void Fold(); |
|
304 IMPORT_C void Collate(); |
|
305 IMPORT_C void LowerCase(); |
|
306 IMPORT_C void UpperCase(); |
|
307 IMPORT_C void Capitalize(); |
|
308 IMPORT_C void Repeat(const TDesC16 &aDes); |
|
309 IMPORT_C void Repeat(const TUint16 *aBuf,TInt aLength); |
|
310 IMPORT_C void Trim(); |
|
311 IMPORT_C void TrimAll(); |
|
312 IMPORT_C void TrimLeft(); |
|
313 IMPORT_C void TrimRight(); |
|
314 IMPORT_C void Insert(TInt aPos,const TDesC16 &aDes); |
|
315 IMPORT_C void Delete(TInt aPos,TInt aLength); |
|
316 IMPORT_C void Replace(TInt aPos,TInt aLength,const TDesC16 &aDes); |
|
317 IMPORT_C void Justify(const TDesC16 &aDes,TInt aWidth,TAlign anAlignment,TChar aFill); |
|
318 IMPORT_C void NumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth); |
|
319 IMPORT_C void NumUC(TUint64 aVal, TRadix aRadix=EDecimal); |
|
320 IMPORT_C TInt Num(TReal aVal,const TRealFormat &aFormat) __SOFTFP; |
|
321 IMPORT_C void Num(TInt64 aVal); |
|
322 IMPORT_C void Num(TUint64 aVal, TRadix aRadix); |
|
323 IMPORT_C void Format(TRefByValue<const TDesC16> aFmt,...); |
|
324 IMPORT_C void FormatList(const TDesC16 &aFmt,VA_LIST aList); |
|
325 IMPORT_C void AppendJustify(const TDesC16 &Des,TInt aWidth,TAlign anAlignment,TChar aFill); |
|
326 IMPORT_C void AppendJustify(const TDesC16 &Des,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill); |
|
327 IMPORT_C void AppendJustify(const TUint16 *aString,TInt aWidth,TAlign anAlignment,TChar aFill); |
|
328 IMPORT_C void AppendJustify(const TUint16 *aString,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill); |
|
329 IMPORT_C void AppendNumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth); |
|
330 IMPORT_C void AppendNumUC(TUint64 aVal, TRadix aRadix=EDecimal); |
|
331 IMPORT_C TInt AppendNum(TReal aVal,const TRealFormat &aFormat) __SOFTFP; |
|
332 IMPORT_C void AppendNum(TInt64 aVal); |
|
333 IMPORT_C void AppendNum(TUint64 aVal, TRadix aRadix); |
|
334 IMPORT_C void AppendFormat(TRefByValue<const TDesC16> aFmt,TDes16Overflow *aOverflowHandler,...); |
|
335 IMPORT_C void AppendFormat(TRefByValue<const TDesC16> aFmt,...); |
|
336 IMPORT_C void AppendFormatList(const TDesC16 &aFmt,VA_LIST aList,TDes16Overflow *aOverflowHandler=NULL); |
|
337 IMPORT_C TPtr8 Collapse(); |
|
338 protected: |
|
339 inline TDes16() {} |
|
340 inline TDes16(TInt aType,TInt aLength,TInt aMaxLength); |
|
341 // delay this for a while |
|
342 #ifdef SYMBIAN_FIX_TDESC_CONSTRUCTORS |
|
343 inline TDes16(const TDes16& aOther) : TDesC16(aOther), iMaxLength(aOther.iMaxLength) {} |
|
344 #endif |
|
345 inline TUint16 *WPtr() const; |
|
346 void DoAppendNum(TUint64 aVal, TRadix aRadix, TUint aA, TInt aW); |
|
347 void DoPadAppendNum(TInt aLength, TInt aW, const TUint8* aBuf); |
|
348 protected: |
|
349 TInt iMaxLength; |
|
350 __DECLARE_TEST; |
|
351 }; |
|
352 // |
|
353 class TPtr16 : public TDes16 |
|
354 /** |
|
355 @publishedAll |
|
356 @released |
|
357 |
|
358 16-bit modifiable pointer descriptor |
|
359 |
|
360 This is a descriptor class intended for instantiation and encapsulates a |
|
361 pointer to the 16-bit data that it represents. The data can live in ROM or |
|
362 RAM and this location is separate from the descriptor object itself. |
|
363 |
|
364 The data is intended to be accessed and modified through this descriptor. |
|
365 The base classes provide the functions through which the data can be |
|
366 manipulated. |
|
367 |
|
368 @see TPtr |
|
369 @see TPtrC16 |
|
370 @see TDesC16 |
|
371 @see TDes16 |
|
372 @see TBufC16 |
|
373 @see TBuf16 |
|
374 @see HBufC16 |
|
375 */ |
|
376 { |
|
377 public: |
|
378 IMPORT_C TPtr16(TUint16 *aBuf,TInt aMaxLength); |
|
379 IMPORT_C TPtr16(TUint16 *aBuf,TInt aLength,TInt aMaxLength); |
|
380 inline TPtr16& operator=(const TUint16 *aString); |
|
381 inline TPtr16& operator=(const TDesC16& aDes); |
|
382 inline TPtr16& operator=(const TPtr16& aDes); |
|
383 inline void Set(TUint16 *aBuf,TInt aLength,TInt aMaxLength); |
|
384 inline void Set(const TPtr16 &aPtr); |
|
385 private: |
|
386 IMPORT_C TPtr16(TBufCBase16 &aLcb,TInt aMaxLength); |
|
387 protected: |
|
388 TUint16 *iPtr; |
|
389 private: |
|
390 friend class TBufCBase16; |
|
391 __DECLARE_TEST; |
|
392 }; |
|
393 // |
|
394 class TBufCBase16 : public TDesC16 |
|
395 /** |
|
396 @internalAll |
|
397 */ |
|
398 { |
|
399 protected: |
|
400 IMPORT_C TBufCBase16(); |
|
401 inline TBufCBase16(TInt aLength); |
|
402 IMPORT_C TBufCBase16(const TUint16 *aString,TInt aMaxLength); |
|
403 IMPORT_C TBufCBase16(const TDesC16 &aDes,TInt aMaxLength); |
|
404 IMPORT_C void Copy(const TUint16 *aString,TInt aMaxLength); |
|
405 IMPORT_C void Copy(const TDesC16 &aDes,TInt aMaxLength); |
|
406 inline TPtr16 DoDes(TInt aMaxLength); |
|
407 inline TUint16 *WPtr() const; |
|
408 }; |
|
409 // |
|
410 class RReadStream; |
|
411 class HBufC16 : public TBufCBase16 |
|
412 /** |
|
413 @publishedAll |
|
414 @released |
|
415 |
|
416 16-bit heap descriptor. |
|
417 |
|
418 This is a descriptor class which provides a buffer of fixed length, allocated |
|
419 on the heap, for containing and accessing data. |
|
420 |
|
421 The class is intended for instantiation. |
|
422 |
|
423 Heap descriptors have the important property that they can be made larger |
|
424 or smaller, changing the size of the descriptor buffer. This is achieved by |
|
425 reallocating the descriptor. Unlike the behaviour of dynamic buffers, reallocation |
|
426 is not done automatically. |
|
427 |
|
428 Data is intended to be accessed, but not modified; however, it can be completely |
|
429 replaced using the assignment operators of this class. The base class (TDesC16) provides |
|
430 the functions through which the data is accessed. |
|
431 |
|
432 The descriptor is hosted by a heap cell, and the 16-bit data that the descriptor |
|
433 represents is part of the descriptor object itself. The size of the cell depends |
|
434 on the requested maximum length of the descriptor buffer when the descriptor |
|
435 is created or re-allocated. |
|
436 |
|
437 It is important to note that the size of the allocated cell, and, therefore, |
|
438 the resulting maximum length of the descriptor, may be larger than requested |
|
439 due to the way memory is allocated in Symbian OS. The amount by which this |
|
440 may be rounded up depends on the platform and build type. |
|
441 |
|
442 @see HBufC |
|
443 @see TPtr16 |
|
444 @see TDesC16 |
|
445 */ |
|
446 { |
|
447 public: |
|
448 IMPORT_C static HBufC16 *New(TInt aMaxLength); |
|
449 IMPORT_C static HBufC16 *NewL(TInt aMaxLength); |
|
450 IMPORT_C static HBufC16 *NewLC(TInt aMaxLength); |
|
451 IMPORT_C static HBufC16 *NewMax(TInt aMaxLength); |
|
452 IMPORT_C static HBufC16 *NewMaxL(TInt aMaxLength); |
|
453 IMPORT_C static HBufC16 *NewMaxLC(TInt aMaxLength); |
|
454 IMPORT_C static HBufC16 *NewL(RReadStream &aStream,TInt aMaxLength); |
|
455 IMPORT_C static HBufC16 *NewLC(RReadStream &aStream,TInt aMaxLength); |
|
456 IMPORT_C HBufC16& operator=(const TUint16 *aString); |
|
457 IMPORT_C HBufC16& operator=(const TDesC16 &aDes); |
|
458 inline HBufC16& operator=(const HBufC16 &aLcb); |
|
459 IMPORT_C HBufC16 *ReAlloc(TInt aMaxLength); |
|
460 IMPORT_C HBufC16 *ReAllocL(TInt aMaxLength); |
|
461 IMPORT_C TPtr16 Des(); |
|
462 private: |
|
463 inline HBufC16(TInt aLength); |
|
464 private: |
|
465 TText16 iBuf[1]; |
|
466 __DECLARE_TEST; |
|
467 }; |
|
468 // |
|
469 /** |
|
470 @internalComponent |
|
471 */ |
|
472 #define __Size16 (sizeof(TInt)/sizeof(TInt16)) |
|
473 /** |
|
474 @internalComponent |
|
475 */ |
|
476 #define __Align16(s) ((((s)+__Size16-1)/__Size16)*__Size16) |
|
477 // |
|
478 template <TInt S> |
|
479 class TBufC16 : public TBufCBase16 |
|
480 /** |
|
481 @publishedAll |
|
482 @released |
|
483 |
|
484 16-bit non-modifiable buffer descriptor. |
|
485 |
|
486 This is a descriptor class which provides a buffer of fixed length for |
|
487 containing and accessing TUint16 data. |
|
488 |
|
489 The class intended for instantiation. The 16-bit data that the descriptor |
|
490 represents is part of the descriptor object itself. |
|
491 |
|
492 The class is templated, based on an integer value which defines the size of |
|
493 the descriptor's data area. |
|
494 |
|
495 The data is intended to be accessed, but not modified; however, it can be |
|
496 completely replaced using the assignment operators of this class. The base |
|
497 class provides the functions through which the data is accessed. |
|
498 |
|
499 @see TBufC |
|
500 @see TDesC16 |
|
501 @see TPtr16 |
|
502 @see TUint16 |
|
503 */ |
|
504 { |
|
505 public: |
|
506 inline TBufC16(); |
|
507 inline TBufC16(const TUint16 *aString); |
|
508 inline TBufC16(const TDesC16 &aDes); |
|
509 inline TBufC16<S> &operator=(const TUint16 *aString); |
|
510 inline TBufC16<S> &operator=(const TDesC16 &aDes); |
|
511 inline TPtr16 Des(); |
|
512 protected: |
|
513 TUint16 iBuf[__Align16(S)]; |
|
514 }; |
|
515 // |
|
516 class TBufBase16 : public TDes16 |
|
517 /** |
|
518 @internalAll |
|
519 */ |
|
520 { |
|
521 protected: |
|
522 IMPORT_C TBufBase16(TInt aMaxLength); |
|
523 IMPORT_C TBufBase16(TInt aLength,TInt aMaxLength); |
|
524 IMPORT_C TBufBase16(const TUint16* aString,TInt aMaxLength); |
|
525 IMPORT_C TBufBase16(const TDesC16& aDes,TInt aMaxLength); |
|
526 }; |
|
527 // |
|
528 template <TInt S> |
|
529 class TBuf16 : public TBufBase16 |
|
530 /** |
|
531 @publishedAll |
|
532 @released |
|
533 |
|
534 A descriptor class which provides a buffer of fixed length for |
|
535 containing, accessing and manipulating TUint16 data. |
|
536 |
|
537 The class is intended for instantiation. The 16-bit data that the descriptor |
|
538 represents is part of the descriptor object itself. |
|
539 |
|
540 The class is templated, based on an integer value which determines the size |
|
541 of the data area which is created as part of the buffer descriptor object; |
|
542 this is also the maximum length of the descriptor. |
|
543 |
|
544 The data is intended to be both accessed and modified. The base classes provide |
|
545 the functions through which the data is accessed. |
|
546 |
|
547 @see TBuf |
|
548 @see TDesC16 |
|
549 @see TDes16 |
|
550 @see TPtr16 |
|
551 */ |
|
552 { |
|
553 public: |
|
554 inline TBuf16(); |
|
555 inline explicit TBuf16(TInt aLength); |
|
556 inline TBuf16(const TUint16* aString); |
|
557 inline TBuf16(const TDesC16& aDes); |
|
558 inline TBuf16<S>& operator=(const TUint16* aString); |
|
559 inline TBuf16<S>& operator=(const TDesC16& aDes); |
|
560 inline TBuf16<S>& operator=(const TBuf16<S>& aDes); |
|
561 protected: |
|
562 TUint16 iBuf[__Align16(S)]; |
|
563 }; |
|
564 |
|
565 |
|
566 #ifndef __KERNEL_MODE__ |
|
567 |
|
568 class RBuf16 : public TDes16 |
|
569 /** |
|
570 @publishedAll |
|
571 @released |
|
572 |
|
573 16 bit resizable buffer descriptor. |
|
574 |
|
575 The class provides a buffer that contains, accesses and manipulates |
|
576 TUint16 data. The buffer itself is on the heap, and is managed by the class. |
|
577 |
|
578 Internally, RBuf16 behaves in one of two ways: |
|
579 |
|
580 - as a TPtr16 descriptor type, where the buffer just contains data |
|
581 - as a pointer to a heap descriptor, an HBufC16* type, where the buffer |
|
582 contains both descriptor information and the data. |
|
583 |
|
584 Note that the handling of the distinction is hidden from view. |
|
585 |
|
586 An RBuf16 object can allocate its own buffer. Alternatively, it can take |
|
587 ownership of a pre-existing section of allocated memory, or it can take |
|
588 ownership of a pre-existing heap descriptor. It can also reallocate the buffer |
|
589 to resize it. Regardless of the way in which the buffer has been allocated, |
|
590 the RBuf16 object is responsible for freeing memory when the object itself is closed. |
|
591 |
|
592 The class is intended for instantiation. |
|
593 |
|
594 The class is derived from TDes16, which means that data can be both accessed |
|
595 and modified. The base classes provide the functions through which the data is |
|
596 accessed. In addition, an RBuf16 object can be passed to any function that is |
|
597 prototyped to take a TDes16 or a TDesC16 type. |
|
598 |
|
599 @see TBuf16 |
|
600 @see TPtr16 |
|
601 @see HBufC16 |
|
602 @see TDesC16 |
|
603 @see TDes16 |
|
604 */ |
|
605 { |
|
606 public: |
|
607 IMPORT_C RBuf16(); |
|
608 IMPORT_C explicit RBuf16(HBufC16* aHBuf); |
|
609 inline RBuf16& operator=(const TUint16* aString); |
|
610 inline RBuf16& operator=(const TDesC16& aDes); |
|
611 inline RBuf16& operator=(const RBuf16& aDes); |
|
612 IMPORT_C void Assign(const RBuf16& aRBuf); |
|
613 IMPORT_C void Assign(TUint16 *aHeapCell,TInt aMaxLength); |
|
614 IMPORT_C void Assign(TUint16 *aHeapCell,TInt aLength,TInt aMaxLength); |
|
615 IMPORT_C void Assign(HBufC16* aHBuf); |
|
616 IMPORT_C void Swap(RBuf16& aRBuf); |
|
617 IMPORT_C TInt Create(TInt aMaxLength); |
|
618 IMPORT_C void CreateL(TInt aMaxLength); |
|
619 IMPORT_C TInt CreateMax(TInt aMaxLength); |
|
620 IMPORT_C void CreateMaxL(TInt aMaxLength); |
|
621 inline void CreateL(RReadStream &aStream,TInt aMaxLength); |
|
622 IMPORT_C TInt Create(const TDesC16& aDes); |
|
623 IMPORT_C void CreateL(const TDesC16& aDes); |
|
624 IMPORT_C TInt Create(const TDesC16& aDes,TInt aMaxLength); |
|
625 IMPORT_C void CreateL(const TDesC16& aDes,TInt aMaxLength); |
|
626 IMPORT_C TInt ReAlloc(TInt aMaxLength); |
|
627 IMPORT_C void ReAllocL(TInt aMaxLength); |
|
628 IMPORT_C void Close(); |
|
629 IMPORT_C void CleanupClosePushL(); |
|
630 |
|
631 protected: |
|
632 IMPORT_C RBuf16(TInt aType,TInt aLength,TInt aMaxLength); |
|
633 RBuf16(const RBuf16&); // Outlaw copy construction |
|
634 union |
|
635 { |
|
636 TUint16* iEPtrType; //Pointer to data used when RBuf is of EPtr type |
|
637 HBufC16* iEBufCPtrType; //Pointer to data used when RBuf is of EBufCPtr type |
|
638 }; |
|
639 __DECLARE_TEST; |
|
640 }; |
|
641 |
|
642 #endif //__KERNEL_MODE__ |
|
643 |
|
644 |
|
645 /** |
|
646 @publishedAll |
|
647 @released |
|
648 |
|
649 Value reference used in operator TLitC16::__TRefDesC16() |
|
650 |
|
651 @see TRefByValue |
|
652 */ |
|
653 typedef TRefByValue<const TDesC16> __TRefDesC16; |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 template <TInt S> |
|
659 class TLitC16 |
|
660 /** |
|
661 @publishedAll |
|
662 @released |
|
663 |
|
664 Encapsulates literal text. |
|
665 |
|
666 This is always constructed using an _LIT16 macro. |
|
667 |
|
668 This class is build independent; i.e. an explicit 16-bit build variant |
|
669 is generated for both a non-Unicode build and a Unicode build. |
|
670 |
|
671 The class has no explicit constructors. |
|
672 |
|
673 @see _LIT16 |
|
674 */ |
|
675 { |
|
676 public: |
|
677 inline const TDesC16* operator&() const; |
|
678 inline operator const TDesC16&() const; |
|
679 inline const TDesC16& operator()() const; |
|
680 inline operator const __TRefDesC16() const; |
|
681 public: |
|
682 #if defined(__GCC32__) |
|
683 /** |
|
684 @internalComponent |
|
685 */ |
|
686 typedef wchar_t __TText; |
|
687 #elif defined(__VC32__) |
|
688 /** |
|
689 @internalComponent |
|
690 */ |
|
691 typedef TUint16 __TText; |
|
692 #elif defined(__CW32__) |
|
693 /** |
|
694 @internalComponent |
|
695 */ |
|
696 typedef TUint16 __TText; |
|
697 #elif !defined(__TText_defined) |
|
698 #error no typedef for __TText |
|
699 #endif |
|
700 public: |
|
701 /** |
|
702 @internalComponent |
|
703 */ |
|
704 TUint iTypeLength; |
|
705 |
|
706 /** |
|
707 @internalComponent |
|
708 */ |
|
709 __TText iBuf[__Align16(S)]; |
|
710 }; |
|
711 |
|
712 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
713 #include <e32des16_private.h> |
|
714 #endif |
|
715 |
|
716 #endif |