author | Mark Wilcox <markw@symbian.org> |
Tue, 25 May 2010 13:20:47 +0100 | |
changeset 116 | 57eea1054f46 |
parent 90 | 947f0dc9f7a8 |
child 153 | 1f2940c968a9 |
child 245 | 647ab20fee2e |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1994-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\common\des16.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "common.h" |
|
19 |
#include <e32des16_private.h> |
|
20 |
#include <collate.h> |
|
21 |
#ifdef _UNICODE |
|
22 |
#include <unicode.h> |
|
23 |
#include "collateimp.h" |
|
24 |
#endif |
|
25 |
#include "CompareImp.h" |
|
26 |
||
27 |
||
28 |
#define __CHECK_ALIGNMENT(p,c) __ASSERT_DEBUG(!(TUint(p)&1),Des16Panic(c)) |
|
29 |
||
30 |
enum TDes16Panic |
|
31 |
{ |
|
32 |
ETDesC16ConstructCString=0, |
|
33 |
ETDesC16ConstructBufLength=1, |
|
34 |
ETDesC16ConstructBufLengthMax=2, |
|
35 |
ETDesC16FindPtrLen=3, |
|
36 |
ETDesC16FindFPtrLen=4, |
|
37 |
ETDesC16FindCPtrLen=5, |
|
38 |
ETBufCBase16CopyStringMax=6, |
|
39 |
EHBufC16AssignCString=7, |
|
40 |
ETDes16AssignCString=8, |
|
41 |
ETDes16CopyCString=9, |
|
42 |
ETDes16CopyBufLength=10, |
|
43 |
ETDes16AppendBufLength=11, |
|
44 |
ETDes16RepeatBufLength=12, |
|
45 |
ETDes16AppendJustify1=13, |
|
46 |
ETDes16AppendJustify2=14, |
|
47 |
ETPtrC16SetBufLength=15, |
|
48 |
ETPtr16SetBufLengthMax=16, |
|
49 |
ETDesC16Invariant=17, |
|
50 |
ETDesC16Ptr=18 |
|
51 |
}; |
|
52 |
||
53 |
#ifdef _DEBUG |
|
54 |
_LIT(KLitDes16Align,"Des16Align"); |
|
55 |
void Des16Panic(TDes16Panic aPanic) |
|
56 |
{ |
|
57 |
PANIC_CURRENT_THREAD(KLitDes16Align,aPanic); |
|
58 |
} |
|
59 |
#endif |
|
60 |
||
61 |
inline TUint16* memCopy(TUint16* aPtr, const TUint16* aSrc, TInt aLength) |
|
62 |
{ |
|
63 |
return (TUint16 *)Mem::Copy(aPtr,aSrc,aLength<<1); |
|
64 |
} |
|
65 |
||
66 |
#if !defined( __DES16_MACHINE_CODED__) | defined(__EABI_CTORS__) |
|
67 |
inline TInt StringLength(const TUint16* aPtr) |
|
68 |
{ |
|
69 |
const TUint16* p = aPtr; |
|
70 |
while (*p) |
|
71 |
++p; |
|
72 |
return p-aPtr; |
|
73 |
} |
|
74 |
#endif |
|
75 |
||
76 |
inline TDesC16::TDesC16(TInt aType,TInt aLength) |
|
77 |
:iLength(aLength|(aType<<KShiftDesType16)) |
|
78 |
{} |
|
79 |
inline TInt TDesC16::Type() const |
|
80 |
// |
|
81 |
// Return the descriptor type |
|
82 |
// |
|
83 |
{ |
|
84 |
return(iLength>>KShiftDesType16); |
|
85 |
} |
|
86 |
||
87 |
inline TDes16::TDes16(TInt aType,TInt aLength,TInt aMaxLength) |
|
88 |
: TDesC16(aType,aLength),iMaxLength(aMaxLength) |
|
89 |
{} |
|
90 |
||
91 |
// Class TBufCBase16 |
|
92 |
inline TBufCBase16::TBufCBase16(TInt aLength) |
|
93 |
:TDesC16(EBufC,aLength) |
|
94 |
{} |
|
95 |
inline TUint16* TBufCBase16::WPtr() const |
|
96 |
{return const_cast<TUint16*>(Ptr());} |
|
97 |
||
98 |
#if !defined( __DES16_MACHINE_CODED__) | defined(__EABI_CTORS__) |
|
99 |
EXPORT_C TPtr16::TPtr16(TBufCBase16& aLcb, TInt aMaxLength) |
|
100 |
: TDes16(EBufCPtr,aLcb.Length(),aMaxLength),iPtr((TUint16*)&aLcb) |
|
101 |
{ |
|
102 |
__ASSERT_DEBUG(aLcb.Length()<=aMaxLength,Panic(ETDes16LengthOutOfRange)); |
|
103 |
} |
|
104 |
#endif |
|
105 |
||
106 |
#if !defined( __DES16_MACHINE_CODED__) |
|
107 |
/** |
|
108 |
Gets a pointer to the data represented by the descriptor. |
|
109 |
||
110 |
The data cannot be changed through the returned pointer. |
|
111 |
||
112 |
@return A pointer to the data |
|
113 |
*/ |
|
114 |
EXPORT_C const TUint16 *TDesC16::Ptr() const |
|
115 |
{ |
|
116 |
||
117 |
const TUint16* p=NULL; |
|
118 |
switch (Type()) |
|
119 |
{ |
|
120 |
case EBufC: |
|
121 |
p=(&((SBufC16 *)this)->buf[0]); break; |
|
122 |
case EPtrC: |
|
123 |
p=(((SPtrC16 *)this)->ptr); break; |
|
124 |
case EPtr: |
|
125 |
p=(((SPtr16 *)this)->ptr); break; |
|
126 |
case EBuf: |
|
127 |
p=(&((SBuf16 *)this)->buf[0]); break; |
|
128 |
case EBufCPtr: |
|
129 |
p=(&((SBufCPtr16 *)this)->ptr->buf[0]); break; |
|
130 |
default: |
|
131 |
Panic(ETDes16BadDescriptorType); |
|
132 |
} |
|
133 |
__CHECK_ALIGNMENT(p,ETDesC16Ptr); |
|
134 |
return p; |
|
135 |
} |
|
136 |
||
137 |
EXPORT_C const TUint16 &TDesC16::AtC(TInt anIndex) const |
|
138 |
// |
|
139 |
// Return a reference to the character in the buffer. |
|
140 |
// |
|
141 |
{ |
|
142 |
||
143 |
__ASSERT_ALWAYS(anIndex>=0 && anIndex<Length(),Panic(ETDes16IndexOutOfRange)); |
|
144 |
return(Ptr()[anIndex]); |
|
145 |
} |
|
146 |
||
147 |
||
148 |
||
149 |
||
150 |
/** |
|
151 |
Compares this descriptor's data with the specified descriptor's data. |
|
152 |
||
153 |
The comparison proceeds on a double-byte for double byte basis. |
|
154 |
The result of the comparison is based on the difference of the first pair |
|
155 |
of bytes to disagree. |
|
156 |
||
157 |
Two descriptors are equal if they have the same length and content. Where |
|
158 |
two descriptors have different lengths and the shorter descriptor's data |
|
159 |
matches the first part of the longer descriptor's data, the shorter is |
|
160 |
considered to be less than the longer. |
|
161 |
||
162 |
@param aDes The 16-bit non-modifable descriptor whose data is to be compared |
|
163 |
with this descriptor's data. |
|
164 |
||
165 |
@return Positive. if this descriptor is greater than the specified descriptor. |
|
166 |
Negative. if this descriptor is less than the specified descriptor. |
|
167 |
Zero, if both descriptors have the same length and the their contents |
|
168 |
are the same. |
|
169 |
*/ |
|
170 |
EXPORT_C TInt TDesC16::Compare(const TDesC16 &aDes) const |
|
171 |
{ |
|
172 |
return MEM_COMPARE_16(Ptr(),Length(),aDes.Ptr(),aDes.Length()); |
|
173 |
} |
|
174 |
||
175 |
||
176 |
||
177 |
||
178 |
/** |
|
179 |
Compares this descriptor's folded data with the specified descriptor's folded |
|
180 |
data. |
|
181 |
||
182 |
Note that folding is locale-independent behaviour. It is also important to |
|
183 |
note that there can be no guarantee that folding is in any way culturally |
|
184 |
appropriate, and should not be used for comparing strings in natural language; |
|
185 |
use CompareC() for this. |
|
186 |
||
187 |
@param aDes The 16-bit non-modifable descriptor whose data is to be compared |
|
188 |
with this descriptor's data. |
|
189 |
||
190 |
@return Positive, if this descriptor is greater than the specified descriptor. |
|
191 |
Negative, if this descriptor is less than the specified descriptor. |
|
192 |
Zero, if both descriptors have the same length and the their contents |
|
193 |
are the same. |
|
194 |
||
195 |
@see TDesC16::Compare() |
|
196 |
*/ |
|
197 |
EXPORT_C TInt TDesC16::CompareF(const TDesC16 &aDes) const |
|
198 |
{ |
|
199 |
||
200 |
return(Mem::CompareF(Ptr(),Length(),aDes.Ptr(),aDes.Length())); |
|
201 |
} |
|
202 |
||
203 |
||
204 |
||
205 |
||
206 |
/** |
|
207 |
Compares this descriptor's data with the specified descriptor's data using |
|
208 |
the standard collation method appropriate to the current locale. |
|
209 |
||
210 |
@param aDes The 16-bit non-modifable descriptor whose data is to be compared |
|
211 |
with this descriptor's data. |
|
212 |
||
213 |
@return Positive, if this descriptor is greater than the specified descriptor. |
|
214 |
Negative, if this descriptor is less than the specified descriptor. |
|
215 |
Zero, if the content of both descriptors match. |
|
216 |
||
217 |
@see TDesC16::Compare() |
|
218 |
*/ |
|
219 |
EXPORT_C TInt TDesC16::CompareC(const TDesC16 &aDes) const |
|
220 |
{ |
|
221 |
||
222 |
return(Mem::CompareC(Ptr(),Length(),aDes.Ptr(),aDes.Length())); |
|
223 |
} |
|
224 |
#endif |
|
225 |
||
226 |
||
227 |
||
228 |
||
229 |
#ifdef _UNICODE |
|
230 |
/** |
|
231 |
Compares this descriptor's data with the specified descriptor's data to the |
|
232 |
specified maximum collation level and using the specified collation method. |
|
233 |
||
234 |
If no collation method is supplied, a default method is used that uses a |
|
235 |
locale-independent collation table. This means that sorting and matching will |
|
236 |
not be based on the current locale. |
|
237 |
||
238 |
This function is only defined for 16-bit (Unicode) build variants. This means |
|
239 |
that the function is not defined for 8-bit build variants, even when an |
|
240 |
explicit 16-bit descriptor is used. |
|
241 |
||
242 |
Strings may match even if the lengths of their respective descriptors are |
|
243 |
different. |
|
244 |
||
245 |
@param aDes The 16-bit non-modifable descriptor whose data is to |
|
246 |
be compared with this descriptor's data. |
|
247 |
||
248 |
@param aMaxLevel The maximum collation level. This is an integer with |
|
249 |
values: 0, 1, 2 or 3, which, effectively, determines |
|
250 |
how 'tight' the matching should be. Level 3 is always |
|
251 |
used if the aim is to sort strings. |
|
252 |
||
253 |
@param aCollationMethod A pointer to the collation method or NULL. Collation |
|
254 |
methods can be retrieved by calls to |
|
255 |
Mem::CollationMethodByIndex() |
|
256 |
and Mem::CollationMethodById(). |
|
257 |
Specifying NULL means that the default method is used. |
|
258 |
||
259 |
@return Positive, if this descriptor is greater than the specified descriptor. |
|
260 |
Negative, if this descriptor is less than the specified descriptor. |
|
261 |
Zero, if the content of both descriptors match. |
|
262 |
||
263 |
@see Mem::CollationMethodByIndex() |
|
264 |
@see Mem::CollationMethodById() |
|
265 |
@see TDesC16::Compare() |
|
266 |
*/ |
|
267 |
EXPORT_C TInt TDesC16::CompareC(const TDesC16& aDes, TInt aMaxLevel, const TCollationMethod* aCollationMethod) const |
|
268 |
{ |
|
269 |
return Mem::CompareC(Ptr(),Length(),aDes.Ptr(),aDes.Length(),aMaxLevel,aCollationMethod); |
|
270 |
} |
|
271 |
||
272 |
/** |
|
273 |
Get the normalized decomposed form of this 16 bit descriptor |
|
274 |
@return A pointer to the 16-bit heap buffer containing normalized decomposed form |
|
275 |
if creation is successful |
|
276 |
@leave KErrNoMemory if not enough memory to construct the output buffer |
|
277 |
*/ |
|
278 |
EXPORT_C HBufC16* TDesC16::GetNormalizedDecomposedFormL() const |
|
279 |
{ |
|
280 |
//pre create a buffer with of size Length |
|
281 |
TInt strLength=Length(); |
|
282 |
HBufC16* outBuf=HBufC16::NewL(strLength); |
|
283 |
||
284 |
TUTF32Iterator input(Ptr(),Ptr()+strLength); |
|
285 |
TCanonicalDecompositionIterator output; |
|
286 |
output.Set(input); |
|
287 |
||
288 |
TInt currentAllocateCount=0; |
|
289 |
TUint16* outPtr = (TUint16* )outBuf->Des().Ptr(); |
|
290 |
TInt preAllocateCount= outBuf->Des().MaxLength(); |
|
291 |
||
292 |
for (;!output.AtEnd();output.Next(),currentAllocateCount++) |
|
293 |
{ |
|
294 |
if (currentAllocateCount>=preAllocateCount) |
|
295 |
{ |
|
296 |
const TInt KMaxGrowSize=16; |
|
297 |
HBufC16* newOutBuf = outBuf->ReAlloc(preAllocateCount+KMaxGrowSize); |
|
298 |
if(!newOutBuf) |
|
299 |
{ |
|
300 |
delete outBuf; |
|
301 |
User::Leave(KErrNoMemory); |
|
302 |
} |
|
303 |
outBuf = newOutBuf; |
|
304 |
outPtr = (TUint16* )outBuf->Des().Ptr(); |
|
305 |
preAllocateCount = outBuf->Des().MaxLength(); |
|
306 |
} |
|
307 |
outPtr[currentAllocateCount] = (TUint16)(TUint)(output.Current()); |
|
308 |
} |
|
309 |
// update the length of the buffer... |
|
310 |
outBuf->Des().SetLength(currentAllocateCount); |
|
311 |
||
312 |
//compress the unused slot |
|
313 |
if (currentAllocateCount<preAllocateCount) |
|
314 |
outBuf = outBuf->ReAlloc(currentAllocateCount); // can't fail to shrink memory |
|
315 |
return outBuf; |
|
316 |
} |
|
317 |
||
318 |
/** |
|
319 |
Get the folded decomposed form of this 16 bit descriptor |
|
320 |
@return A pointer to the 16-bit heap buffer containing folded decomposed form |
|
321 |
if creation is succesful |
|
322 |
@leave KErrNoMemory if not enough memory to construct the output buffer |
|
323 |
*/ |
|
324 |
EXPORT_C HBufC16* TDesC16::GetFoldedDecomposedFormL() const |
|
325 |
{ |
|
326 |
//pre create a buffer with of size Length |
|
327 |
TInt strLength=Length(); |
|
328 |
HBufC16* outBuf=HBufC16::NewL(strLength); |
|
329 |
||
330 |
TUTF32Iterator input(Ptr(),Ptr()+strLength); |
|
331 |
TFoldedCanonicalIterator output (input); |
|
332 |
||
333 |
TInt currentAllocateCount=0; |
|
334 |
TUint16* outPtr = (TUint16* )outBuf->Des().Ptr(); |
|
335 |
TInt preAllocateCount= outBuf->Des().MaxLength(); |
|
336 |
const TUnicodeDataSet* charDataSet = GetLocaleCharSet()->iCharDataSet; |
|
337 |
for (;!output.AtEnd();output.Next(charDataSet),currentAllocateCount++) |
|
338 |
{ |
|
339 |
if (currentAllocateCount>=preAllocateCount) |
|
340 |
{ |
|
341 |
const TInt KMaxGrowSize=16; |
|
342 |
HBufC16* newOutBuf = outBuf->ReAlloc(preAllocateCount+KMaxGrowSize); |
|
343 |
if(!newOutBuf) |
|
344 |
{ |
|
345 |
delete outBuf; |
|
346 |
User::Leave(KErrNoMemory); |
|
347 |
} |
|
348 |
outBuf = newOutBuf; |
|
349 |
outPtr = (TUint16* )outBuf->Des().Ptr(); |
|
350 |
preAllocateCount = outBuf->Des().MaxLength(); |
|
351 |
} |
|
352 |
outPtr[currentAllocateCount] = (TUint16)(TUint)(output.Current()); |
|
353 |
} |
|
354 |
// update the length of the buffer... |
|
355 |
outBuf->Des().SetLength(currentAllocateCount); |
|
356 |
||
357 |
//compress the unused slot |
|
358 |
if (currentAllocateCount<preAllocateCount) |
|
359 |
outBuf = outBuf->ReAlloc(currentAllocateCount); // can't fail to shrink memory |
|
360 |
return outBuf; |
|
361 |
} |
|
362 |
||
363 |
//some utils function |
|
364 |
static void ResetAndDestroyArray(TAny* aPtr) |
|
365 |
{ |
|
366 |
(STATIC_CAST(RPointerArray<HBufC8>*,aPtr))->ResetAndDestroy(); |
|
367 |
} |
|
368 |
||
369 |
/** |
|
370 |
Get the collation keys of this 16 bit descriptor for a given collation level |
|
371 |
If no collation method is supplied, a default method is used that uses a |
|
372 |
locale-independent collation table. |
|
373 |
@param aMaxLevel The maximum collation level. This is an integer with |
|
374 |
values: 0, 1, 2 or 3. Level 3 is always |
|
375 |
used if the aim is to sort strings. |
|
376 |
@param aCollationMethod A pointer to the collation method or NULL. Collation |
|
377 |
methods can be retrieved by calls to |
|
378 |
Mem::CollationMethodByIndex() |
|
379 |
and Mem::CollationMethodById(). |
|
380 |
Specifying NULL means that the default method is used. |
|
381 |
@return A pointer to the 8-bit heap buffer containing the collation keys if |
|
382 |
creation is succesful |
|
383 |
@leave KErrNoMemory if not enough memory to construct the output buffer |
|
384 |
*/ |
|
385 |
EXPORT_C HBufC8* TDesC16::GetCollationKeysL(TInt aMaxLevel,const TCollationMethod* aCollationMethod) const |
|
386 |
{ |
|
387 |
// Clamp the maximum level of the comparison. |
|
388 |
if(aMaxLevel < 0) |
|
389 |
aMaxLevel = 0; |
|
390 |
if(aMaxLevel > 3) |
|
391 |
aMaxLevel = 3; |
|
392 |
||
393 |
RPointerArray<HBufC8> levelBuffer; |
|
394 |
CleanupStack::PushL(TCleanupItem(ResetAndDestroyArray, &levelBuffer)); |
|
395 |
TInt strLength=Length(); |
|
396 |
TInt outputBufferSize=0; |
|
397 |
||
398 |
//preallocate some initial buffer size as it is not possible to determine the max buffer |
|
399 |
//required as a character can be further decomposed and each character can possibly |
|
400 |
//have up to 8 collation keys and this limit might still change. |
|
401 |
for (TInt i=0;i<=aMaxLevel;i++) |
|
402 |
{ |
|
403 |
TInt levelKeySize=TCollationKey::MaxSizePerKey(i); |
|
404 |
HBufC8* buffer=HBufC8::NewLC(strLength*levelKeySize); |
|
405 |
levelBuffer.AppendL(buffer); |
|
406 |
CleanupStack::Pop(); |
|
407 |
outputBufferSize+=levelKeySize; |
|
408 |
} |
|
409 |
TCollationMethod clm; |
|
410 |
||
411 |
//if collationMethod is NULL, use the default one |
|
412 |
if (aCollationMethod==NULL) |
|
413 |
{ |
|
414 |
clm=*(GetLocaleCharSet()->iCollationDataSet->iMethod); |
|
415 |
} |
|
416 |
else |
|
417 |
{ |
|
418 |
clm = *aCollationMethod; |
|
419 |
} |
|
420 |
//if the main table is empty use the standard table |
|
421 |
if (clm.iMainTable==NULL) |
|
422 |
clm.iMainTable=StandardCollationMethod(); |
|
423 |
||
424 |
TCollationValueIterator tvi(clm); |
|
425 |
TUTF32Iterator input(Ptr(),Ptr()+strLength); |
|
426 |
tvi.SetSourceIt(input); |
|
427 |
||
428 |
//Expand the buffer by 16 bytes if buffer is exhausted |
|
429 |
const TInt KMaxBufferGrowSize=16; |
|
430 |
TInt currentKeyCount=0; |
|
431 |
TInt preAllocateCount=strLength; |
|
432 |
TCollationKey collateKey; |
|
433 |
for (;tvi.GetCurrentKey(collateKey);tvi.Increment(),currentKeyCount++) |
|
434 |
{ |
|
435 |
for (TInt i=0;i<=aMaxLevel;i++) |
|
436 |
{ |
|
437 |
if (currentKeyCount==preAllocateCount) |
|
438 |
levelBuffer[i]=levelBuffer[i]->ReAllocL((currentKeyCount+KMaxBufferGrowSize)*TCollationKey::MaxSizePerKey(i)); |
|
439 |
||
440 |
collateKey.AppendToDescriptor(levelBuffer[i]->Des(),i); |
|
441 |
} |
|
442 |
if (currentKeyCount==preAllocateCount) |
|
443 |
preAllocateCount+=KMaxBufferGrowSize; |
|
444 |
} |
|
445 |
//append the level separator which is a "\x00\x00" for level 0 and \x00 for other level |
|
446 |
outputBufferSize=(outputBufferSize*currentKeyCount)+(aMaxLevel==0?0:4+(aMaxLevel-1)*2); |
|
447 |
HBufC8* outputResult=HBufC8::NewL(outputBufferSize); |
|
448 |
TPtr8 outputResultPtr(outputResult->Des()); |
|
449 |
for (TInt count=0;count<=aMaxLevel;count++) |
|
450 |
{ |
|
451 |
outputResultPtr.Append(*levelBuffer[count]); |
|
452 |
if (count!=aMaxLevel) |
|
453 |
{ |
|
454 |
if (count==0) |
|
455 |
outputResultPtr.Append(0); |
|
456 |
outputResultPtr.Append(0); |
|
457 |
} |
|
458 |
} |
|
459 |
CleanupStack::PopAndDestroy(); |
|
460 |
return outputResult; |
|
461 |
} |
|
462 |
||
463 |
#endif |
|
464 |
||
465 |
/** |
|
466 |
Searches for the first occurrence of the specified data sequence within this |
|
467 |
descriptor. |
|
468 |
||
469 |
Searching always starts at the beginning of this descriptor's data. |
|
470 |
||
471 |
@param pS A pointer to a location containing the data sequence to be searched |
|
472 |
for. |
|
473 |
||
474 |
@param aLenS The length of the data sequence to be searched for. This value |
|
475 |
must not be negative, otherwise the function raises a panic. |
|
476 |
||
477 |
@return The offset of the data sequence from the beginning of this descriptor's |
|
478 |
data. KErrNotFound, if the data sequence cannot be found. |
|
479 |
||
480 |
@panic USER 17 if aLenS is negative. |
|
481 |
*/ |
|
482 |
EXPORT_C TInt TDesC16::Find(const TUint16 *pS,TInt aLenS) const |
|
483 |
{ |
|
484 |
||
485 |
if (!aLenS) |
|
486 |
return(0); |
|
487 |
__ASSERT_ALWAYS(aLenS>0,Panic(ETDes16LengthNegative)); |
|
488 |
__CHECK_ALIGNMENT(pS,ETDesC16FindPtrLen); |
|
489 |
const TUint16 *pB=Ptr(); |
|
490 |
TInt aLenB=Length(); |
|
491 |
const TUint16 *pC=pB-1; // using pre-increment addressing |
|
492 |
TInt i=aLenB-aLenS; |
|
493 |
if (i>=0) |
|
494 |
{ |
|
495 |
const TUint16* pEndS=pS+aLenS-1; // using pre-increment addressing |
|
496 |
const TUint16 *pEndB=pB+i; // using pre-increment addressing |
|
497 |
TUint s=*pS; |
|
498 |
for (;;) |
|
499 |
{ |
|
500 |
do |
|
501 |
{ |
|
502 |
if (pC==pEndB) |
|
503 |
return KErrNotFound; |
|
504 |
} while (*++pC!=s); |
|
505 |
const TUint16 *p1=pC; |
|
506 |
const TUint16 *p2=pS; |
|
507 |
do |
|
508 |
{ |
|
509 |
if (p2==pEndS) |
|
510 |
return (pC-pB); |
|
511 |
} while (*++p1==*++p2); |
|
512 |
} |
|
513 |
} |
|
514 |
return(KErrNotFound); |
|
515 |
} |
|
516 |
||
517 |
||
518 |
||
519 |
||
520 |
/** |
|
521 |
Searches for the first occurrence of the specified data sequence within this |
|
522 |
descriptor. |
|
523 |
||
524 |
Searching always starts at the beginning of this descriptor's |
|
525 |
data. |
|
526 |
||
527 |
@param aDes The 16-bit non-modifiable descriptor containing the data sequence |
|
528 |
to be searched for. |
|
529 |
||
530 |
@return The offset of the data sequence from the beginning of this descriptor's |
|
531 |
data. KErrNotFound, if the data sequence cannot be found. |
|
532 |
*/ |
|
533 |
EXPORT_C TInt TDesC16::Find(const TDesC16 &aDes) const |
|
534 |
{ |
|
535 |
||
536 |
return(Find(aDes.Ptr(),aDes.Length())); |
|
537 |
} |
|
538 |
||
539 |
||
540 |
||
541 |
||
542 |
/** |
|
543 |
Searches for the first occurrence of the specified folded data sequence within |
|
544 |
this descriptor's folded data. |
|
545 |
||
546 |
Searching always starts at the beginning of this descriptor's data. |
|
547 |
||
548 |
Note that folding is locale-independent behaviour. It is also important to |
|
549 |
note that there can be no guarantee that folding is in any way culturally |
|
550 |
appropriate, and should not be used for finding strings in natural language; |
|
551 |
use FindC() for this. |
|
552 |
||
553 |
@param pS A pointer to a location containing the data sequence to be |
|
554 |
searched for. |
|
555 |
@param aLenS The length of the data sequence to be searched for. This value |
|
556 |
must not be negative, otherwise the function raises a panic. |
|
557 |
||
558 |
@return The offset of the data sequence from the beginning of this descriptor's |
|
559 |
data. KErrNotFound, if the data sequence cannot be found. Zero, if the |
|
560 |
length of the search data sequence is zero. |
|
561 |
||
562 |
@panic USER 17 if aLenS is negative |
|
563 |
||
564 |
@see TDesC16::FindC() |
|
565 |
*/ |
|
566 |
EXPORT_C TInt TDesC16::FindF(const TUint16 *pS,TInt aLenS) const |
|
567 |
{ |
|
568 |
__CHECK_ALIGNMENT(pS,ETDesC16FindFPtrLen); |
|
569 |
TUTF32Iterator candidateStrIt(Ptr(), Ptr() + Length()); |
|
570 |
TUTF32Iterator searchTermIt(pS, pS + aLenS); |
|
571 |
return ::FindFolded(candidateStrIt, searchTermIt); |
|
572 |
} |
|
573 |
||
574 |
||
575 |
||
576 |
||
577 |
/** |
|
578 |
Searches for the first occurrence of the specified folded data sequence within |
|
579 |
this descriptor's folded data. |
|
580 |
||
581 |
Searching always starts at the beginning of this descriptor's data. |
|
582 |
||
583 |
Note that folding is locale-independent behaviour. It is also important to |
|
584 |
note that there can be no guarantee that folding is in any way culturally |
|
585 |
appropriate, and should not be used for finding strings in natural language; |
|
586 |
use FindC() for this. |
|
587 |
||
588 |
@param aDes The 16-bit non-modifable descriptor containing the data sequence |
|
589 |
to be searched for. |
|
590 |
||
591 |
@return The offset of the data sequence from the beginning of this descriptor's |
|
592 |
data. KErrNotFound, if the data sequence cannot be found. |
|
593 |
Zero, if the length of the search data sequence is zero. |
|
594 |
||
595 |
@see TDesC16::FindC() |
|
596 |
*/ |
|
597 |
EXPORT_C TInt TDesC16::FindF(const TDesC16 &aDes) const |
|
598 |
{ |
|
599 |
TUTF32Iterator candidateStrIt(Ptr(), Ptr() + Length()); |
|
600 |
TUTF32Iterator searchTermIt(aDes.Ptr(), aDes.Ptr() + aDes.Length()); |
|
601 |
return ::FindFolded(candidateStrIt, searchTermIt); |
|
602 |
} |
|
603 |
||
604 |
||
605 |
||
606 |
||
607 |
/** |
|
608 |
Searches for the first occurrence of the specified collated data sequence within |
|
609 |
this descriptor's collated data. |
|
610 |
||
611 |
Searching always starts at the beginning of this descriptor's data. The function |
|
612 |
uses the standard collation method appropriate to the current locale. |
|
613 |
||
614 |
@param aText A pointer to a location containing the data sequence to be |
|
615 |
searched for. |
|
616 |
@param aLength The length of the data sequence to be searched for. |
|
617 |
||
618 |
@return The offset of the data sequence from the beginning of this descriptor's data. |
|
619 |
KErrNotFound, if the data sequence cannot be found. |
|
620 |
||
621 |
@panic USER 17 if aLength is negative. |
|
622 |
*/ |
|
623 |
EXPORT_C TInt TDesC16::FindC(const TUint16 *aText,TInt aLength) const |
|
624 |
{ |
|
625 |
__CHECK_ALIGNMENT(aText,ETDesC16FindCPtrLen); |
|
626 |
||
627 |
TCollate c(GetLocaleCharSet(),TCollationMethod::EIgnoreNone | TCollationMethod::EFoldCase); |
|
628 |
return c.Find(Ptr(),Length(),aText,aLength,1); |
|
629 |
} |
|
630 |
||
631 |
||
632 |
||
633 |
||
634 |
/** |
|
635 |
Searches for the first occurrence of the specified collated data sequence |
|
636 |
within this descriptor's collated data to the specified maximum collation |
|
637 |
level. |
|
638 |
||
639 |
@param aText A pointer to a location containing the data sequence to |
|
640 |
be searched for. |
|
641 |
||
642 |
@param aLength The length of the data sequence to be searched for. |
|
643 |
||
644 |
@param aMaxLevel The maximum collation level. This is an integer with |
|
645 |
values: 0, 1, 2 or 3, which, effectively, determines |
|
646 |
how 'tight' the matching should be. Level 3 is always |
|
647 |
used if the aim is to sort strings. |
|
648 |
||
649 |
@return The offset of the data sequence from the beginning of this descriptor's data. |
|
650 |
KErrNotFound, if the data sequence cannot be found. |
|
651 |
*/ |
|
652 |
EXPORT_C TInt TDesC16::FindC(const TUint16 *aText,TInt aLength, TInt aMaxLevel) const |
|
653 |
||
654 |
{ |
|
655 |
__CHECK_ALIGNMENT(aText,ETDesC16FindCPtrLen); |
|
656 |
||
657 |
TCollate c(GetLocaleCharSet(),TCollationMethod::EIgnoreNone | TCollationMethod::EFoldCase); |
|
658 |
return c.Find(Ptr(),Length(),aText,aLength,aMaxLevel); |
|
659 |
} |
|
660 |
||
661 |
||
662 |
||
663 |
||
664 |
/** |
|
665 |
Searches for the first occurrence of the specified collated data sequence |
|
666 |
within this descriptor's collated data. |
|
667 |
||
668 |
Searching always starts at the beginning of this descriptor's data. The |
|
669 |
function uses the standard collation method appropriate to the current |
|
670 |
locale. |
|
671 |
||
672 |
@param aDes The 16-bit non-modifable descriptor containing the data sequence |
|
673 |
to be searched for. |
|
674 |
||
675 |
@return The offset of the data sequence from the beginning of this descriptor's |
|
676 |
data. KErrNotFound, if the data sequence cannot be found. |
|
677 |
*/ |
|
678 |
EXPORT_C TInt TDesC16::FindC(const TDesC16 &aDes) const |
|
679 |
{ |
|
680 |
||
681 |
return(FindC(aDes.Ptr(),aDes.Length())); |
|
682 |
} |
|
683 |
||
684 |
/** |
|
685 |
Searches for the first occurrence of the specified collated data sequence |
|
686 |
within this descriptor's collated data. |
|
687 |
||
688 |
Searching always starts at the beginning of this descriptor's data. The |
|
689 |
function uses the standard collation method appropriate to the current |
|
690 |
locale. |
|
691 |
||
692 |
@param aDes The 16-bit non-modifable descriptor containing the data sequence |
|
693 |
to be searched for. |
|
694 |
||
695 |
@param aLengthFound A refernce to the maximal length of the match found in the candidate |
|
696 |
string. KErrNotFound, if the data sequence cannot be found. |
|
697 |
||
698 |
@param aCollationMethod A pointer to the collation method or NULL. Collation |
|
699 |
methods can be retrieved by calls to |
|
700 |
Mem::CollationMethodByIndex() |
|
701 |
and Mem::CollationMethodById(). |
|
702 |
Specifying NULL means that the default method is used. |
|
703 |
||
704 |
@param aMaxLevel The maximum collation level. This is an integer with |
|
705 |
values: 0, 1, 2 or 3, which, effectively, determines |
|
706 |
how 'tight' the matching should be. Level 3 is always |
|
707 |
used if the aim is to sort strings. |
|
708 |
||
709 |
@return The offset of the data sequence from the beginning of this descriptor's |
|
710 |
data. KErrNotFound, if the data sequence cannot be found. |
|
711 |
*/ |
|
712 |
EXPORT_C TInt TDesC16::FindC(const TDesC16 &aDes, TInt &aLengthFound, const TCollationMethod &aMethod, TInt aMaxLevel) const |
|
713 |
{ |
|
714 |
TCollate c(aMethod); |
|
715 |
return c.Find(Ptr(),Length(),aDes.Ptr(),aDes.Length(),aLengthFound,aMaxLevel); |
|
716 |
} |
|
717 |
||
718 |
||
719 |
#ifdef _UNICODE |
|
720 |
LOCAL_C const TText* convTable(TMatchType aType) |
|
721 |
{ |
|
722 |
switch (aType) |
|
723 |
{ |
|
724 |
case EMatchFolded: // at present, folding is... |
|
725 |
case EMatchCollated: return (const TText *)(TChar::EFoldStandard); // ...the same as collation: use all folding methods |
|
726 |
default: return 0; |
|
727 |
} |
|
728 |
} |
|
729 |
#else |
|
730 |
LOCAL_C const TText* convTable(TMatchType aType) |
|
731 |
{ |
|
732 |
switch (aType) |
|
733 |
{ |
|
734 |
case EMatchFolded: return Locl::FoldTable(); |
|
735 |
case EMatchCollated: return Locl::CollTable(); |
|
736 |
default: return NULL; |
|
737 |
} |
|
738 |
} |
|
739 |
#endif |
|
740 |
||
741 |
inline TUint conv(const TUint16* aStr,const TText *aConv, const TUnicodeDataSet* aCharDataSet) |
|
742 |
// |
|
743 |
// If aConv is not NULL then convert the character. |
|
744 |
// |
|
745 |
{ |
|
746 |
||
747 |
#ifdef _UNICODE |
|
748 |
if (aConv) |
|
749 |
return TUnicode(*aStr).Fold((TInt)aConv, aCharDataSet); |
|
750 |
else |
|
751 |
return *aStr; |
|
752 |
#else |
|
753 |
TUint c=*aStr; |
|
754 |
return aConv && c<0x100 ? aConv[c] : c; |
|
755 |
#endif |
|
756 |
} |
|
757 |
||
758 |
inline TUint lookup(const TUint16* aStr,const TText *aConv) |
|
759 |
{ |
|
760 |
#ifdef _UNICODE |
|
761 |
return TUnicode(*aStr).Fold((TInt)aConv,GetLocaleCharSet()->iCharDataSet); |
|
762 |
#else |
|
763 |
TUint c=*aStr; |
|
764 |
return c<0x100 ? aConv[c] : c; |
|
765 |
#endif |
|
766 |
} |
|
767 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
768 |
// Surrogate-aware version of lookup() above. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
769 |
// aChar can be over 0xFFFF. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
770 |
inline TUint lookup2(const TUint aChar, const TText *aConv) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
771 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
772 |
return TUnicode(aChar).Fold((TInt)aConv, GetLocaleCharSet()->iCharDataSet); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
773 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
774 |
|
0 | 775 |
TInt DoMatch16(const TDesC16 &aLeftD,const TDesC16 &aRightD,TMatchType aType) |
776 |
{ |
|
777 |
const TText* table=convTable(aType); |
|
778 |
const TUint16* pRight=aRightD.Ptr(); |
|
779 |
const TUint16* pM=pRight-1; // pre-increment addressing |
|
780 |
const TUint16* pP=pM+aRightD.Length(); |
|
781 |
const TUint16* pLeft=aLeftD.Ptr()-1; // pre-increment addressing |
|
782 |
const TUint16* pB=pLeft; |
|
783 |
const TUint16* pE=pB+aLeftD.Length(); |
|
784 |
||
785 |
||
786 |
const TUnicodeDataSet* charDataSet = GetLocaleCharSet()->iCharDataSet; |
|
787 |
||
788 |
// Match any pattern up to the first star |
|
789 |
TUint c; |
|
790 |
for (;;) |
|
791 |
{ |
|
792 |
if (pM==pP) // exhausted the pattern |
|
793 |
return pB==pE ? 0 : KErrNotFound; |
|
794 |
TUint c=conv(++pM,table, charDataSet); |
|
795 |
if (c==KMatchAny) |
|
796 |
break; |
|
797 |
if (pB==pE) // no more input |
|
798 |
return KErrNotFound; |
|
799 |
if (c!=conv(++pB,table, charDataSet) && c!=KMatchOne) // match failed |
|
800 |
return KErrNotFound; |
|
801 |
} |
|
802 |
// reached a star |
|
803 |
if (pM==pP) |
|
804 |
return 0; |
|
805 |
TInt r=pM==pRight ? -1 : 0; |
|
806 |
for (;;) |
|
807 |
{ |
|
808 |
c=conv(++pM,table, charDataSet); |
|
809 |
if (c==KMatchAny) |
|
810 |
{ |
|
811 |
star: if (pM==pP) // star at end of pattern, always matches |
|
812 |
return Max(r,0); |
|
813 |
if (r<-1) // skipped some '?', matches at beginning |
|
814 |
r=0; |
|
815 |
continue; |
|
816 |
} |
|
817 |
if (pB==pE) // no more input |
|
818 |
return KErrNotFound; |
|
819 |
if (c==KMatchOne) |
|
820 |
{ // skip a character in the input |
|
821 |
if (pM==pP) |
|
822 |
return r+((r>=0) ? 0 : (pE-pLeft)); |
|
823 |
++pB; |
|
824 |
if (r<0) |
|
825 |
--r; |
|
826 |
continue; |
|
827 |
} |
|
828 |
// Matching a non-wild character |
|
829 |
for (;;) |
|
830 |
{ |
|
831 |
if (table) |
|
832 |
{ |
|
833 |
while (lookup(++pB,table)!=c) |
|
834 |
{ |
|
835 |
if (pB==pE) // no more input |
|
836 |
return KErrNotFound; |
|
837 |
} |
|
838 |
} |
|
839 |
else |
|
840 |
{ |
|
841 |
while (*++pB!=c) |
|
842 |
{ |
|
843 |
if (pB==pE) // no more input |
|
844 |
return KErrNotFound; |
|
845 |
} |
|
846 |
} |
|
847 |
// Try to match up to the next star |
|
848 |
const TUint16* pb=pB; |
|
849 |
const TUint16* pm=pM; |
|
850 |
for (;;) |
|
851 |
{ |
|
852 |
if (pm<pP) |
|
853 |
{ |
|
854 |
TUint cc=conv(++pm,table, charDataSet); |
|
855 |
if (cc==KMatchAny) |
|
856 |
{ // sub-match successful, back to main loop |
|
857 |
r+=(r>=0 ? 0 : pB-pLeft); |
|
858 |
pB=pb; |
|
859 |
pM=pm; |
|
860 |
goto star; |
|
861 |
} |
|
862 |
if (pb==pE) |
|
863 |
return KErrNotFound; // no more input |
|
864 |
if (cc!=conv(++pb,table, charDataSet) && cc!=KMatchOne) |
|
865 |
break; // sub-match failed, try next input character |
|
866 |
} |
|
867 |
else if (pb==pE) // end of matching pattern |
|
868 |
return r+(r>=0 ? 0 : pB-pLeft); // end of input, so have a match |
|
869 |
else |
|
870 |
break; // try next input character |
|
871 |
} |
|
872 |
} |
|
873 |
} |
|
874 |
} |
|
875 |
||
876 |
||
877 |
||
878 |
EXPORT_C TDesC16::TPrefix TDesC16::HasPrefixC(const TDesC16& aPossiblePrefix, |
|
879 |
TInt aLevel, const TCollationMethod* aCollationMethod) const |
|
880 |
/** |
|
881 |
Compares aPossiblePrefix against the start of the descriptor, using a |
|
882 |
collated comparison. |
|
883 |
||
884 |
@param aLevel The maximum level at which to perform the collation. |
|
885 |
||
886 |
0: Only check character identities. |
|
887 |
||
888 |
1: Check accents as well. |
|
889 |
||
890 |
2: Check case as well. |
|
891 |
||
892 |
3: Check Unicode values. |
|
893 |
||
894 |
Currently only level 0 is supported. |
|
895 |
||
896 |
@param aCollationMethod The collation method to be used for the matching. |
|
897 |
||
898 |
@return EIsPrefix, if aPossiblePrefix can be extended to |
|
899 |
be equivalent to the text at the start of this descriptor. |
|
900 |
EIsNotPrefix if aPossiblePrefix cannot |
|
901 |
be extended to be equivalent to the text at the start of this descriptor. |
|
902 |
EMightBePrefix if it currently does not seem to be a prefix, but it |
|
903 |
is possible that it could be extended to become equivalent to text at |
|
904 |
the start of this descriptor. |
|
905 |
EMightBePrefix is returned in cases where it would be expensive |
|
906 |
to determine for sure. |
|
907 |
*/ |
|
908 |
{ |
|
909 |
const TText16* lp = aPossiblePrefix.Ptr(); |
|
910 |
const TText16* rp = Ptr(); |
|
911 |
TInt ll = aPossiblePrefix.Length(); |
|
912 |
TInt rl = Length(); |
|
913 |
TInt r; |
|
914 |
if (!aCollationMethod) |
|
915 |
{ |
|
916 |
TCollate c(GetLocaleCharSet()); |
|
917 |
r = c.Compare(rp, rl, lp, ll, aLevel); |
|
918 |
} |
|
919 |
else |
|
920 |
{ |
|
921 |
TCollate c(*aCollationMethod); |
|
922 |
r = c.Compare(rp, rl, lp, ll, aLevel); |
|
923 |
} |
|
924 |
return r == 1 || r == 0? EIsPrefix : EIsNotPrefix; |
|
925 |
} |
|
926 |
||
927 |
EXPORT_C TInt TDesC16::Match(const TDesC16 &aDes) const |
|
928 |
/** |
|
929 |
Searches this descriptor's data for a match with the match pattern supplied |
|
930 |
in the specified descriptor. |
|
931 |
||
932 |
The match pattern can contain the wildcard characters "*" and "?", where "*" |
|
933 |
matches zero or more consecutive occurrences of any character and "?" matches |
|
934 |
a single occurrence of any character. |
|
935 |
||
936 |
Note that there is no 'escape character', which means that it is not possible |
|
937 |
to match either the "*" character itself or the "?" character itself using |
|
938 |
this function. |
|
939 |
||
940 |
@param aDes A 16-bit non-modifable descriptor containing the match pattern. |
|
941 |
||
942 |
@return If a match is found, the offset within this descriptor's data where |
|
943 |
the match first occurs. KErrNotFound, if there is no match. |
|
944 |
*/ |
|
945 |
{ |
|
946 |
||
947 |
return DoMatch16(*this,aDes,EMatchNormal); |
|
948 |
||
949 |
} |
|
950 |
||
951 |
EXPORT_C TInt TDesC16::MatchF(const TDesC16 &aDes) const |
|
952 |
/** |
|
953 |
Searches this descriptor's folded data for a match with the folded match pattern |
|
954 |
supplied in the specified descriptor. |
|
955 |
||
956 |
The match pattern can contain the wildcard characters "*" and "?", where "*" |
|
957 |
matches zero or more consecutive occurrences of any character and "?" matches |
|
958 |
a single occurrence of any character. |
|
959 |
||
960 |
Note that folding is locale-independent behaviour. It is also important to |
|
961 |
note that there can be no guarantee that folding is in any way culturally |
|
962 |
appropriate, and should not be used for matching strings in natural language; |
|
963 |
use MatchC() for this. |
|
964 |
||
965 |
Note that there is no 'escape character', which means that it is not possible |
|
966 |
to match either the "*" character itself or the "?" character itself using |
|
967 |
this function. |
|
968 |
||
969 |
@param aDes A 16-bit non-modifable descriptor containing the match pattern. |
|
970 |
||
971 |
@return If a match is found, the offset within this descriptor's data where |
|
972 |
the match first occurs. KErrNotFound, if there is no match. |
|
973 |
||
974 |
@see TDesC16::MatchC() |
|
975 |
*/ |
|
976 |
{ |
|
977 |
const TText16* csp = Ptr(); |
|
978 |
const TText16* stp = aDes.Ptr(); |
|
979 |
return LocateMatchStringFolded(csp, csp + Length(), stp, stp + aDes.Length()); |
|
980 |
} |
|
981 |
||
982 |
EXPORT_C TInt TDesC16::MatchC(const TDesC16 &aPattern) const |
|
983 |
/** |
|
984 |
Searches this descriptor's collated data for a match with the collated match |
|
985 |
pattern supplied in the specified descriptor. |
|
986 |
||
987 |
The function uses the standard collation method appropriate to |
|
988 |
the current locale. |
|
989 |
||
990 |
The match pattern can contain the wildcard characters "*" and "?", where "*" |
|
991 |
matches zero or more consecutive occurrences of any character and "?" matches |
|
992 |
a single occurrence of any character. |
|
993 |
||
994 |
Note that there is no 'escape character', which means that it is not possible |
|
995 |
to match either the "*" character itself or the "?" character itself using |
|
996 |
this function. |
|
997 |
||
998 |
@param aPattern A 16-bit non-modifable descriptor containing the match pattern. |
|
999 |
||
1000 |
@return If a match is found, the offset within this descriptor's data where |
|
1001 |
the match first occurs. KErrNotFound, if there is no match. |
|
1002 |
*/ |
|
1003 |
{ |
|
1004 |
TCollationMethod m=*Mem::GetDefaultMatchingTable(); |
|
1005 |
m.iFlags |= (TCollationMethod::EIgnoreNone | TCollationMethod::EFoldCase); |
|
1006 |
TCollate c(m); |
|
1007 |
return c.Match(Ptr(), Length(), aPattern.Ptr(), aPattern.Length(), 0, '?', '*'); |
|
1008 |
} |
|
1009 |
||
1010 |
/** |
|
1011 |
Searches this descriptor's collated data for a match with the collated match |
|
1012 |
pattern supplied in the specified descriptor. |
|
1013 |
||
1014 |
The function uses the standard collation method appropriate to |
|
1015 |
the current locale. |
|
1016 |
||
1017 |
The match pattern can contain the wildcard characters specified by aWildChar and aWildSequenceChar |
|
1018 |
parameters, where aWildSequenceChar matches zero or more consecutive occurrences of any character and |
|
1019 |
aWildChar matches a single occurrence of any character. |
|
1020 |
||
1021 |
@param aPattern A 16-bit non-modifable descriptor containing the match pattern. |
|
1022 |
@param aWildChar Wild card character which may be specified for aSearchTerm. |
|
1023 |
@param aWildSequenceChar Wild card sequence character which may be specified for aSearchTerm. |
|
1024 |
@param aEscapeChar The escape character, or 0 if there is to be none. The escape character removes any |
|
1025 |
special meaning from the subsequent character. For example, if the escape, wild card |
|
1026 |
and wild sequence characters are \, ? And * respectively, the search term "\?\*\\" matches |
|
1027 |
only the candidate string "?*\"; |
|
1028 |
@param aMaxLevel Determines the tightness of the collation. At level 0, only |
|
1029 |
character identities are distinguished. At level 1 accents are |
|
1030 |
distinguished as well. At level 2 case is distinguishes as well. At |
|
1031 |
level 3 all valid different Unicode characters are considered different. |
|
1032 |
@param aCollationMethod A pointer to the collation method or NULL. Collation methods can be retrieved by calls to |
|
1033 |
Mem::CollationMethodByIndex() and Mem::CollationMethodById(). |
|
1034 |
Specifying NULL means that the default method is used. |
|
1035 |
||
1036 |
@return If a match is found, the offset within this descriptor's data where |
|
1037 |
the match first occurs. KErrNotFound, if there is no match. |
|
1038 |
*/ |
|
1039 |
EXPORT_C TInt TDesC16::MatchC(const TDesC16 &aPattern, TInt aWildChar, TInt aWildSequenceChar, |
|
1040 |
TInt aEscapeChar, TInt aMaxLevel, const TCollationMethod* aCollationMethod) const |
|
1041 |
{ |
|
1042 |
TCollationMethod m(aCollationMethod ? *aCollationMethod : *Mem::GetDefaultMatchingTable()); |
|
1043 |
m.iFlags |= (TCollationMethod::EIgnoreNone | TCollationMethod::EFoldCase); |
|
1044 |
TCollate c(m); |
|
1045 |
return c.Match(Ptr(), Length(), aPattern.Ptr(), aPattern.Length(), aMaxLevel, aWildChar, aWildSequenceChar, aEscapeChar); |
|
1046 |
} |
|
1047 |
||
1048 |
||
1049 |
/** |
|
1050 |
Searches this descriptor's collated data for a match with the collated match |
|
1051 |
pattern supplied in the specified descriptor. |
|
1052 |
||
1053 |
The function uses the standard collation method appropriate to |
|
1054 |
the current locale. |
|
1055 |
||
1056 |
The match pattern can contain the wildcard characters specified by aWildChar and aWildSequenceChar |
|
1057 |
parameters, where aWildSequenceChar matches zero or more consecutive occurrences of any character and |
|
1058 |
aWildChar matches a single occurrence of any character. |
|
1059 |
||
1060 |
@param aPattern A 16-bit non-modifable descriptor containing the match pattern. |
|
1061 |
@param aFlags Flags providing advanced control of the collation algorithm @see TCollationFlag |
|
1062 |
@param aWildChar Wild card character which may be specified for aSearchTerm. Defaulted to '?' if omitted. |
|
1063 |
@param aWildSequenceChar Wild card sequence character which may be specified for aSearchTerm. |
|
1064 |
Defaulted to '*' if omitted. |
|
1065 |
@param aEscapeChar The escape character, or 0 if there is to be none. The escape character removes any |
|
1066 |
special meaning from the subsequent character. For example, if the escape, wild card |
|
1067 |
and wild sequence characters are \, ? And * respectively, the search term "\?\*\\" matches |
|
1068 |
only the candidate string "?*\". Defaulted to 0 if omitted. |
|
1069 |
@param aMaxLevel Determines the tightness of the collation. Defaulted to 3 if omitted. At level 0, only |
|
1070 |
character identities are distinguished. At level 1 accents are |
|
1071 |
distinguished as well. At level 2 case is distinguishes as well. At |
|
1072 |
level 3 all valid different Unicode characters are considered different. |
|
1073 |
@param aCollationMethod A pointer to the collation method. Collation methods can be retrieved by calls to |
|
1074 |
Mem::CollationMethodByIndex(), Mem::CollationMethodById() or by custom defined name. |
|
1075 |
Flags can be set on definition of the custom TCollationMethod, or by const_cast-ing |
|
1076 |
the returned pointer and setting the iFlags field directly. @see TCollationMethod |
|
1077 |
@return If a match is found, the offset within this descriptor's data where |
|
1078 |
the match first occurs. KErrNotFound, if there is no match. |
|
1079 |
*/ |
|
1080 |
EXPORT_C TInt TDesC16::MatchC(const TDesC16 &aPattern, const TCollationMethod* aCollationMethod, |
|
1081 |
TInt aMaxLevel, TInt aWildChar, TInt aWildSequenceChar, TInt aEscapeChar) const |
|
1082 |
{ |
|
1083 |
TCollate c(*aCollationMethod); |
|
1084 |
return c.Match(Ptr(), Length(), aPattern.Ptr(), aPattern.Length(), aMaxLevel, aWildChar, aWildSequenceChar, aEscapeChar); |
|
1085 |
} |
|
1086 |
||
1087 |
||
1088 |
#ifndef __DES16_MACHINE_CODED_HWORD__ |
|
1089 |
EXPORT_C TInt TDesC16::Locate(TChar aChar) const |
|
1090 |
/** |
|
1091 |
Searches for the first occurrence of a character within this descriptor's |
|
1092 |
data. |
|
1093 |
||
1094 |
The search starts at the beginning of the data, i.e. at the leftmost |
|
1095 |
position. |
|
1096 |
||
1097 |
@param aChar The character to be found. |
|
1098 |
||
1099 |
@return The offset of the character position from the beginning of the data. |
|
1100 |
KErrNotFound, if no matching character can be found. |
|
1101 |
*/ |
|
1102 |
{ |
|
1103 |
||
1104 |
const TUint16 *pBuf=Ptr(); |
|
1105 |
const TUint16 *pB=pBuf-1; |
|
1106 |
const TUint16 *pE=pB+Length(); |
|
1107 |
do |
|
1108 |
{ |
|
1109 |
if (pB==pE) |
|
1110 |
return KErrNotFound; |
|
1111 |
} while (TUint(*++pB)!=aChar); |
|
1112 |
return pB-pBuf; |
|
1113 |
} |
|
1114 |
#endif |
|
1115 |
||
1116 |
LOCAL_C TInt DoLocateF16(const TDesC16& aDes,TUint aChar) |
|
1117 |
// |
|
1118 |
// Locate character aChar in the descriptor folded. |
|
1119 |
// |
|
1120 |
{ |
|
1121 |
#ifdef _UNICODE |
|
1122 |
const TText* table = convTable(EMatchFolded); |
|
1123 |
TUint16 aChar16 = (TUint16)aChar; |
|
1124 |
aChar = lookup(&aChar16,table); |
|
1125 |
#else |
|
1126 |
const TText* table=Locl::FoldTable; |
|
1127 |
if (aChar<0x100) |
|
1128 |
aChar=table[aChar]; |
|
1129 |
#endif |
|
1130 |
const TUint16 *pBuf=aDes.Ptr(); |
|
1131 |
const TUint16 *pB=pBuf-1; |
|
1132 |
const TUint16 *pE=pB+aDes.Length(); |
|
1133 |
do |
|
1134 |
{ |
|
1135 |
if (pB==pE) |
|
1136 |
return KErrNotFound; |
|
1137 |
} while (lookup(++pB,table)!=aChar); |
|
1138 |
return pB-pBuf; |
|
1139 |
} |
|
1140 |
||
1141 |
EXPORT_C TInt TDesC16::LocateF(TChar aChar) const |
|
1142 |
/** |
|
1143 |
Searches for the first occurrence of a folded character within this |
|
1144 |
descriptor's folded data. |
|
1145 |
||
1146 |
The search starts at the beginning of the data, i.e. at the leftmost |
|
1147 |
position. |
|
1148 |
||
1149 |
Note that folding is locale-independent behaviour. It is also important to |
|
1150 |
note that there can be no guarantee that folding is in any way culturally |
|
1151 |
appropriate, and should not be used for searching strings in natural language. |
|
1152 |
||
1153 |
@param aChar The character to be found. |
|
1154 |
||
1155 |
@return The offset of the character position from the beginning of the data. |
|
1156 |
KErrNotFound, if no matching character can be found. |
|
1157 |
*/ |
|
1158 |
{ |
|
1159 |
||
1160 |
return DoLocateF16(*this,aChar); |
|
1161 |
||
1162 |
} |
|
1163 |
||
1164 |
#ifndef __DES16_MACHINE_CODED_HWORD__ |
|
1165 |
EXPORT_C TInt TDesC16::LocateReverse(TChar aChar) const |
|
1166 |
/** |
|
1167 |
Searches for the first occurrence of a character within this descriptor's |
|
1168 |
data, searching from the end of the data. |
|
1169 |
||
1170 |
The search starts at the rightmost position. |
|
1171 |
||
1172 |
@param aChar The character to be found. |
|
1173 |
||
1174 |
@return The offset of the character position from the beginning of the data. |
|
1175 |
KErrNotFound, if no matching character can be found. |
|
1176 |
*/ |
|
1177 |
{ |
|
1178 |
||
1179 |
TInt len=Length(); |
|
1180 |
if (len==0) |
|
1181 |
return(KErrNotFound); |
|
1182 |
const TUint16 *pB=Ptr(); |
|
1183 |
const TUint16 *pE=pB+len-1; |
|
1184 |
while (pE>=pB) |
|
1185 |
{ |
|
1186 |
if (TUint(*pE)==aChar) |
|
1187 |
break; |
|
1188 |
pE--; |
|
1189 |
} |
|
1190 |
return(pE<pB ? KErrNotFound : pE-pB); |
|
1191 |
} |
|
1192 |
#endif |
|
1193 |
||
1194 |
EXPORT_C TInt TDesC16::LocateReverseF(TChar aChar) const |
|
1195 |
/** |
|
1196 |
Searches for the first occurrence of a folded character within this descriptor's |
|
1197 |
folded data, searching from the end of the data. |
|
1198 |
||
1199 |
The search starts at the rightmost position. |
|
1200 |
||
1201 |
Note that folding is locale-independent behaviour. It is also important to |
|
1202 |
note that there can be no guarantee that folding is in any way culturally |
|
1203 |
appropriate, and should not be used for searching strings in natural language. |
|
1204 |
||
1205 |
@param aChar The character to be found |
|
1206 |
@return The offset of the character position from the beginning of the data. |
|
1207 |
KErrNotFound, if no matching character can be found. |
|
1208 |
*/ |
|
1209 |
{ |
|
1210 |
||
1211 |
TInt len=Length(); |
|
1212 |
if (len==0) |
|
1213 |
return(KErrNotFound); |
|
1214 |
const TUint16 *pB=Ptr(); |
|
1215 |
const TUint16 *pE=pB+len-1; |
|
1216 |
aChar.Fold(); |
|
1217 |
while (pE>=pB) |
|
1218 |
{ |
|
1219 |
TCharF c(*pE); |
|
1220 |
if (c==aChar) |
|
1221 |
break; |
|
1222 |
pE--; |
|
1223 |
} |
|
1224 |
return(pE<pB ? KErrNotFound : pE-pB); |
|
1225 |
} |
|
1226 |
||
1227 |
EXPORT_C HBufC16 *TDesC16::Alloc() const |
|
1228 |
/** |
|
1229 |
Creates a new 16-bit heap descriptor and initialises it with a copy of this |
|
1230 |
descriptor's data. |
|
1231 |
||
1232 |
@return A pointer to the new 16-bit heap descriptor, if creation is successful. |
|
1233 |
NULL, if creation of the descriptor fails. |
|
1234 |
*/ |
|
1235 |
{ |
|
1236 |
||
1237 |
HBufC16 *pH=HBufC16::New(Length()); |
|
1238 |
if (pH) |
|
1239 |
*pH=(*this); |
|
1240 |
return(pH); |
|
1241 |
} |
|
1242 |
||
1243 |
EXPORT_C HBufC16 *TDesC16::AllocL() const |
|
1244 |
/** |
|
1245 |
Creates a new 16-bit heap descriptor and initialises it with a copy of this |
|
1246 |
descriptor's data. |
|
1247 |
||
1248 |
The function leaves, if creation of the descriptor fails. |
|
1249 |
||
1250 |
@return A pointer to the 16-bit heap descriptor, if creation is successful. |
|
1251 |
*/ |
|
1252 |
{ |
|
1253 |
||
1254 |
HBufC16 *pH=HBufC16::NewL(Length()); |
|
1255 |
*pH=(*this); |
|
1256 |
return(pH); |
|
1257 |
} |
|
1258 |
||
1259 |
EXPORT_C HBufC16 *TDesC16::AllocLC() const |
|
1260 |
/** |
|
1261 |
Creates a new 16-bit heap descriptor, initialises it with a copy of this |
|
1262 |
descriptor's data, and puts a pointer to the descriptor onto the cleanup stack. |
|
1263 |
||
1264 |
The function leaves, if creation of the descriptor fails. |
|
1265 |
||
1266 |
@return A pointer to the 16-bit heap descriptor, if creation is successful. |
|
1267 |
The pointer is also put onto the cleanup stack. |
|
1268 |
*/ |
|
1269 |
{ |
|
1270 |
||
1271 |
HBufC16 *pH=HBufC16::NewLC(Length()); |
|
1272 |
*pH=(*this); |
|
1273 |
return(pH); |
|
1274 |
} |
|
1275 |
||
1276 |
#if !defined(__DES16_MACHINE_CODED__) |
|
1277 |
||
1278 |
EXPORT_C TPtrC16 TDesC16::Left(TInt aLength) const |
|
1279 |
/** |
|
1280 |
Extracts the leftmost part of the data. |
|
1281 |
||
1282 |
The function does not cut or remove any data but constructs a non-modifiable |
|
1283 |
pointer descriptor to represent the leftmost part of the data. |
|
1284 |
||
1285 |
@param aLength The length of the data to be extracted. If this value is |
|
1286 |
greater than the length of the descriptor, the function |
|
1287 |
extracts the whole of the descriptor. |
|
1288 |
||
1289 |
@return The 16-bit non-modifiable pointer descriptor representing the leftmost |
|
1290 |
part of the data. |
|
1291 |
||
1292 |
@panic USER 10 if aLength is negative. |
|
1293 |
*/ |
|
1294 |
{ |
|
1295 |
||
1296 |
__ASSERT_ALWAYS(aLength>=0,Panic(ETDes16PosOutOfRange)); |
|
1297 |
return(TPtrC16(Ptr(),Min(aLength,Length()))); |
|
1298 |
} |
|
1299 |
||
1300 |
EXPORT_C TPtrC16 TDesC16::Right(TInt aLength) const |
|
1301 |
/** |
|
1302 |
Extracts the rightmost part of the data. |
|
1303 |
||
1304 |
The function does not cut or remove any data but constructs a non-modifiable |
|
1305 |
pointer descriptor to represent the rightmost part of the data. |
|
1306 |
||
1307 |
@param aLength The length of data to be extracted. If this value |
|
1308 |
is greater than the length of the descriptor, the function |
|
1309 |
extracts the whole of the descriptor. |
|
1310 |
||
1311 |
@return The 16-bit non-modifiable pointer descriptor representing the rightmost |
|
1312 |
part of the data. |
|
1313 |
||
1314 |
@panic USER 10 if aLength is negative. |
|
1315 |
*/ |
|
1316 |
{ |
|
1317 |
||
1318 |
__ASSERT_ALWAYS(aLength>=0,Panic(ETDes16PosOutOfRange)); |
|
1319 |
TInt len=Length(); |
|
1320 |
if (aLength>len) |
|
1321 |
aLength=len; |
|
1322 |
return(TPtrC16(Ptr()+len-aLength,aLength)); |
|
1323 |
} |
|
1324 |
||
1325 |
EXPORT_C TPtrC16 TDesC16::Mid(TInt aPos) const |
|
1326 |
/** |
|
1327 |
Extracts a portion of the data. |
|
1328 |
||
1329 |
The function does not cut or remove any data but constructs a non-modifiable |
|
1330 |
pointer descriptor to represent the defined portion. |
|
1331 |
||
1332 |
The portion is identified by its starting position and by the length of the |
|
1333 |
remainder of the data starting from the specified position. |
|
1334 |
||
1335 |
@param aPos The starting position of the data to be extracted. This is an |
|
1336 |
offset value; a zero value refers to the leftmost data position. |
|
1337 |
||
1338 |
@return The 16-bit non-modifiable pointer descriptor representing the specified |
|
1339 |
portion of the data. |
|
1340 |
||
1341 |
@panic USER 10 if aPos is negative or aPos is greater than the |
|
1342 |
length of the descriptor. |
|
1343 |
*/ |
|
1344 |
{ |
|
1345 |
||
1346 |
TInt len=Length(); |
|
1347 |
__ASSERT_ALWAYS(aPos>=0 && aPos<=len,Panic(ETDes16PosOutOfRange)); |
|
1348 |
return(TPtrC16(Ptr()+aPos,len-aPos)); |
|
1349 |
} |
|
1350 |
||
1351 |
EXPORT_C TPtrC16 TDesC16::Mid(TInt aPos,TInt aLength) const |
|
1352 |
/** |
|
1353 |
Extracts a portion of the data. |
|
1354 |
||
1355 |
The function does not cut or remove any data but constructs a non-modifiable |
|
1356 |
pointer descriptor to represent the defined portion. |
|
1357 |
||
1358 |
The portion is identified by its starting position and by its length. |
|
1359 |
||
1360 |
@param aPos The starting position of the data to be extracted. This is an |
|
1361 |
offset value; a zero value refers to the leftmost data position. |
|
1362 |
@param aLength The length of data to be extracted. |
|
1363 |
||
1364 |
@return The 16-bit non-modifiable pointer descriptor representing the specified |
|
1365 |
portion of the data. |
|
1366 |
||
1367 |
@panic USER 10 if aPos is negative or aPos plus aLength is greater than the |
|
1368 |
length of the descriptor. |
|
1369 |
*/ |
|
1370 |
{ |
|
1371 |
||
1372 |
__ASSERT_ALWAYS(aPos>=0 && (aPos+aLength)<=Length(),Panic(ETDes16PosOutOfRange)); |
|
1373 |
return(TPtrC16(Ptr()+aPos,aLength)); |
|
1374 |
} |
|
1375 |
||
1376 |
#endif // !defined(__DES16_MACHINE_CODED__) |
|
1377 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1378 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1379 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1380 |
* A helper function, which moves a pointer one Unicode character forward. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1381 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1382 |
* @aStart points to the head of the string to process. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1383 |
* @aEnd points to the end of the string. Note that aEnd points to the first |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1384 |
* 16-bit unit after the string. That is, the string length (i.e, count |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1385 |
* of 16-bit units) is (aEnd-aStart). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1386 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1387 |
* On return, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1388 |
* if find valid character, then return KErrNone, with aNewStart pointing |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1389 |
* to the 16-bit unit after the found character; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1390 |
* if meet corrupt surrogate before find a valid character, then return |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1391 |
* KErrCorruptSurrogateFound, with aNewStart pointing to the corrupt surrogate; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1392 |
* if meet aEnd before find a valid character, then return KErrNotFound. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1393 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1394 |
* @return KErrNone if ok; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1395 |
* KErrNotFound if get to aEnd; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1396 |
* KErrCorruptSurrogateFound if meet corrupt surrogate. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1397 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1398 |
TInt ProceedOneCharacter(const TText16* aStart, const TText16* aEnd, TText16*& aNewStart, TUint& aCurrentChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1399 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1400 |
if (!aStart || !aEnd || aStart>=aEnd) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1401 |
return KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1402 |
if (!TChar::IsSurrogate(aStart[0])) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1403 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1404 |
aCurrentChar = aStart[0]; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1405 |
aNewStart = const_cast<TText16*> (aStart + 1); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1406 |
return KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1407 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1408 |
else if (TChar::IsHighSurrogate(aStart[0])) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1409 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1410 |
if (aEnd < aStart + 2) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1411 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1412 |
if (!TChar::IsLowSurrogate(aStart[1])) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1413 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1414 |
aNewStart = const_cast<TText16*> (aStart + 2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1415 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1416 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1417 |
aCurrentChar = TChar::JoinSurrogate(aStart[0], aStart[1]); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1418 |
aNewStart = const_cast<TText16*> (aStart + 2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1419 |
return KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1420 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1421 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1422 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1423 |
aNewStart = const_cast<TText16*> (aStart); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1424 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1425 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1426 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1427 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1428 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1429 |
* A helper function, which moves a pointer one or more Unicode characters forward. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1430 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1431 |
* This function starts from aStart, stops when one of below conditions matched: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1432 |
* 1) 16-bit position >= (aEnd - aStart); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1433 |
* 2) 16-bit position >= aMaxInt16Position; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1434 |
* 3) character position >= aMaxCharacterPosition; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1435 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1436 |
* Specify a huge integer (say KMaskDesLength16) for aMaxInt16Position or |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1437 |
* aMaxCharacterPosition to indicate unlimited 16-bit position or character |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1438 |
* position. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1439 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1440 |
* When return, aOutInt16Position, aOutCharacterPosition and aLastChar will |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1441 |
* indicate the same one character, whose |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1442 |
* 16-bit position <= aMaxInt16Position, and |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1443 |
* character position <= aMaxCharacterPosition. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1444 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1445 |
* @return KErrNone if no error found; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1446 |
* KErrNotFound if get to aEnd before find wanted position; or, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1447 |
* if aMaxIntPosition<=0 or aMaxCharacterPosition<=0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1448 |
* KErrCorruptSurrogateFound if meet corrupt surrogate. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1449 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1450 |
TInt ProceedMultiCharacters(const TText16* aStart, const TText16* aEnd, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1451 |
const TInt aMaxInt16Position, const TInt aMaxCharacterPosition, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1452 |
TInt& aOutInt16Position, TInt& aOutCharacterPosition, TUint& aLastChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1453 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1454 |
TText16 *next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1455 |
TInt status = KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1456 |
aOutInt16Position = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1457 |
aOutCharacterPosition = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1458 |
while (aOutInt16Position <= aMaxInt16Position && aOutCharacterPosition <= aMaxCharacterPosition) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1459 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1460 |
status = ::ProceedOneCharacter(aStart+aOutInt16Position, aEnd, next, aLastChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1461 |
if (status == KErrNotFound || status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1462 |
return status; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1463 |
if (next - aStart > aMaxInt16Position || aOutInt16Position == aMaxInt16Position || aOutCharacterPosition == aMaxCharacterPosition) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1464 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1465 |
return status; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1466 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1467 |
aOutInt16Position = (next - aStart); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1468 |
++aOutCharacterPosition; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1469 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1470 |
return status; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1471 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1472 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1473 |
EXPORT_C TInt TDesC16::FindCorruptSurrogate() const |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1474 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1475 |
Look for the first corrupt surrogate in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1476 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1477 |
@return The 16-bit position of the first corrupt surrogate. KErrNotFound, if |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1478 |
not found. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1479 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1480 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1481 |
// Do not use TUTF32Iterator, because it hides some characters, including corrupt surrogate. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1482 |
TInt strLength = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1483 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1484 |
const TText16* start = Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1485 |
const TText16* end = Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1486 |
TInt int16Pos; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1487 |
TInt charPos; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1488 |
TUint lastChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1489 |
TInt status = ::ProceedMultiCharacters(start, end, KMaskDesLength16, KMaskDesLength16, int16Pos, charPos, lastChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1490 |
if (status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1491 |
return int16Pos; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1492 |
return KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1493 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1494 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1495 |
EXPORT_C TInt TDesC16::Locate2(TChar aChar) const |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1496 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1497 |
The surrogate aware version of Locate(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1498 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1499 |
Searches for the first occurrence of a character within this descriptor's |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1500 |
data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1501 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1502 |
The search starts at the beginning of the data, i.e. at the leftmost |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1503 |
position. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1504 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1505 |
@param aChar The Unicode character to be found. Can be inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1506 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1507 |
@return The offset of the character position from the beginning of the data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1508 |
KErrNotFound, if no matching character can be found. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1509 |
KErrCorruptSurrogateFound, if meet corrupt surrogate in the searching. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1510 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1511 |
@see TDesC16::Locate() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1512 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1513 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1514 |
TInt strLength = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1515 |
const TText16* start = Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1516 |
const TText16* end = Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1517 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1518 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1519 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1520 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1521 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1522 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1523 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1524 |
if (status != KErrNone) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1525 |
return status; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1526 |
if (currentChar == aChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1527 |
return int16Index; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1528 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1529 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1530 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1531 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1532 |
LOCAL_C TInt DoLocateF16_2(const TDesC16& aDes, TUint aChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1533 |
// Surrogate-aware version of DoLocateF16(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1534 |
// Locate character aChar in the descriptor folded. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1535 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1536 |
const TText* table = convTable(EMatchFolded); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1537 |
TUint aChar32 = aChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1538 |
aChar = lookup2(aChar32, table); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1539 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1540 |
// find aChar in aDes |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1541 |
TInt strLength = aDes.Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1542 |
const TText16* start = aDes.Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1543 |
const TText16* end = aDes.Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1544 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1545 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1546 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1547 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1548 |
while (status == KErrNone) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1549 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1550 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1551 |
if (status != KErrNone) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1552 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1553 |
if (lookup2(currentChar, table) == aChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1554 |
return int16Index; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1555 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1556 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1557 |
return status; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1558 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1559 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1560 |
EXPORT_C TInt TDesC16::LocateF2(TChar aChar) const |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1561 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1562 |
The surrogate aware version of LocateF(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1563 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1564 |
Searches for the first occurrence of a folded character within this |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1565 |
descriptor's folded data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1566 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1567 |
The search starts at the beginning of the data, i.e. at the leftmost |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1568 |
position. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1569 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1570 |
Note that folding is locale-independent behaviour. It is also important to |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1571 |
note that there can be no guarantee that folding is in any way culturally |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1572 |
appropriate, and should not be used for searching strings in natural language. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1573 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1574 |
@param aChar The Unicode character to be found. Can be inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1575 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1576 |
@return The offset of the character position from the beginning of the data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1577 |
KErrNotFound, if no matching character can be found. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1578 |
KErrCorruptSurrogateFound, if meet corrupt surrogate in the searching. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1579 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1580 |
@see TDesC16::LocateF() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1581 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1582 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1583 |
return DoLocateF16_2(*this, aChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1584 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1585 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1586 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1587 |
* Proceed backward from aEnd toward aStart by one character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1588 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1589 |
* @aStart points to the first 16-bit unit in a descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1590 |
* @aEnd points to the 16-bit unit after the last one. So, count of 16-bit |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1591 |
* units to process is (aEnd-aStart). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1592 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1593 |
* On return, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1594 |
* if valid character found, then return KErrNone, with aNewEnd pointing |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1595 |
* to the character found; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1596 |
* if meet corrupt surrogate before find a valid character, then return |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1597 |
* KErrCorruptSurrogateFound, with aNewStart point to the corrupt |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1598 |
* surrogate; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1599 |
* if aStart met, then return KErrNotFound. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1600 |
* |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1601 |
* @return KErrNone if ok; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1602 |
* KErrNotFound if get to aStart; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1603 |
* KErrCorruptSurrogateFound if meet corrupt surrogate. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1604 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1605 |
TInt RecedeOneCharacter(const TText16* aStart, const TText16* aEnd, TText16*& aNewEnd, TUint& aCurrentChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1606 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1607 |
if (!aStart || !aEnd || aStart>=aEnd) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1608 |
return KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1609 |
if (!TChar::IsSurrogate(aEnd[-1])) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1610 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1611 |
aCurrentChar = aEnd[-1]; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1612 |
aNewEnd = const_cast<TText16*> (aEnd - 1); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1613 |
return KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1614 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1615 |
else if (TChar::IsLowSurrogate(aEnd[-1])) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1616 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1617 |
if (aEnd < aStart + 2) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1618 |
return KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1619 |
if (!TChar::IsHighSurrogate(aEnd[-2])) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1620 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1621 |
aNewEnd = const_cast<TText16*> (aEnd - 2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1622 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1623 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1624 |
aCurrentChar = TChar::JoinSurrogate(aEnd[-2], aEnd[-1]); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1625 |
aNewEnd = const_cast<TText16*> (aEnd - 2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1626 |
return KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1627 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1628 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1629 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1630 |
aNewEnd = const_cast<TText16*> (aEnd); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1631 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1632 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1633 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1634 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1635 |
EXPORT_C TInt TDesC16::LocateReverse2(TChar aChar) const |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1636 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1637 |
The surrogate aware version of LocateReverse(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1638 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1639 |
Searches for the first occurrence of a character within this descriptor's |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1640 |
data, searching from the end of the data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1641 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1642 |
The search starts at the rightmost position. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1643 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1644 |
@param aChar The Unicode character to be found. Can be inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1645 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1646 |
@return The offset of the character position from the beginning of the data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1647 |
KErrNotFound, if no matching character can be found. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1648 |
KErrCorruptSurrogateFound, if meet corrupt surrogate in the searching. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1649 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1650 |
@see TDesC16::LocateReverse() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1651 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1652 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1653 |
TInt strLength = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1654 |
const TText16* start = Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1655 |
TText16* newEnd; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1656 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1657 |
TInt int16Index = strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1658 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1659 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1660 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1661 |
status = ::RecedeOneCharacter(start, start+int16Index, newEnd, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1662 |
if (status != KErrNone) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1663 |
return status; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1664 |
int16Index = (newEnd - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1665 |
if (currentChar == aChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1666 |
return int16Index; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1667 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1668 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1669 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1670 |
EXPORT_C TInt TDesC16::LocateReverseF2(TChar aChar) const |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1671 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1672 |
The surrogate aware version of LocateReverseF(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1673 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1674 |
Searches for the first occurrence of a folded character within this descriptor's |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1675 |
folded data, searching from the end of the data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1676 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1677 |
The search starts at the rightmost position. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1678 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1679 |
Note that folding is locale-independent behaviour. It is also important to |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1680 |
note that there can be no guarantee that folding is in any way culturally |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1681 |
appropriate, and should not be used for searching strings in natural language. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1682 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1683 |
@param aChar The Unicode character to be found. Can be inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1684 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1685 |
@return The offset of the character position from the beginning of the data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1686 |
KErrNotFound, if no matching character can be found. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1687 |
KErrCorruptSurrogateFound, if meet corrupt surrogate in the searching. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1688 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1689 |
@see TDesC16::LocateReverseF() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1690 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1691 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1692 |
TInt strLength = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1693 |
const TText16* start = Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1694 |
const TText16* end = Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1695 |
TText16* newEnd; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1696 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1697 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1698 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1699 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1700 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1701 |
status = ::RecedeOneCharacter(start, end, newEnd, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1702 |
if (status != KErrNone) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1703 |
return status; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1704 |
TCharF c(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1705 |
if (c == aChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1706 |
return int16Index; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1707 |
int16Index = (newEnd - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1708 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1709 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1710 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1711 |
inline TUint conv2(TUint aChar, const TText *aConv, const TUnicodeDataSet* aCharDataSet) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1712 |
// Surrogate-aware version of conv(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1713 |
// If aConv is not NULL then convert the character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1714 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1715 |
if (aConv) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1716 |
return TUnicode(aChar).Fold((TInt)aConv, aCharDataSet); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1717 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1718 |
return aChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1719 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1720 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1721 |
// Surrogate-aware version of DoMatch16(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1722 |
// This helper function uses the same search algorithm as DoMatch16(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1723 |
TInt DoMatch16_2(const TDesC16 &aLeftD, const TDesC16 &aRightD, TMatchType aType) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1724 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1725 |
const TText* table=convTable(aType); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1726 |
const TUint16* const pRight=aRightD.Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1727 |
const TUint16* pM=pRight-1; // pre-increment addressing |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1728 |
const TUint16* const pP=pM+aRightD.Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1729 |
const TUint16* const pLeft=aLeftD.Ptr()-1; // pre-increment addressing |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1730 |
const TUint16* pB=pLeft; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1731 |
const TUint16* pB2=pLeft; // always points to current char; pB2==pB or pB-1 |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1732 |
const TUint16* const pE=pB+aLeftD.Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1733 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1734 |
// Note: pM and pB always point to the int16 unit before the character to handle. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1735 |
// so, pM[0] and pB[0] may be a low surrogate. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1736 |
// but, pM[1] and pB[1] must be start of a character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1737 |
// Note: pB2 always points to current character being handled. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1738 |
// pB2 is used to generated return value. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1739 |
// if pB[0] is low surrogate, then pB2=pB-1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1740 |
// if pB[0] is BMP, then pB2=pB. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1741 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1742 |
// A 'diagram' shows the pointers: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1743 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1744 |
// before search: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1745 |
// left: ############################ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1746 |
// ^ ^ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1747 |
// pLeft/pB/pB2 pE |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1748 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1749 |
// right: ############################ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1750 |
// ^^ ^ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1751 |
// pM pRight pP |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1752 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1753 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1754 |
// after several iterations (C is the next character going to be checked): |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1755 |
// left: ###############C############ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1756 |
// ^ ^ ^ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1757 |
// pLeft pB/pB2 pE |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1758 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1759 |
// right: ##########C################# |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1760 |
// ^ ^ ^ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1761 |
// pRight pM pP |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1762 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1763 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1764 |
const TUnicodeDataSet* charDataSet = GetLocaleCharSet()->iCharDataSet; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1765 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1766 |
// Match any pattern up to the first star |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1767 |
TUint c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1768 |
TInt status; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1769 |
TText* newStart; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1770 |
for (;;) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1771 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1772 |
status = ::ProceedOneCharacter(pM+1, pP+1, newStart, c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1773 |
if (status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1774 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1775 |
if (status == KErrNotFound) // exhausted the pattern |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1776 |
return pB==pE ? 0 : KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1777 |
pM = newStart - 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1778 |
c = conv2(c, table, charDataSet); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1779 |
if (c==KMatchAny) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1780 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1781 |
if (pB==pE) // no more input |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1782 |
return KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1783 |
TUint c2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1784 |
pB2 = pB + 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1785 |
status = ::ProceedOneCharacter(pB+1, pE+1, newStart, c2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1786 |
if (status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1787 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1788 |
pB = newStart - 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1789 |
if (c != conv2(c2, table, charDataSet) && c != KMatchOne) // match failed |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1790 |
return KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1791 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1792 |
// reached a star |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1793 |
if (pM==pP) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1794 |
return 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1795 |
TInt r=pM==pRight ? -1 : 0; // r = how many int16 has been matched in candidate (aLeftD) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1796 |
for (;;) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1797 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1798 |
status = ::ProceedOneCharacter(pM+1, pP+1, newStart, c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1799 |
if (status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1800 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1801 |
pM = newStart - 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1802 |
c = conv2(c, table, charDataSet); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1803 |
if (c==KMatchAny) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1804 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1805 |
star: if (pM==pP) // star at end of pattern, always matches |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1806 |
return Max(r,0); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1807 |
if (r<-1) // skipped some '?', matches at beginning |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1808 |
r=0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1809 |
continue; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1810 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1811 |
if (pB==pE) // no more input |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1812 |
return KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1813 |
if (c==KMatchOne) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1814 |
{ // skip a character in the input |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1815 |
if (pM==pP) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1816 |
return r+((r>=0) ? 0 : (pE-pLeft)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1817 |
TUint dummyC; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1818 |
pB2 = pB + 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1819 |
status = ::ProceedOneCharacter(pB+1, pE+1, newStart, dummyC); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1820 |
if (status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1821 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1822 |
pB = newStart - 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1823 |
if (r < 0) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1824 |
r -= (newStart - pB2); // back r by 1 or 2, depending on dummyC is BMP or non-BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1825 |
continue; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1826 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1827 |
// Matching a non-wild character |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1828 |
for (;;) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1829 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1830 |
if (table) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1831 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1832 |
TUint c2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1833 |
for (;;) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1834 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1835 |
pB2 = pB + 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1836 |
status = ::ProceedOneCharacter(pB+1, pE+1, newStart, c2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1837 |
if (status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1838 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1839 |
pB = newStart - 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1840 |
if (lookup2(c2, table) == c) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1841 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1842 |
if (pB==pE) // no more input |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1843 |
return KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1844 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1845 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1846 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1847 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1848 |
TUint c2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1849 |
for (;;) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1850 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1851 |
pB2 = pB + 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1852 |
status = ::ProceedOneCharacter(pB+1, pE+1, newStart, c2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1853 |
if (status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1854 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1855 |
pB = newStart - 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1856 |
if (c2 == c) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1857 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1858 |
if (pB==pE) // no more input |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1859 |
return KErrNotFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1860 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1861 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1862 |
// Try to match up to the next star |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1863 |
const TUint16* pb=pB; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1864 |
const TUint16* pm=pM; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1865 |
for (;;) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1866 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1867 |
if (pm<pP) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1868 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1869 |
TUint cc; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1870 |
status = ::ProceedOneCharacter(pm+1, pP+1, newStart, cc); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1871 |
if (status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1872 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1873 |
pm = newStart - 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1874 |
cc = conv2(cc, table, charDataSet); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1875 |
if (cc==KMatchAny) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1876 |
{ // sub-match successful, back to main loop |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1877 |
r+=(r>=0 ? 0 : pB2-pLeft); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1878 |
pB=pb; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1879 |
pM=pm; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1880 |
goto star; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1881 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1882 |
if (pb==pE) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1883 |
return KErrNotFound; // no more input |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1884 |
TUint cc2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1885 |
status = ::ProceedOneCharacter(pb+1, pE+1, newStart, cc2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1886 |
if (status == KErrCorruptSurrogateFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1887 |
return KErrCorruptSurrogateFound; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1888 |
pb = newStart - 1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1889 |
if (cc != conv2(cc2, table, charDataSet) && cc != KMatchOne) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1890 |
break; // sub-match failed, try next input character |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1891 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1892 |
else if (pb==pE) // end of matching pattern |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1893 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1894 |
return r+(r>=0 ? 0 : pB2-pLeft); // end of input, so have a match |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1895 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1896 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1897 |
break; // try next input character |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1898 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1899 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1900 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1901 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1902 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1903 |
EXPORT_C TInt TDesC16::Match2(const TDesC16 &aDes) const |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1904 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1905 |
The surrogate aware version of Match(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1906 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1907 |
Searches this descriptor's data for a match with the match pattern supplied |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1908 |
in the specified descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1909 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1910 |
The match pattern can contain the wildcard characters "*" and "?", where "*" |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1911 |
matches zero or more consecutive occurrences of any character and "?" matches |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1912 |
a single occurrence of any character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1913 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1914 |
Note that there is no 'escape character', which means that it is not possible |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1915 |
to match either the "*" character itself or the "?" character itself using |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1916 |
this function. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1917 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1918 |
@param aDes A 16-bit non-modifable descriptor containing the match pattern. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1919 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1920 |
@return If a match is found, the offset within this descriptor's data where |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1921 |
the match first occurs. KErrNotFound, if there is no match. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1922 |
KErrCorruptSurrogateFound, if meet corrupt surrogate in the searching. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1923 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1924 |
@see TDesC16::Match() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1925 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1926 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1927 |
return DoMatch16_2(*this, aDes, EMatchNormal); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1928 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1929 |
|
0 | 1930 |
#if !defined( __DES16_MACHINE_CODED__) | defined(__EABI_CTORS__) |
1931 |
EXPORT_C TBufCBase16::TBufCBase16() |
|
1932 |
// |
|
1933 |
// Constructor |
|
1934 |
// |
|
1935 |
: TDesC16(EBufC,0) |
|
1936 |
{} |
|
1937 |
#endif |
|
1938 |
||
1939 |
#if !defined( __DES16_MACHINE_CODED_HWORD__) | defined(__EABI_CTORS__) |
|
1940 |
EXPORT_C TBufCBase16::TBufCBase16(const TUint16 *aString,TInt aMaxLength) |
|
1941 |
// |
|
1942 |
// Constructor |
|
1943 |
// |
|
1944 |
: TDesC16(EBufC,0) |
|
1945 |
{ |
|
1946 |
Copy(aString,aMaxLength); |
|
1947 |
} |
|
1948 |
#endif |
|
1949 |
||
1950 |
#if !defined( __DES16_MACHINE_CODED__) | defined(__EABI_CTORS__) |
|
1951 |
EXPORT_C TBufCBase16::TBufCBase16(const TDesC16 &aDes,TInt aMaxLength) |
|
1952 |
// |
|
1953 |
// Constructor |
|
1954 |
// |
|
1955 |
: TDesC16(EBufC,0) |
|
1956 |
{ |
|
1957 |
Copy(aDes,aMaxLength); |
|
1958 |
} |
|
1959 |
#endif |
|
1960 |
||
1961 |
#ifndef __DES16_MACHINE_CODED_HWORD__ |
|
1962 |
EXPORT_C void TBufCBase16::Copy(const TUint16 *aString,TInt aMaxLength) |
|
1963 |
// |
|
1964 |
// Copy from a string. |
|
1965 |
// |
|
1966 |
{ |
|
1967 |
||
1968 |
__CHECK_ALIGNMENT(aString,ETBufCBase16CopyStringMax); |
|
1969 |
TInt len=STRING_LENGTH_16(aString); |
|
1970 |
__ASSERT_ALWAYS(len<=aMaxLength,Panic(ETDes16Overflow)); |
|
1971 |
memCopy(WPtr(),aString,len); |
|
1972 |
DoSetLength(len); |
|
1973 |
} |
|
1974 |
#endif |
|
1975 |
||
1976 |
#ifndef __DES16_MACHINE_CODED__ |
|
1977 |
EXPORT_C void TBufCBase16::Copy(const TDesC16 &aDes,TInt aMaxLength) |
|
1978 |
// |
|
1979 |
// Copy from a descriptor. |
|
1980 |
// |
|
1981 |
{ |
|
1982 |
||
1983 |
TInt len=aDes.Length(); |
|
1984 |
__ASSERT_ALWAYS(len<=aMaxLength,Panic(ETDes16Overflow)); |
|
1985 |
memCopy(WPtr(),aDes.Ptr(),len); |
|
1986 |
DoSetLength(len); |
|
1987 |
} |
|
1988 |
#endif |
|
1989 |
||
1990 |
inline HBufC16::HBufC16(TInt aLength) |
|
1991 |
:TBufCBase16(aLength) |
|
1992 |
{} |
|
1993 |
||
1994 |
EXPORT_C HBufC16 *HBufC16::New(TInt aMaxLength) |
|
1995 |
/** |
|
1996 |
Creates, and returns a pointer to, a new 16-bit heap descriptor. |
|
1997 |
||
1998 |
The heap descriptor is empty and its length is zero. |
|
1999 |
||
2000 |
Data can, subsequently, be assigned into it using the assignment operators. |
|
2001 |
||
2002 |
@param aMaxLength The requested maximum length of the descriptor. Note that |
|
2003 |
the resulting heap cell size and, therefore, the resulting |
|
2004 |
maximum length of the descriptor may be larger than |
|
2005 |
requested. |
|
2006 |
||
2007 |
@return A pointer to the new 16-bit heap descriptor. NULL, if the 16-bit heap |
|
2008 |
descriptor cannot be created. |
|
2009 |
||
2010 |
@panic USER 18 if aMaxLength is negative. |
|
2011 |
||
2012 |
@see HBufC16::operator=() |
|
2013 |
*/ |
|
2014 |
{ |
|
2015 |
__ASSERT_ALWAYS(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
2016 |
return new(STD_CLASS::Alloc(_FOFF(HBufC16,iBuf[aMaxLength]))) HBufC16(0); |
|
2017 |
} |
|
2018 |
||
2019 |
EXPORT_C HBufC16 *HBufC16::NewL(TInt aMaxLength) |
|
2020 |
/** |
|
2021 |
Creates, and returns a pointer to, a new 16-bit heap descriptor, and leaves |
|
2022 |
on failure. |
|
2023 |
||
2024 |
The heap descriptor is empty and its length is zero. |
|
2025 |
||
2026 |
Data can, subsequently, be assigned into it using the assignment operators. |
|
2027 |
||
2028 |
@param aMaxLength The requested maximum length of the descriptor. Note that |
|
2029 |
the resulting heap cell size and, therefore, the resulting |
|
2030 |
maximum length of the descriptor may be larger |
|
2031 |
than requested. |
|
2032 |
||
2033 |
@return A pointer to the new 16-bit heap descriptor. The function leaves, if |
|
2034 |
the new 16-bit heap descriptor cannot be created. |
|
2035 |
||
2036 |
||
2037 |
@panic USER 18 if aMaxLength is negative. |
|
2038 |
||
2039 |
@see HBufC16::operator=() |
|
2040 |
*/ |
|
2041 |
{ |
|
2042 |
return static_cast<HBufC16*>(User::LeaveIfNull(New(aMaxLength))); |
|
2043 |
} |
|
2044 |
||
2045 |
EXPORT_C HBufC16 *HBufC16::NewLC(TInt aMaxLength) |
|
2046 |
/** |
|
2047 |
Creates, adds a pointer onto the cleanup stack and returns a pointer to, a |
|
2048 |
new 16-bit heap descriptor; leaves on failure. |
|
2049 |
||
2050 |
The heap descriptor is empty and its length is zero. |
|
2051 |
||
2052 |
Data can, subsequently, be assigned into it using the assignment operators. |
|
2053 |
||
2054 |
@param aMaxLength The requested maximum length of the descriptor. Note that |
|
2055 |
the resulting heap cell size and, therefore, the resulting |
|
2056 |
maximum length of the descriptor may be larger |
|
2057 |
than requested. |
|
2058 |
||
2059 |
@return A pointer to the new 16-bit heap descriptor. The function leaves, if |
|
2060 |
the new 16-bit heap descriptor cannot be created. |
|
2061 |
||
2062 |
@panic USER 18 if aMaxLength is negative. |
|
2063 |
||
2064 |
@see HBufC16::operator=() |
|
2065 |
*/ |
|
2066 |
{ |
|
2067 |
HBufC16* buf=NewL(aMaxLength); |
|
2068 |
CleanupStack::PushL(buf); |
|
2069 |
return buf; |
|
2070 |
} |
|
2071 |
||
2072 |
EXPORT_C HBufC16 *HBufC16::NewMax(TInt aMaxLength) |
|
2073 |
/** |
|
2074 |
Creates, and returns a pointer to, a new 16-bit heap descriptor. |
|
2075 |
||
2076 |
No data is assigned into the new descriptor but its length |
|
2077 |
is set to aMaxLength. |
|
2078 |
||
2079 |
Data can, subsequently, be assigned into it using the assignment operators. |
|
2080 |
||
2081 |
@param aMaxLength The requested maximum length of the descriptor. Note that |
|
2082 |
the resulting heap cell size and, therefore, the resulting |
|
2083 |
maximum length of the descriptor may be larger |
|
2084 |
than requested. This also means that the resulting maximum |
|
2085 |
length of the descriptor may be greater than its length. |
|
2086 |
@return A pointer to the new 16-bit heap descriptor. NULL, if the new 16-bit |
|
2087 |
heap descriptor cannot be created. |
|
2088 |
||
2089 |
@panic USER 18 if aMaxLength is negative. |
|
2090 |
||
2091 |
@see HBufC16::operator=() |
|
2092 |
*/ |
|
2093 |
{ |
|
2094 |
__ASSERT_ALWAYS(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
2095 |
return new(STD_CLASS::Alloc(_FOFF(HBufC16,iBuf[aMaxLength]))) HBufC16(aMaxLength); |
|
2096 |
} |
|
2097 |
||
2098 |
EXPORT_C HBufC16 *HBufC16::NewMaxL(TInt aMaxLength) |
|
2099 |
/** |
|
2100 |
Creates, and returns a pointer to, a new 16-bit heap descriptor; |
|
2101 |
leaves on failure. |
|
2102 |
||
2103 |
No data is assigned into the new descriptor but its length is set |
|
2104 |
to aMaxLength. |
|
2105 |
||
2106 |
Data can, subsequently, be assigned into it using the assignment operators. |
|
2107 |
||
2108 |
@param aMaxLength The requested maximum length of the descriptor. Note that |
|
2109 |
the resulting heap cell size and, therefore, the resulting |
|
2110 |
maximum length of the descriptor may be larger |
|
2111 |
than requested. This also means that the resulting |
|
2112 |
maximum length of the descriptor may be greater than its length. |
|
2113 |
||
2114 |
@return A pointer to the new 16-bit heap descriptor. The function leaves, if |
|
2115 |
the new 16-bit heap descriptor cannot be created. |
|
2116 |
||
2117 |
@panic USER 18 if aMaxLength is negative. |
|
2118 |
||
2119 |
@see HBufC16::operator=() |
|
2120 |
*/ |
|
2121 |
{ |
|
2122 |
return static_cast<HBufC16*>(User::LeaveIfNull(NewMax(aMaxLength))); |
|
2123 |
} |
|
2124 |
||
2125 |
EXPORT_C HBufC16 *HBufC16::NewMaxLC(TInt aMaxLength) |
|
2126 |
/** |
|
2127 |
Creates, adds a pointer onto the cleanup stack and returns a pointer to, a |
|
2128 |
new 16-bit heap descriptor; leaves on failure. |
|
2129 |
||
2130 |
No data is assigned into the new descriptor but its length |
|
2131 |
is set to aMaxLength. |
|
2132 |
||
2133 |
Data can, subsequently, be assigned into it using the assignment operators. |
|
2134 |
||
2135 |
@param aMaxLength The requested maximum length of the descriptor. Note that |
|
2136 |
the resulting heap cell size and, therefore, the resulting |
|
2137 |
maximum length of the descriptor may be larger than requested. |
|
2138 |
||
2139 |
@return A pointer to the new 16-bit heap descriptor. This is also put onto |
|
2140 |
the cleanup stack. The function leaves, if the new 16-bit heap descriptor |
|
2141 |
cannot be created. |
|
2142 |
||
2143 |
@panic USER 18 if aMaxLength is negative. |
|
2144 |
||
2145 |
@see HBufC16::operator=() |
|
2146 |
*/ |
|
2147 |
{ |
|
2148 |
HBufC16* buf=NewMaxL(aMaxLength); |
|
2149 |
CleanupStack::PushL(buf); |
|
2150 |
return buf; |
|
2151 |
} |
|
2152 |
||
2153 |
EXPORT_C HBufC16 &HBufC16::operator=(const TUint16 *aString) |
|
2154 |
/** |
|
2155 |
Copies data into this 16-bit heap descriptor replacing any existing data. |
|
2156 |
||
2157 |
The length of this descriptor is set to reflect the new data. |
|
2158 |
||
2159 |
Note that the maximum length of this (target) descriptor is the length |
|
2160 |
of the descriptor buffer in the allocated host heap cell; this may be greater |
|
2161 |
than the maximum length specified when this descriptor was created or |
|
2162 |
last re-allocated. |
|
2163 |
||
2164 |
@param aString A pointer to a zero-terminated string. |
|
2165 |
||
2166 |
@return A reference to this 16-bit heap descriptor. |
|
2167 |
||
2168 |
@panic USER 11 if the length of the string, excluding the zero terminator, |
|
2169 |
is greater than the maximum length of this (target) descriptor. |
|
2170 |
*/ |
|
2171 |
{ |
|
2172 |
||
2173 |
__CHECK_ALIGNMENT(aString,EHBufC16AssignCString); |
|
2174 |
Copy(aString,(STD_CLASS::AllocLen(this)-sizeof(TDesC16))/sizeof(TUint16)); |
|
2175 |
return(*this); |
|
2176 |
} |
|
2177 |
||
2178 |
EXPORT_C HBufC16 &HBufC16::operator=(const TDesC16 &aDes) |
|
2179 |
/** |
|
2180 |
Copies data into this 16-bit heap descriptor replacing any existing data. |
|
2181 |
||
2182 |
The length of this descriptor is set to reflect the new data. |
|
2183 |
||
2184 |
Note that the maximum length of this (target) descriptor is the length |
|
2185 |
of the descriptor buffer in the allocated host heap cell; this may be greater |
|
2186 |
than the maximum length specified when this descriptor was created or |
|
2187 |
last re-allocated. |
|
2188 |
||
2189 |
@param aDes A 16-bit non-modifiable descriptor. |
|
2190 |
||
2191 |
@return A reference to this 16-bit heap descriptor. |
|
2192 |
||
2193 |
@panic USER 11 if the length of the descriptor aDes is greater than the |
|
2194 |
maximum length of this (target) descriptor |
|
2195 |
*/ |
|
2196 |
{ |
|
2197 |
||
2198 |
Copy(aDes,(STD_CLASS::AllocLen(this)-sizeof(TDesC16))/sizeof(TUint16)); |
|
2199 |
return(*this); |
|
2200 |
} |
|
2201 |
||
2202 |
EXPORT_C HBufC16 *HBufC16::ReAlloc(TInt aMaxLength) |
|
2203 |
/** |
|
2204 |
Expands or contracts this 16-bit heap descriptor. |
|
2205 |
||
2206 |
This is done by: |
|
2207 |
||
2208 |
1. creating a new heap descriptor. |
|
2209 |
||
2210 |
2. copying the original data into the new descriptor. |
|
2211 |
||
2212 |
3. deleting the original descriptor. |
|
2213 |
||
2214 |
@param aMaxLength The new requested maximum length of the descriptor. |
|
2215 |
Note that the resulting heap cell size and, therefore, |
|
2216 |
the resulting maximum length of the descriptor may be |
|
2217 |
larger than requested. |
|
2218 |
||
2219 |
@return A pointer to the new expanded or contracted 16-bit heap descriptor - |
|
2220 |
the original descriptor is deleted. NULL, if the new 16-bit heap descriptor |
|
2221 |
cannot be created - the original descriptor remains unchanged. |
|
2222 |
||
2223 |
@panic USER 14 if aMaxLength is less than the length of the existing data. |
|
2224 |
@panic USER 18 if aMaxLength is negative. |
|
2225 |
*/ |
|
2226 |
{ |
|
2227 |
||
2228 |
__ASSERT_ALWAYS(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
2229 |
__ASSERT_ALWAYS(Length()<=aMaxLength,Panic(ETDes16ReAllocTooSmall)); |
|
2230 |
return((HBufC16 *)STD_CLASS::ReAlloc(this,(aMaxLength*sizeof(TUint16))+sizeof(TDesC16))); |
|
2231 |
} |
|
2232 |
||
2233 |
EXPORT_C HBufC16 *HBufC16::ReAllocL(TInt aMaxLength) |
|
2234 |
/** |
|
2235 |
Expands or contracts this 16-bit heap descriptor; leaves on failure. |
|
2236 |
||
2237 |
This is done by: |
|
2238 |
||
2239 |
1. creating a new heap descriptor. |
|
2240 |
||
2241 |
2. copying the original data into the new descriptor. |
|
2242 |
||
2243 |
3. deleting the original descriptor. |
|
2244 |
||
2245 |
@param aMaxLength The new requested maximum length of the descriptor. |
|
2246 |
Note that the resulting heap cell size and, therefore, |
|
2247 |
the resulting maximum length of the descriptor may be |
|
2248 |
larger than requested. |
|
2249 |
||
2250 |
@return A pointer to the new expanded or contracted 16-bit heap descriptor - |
|
2251 |
the original descriptor is deleted. The function leaves, if the new |
|
2252 |
16-bit heap descriptor cannot be created - the original descriptor |
|
2253 |
remains unchanged. |
|
2254 |
||
2255 |
@panic USER 14 if aMaxLength is less than the length of the existing data. |
|
2256 |
@panic USER 18 if aMaxLength is negative. |
|
2257 |
*/ |
|
2258 |
{ |
|
2259 |
||
2260 |
__ASSERT_ALWAYS(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
2261 |
__ASSERT_ALWAYS(Length()<=aMaxLength,Panic(ETDes16ReAllocTooSmall)); |
|
2262 |
return((HBufC16 *)STD_CLASS::ReAllocL(this,(aMaxLength*sizeof(TUint16))+sizeof(TDesC16))); |
|
2263 |
} |
|
2264 |
||
2265 |
EXPORT_C TPtr16 HBufC16::Des() |
|
2266 |
/** |
|
2267 |
Creates and returns a 16-bit modifiable pointer descriptor for the data |
|
2268 |
represented by this 16-bit heap descriptor. |
|
2269 |
||
2270 |
The content of a heap descriptor normally cannot be altered, other than by |
|
2271 |
complete replacement of the data. Creating a modifiable pointer descriptor |
|
2272 |
provides a way of changing the data. |
|
2273 |
||
2274 |
The modifiable pointer descriptor is set to point to this heap descriptor's |
|
2275 |
data. |
|
2276 |
||
2277 |
The length of the modifiable pointer descriptor is set to the length of this |
|
2278 |
heap descriptor. |
|
2279 |
||
2280 |
The maximum length of the modifiable pointer descriptor is set to the length |
|
2281 |
of the heap descriptor's buffer. Note that the maximum length is the length |
|
2282 |
of the descriptor buffer in the allocated host heap cell; this may be greater |
|
2283 |
than the maximum length requested when this descriptor was originally created |
|
2284 |
or last re-allocated. |
|
2285 |
||
2286 |
When data is modified through this new pointer descriptor, the lengths of |
|
2287 |
both it and this heap descriptor are changed. |
|
2288 |
||
2289 |
Note that it is a common mistake to use Des() to create a TDesC16& reference. |
|
2290 |
While not incorrect, it is simpler and much more efficient to simply dereference |
|
2291 |
the heap descriptor. |
|
2292 |
||
2293 |
@return A 16-bit modifiable pointer descriptor representing the data in this |
|
2294 |
16-bit heap descriptor. |
|
2295 |
*/ |
|
2296 |
{ |
|
2297 |
||
2298 |
return DoDes((STD_CLASS::AllocLen(this)-sizeof(TDesC16))/sizeof(TUint16)); |
|
2299 |
} |
|
2300 |
||
2301 |
#ifndef __DES16_MACHINE_CODED__ |
|
2302 |
EXPORT_C void TDes16::SetLength(TInt aLength) |
|
2303 |
/** |
|
2304 |
Sets the length of the data represented by the descriptor to the |
|
2305 |
specified value. |
|
2306 |
||
2307 |
@param aLength The new length of the descriptor. |
|
2308 |
||
2309 |
@panic USER 11 if aLength is negative or is greater than the maximum length of |
|
2310 |
this (target) descriptor. |
|
2311 |
*/ |
|
2312 |
{ |
|
2313 |
||
2314 |
__ASSERT_ALWAYS(TUint(aLength)<=TUint(MaxLength()),Panic(ETDes16Overflow)); |
|
2315 |
DoSetLength(aLength); |
|
2316 |
if (Type()==EBufCPtr) |
|
2317 |
((SBufCPtr16 *)this)->ptr->length=aLength; // Relies on iType==0 for an TBufC |
|
2318 |
} |
|
2319 |
||
2320 |
EXPORT_C void TDes16::SetMax() |
|
2321 |
/** |
|
2322 |
Sets the length of the data to the maximum length of the descriptor. |
|
2323 |
*/ |
|
2324 |
{ |
|
2325 |
||
2326 |
SetLength(iMaxLength); |
|
2327 |
} |
|
2328 |
#endif |
|
2329 |
||
2330 |
#ifndef __DES16_MACHINE_CODED_HWORD__ |
|
2331 |
EXPORT_C void TDes16::Copy(const TUint16 *aString) |
|
2332 |
/** |
|
2333 |
Copies data into this descriptor replacing any existing data. |
|
2334 |
||
2335 |
The length of this descriptor is set to reflect the new data. |
|
2336 |
||
2337 |
@param aString A pointer to a zero-terminated string. |
|
2338 |
||
2339 |
@panic USER 11 if the length of aString, excluding the zero terminator, is |
|
2340 |
greater than the maximum length of this (target) descriptor. |
|
2341 |
*/ |
|
2342 |
{ |
|
2343 |
||
2344 |
__CHECK_ALIGNMENT(aString,ETDes16CopyCString); |
|
2345 |
TInt len=STRING_LENGTH_16(aString); |
|
2346 |
SetLength(len); |
|
2347 |
memCopy(WPtr(),aString,len); |
|
2348 |
} |
|
2349 |
#endif |
|
2350 |
||
2351 |
#ifndef __DES16_MACHINE_CODED__ |
|
2352 |
EXPORT_C void TDes16::Copy(const TUint16 *aBuf,TInt aLength) |
|
2353 |
/** |
|
2354 |
Copies data into this descriptor replacing any existing data. |
|
2355 |
||
2356 |
The length of this descriptor is set to reflect the new data. |
|
2357 |
||
2358 |
@param aBuf The start address of data to be copied. |
|
2359 |
@param aLength The length of data to be copied. |
|
2360 |
||
2361 |
@panic USER 11 if aLength is negative or is greater than maximum length |
|
2362 |
of this (target) descriptor. |
|
2363 |
*/ |
|
2364 |
{ |
|
2365 |
||
2366 |
__CHECK_ALIGNMENT(aBuf,ETDes16CopyBufLength); |
|
2367 |
SetLength(aLength); |
|
2368 |
memCopy(WPtr(),aBuf,aLength); |
|
2369 |
} |
|
2370 |
||
2371 |
EXPORT_C void TDes16::Copy(const TDesC16 &aDes) |
|
2372 |
/** |
|
2373 |
Copies data into this descriptor replacing any existing data. |
|
2374 |
||
2375 |
The length of this descriptor is set to reflect the new data. |
|
2376 |
||
2377 |
@param aDes A 16-bit non modifiable descriptor. |
|
2378 |
||
2379 |
@panic USER 11 if the length of aDes is greater than the maximum length |
|
2380 |
of this (target) descriptor. |
|
2381 |
*/ |
|
2382 |
{ |
|
2383 |
||
2384 |
TInt len=aDes.Length(); |
|
2385 |
SetLength(len); |
|
2386 |
memCopy(WPtr(),aDes.Ptr(),len); |
|
2387 |
} |
|
2388 |
#endif |
|
2389 |
||
2390 |
EXPORT_C void TDes16::Copy(const TDesC8 &aDes) |
|
2391 |
/** |
|
2392 |
Copies data into this descriptor replacing any existing data. |
|
2393 |
||
2394 |
The length of this descriptor is set to reflect the new data. |
|
2395 |
||
2396 |
@param aDes An 8 bit non modifiable descriptor. |
|
2397 |
||
2398 |
@panic USER 11 if the length of aDes is greater than the maximum |
|
2399 |
length of this (target) descriptor. |
|
2400 |
*/ |
|
2401 |
{ |
|
2402 |
||
2403 |
TInt len=aDes.Length(); |
|
2404 |
SetLength(len); |
|
2405 |
const TUint8 *pS=aDes.Ptr(); |
|
2406 |
const TUint8 *pE=pS+len; |
|
2407 |
TUint16 *pT=WPtr(); |
|
2408 |
while (pS<pE) |
|
2409 |
*pT++=(*pS++); |
|
2410 |
} |
|
2411 |
||
2412 |
#ifndef __DES16_MACHINE_CODED_HWORD__ |
|
2413 |
EXPORT_C void TDes16::Append(TChar aChar) |
|
2414 |
/** |
|
2415 |
Appends data onto the end of this descriptor's data. |
|
2416 |
||
2417 |
The length of this descriptor is incremented to reflect the new content. |
|
2418 |
||
2419 |
@param aChar A single character to be appended. The length of the descriptor |
|
2420 |
is incremented by one. |
|
2421 |
||
2422 |
@panic USER 11 if the resulting new length of this descriptor is greater than |
|
2423 |
its maximum length. |
|
2424 |
*/ |
|
2425 |
{ |
|
2426 |
||
2427 |
TInt len=Length(); |
|
2428 |
TUint16 *pB=WPtr()+len; |
|
2429 |
SetLength(len+1); |
|
2430 |
*pB++=(TUint16)aChar; |
|
2431 |
} |
|
2432 |
#endif |
|
2433 |
||
2434 |
#ifndef __DES16_MACHINE_CODED__ |
|
2435 |
EXPORT_C void TDes16::Append(const TUint16 *aBuf,TInt aLength) |
|
2436 |
/** |
|
2437 |
Appends data onto the end of this descriptor's data. |
|
2438 |
||
2439 |
The length of this descriptor is incremented to reflect the new content. |
|
2440 |
||
2441 |
@param aBuf A pointer to the data to be copied. |
|
2442 |
@param aLength The length of data to be copied. |
|
2443 |
||
2444 |
@panic USER 11 if the resulting new length of this descriptor is greater than |
|
2445 |
its maximum length. |
|
2446 |
@panic USER 17 if aLength is negative. |
|
2447 |
*/ |
|
2448 |
{ |
|
2449 |
||
2450 |
__ASSERT_ALWAYS(aLength>=0,Panic(ETDes16LengthNegative)); |
|
2451 |
__CHECK_ALIGNMENT(aBuf,ETDes16AppendBufLength); |
|
2452 |
TInt len=Length(); |
|
2453 |
SetLength(len+aLength); |
|
2454 |
memCopy(WPtr()+len,aBuf,aLength); |
|
2455 |
} |
|
2456 |
||
2457 |
EXPORT_C void TDes16::Append(const TDesC16 &aDes) |
|
2458 |
/** |
|
2459 |
Appends data onto the end of this descriptor's data. |
|
2460 |
||
2461 |
The length of this descriptor is incremented to reflect the new content. |
|
2462 |
||
2463 |
@param aDes A 16-bit non modifiable descriptor whose data is to be appended. |
|
2464 |
||
2465 |
@panic USER 11 if the resulting new length of this descriptor is greater than |
|
2466 |
its maximum length. |
|
2467 |
*/ |
|
2468 |
{ |
|
2469 |
||
2470 |
TInt len=Length(); |
|
2471 |
TInt n=aDes.Length(); |
|
2472 |
SetLength(len+n); |
|
2473 |
memCopy(WPtr()+len,aDes.Ptr(),n); |
|
2474 |
} |
|
2475 |
#endif |
|
2476 |
||
2477 |
EXPORT_C void TDes16::Swap(TDes16 &aDes) |
|
2478 |
/** |
|
2479 |
Swaps the data represented by this descriptor with the data represented by |
|
2480 |
the specified descriptor. |
|
2481 |
||
2482 |
The lengths of both descriptors are also swapped to reflect the change. |
|
2483 |
||
2484 |
Note that each descriptor must be capable of accommodating the contents of |
|
2485 |
the other descriptor. |
|
2486 |
||
2487 |
Each descriptor must be capable of accommodating the contents of the other |
|
2488 |
descriptor. If the maximum length of either descriptor is smaller than the |
|
2489 |
length of the other descriptor, then the function raises a USER 11 panic. |
|
2490 |
||
2491 |
@param aDes The 16-bit modifiable descriptor whose data is to be swapped with |
|
2492 |
the data of this descriptor. |
|
2493 |
||
2494 |
@panic USER 11 if the maximum length of either descriptor is smaller than the |
|
2495 |
length of the other descriptor. |
|
2496 |
*/ |
|
2497 |
{ |
|
2498 |
||
2499 |
TInt l=Length(); |
|
2500 |
TInt r=aDes.Length(); |
|
2501 |
aDes.SetLength(l); |
|
2502 |
SetLength(r); |
|
2503 |
TInt s=Min(l,r); |
|
2504 |
l-=s; |
|
2505 |
r-=s; |
|
2506 |
TUint16 *pL=WPtr(); |
|
2507 |
TUint16 *pR=aDes.WPtr(); |
|
2508 |
while (s--) |
|
2509 |
{ |
|
2510 |
TChar a=(*pL); |
|
2511 |
*pL++=(*pR); |
|
2512 |
*pR++=(TUint16)a; |
|
2513 |
} |
|
2514 |
while (l--) |
|
2515 |
*pR++=(*pL++); |
|
2516 |
while (r--) |
|
2517 |
*pL++=(*pR++); |
|
2518 |
} |
|
2519 |
||
2520 |
#ifndef __DES16_MACHINE_CODED_HWORD__ |
|
2521 |
EXPORT_C void TDes16::Fill(TChar aChar) |
|
2522 |
/** |
|
2523 |
Fills the descriptor's data area with the specified character, replacing any |
|
2524 |
existing data. |
|
2525 |
||
2526 |
The descriptor is filled from the beginning up to its current length. The |
|
2527 |
descriptor's length does not change. It is not filled to its maximum length. |
|
2528 |
||
2529 |
@param aChar The fill character. |
|
2530 |
*/ |
|
2531 |
{ |
|
2532 |
||
2533 |
TUint16 *pB=WPtr(); |
|
2534 |
TUint16 *pE=pB+Length(); |
|
2535 |
while (pB<pE) |
|
2536 |
*pB++=(TUint16)aChar; |
|
2537 |
} |
|
2538 |
#endif |
|
2539 |
||
2540 |
EXPORT_C void TDes16::Fill(TChar aChar,TInt aLength) |
|
2541 |
/** |
|
2542 |
Fills the descriptor's data area with the specified character, replacing any |
|
2543 |
existing data. |
|
2544 |
||
2545 |
The descriptor is filled with the specified number of characters, |
|
2546 |
and its length is changed to reflect this. |
|
2547 |
||
2548 |
@param aChar The fill character. |
|
2549 |
@param aLength The new length of the descriptor and the number of fill characters |
|
2550 |
to be copied into it. |
|
2551 |
||
2552 |
@panic USER 11 if aLength is negative or is greater than the maximum length |
|
2553 |
of this descriptor. |
|
2554 |
*/ |
|
2555 |
{ |
|
2556 |
||
2557 |
SetLength(aLength); |
|
2558 |
Fill(aChar); |
|
2559 |
} |
|
2560 |
||
2561 |
EXPORT_C void TDes16::AppendFill(TChar aChar,TInt aLength) |
|
2562 |
/** |
|
2563 |
Appends and fills this descriptor with the specified character. |
|
2564 |
||
2565 |
The descriptor is appended with the specified number of characters. |
|
2566 |
and its length is changed to reflect this. |
|
2567 |
||
2568 |
@param aChar The fill character. |
|
2569 |
@param aLength The number of fill characters to be appended. |
|
2570 |
||
2571 |
@panic USER 11 if aLength is negative, or the resulting length of this |
|
2572 |
descriptor is greater than its maximum length. |
|
2573 |
*/ |
|
2574 |
{ |
|
2575 |
||
2576 |
TInt len=Length(); |
|
2577 |
TUint16 *pB=WPtr()+len; |
|
2578 |
SetLength(len+aLength); |
|
2579 |
TUint16 *pE=pB+aLength; |
|
2580 |
while (pB<pE) |
|
2581 |
*pB++=(TUint16)aChar; |
|
2582 |
} |
|
2583 |
||
2584 |
#ifndef __DES16_MACHINE_CODED_HWORD__ |
|
2585 |
EXPORT_C void TDes16::ZeroTerminate() |
|
2586 |
/** |
|
2587 |
Appends a zero terminator onto the end of this descriptor's data. |
|
2588 |
||
2589 |
The length of the descriptor is not changed. It must, however, be strictly less than |
|
2590 |
the descriptor's maximum length. |
|
2591 |
This condition guarantees that there is sufficient space for the zero terminator. |
|
2592 |
||
2593 |
@panic USER 11 if the descriptor's length is not strictly less than its |
|
2594 |
maximum length. |
|
2595 |
*/ |
|
2596 |
{ |
|
2597 |
||
2598 |
TInt len=Length(); |
|
2599 |
__ASSERT_ALWAYS(len<MaxLength(),Panic(ETDes16Overflow)); |
|
2600 |
WPtr()[len]=0; |
|
2601 |
} |
|
2602 |
||
2603 |
EXPORT_C const TUint16 *TDes16::PtrZ() |
|
2604 |
/** |
|
2605 |
Appends a zero terminator onto the end of this descriptor's data and returns |
|
2606 |
a pointer to the data. |
|
2607 |
||
2608 |
The length of the descriptor is not changed. It must be strictly less than |
|
2609 |
the descriptor's maximum length. |
|
2610 |
This condition guarantees that there is sufficient space for the |
|
2611 |
zero terminator. |
|
2612 |
||
2613 |
@return A pointer to the descriptor's zero terminated data. |
|
2614 |
||
2615 |
@panic USER 11 if the descriptor's length is not strictly less than its |
|
2616 |
maximum length. |
|
2617 |
*/ |
|
2618 |
{ |
|
2619 |
||
2620 |
ZeroTerminate(); |
|
2621 |
return(Ptr()); |
|
2622 |
} |
|
2623 |
#endif |
|
2624 |
||
2625 |
#ifndef __DES16_MACHINE_CODED__ |
|
2626 |
EXPORT_C void TDes16::Zero() |
|
2627 |
/** |
|
2628 |
Sets the length of the data to zero. |
|
2629 |
*/ |
|
2630 |
{ |
|
2631 |
||
2632 |
SetLength(0); |
|
2633 |
} |
|
2634 |
#endif |
|
2635 |
||
2636 |
#ifndef __DES16_MACHINE_CODED__ |
|
2637 |
EXPORT_C void TDes16::FillZ() |
|
2638 |
/** |
|
2639 |
Fills the descriptor's data area with binary zeroes, i.e.0x0000, replacing any |
|
2640 |
existing data. |
|
2641 |
||
2642 |
The descriptor is filled from the beginning up to its current length. The |
|
2643 |
descriptor's length does not change. It is not filled to its maximum length. |
|
2644 |
*/ |
|
2645 |
{ |
|
2646 |
||
2647 |
memclr(WPtr(),Length()*2); |
|
2648 |
} |
|
2649 |
#endif |
|
2650 |
||
2651 |
EXPORT_C void TDes16::FillZ(TInt aLength) |
|
2652 |
/** |
|
2653 |
Fills the descriptor's data area with binary zeroes, i.e. 0x0000, replacing any |
|
2654 |
existing data, and changes its length. |
|
2655 |
||
2656 |
The descriptor is filled with the specified number of binary zeroes. |
|
2657 |
The descriptor's length is changed to reflect this. |
|
2658 |
||
2659 |
@param aLength The new length of the descriptor and the number of binary zeroes |
|
2660 |
to be copied into it. |
|
2661 |
||
2662 |
@panic USER 11 if aLength is negative, or is greater than the maximum length |
|
2663 |
of this descriptor. |
|
2664 |
*/ |
|
2665 |
{ |
|
2666 |
||
2667 |
SetLength(aLength); |
|
2668 |
FillZ(); |
|
2669 |
} |
|
2670 |
||
2671 |
EXPORT_C void TDes16::Fold() |
|
2672 |
/** |
|
2673 |
Performs folding on the content of this descriptor. |
|
2674 |
||
2675 |
Note that folding is locale-independent behaviour. It is also important to |
|
2676 |
note that there can be no guarantee that folding is in any way culturally |
|
2677 |
appropriate, and should not be used when dealing with strings in natural |
|
2678 |
language. |
|
2679 |
*/ |
|
2680 |
{ |
|
2681 |
||
2682 |
TUint16 *pB=WPtr(); |
|
2683 |
TInt len=Length(); |
|
2684 |
while (len--) |
|
2685 |
{ |
|
2686 |
TCharF c(*pB); |
|
2687 |
*pB++=(TUint16)c; |
|
2688 |
} |
|
2689 |
} |
|
2690 |
||
2691 |
EXPORT_C void TDes16::Collate() |
|
2692 |
/** |
|
2693 |
Performs collation on the content of this descriptor. |
|
2694 |
*/ |
|
2695 |
{ |
|
2696 |
||
2697 |
TUint16 *pB=WPtr(); |
|
2698 |
TInt len=Length(); |
|
2699 |
while (len--) |
|
2700 |
{ |
|
2701 |
TChar c=User::Collate(*pB); |
|
2702 |
*pB++=(TUint16)c; |
|
2703 |
} |
|
2704 |
} |
|
2705 |
||
2706 |
EXPORT_C void TDes16::LowerCase() |
|
2707 |
/** |
|
2708 |
Converts the content of this descriptor to lower case. |
|
2709 |
||
2710 |
Conversion is implemented as appropriate to the current locale. |
|
2711 |
*/ |
|
2712 |
{ |
|
2713 |
||
2714 |
TUint16 *pB=WPtr(); |
|
2715 |
TInt len=Length(); |
|
2716 |
while (len--) |
|
2717 |
{ |
|
2718 |
TCharLC c(*pB); |
|
2719 |
*pB++=(TUint16)c; |
|
2720 |
} |
|
2721 |
} |
|
2722 |
||
2723 |
EXPORT_C void TDes16::UpperCase() |
|
2724 |
/** |
|
2725 |
Converts the content of this descriptor to upper case. |
|
2726 |
||
2727 |
Conversion is implemented as appropriate to the current locale. |
|
2728 |
*/ |
|
2729 |
{ |
|
2730 |
||
2731 |
TUint16 *pB=WPtr(); |
|
2732 |
TInt len=Length(); |
|
2733 |
while (len--) |
|
2734 |
{ |
|
2735 |
TCharUC c(*pB); |
|
2736 |
*pB++=(TUint16)c; |
|
2737 |
} |
|
2738 |
} |
|
2739 |
||
2740 |
EXPORT_C void TDes16::Capitalize() |
|
2741 |
/** |
|
2742 |
Capitalises the content of this descriptor. |
|
2743 |
||
2744 |
Capitalisation is implemented as appropriate to the current locale. |
|
2745 |
*/ |
|
2746 |
{ |
|
2747 |
||
2748 |
TUint16 *pB=WPtr(); |
|
2749 |
TInt len=Length(); |
|
2750 |
if (len--) |
|
2751 |
{ |
|
2752 |
*pB=(TUint16)User::TitleCase(*pB); |
|
2753 |
++pB; |
|
2754 |
while (len--) |
|
2755 |
{ |
|
2756 |
*pB=(TUint16)User::LowerCase(*pB); |
|
2757 |
++pB; |
|
2758 |
} |
|
2759 |
} |
|
2760 |
} |
|
2761 |
||
2762 |
EXPORT_C void TDes16::CopyF(const TDesC16 &aDes) |
|
2763 |
/** |
|
2764 |
Copies and folds data from the specified descriptor into this descriptor replacing |
|
2765 |
any existing data. |
|
2766 |
||
2767 |
The length of this descriptor is set to reflect the new |
|
2768 |
data. |
|
2769 |
||
2770 |
Note that folding is locale-independent behaviour. It is also important to |
|
2771 |
note that there can be no guarantee that folding is in any way culturally |
|
2772 |
appropriate, and should not be used when dealing with strings in natural |
|
2773 |
language. |
|
2774 |
||
2775 |
@param aDes A 16-bit non-modifiable descriptor. |
|
2776 |
||
2777 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
|
2778 |
this target descriptor. |
|
2779 |
*/ |
|
2780 |
{ |
|
2781 |
||
2782 |
TInt len=aDes.Length(); |
|
2783 |
SetLength(len); |
|
2784 |
const TUint16 *pS=aDes.Ptr(); |
|
2785 |
TUint16 *pT=WPtr(); |
|
2786 |
while (len--) |
|
2787 |
{ |
|
2788 |
TCharF c(*pS++); |
|
2789 |
*pT++=(TUint16)c; |
|
2790 |
} |
|
2791 |
} |
|
2792 |
||
2793 |
EXPORT_C void TDes16::CopyC(const TDesC16 &aDes) |
|
2794 |
/** |
|
2795 |
Copies and collates data from the specified descriptor |
|
2796 |
into this descriptor replacing any existing data. |
|
2797 |
||
2798 |
The length of this descriptor is set to reflect the new data. |
|
2799 |
||
2800 |
@param aDes A 16-bit non-modifiable descriptor. |
|
2801 |
||
2802 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
|
2803 |
this target descriptor. |
|
2804 |
*/ |
|
2805 |
{ |
|
2806 |
||
2807 |
TInt len=aDes.Length(); |
|
2808 |
SetLength(len); |
|
2809 |
const TUint16 *pS=aDes.Ptr(); |
|
2810 |
TUint16 *pT=WPtr(); |
|
2811 |
while (len--) |
|
2812 |
{ |
|
2813 |
TChar c=User::Collate(*pS++); |
|
2814 |
*pT++=(TUint16)c; |
|
2815 |
} |
|
2816 |
} |
|
2817 |
||
2818 |
EXPORT_C void TDes16::CopyLC(const TDesC16 &aDes) |
|
2819 |
/** |
|
2820 |
Copies text from the specified descriptor and converts it to lower case before |
|
2821 |
putting it into this descriptor, replacing any existing data. |
|
2822 |
||
2823 |
The length of this descriptor is set to reflect the new data. |
|
2824 |
||
2825 |
Conversion to lower case is implemented as appropriate to the current locale. |
|
2826 |
||
2827 |
@param aDes A 16-bit non modifiable descriptor. |
|
2828 |
||
2829 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
|
2830 |
this target descriptor. |
|
2831 |
*/ |
|
2832 |
{ |
|
2833 |
||
2834 |
TInt len=aDes.Length(); |
|
2835 |
SetLength(len); |
|
2836 |
const TUint16 *pS=aDes.Ptr(); |
|
2837 |
TUint16 *pT=WPtr(); |
|
2838 |
while (len--) |
|
2839 |
{ |
|
2840 |
TCharLC c(*pS++); |
|
2841 |
*pT++=(TUint16)c; |
|
2842 |
} |
|
2843 |
} |
|
2844 |
||
2845 |
EXPORT_C void TDes16::CopyUC(const TDesC16 &aDes) |
|
2846 |
/** |
|
2847 |
Copies text from the specified descriptor and converts it to upper case before |
|
2848 |
putting it into this descriptor, replacing any existing data. |
|
2849 |
||
2850 |
The length of this descriptor is set to reflect the new data. |
|
2851 |
||
2852 |
Conversion to upper case is implemented as appropriate to the current locale. |
|
2853 |
||
2854 |
@param aDes A 16-bit non modifiable descriptor. |
|
2855 |
||
2856 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
|
2857 |
this target descriptor. |
|
2858 |
*/ |
|
2859 |
{ |
|
2860 |
||
2861 |
TInt len=aDes.Length(); |
|
2862 |
SetLength(len); |
|
2863 |
const TUint16 *pS=aDes.Ptr(); |
|
2864 |
TUint16 *pT=WPtr(); |
|
2865 |
while (len--) |
|
2866 |
{ |
|
2867 |
TCharUC c(*pS++); |
|
2868 |
*pT++=(TUint16)c; |
|
2869 |
} |
|
2870 |
} |
|
2871 |
||
2872 |
EXPORT_C void TDes16::CopyCP(const TDesC16 &aDes) |
|
2873 |
/** |
|
2874 |
Copies text from the specified descriptor and capitalises it before putting |
|
2875 |
it into this descriptor, replacing any existing data. |
|
2876 |
||
2877 |
The length of this descriptor is set to reflect the new data. |
|
2878 |
||
2879 |
Capitalisation is implemented as appropriate to the current locale. |
|
2880 |
||
2881 |
@param aDes A 16-bit non-modifiable descriptor. |
|
2882 |
||
2883 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
|
2884 |
this target descriptor. |
|
2885 |
*/ |
|
2886 |
{ |
|
2887 |
||
2888 |
TInt len=aDes.Length(); |
|
2889 |
SetLength(len); |
|
2890 |
const TUint16 *pS=aDes.Ptr(); |
|
2891 |
TUint16 *pT=WPtr(); |
|
2892 |
if (len--) |
|
2893 |
{ |
|
2894 |
TChar c(*pS++); |
|
2895 |
#ifdef _UNICODE |
|
2896 |
c.TitleCase(); |
|
2897 |
#else |
|
2898 |
c.UpperCase(); |
|
2899 |
#endif |
|
2900 |
*pT++=(TUint16)c; |
|
2901 |
while (len--) |
|
2902 |
{ |
|
2903 |
TCharLC c=(*pS++); |
|
2904 |
*pT++=(TUint16)c; |
|
2905 |
} |
|
2906 |
} |
|
2907 |
} |
|
2908 |
||
2909 |
EXPORT_C void TDes16::Repeat(const TUint16 *aBuf,TInt aLength) |
|
2910 |
/** |
|
2911 |
Copies data with repetition into this descriptor, from a memory location |
|
2912 |
specified by pointer, replacing any existing data. |
|
2913 |
||
2914 |
Copying proceeds until this descriptor is filled up to its current length. |
|
2915 |
If it cannot contain a whole number of copies of the source data, then the |
|
2916 |
last copy is truncated. |
|
2917 |
||
2918 |
@param aBuf A pointer to data to be repeatedly copied. |
|
2919 |
@param aLength The length of data to be copied. |
|
2920 |
||
2921 |
@panic USER 17 if aLength is negative. |
|
2922 |
*/ |
|
2923 |
{ |
|
2924 |
||
2925 |
__ASSERT_ALWAYS(aLength>=0,Panic(ETDes16LengthNegative)); |
|
2926 |
__CHECK_ALIGNMENT(aBuf,ETDes16RepeatBufLength); |
|
2927 |
TUint16 *pB=WPtr(); |
|
2928 |
TInt len=Length(); |
|
2929 |
if (len && aLength) |
|
2930 |
{ |
|
2931 |
while (len) |
|
2932 |
{ |
|
2933 |
TInt i=Min(len,aLength); |
|
2934 |
pB=memCopy(pB,aBuf,i); |
|
2935 |
len-=i; |
|
2936 |
} |
|
2937 |
} |
|
2938 |
} |
|
2939 |
||
2940 |
EXPORT_C void TDes16::Repeat(const TDesC16 &aDes) |
|
2941 |
/** |
|
2942 |
Copies data with repetition into this descriptor, from another descriptor, |
|
2943 |
replacing any existing data. |
|
2944 |
||
2945 |
Copying proceeds until this descriptor is filled up to its current length. |
|
2946 |
If it cannot contain a whole number of copies of the source data, then the |
|
2947 |
last copy is truncated. |
|
2948 |
||
2949 |
@param aDes A 16-bit non modifiable descriptor whose data is to be repeatedly |
|
2950 |
copied. |
|
2951 |
*/ |
|
2952 |
{ |
|
2953 |
||
2954 |
Repeat(aDes.Ptr(),aDes.Length()); |
|
2955 |
} |
|
2956 |
||
2957 |
EXPORT_C void TDes16::Trim() |
|
2958 |
/** |
|
2959 |
Deletes leading and trailing whitespace characters from the descriptor's data. |
|
2960 |
||
2961 |
The length of the descriptor is reduced to reflect the loss of the whitespace characters. |
|
2962 |
||
2963 |
@see TDes16::TrimLeft() |
|
2964 |
@see TDes16::TrimRight() |
|
2965 |
*/ |
|
2966 |
{ |
|
2967 |
||
2968 |
TrimLeft(); |
|
2969 |
TrimRight(); |
|
2970 |
} |
|
2971 |
||
2972 |
EXPORT_C void TDes16::TrimAll() |
|
2973 |
/** |
|
2974 |
Deletes leading and trailing whitespace characters from the descriptor's data |
|
2975 |
and replaces each contiguous set of whitespace characters within the data by one |
|
2976 |
whitespace character. |
|
2977 |
||
2978 |
The length of the descriptor is reduced to reflect the loss of the whitespace |
|
2979 |
characters. |
|
2980 |
||
2981 |
@see TDes16::Trim() |
|
2982 |
*/ |
|
2983 |
{ |
|
2984 |
||
2985 |
TrimLeft(); |
|
2986 |
TrimRight(); |
|
2987 |
TUint16 *pBuf=(TUint16 *)Ptr(); |
|
2988 |
TUint16 *pSrc=pBuf; |
|
2989 |
TUint16 *pDst=pBuf; |
|
2990 |
TInt len=Length(); |
|
2991 |
TInt spaces=0; |
|
2992 |
while (len--) |
|
2993 |
{ |
|
2994 |
TChar c=*pSrc; |
|
2995 |
if (c.IsSpace()) |
|
2996 |
{ |
|
2997 |
if (spaces++==0) |
|
2998 |
{ |
|
2999 |
if (pDst!=pSrc) |
|
3000 |
*pDst=*pSrc; |
|
3001 |
pDst++; |
|
3002 |
} |
|
3003 |
} |
|
3004 |
else |
|
3005 |
{ |
|
3006 |
spaces=0; |
|
3007 |
if (pDst!=pSrc) |
|
3008 |
*pDst=*pSrc; |
|
3009 |
pDst++; |
|
3010 |
} |
|
3011 |
pSrc++; |
|
3012 |
} |
|
3013 |
Delete(pDst-pBuf, pSrc-pDst); |
|
3014 |
} |
|
3015 |
||
3016 |
EXPORT_C void TDes16::TrimLeft() |
|
3017 |
/** |
|
3018 |
Deletes leading whitespace characters from the descriptor's data. |
|
3019 |
||
3020 |
All whitespace characters up to, but not including the first |
|
3021 |
non-whitespace character, are deleted. |
|
3022 |
||
3023 |
The length of the descriptor is reduced to reflect the loss |
|
3024 |
of the whitespace characters. |
|
3025 |
*/ |
|
3026 |
{ |
|
3027 |
||
3028 |
const TUint16 *pBuf=Ptr(); |
|
3029 |
const TUint16 *pB=pBuf; |
|
3030 |
TInt len=Length(); |
|
3031 |
while (len--) |
|
3032 |
{ |
|
3033 |
TChar c=(*pB); |
|
3034 |
if (!c.IsSpace()) |
|
3035 |
break; |
|
3036 |
pB++; |
|
3037 |
} |
|
3038 |
Delete(0,pB-pBuf); |
|
3039 |
} |
|
3040 |
||
3041 |
EXPORT_C void TDes16::TrimRight() |
|
3042 |
/** |
|
3043 |
Deletes trailing whitespace characters from the descriptor's data. |
|
3044 |
||
3045 |
The process starts on the right hand side of the descriptor's data |
|
3046 |
and proceeds to the left. |
|
3047 |
||
3048 |
All whitespace characters up to, but not including the first non-whitespace character, |
|
3049 |
are deleted. |
|
3050 |
||
3051 |
The length of the descriptor is reduced to reflect the loss of the whitespace |
|
3052 |
characters. |
|
3053 |
*/ |
|
3054 |
{ |
|
3055 |
||
3056 |
TInt len=Length(); |
|
3057 |
if (len==0) |
|
3058 |
return; |
|
3059 |
const TUint16 *pB=Ptr()+len-1; |
|
3060 |
TInt s=len; |
|
3061 |
while (s) |
|
3062 |
{ |
|
3063 |
TChar c=(*pB--); |
|
3064 |
if (!c.IsSpace()) |
|
3065 |
break; |
|
3066 |
s--; |
|
3067 |
} |
|
3068 |
Delete(s,len-s); |
|
3069 |
} |
|
3070 |
||
3071 |
EXPORT_C void TDes16::Insert(TInt aPos,const TDesC16 &aDes) |
|
3072 |
/** |
|
3073 |
Inserts data into this descriptor. |
|
3074 |
||
3075 |
The length of this descriptor is changed to reflect the extra data. |
|
3076 |
||
3077 |
@param aPos The position within the data where insertion is to start. This |
|
3078 |
is an offset value; a zero value refers to the leftmost data |
|
3079 |
position. |
|
3080 |
||
3081 |
@param aDes A 16-bit non modifiable descriptor whose data is to be inserted. |
|
3082 |
||
3083 |
@panic USER 10 if aPos is negative or is greater than the length of this |
|
3084 |
descriptor. |
|
3085 |
@panic USER 11 if the resulting length of this descriptor is greater than its |
|
3086 |
maximum length. |
|
3087 |
*/ |
|
3088 |
{ |
|
3089 |
||
3090 |
TInt len=Length(); |
|
3091 |
__ASSERT_ALWAYS(aPos>=0 && aPos<=len,Panic(ETDes16PosOutOfRange)); |
|
3092 |
TInt s=aDes.Length(); |
|
3093 |
__ASSERT_ALWAYS((len+s)<=MaxLength(),Panic(ETDes16Overflow)); |
|
3094 |
TUint16 *pB=WPtr(); |
|
3095 |
memCopy(pB+aPos+s,pB+aPos,len-aPos); |
|
3096 |
memCopy(pB+aPos,aDes.Ptr(),aDes.Length()); |
|
3097 |
SetLength(len+s); |
|
3098 |
} |
|
3099 |
||
3100 |
EXPORT_C void TDes16::Delete(TInt aPos,TInt aLength) |
|
3101 |
/** |
|
3102 |
Deletes data from this descriptor. |
|
3103 |
||
3104 |
The length of this descriptor is changed to reflect the loss of data. |
|
3105 |
||
3106 |
@param aPos The position within the data where deletion is to start. This |
|
3107 |
is an offset value; a zero value refers to the leftmost data |
|
3108 |
position. |
|
3109 |
||
3110 |
@param aLength The length of data to be deleted. If necessary, the function |
|
3111 |
adjusts this value to ensure that no data beyond the end of |
|
3112 |
the descriptor data area is deleted. |
|
3113 |
||
3114 |
@panic USER 10 if aPos is negative or is greater than the length of this |
|
3115 |
descriptor. |
|
3116 |
*/ |
|
3117 |
{ |
|
3118 |
||
3119 |
TInt len=Length(); |
|
3120 |
__ASSERT_ALWAYS(aPos>=0 && aPos<=len,Panic(ETDes16PosOutOfRange)); |
|
3121 |
TInt d=Min(len-aPos,aLength); |
|
3122 |
TUint16 *pB=WPtr(); |
|
3123 |
memCopy(pB+aPos,pB+aPos+d,len-aPos-d); |
|
3124 |
SetLength(len-d); |
|
3125 |
} |
|
3126 |
||
3127 |
EXPORT_C void TDes16::Replace(TInt aPos,TInt aLength,const TDesC16 &aDes) |
|
3128 |
/** |
|
3129 |
Replaces data in this descriptor. |
|
3130 |
||
3131 |
The specified length can be different to the length of the replacement data. |
|
3132 |
The length of this descriptor changes to reflect the change of data. |
|
3133 |
||
3134 |
@param aPos The position within the data where replacement is to start. |
|
3135 |
This is an offset value; a zero value refers to the leftmost |
|
3136 |
data position. |
|
3137 |
||
3138 |
@param aLength The length of data to be replaced. |
|
3139 |
||
3140 |
@param aDes The source 16-bit non modifiable descriptor whose data is to |
|
3141 |
replace the target descriptor's data at aPos. |
|
3142 |
||
3143 |
@panic USER 8 if aLength is negative or the sum of aLength and aPos is |
|
3144 |
greater than the length of this descriptor. |
|
3145 |
||
3146 |
@panic USER 10 if aPos is negative or is greater than the length of this |
|
3147 |
descriptor. |
|
3148 |
||
3149 |
@panic USER 11 if the resulting length of this descriptor is greater than its |
|
3150 |
maximum length. |
|
3151 |
||
3152 |
@panic USER 16 if the length of the source descriptor aDes is negative or is |
|
3153 |
greater than the maximum length of this target descriptor, |
|
3154 |
*/ |
|
3155 |
{ |
|
3156 |
||
3157 |
TInt len=Length(); |
|
3158 |
__ASSERT_ALWAYS(aPos>=0 && aPos<=len,Panic(ETDes16PosOutOfRange)); |
|
3159 |
__ASSERT_ALWAYS(aLength>=0 && aPos+aLength<=len,Panic(ETDes16LengthOutOfRange)); |
|
3160 |
TInt s=aDes.Length(); |
|
3161 |
TInt maxlen=MaxLength(); |
|
3162 |
__ASSERT_ALWAYS(s>=0 && s<=maxlen,Panic(ETDes16RemoteLengthOutOfRange)); |
|
3163 |
__ASSERT_ALWAYS((len+s-aLength)<=maxlen,Panic(ETDes16Overflow)); |
|
3164 |
TUint16 *pB=WPtr(); |
|
3165 |
memCopy(pB+aPos+s,pB+aPos+aLength,len-aPos-aLength); |
|
3166 |
memCopy(pB+aPos,aDes.Ptr(),s); |
|
3167 |
SetLength(len+s-aLength); |
|
3168 |
} |
|
3169 |
||
3170 |
EXPORT_C void TDes16::Justify(const TDesC16 &aDes,TInt aWidth,TAlign anAlignment,TChar aFill) |
|
3171 |
/** |
|
3172 |
Copies data into this descriptor and justifies it, replacing any existing data. |
|
3173 |
||
3174 |
The length of this descriptor is set to reflect the new data. |
|
3175 |
||
3176 |
The target area is considered to be an area of specified width positioned at |
|
3177 |
the beginning of this descriptor's data area. Source data is copied into, and |
|
3178 |
aligned within this target area according to the specified alignment |
|
3179 |
instruction. |
|
3180 |
||
3181 |
If the length of the target area is larger than the length of the source, then |
|
3182 |
spare space within the target area is padded with the fill character. |
|
3183 |
||
3184 |
@param aDes A 16-bit non-modifiable descriptor containing the source data. |
|
3185 |
The length of the data to be copied is the smaller of: |
|
3186 |
the length of the source descriptor, and |
|
3187 |
the width of the target area (only if this is not the |
|
3188 |
explicit negative value KDefaultJustifyWidth). |
|
3189 |
||
3190 |
@param aWidth The width of the target area. If this has the specific |
|
3191 |
negative value KDefaultJustifyWidth, then the width is |
|
3192 |
re-set to the length of the data source. |
|
3193 |
||
3194 |
@param anAlignment The alignment of the data within the target area |
|
3195 |
||
3196 |
@param aFill The fill character used to pad the target area. |
|
3197 |
||
3198 |
@panic USER 11 if the resulting length of this descriptor is greater than |
|
3199 |
its maximum length or aWidth has a negative value other |
|
3200 |
than KDefaultJustifyWidth. |
|
3201 |
*/ |
|
3202 |
{ |
|
3203 |
||
3204 |
Zero(); |
|
3205 |
AppendJustify(aDes.Ptr(),aDes.Length(),aWidth,anAlignment,aFill); |
|
3206 |
} |
|
3207 |
||
3208 |
EXPORT_C void TDes16::AppendJustify(const TDesC16 &aDes,TInt aWidth,TAlign anAlignment,TChar aFill) |
|
3209 |
/** |
|
3210 |
Appends data onto the end of this descriptor's data and justifies it. |
|
3211 |
||
3212 |
The source of the appended data is an existing descriptor. |
|
3213 |
||
3214 |
The target area is considered to be an area of specified width, immediately |
|
3215 |
following this descriptor's existing data. Source data is copied into, and |
|
3216 |
aligned within this target area according to the specified alignment instruction. |
|
3217 |
||
3218 |
If the length of the target area is larger than the length of the source, |
|
3219 |
then spare space within the target area is padded with the fill character. |
|
3220 |
||
3221 |
@param aDes A 16-bit non-modifiable descriptor containing the source |
|
3222 |
data. The length of the data to be copied is the smaller of: |
|
3223 |
the length of the source descriptor, and |
|
3224 |
the width of the target area (only if this is not the |
|
3225 |
explicit negative value KDefaultJustifyWidth). |
|
3226 |
||
3227 |
@param aWidth The width of the target area. If this has the specific |
|
3228 |
negative value KDefaultJustifyWidth, then the width is |
|
3229 |
re-set to the length of the data source. |
|
3230 |
||
3231 |
@param anAlignment The alignment of the data within the target area. |
|
3232 |
||
3233 |
@param aFill The fill character used to pad the target area. |
|
3234 |
||
3235 |
@panic USER 11 if the resulting length of this descriptor is greater than |
|
3236 |
its maximum length or aWidth has a negative value other |
|
3237 |
than KDefaultJustifyWidth. |
|
3238 |
*/ |
|
3239 |
{ |
|
3240 |
||
3241 |
AppendJustify(aDes.Ptr(),aDes.Length(),aWidth,anAlignment,aFill); |
|
3242 |
} |
|
3243 |
||
3244 |
EXPORT_C void TDes16::AppendJustify(const TDesC16 &aDes,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill) |
|
3245 |
/** |
|
3246 |
Appends data onto the end of this descriptor's data and justifies it. |
|
3247 |
||
3248 |
The source of the appended data is an existing descriptor. |
|
3249 |
||
3250 |
The target area is considered to be an area of specified width, immediately |
|
3251 |
following this descriptor's existing data. Source data is copied into, and |
|
3252 |
aligned within this target area according to the specified alignment instruction. |
|
3253 |
||
3254 |
If the length of the target area is larger than the length of the source, |
|
3255 |
then spare space within the target area is padded with the fill character. |
|
3256 |
||
3257 |
@param aDes An 8-bit non-modifiable descriptor containing the source data. |
|
3258 |
||
3259 |
@param aLength The length of data to be copied from the source descriptor. |
|
3260 |
If this is greater than the width of the target area, then |
|
3261 |
the length of data copied is limited to the width. |
|
3262 |
The length of data to be copied must not be greater than |
|
3263 |
the length of the source descriptor. Note that this |
|
3264 |
condition is not automatically tested. |
|
3265 |
||
3266 |
@param aWidth The width of the target area. If this has the specific negative |
|
3267 |
value KDefaultJustifyWidth, then the width is |
|
3268 |
re-set to the length of the data source. |
|
3269 |
||
3270 |
@param anAlignment The alignment of the data within the target area. |
|
3271 |
||
3272 |
@param aFill The fill character used to pad the target area. |
|
3273 |
||
3274 |
@panic USER 11 if the resulting length of this descriptor is greater than |
|
3275 |
its maximum length or aWidth has a negative value other |
|
3276 |
than KDefaultJustifyWidth. |
|
3277 |
*/ |
|
3278 |
{ |
|
3279 |
||
3280 |
AppendJustify(aDes.Ptr(),aLength,aWidth,anAlignment,aFill); |
|
3281 |
} |
|
3282 |
||
3283 |
EXPORT_C void TDes16::AppendJustify(const TUint16 *aString,TInt aWidth,TAlign anAlignment,TChar aFill) |
|
3284 |
/** |
|
3285 |
Appends a zero terminated string onto the end of this descriptor's data and |
|
3286 |
justifies it. |
|
3287 |
||
3288 |
The zero terminator is not copied. |
|
3289 |
||
3290 |
The target area is considered to be an area of specified width, immediately |
|
3291 |
following this descriptor's existing data. Source data is copied into, and |
|
3292 |
aligned within, this target area according to the specified alignment instruction. |
|
3293 |
||
3294 |
If the length of the target area is larger than the length of the source, |
|
3295 |
then spare space within the target area is padded with the fill character. |
|
3296 |
||
3297 |
@param aString A pointer to a zero terminated string The length of the data |
|
3298 |
to be copied is the smaller of: the length of the string (excluding the zero |
|
3299 |
terminator), the width of the target area (only if this is not the explicit |
|
3300 |
negative value KDefaultJustifyWidth). |
|
3301 |
||
3302 |
@param aWidth The width of the target area. If this has the specific negative |
|
3303 |
value KDefaultJustifyWidth, then the width is re-set to the length of the |
|
3304 |
zero terminated string (excluding the zero terminator). |
|
3305 |
||
3306 |
@param anAlignment The alignment of the data within the target area. |
|
3307 |
||
3308 |
@param aFill The fill character used to pad the target area. |
|
3309 |
||
3310 |
@panic USER 11 if the resulting length of this descriptor is greater than |
|
3311 |
its maximum length or aWidth has a negative value other |
|
3312 |
than KDefaultJustifyWidth. |
|
3313 |
*/ |
|
3314 |
{ |
|
3315 |
||
3316 |
__CHECK_ALIGNMENT(aString,ETDes16AppendJustify1); |
|
3317 |
AppendJustify(aString,STRING_LENGTH_16(aString),aWidth,anAlignment,aFill); |
|
3318 |
} |
|
3319 |
||
3320 |
EXPORT_C void TDes16::AppendJustify(const TUint16 *aString,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill) |
|
3321 |
/** |
|
3322 |
Appends data onto the end of this descriptor's data and justifies it. |
|
3323 |
||
3324 |
The source of the appended data is a memory location. |
|
3325 |
||
3326 |
The target area is considered to be an area of specified width, immediately |
|
3327 |
following this descriptor's existing data. Source data is copied into, and |
|
3328 |
aligned within, this target area according to the specified alignment instruction. |
|
3329 |
||
3330 |
If the length of the target area is larger than the length of the source, |
|
3331 |
then spare space within the target area is padded with the fill character. |
|
3332 |
||
3333 |
@param aString A pointer to a source memory location. |
|
3334 |
||
3335 |
@param aLength The length of data to be copied. If this is greater than the |
|
3336 |
width of the target area, then the length of data copied is |
|
3337 |
limited to the width. |
|
3338 |
||
3339 |
@param aWidth The width of the target area. If this has the specific negative |
|
3340 |
value KDefaultJustifyWidth, then the width is |
|
3341 |
re-set to the length of the data source. |
|
3342 |
||
3343 |
@param anAlignment The alignment of the data within the target area. |
|
3344 |
||
3345 |
@param aFill The fill character used to pad the target area. |
|
3346 |
||
3347 |
@panic USER 11 if the resulting length of this descriptor is greater than |
|
3348 |
its maximum length or aWidth has a negative value other |
|
3349 |
than KDefaultJustifyWidth. |
|
3350 |
||
3351 |
@panic USER 17 if aLength is negative. |
|
3352 |
*/ |
|
3353 |
{ |
|
3354 |
||
3355 |
__ASSERT_ALWAYS(aLength>=0,Panic(ETDes16LengthNegative)); |
|
3356 |
__CHECK_ALIGNMENT(aString,ETDes16AppendJustify2); |
|
3357 |
if (aWidth==KDefaultJustifyWidth) |
|
3358 |
aWidth=aLength; |
|
3359 |
if (aLength>aWidth) |
|
3360 |
aLength=aWidth; |
|
3361 |
TInt offset=Length(); |
|
3362 |
AppendFill(aFill,aWidth); |
|
3363 |
TInt r=aWidth-aLength; |
|
3364 |
if (anAlignment==ECenter) |
|
3365 |
r>>=1; |
|
3366 |
else if (anAlignment==ELeft) |
|
3367 |
r=0; |
|
3368 |
memCopy(WPtr()+offset+r,aString,aLength); |
|
3369 |
} |
|
3370 |
||
3371 |
EXPORT_C void TDes16::NumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth) |
|
3372 |
/** |
|
3373 |
Converts the specified unsigned integer into a fixed width character |
|
3374 |
representation based on the specified number system and copies the conversion |
|
3375 |
into this descriptor, replacing any existing data. |
|
3376 |
||
3377 |
The length of this descriptor is set to reflect the new data. |
|
3378 |
||
3379 |
The function generates the exact number of specified characters, either padding |
|
3380 |
to the left with character zeroes or discarding low order characters as necessary. |
|
3381 |
||
3382 |
When a hexadecimal conversion is specified, hexadecimal characters are in |
|
3383 |
lower case. |
|
3384 |
||
3385 |
This function is equivalent to using Format() with parameters which specify: |
|
3386 |
||
3387 |
1. a fixed length target field |
|
3388 |
||
3389 |
2. padding with zero characters, for example "%08x". |
|
3390 |
||
3391 |
When this is the case, always use NumFixedWidth() in preference |
|
3392 |
to Format() as it is more efficient. |
|
3393 |
||
3394 |
@param aVal The unsigned integer value. |
|
3395 |
@param aRadix The number system representation for the unsigned integer. |
|
3396 |
@param aWidth The number of characters: to be used to contain the conversion, |
|
3397 |
to be copied into this descriptor. |
|
3398 |
*/ |
|
3399 |
{ |
|
3400 |
||
3401 |
Zero(); |
|
3402 |
AppendNumFixedWidth(aVal,aRadix,aWidth); |
|
3403 |
} |
|
3404 |
||
3405 |
EXPORT_C void TDes16::NumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth) |
|
3406 |
/** |
|
3407 |
Converts the specified unsigned integer into a fixed width character |
|
3408 |
representation based on the specified number system and copies the conversion |
|
3409 |
into this descriptor, replacing any existing data. |
|
3410 |
||
3411 |
The length of this descriptor is set to reflect the new data. |
|
3412 |
||
3413 |
The function generates the exact number of specified characters, either padding |
|
3414 |
to the left with character zeroes or discarding low order characters as |
|
3415 |
necessary. |
|
3416 |
||
3417 |
When a hexadecimal conversion is specified, hexadecimal characters are in |
|
3418 |
upper case. |
|
3419 |
||
3420 |
This function is equivalent to using Format() with parameters which specify: |
|
3421 |
||
3422 |
1. a fixed length target field |
|
3423 |
||
3424 |
2. padding with zero characters, for example "%08x". |
|
3425 |
||
3426 |
When this is the case, always use NumFixedWidthUC() in |
|
3427 |
preference to Format() as it is more efficient. |
|
3428 |
||
3429 |
@param aVal The unsigned integer value. |
|
3430 |
@param aRadix The number system representation for the unsigned integer. |
|
3431 |
@param aWidth The number of characters: to be used to contain the conversion, |
|
3432 |
to be copied into this descriptor. |
|
3433 |
||
3434 |
@see TDes16::Format() |
|
3435 |
*/ |
|
3436 |
{ |
|
3437 |
||
3438 |
Zero(); |
|
3439 |
AppendNumFixedWidthUC(aVal,aRadix,aWidth); |
|
3440 |
} |
|
3441 |
||
3442 |
EXPORT_C void TDes16::Num(TInt64 aVal) |
|
3443 |
/** |
|
3444 |
Converts the 64-bit signed integer into a decimal character representation |
|
3445 |
and copies the conversion into this descriptor, replacing any existing data. |
|
3446 |
||
3447 |
The length of this descriptor is set to reflect the new data. |
|
3448 |
||
3449 |
If the integer is negative, the character representation is prefixed by a |
|
3450 |
minus sign. |
|
3451 |
||
3452 |
@param aVal The 64-bit signed integer value. |
|
3453 |
*/ |
|
3454 |
{ |
|
3455 |
Zero(); |
|
3456 |
AppendNum(aVal); |
|
3457 |
} |
|
3458 |
||
3459 |
EXPORT_C void TDes16::Num(TUint64 aVal, TRadix aRadix) |
|
3460 |
/** |
|
3461 |
Converts the specified 64 bit unsigned integer into a character representation |
|
3462 |
based on the specified number system and copies the conversion into this |
|
3463 |
descriptor, replacing any existing data. |
|
3464 |
||
3465 |
The length of this descriptor is set to reflect the new data. |
|
3466 |
||
3467 |
When a hexadecimal conversion is specified, hexadecimal characters are in |
|
3468 |
lower case. |
|
3469 |
||
3470 |
@param aVal The 64 bit integer value. This is treated as an unsigned |
|
3471 |
value for all builds. |
|
3472 |
@param aRadix The number system representation for the 64 bit integer. |
|
3473 |
*/ |
|
3474 |
{ |
|
3475 |
||
3476 |
Zero(); |
|
3477 |
AppendNum(aVal,aRadix); |
|
3478 |
} |
|
3479 |
||
3480 |
EXPORT_C void TDes16::NumUC(TUint64 aVal, TRadix aRadix) |
|
3481 |
/** |
|
3482 |
Converts the specified 64 bit unsigned integer into a character representation |
|
3483 |
based on the specified number system and copies the conversion into this |
|
3484 |
descriptor, replacing any existing data. |
|
3485 |
||
3486 |
The length of this descriptor is set to reflect the new data. |
|
3487 |
||
3488 |
When a hexadecimal conversion is specified, hexadecimal characters are in |
|
3489 |
upper case. |
|
3490 |
||
3491 |
@param aVal The 64 bit integer value. This is always treated as an unsigned |
|
3492 |
value for all builds. |
|
3493 |
@param aRadix The number system representation for the 64 bit integer. If no |
|
3494 |
explicit value is specified, then EDecimal is the default. |
|
3495 |
*/ |
|
3496 |
{ |
|
3497 |
||
3498 |
Zero(); |
|
3499 |
AppendNumUC(aVal,aRadix); |
|
3500 |
} |
|
3501 |
||
3502 |
void TDes16::DoPadAppendNum(TInt l, TInt aW, const TUint8* p) |
|
3503 |
{ |
|
3504 |
__ASSERT_DEBUG( ((l|(TInt)p)&1)==0, Panic(EDes16PadAppendBadAlign)); |
|
3505 |
l>>=1; |
|
3506 |
if (aW<=0) |
|
3507 |
{ |
|
3508 |
Append((const TUint16*)p, l); |
|
3509 |
return; |
|
3510 |
} |
|
3511 |
TInt l0 = Length(); |
|
3512 |
SetLength(l0 + aW); |
|
3513 |
TUint16* d = WPtr() + l0; |
|
3514 |
for (; aW>l; --aW) *d++ = (TUint16)'0'; |
|
3515 |
memcpy(d, p, aW*2); |
|
3516 |
} |
|
3517 |
||
3518 |
EXPORT_C void TDes16::AppendNumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth) |
|
3519 |
/** |
|
3520 |
Converts the specified unsigned integer into a fixed width character |
|
3521 |
representation based on the specified number system and appends the conversion |
|
3522 |
onto the end of this descriptor's data. |
|
3523 |
||
3524 |
The length of this descriptor is incremented to reflect the new content. |
|
3525 |
||
3526 |
The function generates the exact number of specified characters, either padding |
|
3527 |
to the left with character zeroes or discarding low order characters as |
|
3528 |
necessary. |
|
3529 |
||
3530 |
When a hexadecimal conversion is specified, hexadecimal characters are in |
|
3531 |
lower case. |
|
3532 |
||
3533 |
@param aVal The unsigned integer value. |
|
3534 |
@param aRadix The number system representation for the unsigned integer. |
|
3535 |
@param aWidth The number of characters to be used to contain the conversion, |
|
3536 |
and to be appended to this descriptor. |
|
3537 |
*/ |
|
3538 |
{ |
|
3539 |
||
3540 |
TBuf16<32> buf; |
|
3541 |
buf.Num(aVal,aRadix); |
|
3542 |
if (buf.Length()>=aWidth) |
|
3543 |
Append(buf.Left(aWidth)); |
|
3544 |
else |
|
3545 |
{ |
|
3546 |
TInt i=aWidth-buf.Length(); |
|
3547 |
while(i--) |
|
3548 |
Append(TChar('0')); |
|
3549 |
Append(buf); |
|
3550 |
} |
|
3551 |
} |
|
3552 |
||
3553 |
#ifndef __DES16_MACHINE_CODED__ |
|
3554 |
EXPORT_C TPtr16 TDes16::LeftTPtr(TInt aLength) const |
|
3555 |
/** |
|
3556 |
Extracts the leftmost part of the data. |
|
3557 |
||
3558 |
The function does not cut or remove any data but constructs a modifiable pointer |
|
3559 |
descriptor to represent the leftmost part of the data. |
|
3560 |
||
3561 |
@param aLength The length of the data to be extracted. If this value is |
|
3562 |
greater than the length of the descriptor, the function |
|
3563 |
extracts the whole of the descriptor. |
|
3564 |
||
3565 |
@return The 16-bit modifiable pointer descriptor representing the leftmost part |
|
3566 |
of the data. |
|
3567 |
||
3568 |
@panic USER 10 if aLength is negative. |
|
3569 |
*/ |
|
3570 |
{ |
|
3571 |
||
3572 |
__ASSERT_ALWAYS(aLength>=0,Panic(ETDes16PosOutOfRange)); |
|
3573 |
TInt len = Min(aLength,Length()); |
|
3574 |
return(TPtr16((TUint16*)Ptr(),len,len)); |
|
3575 |
} |
|
3576 |
||
3577 |
EXPORT_C TPtr16 TDes16::RightTPtr(TInt aLength) const |
|
3578 |
/** |
|
3579 |
Extracts the rightmost part of the data. |
|
3580 |
||
3581 |
The function does not cut or remove any data but constructs a modifiable pointer |
|
3582 |
descriptor to represent the rightmost part of the data. |
|
3583 |
||
3584 |
@param aLength The length of data to be extracted. If this value |
|
3585 |
is greater than the length of the descriptor, the function |
|
3586 |
extracts the whole of the descriptor. |
|
3587 |
||
3588 |
@return The 16-bit modifiable pointer descriptor representing the rightmost part |
|
3589 |
of the data. |
|
3590 |
||
3591 |
@panic USER 10 if aLength is negative. |
|
3592 |
*/ |
|
3593 |
{ |
|
3594 |
||
3595 |
__ASSERT_ALWAYS(aLength>=0,Panic(ETDes16PosOutOfRange)); |
|
3596 |
TInt len=Length(); |
|
3597 |
if (aLength>len) |
|
3598 |
aLength=len; |
|
3599 |
return(TPtr16((TUint16*)Ptr()+len-aLength,aLength,aLength)); |
|
3600 |
} |
|
3601 |
||
3602 |
EXPORT_C TPtr16 TDes16::MidTPtr(TInt aPos) const |
|
3603 |
/** |
|
3604 |
Extracts a portion of the data. |
|
3605 |
||
3606 |
The function does not cut or remove any data but constructs a modifiable pointer |
|
3607 |
descriptor to represent the defined portion. |
|
3608 |
||
3609 |
The portion is identified by its starting position and by the length of the |
|
3610 |
remainder of the data starting from the specified position. |
|
3611 |
||
3612 |
@param aPos The starting position of the data to be extracted. This is an |
|
3613 |
offset value; a zero value refers to the leftmost data position. |
|
3614 |
||
3615 |
@return The 16-bit modifiable pointer descriptor representing the specified |
|
3616 |
portion of the data. |
|
3617 |
||
3618 |
@panic USER 10 if aPos is negative or aPos is greater than the |
|
3619 |
length of the descriptor. |
|
3620 |
*/ |
|
3621 |
{ |
|
3622 |
||
3623 |
TInt len=Length(); |
|
3624 |
__ASSERT_ALWAYS(aPos>=0 && aPos<=len,Panic(ETDes16PosOutOfRange)); |
|
3625 |
return(TPtr16((TUint16*)Ptr()+aPos,len-aPos,len-aPos)); |
|
3626 |
} |
|
3627 |
||
3628 |
EXPORT_C TPtr16 TDes16::MidTPtr(TInt aPos,TInt aLength) const |
|
3629 |
/** |
|
3630 |
Extracts a portion of the data. |
|
3631 |
||
3632 |
The function does not cut or remove any data but constructs a modifiable pointer |
|
3633 |
descriptor to represent the defined portion. |
|
3634 |
||
3635 |
The portion is identified by its starting position and by its length. |
|
3636 |
||
3637 |
@param aPos The starting position of the data to be extracted. This is an |
|
3638 |
offset value; a zero value refers to the leftmost data position. |
|
3639 |
@param aLength The length of data to be extracted. |
|
3640 |
||
3641 |
@return The 16-bit modifiable pointer descriptor representing the specified |
|
3642 |
portion of the data. |
|
3643 |
||
3644 |
@panic USER 10 if aPos is negative or aPos plus aLength is greater than the |
|
3645 |
length of the descriptor. |
|
3646 |
*/ |
|
3647 |
{ |
|
3648 |
||
3649 |
__ASSERT_ALWAYS(aPos>=0 && (aPos+aLength)<=Length(),Panic(ETDes16PosOutOfRange)); |
|
3650 |
return(TPtr16((TUint16*)Ptr()+aPos,aLength,aLength)); |
|
3651 |
} |
|
3652 |
#endif |
|
3653 |
||
3654 |
EXPORT_C void TDes16::AppendNumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth) |
|
3655 |
/** |
|
3656 |
Converts the specified unsigned integer into a fixed width character |
|
3657 |
representation based on the specified number system and appends the conversion |
|
3658 |
onto the end of this descriptor's data. |
|
3659 |
||
3660 |
The length of this descriptor is incremented to reflect the new content. |
|
3661 |
||
3662 |
The function generates the exact number of specified characters, either |
|
3663 |
padding to the left with character zeroes or discarding low order characters |
|
3664 |
as necessary. |
|
3665 |
||
3666 |
When a hexadecimal conversion is specified, hexadecimal characters are in |
|
3667 |
upper case. |
|
3668 |
||
3669 |
@param aVal The unsigned integer value. |
|
3670 |
@param aRadix The number system representation for the unsigned integer. |
|
3671 |
@param aWidth The number of characters: to be used to contain the conversion, |
|
3672 |
to be appended to this descriptor. |
|
3673 |
*/ |
|
3674 |
{ |
|
3675 |
||
3676 |
TBuf16<32> buf; |
|
3677 |
buf.NumUC(aVal,aRadix); |
|
3678 |
if (buf.Length()>=aWidth) |
|
3679 |
Append(buf.Left(aWidth)); |
|
3680 |
else |
|
3681 |
{ |
|
3682 |
TInt i=aWidth-buf.Length(); |
|
3683 |
while(i--) |
|
3684 |
Append(TChar('0')); |
|
3685 |
Append(buf); |
|
3686 |
} |
|
3687 |
} |
|
3688 |
||
3689 |
EXPORT_C void TDes16::AppendNum(TInt64 aVal) |
|
3690 |
/** |
|
3691 |
Converts the 64-bit signed integer into a decimal character representation |
|
3692 |
and appends the conversion onto the end of this descriptor's data. |
|
3693 |
||
3694 |
The length of this descriptor is incremented to reflect the new content. |
|
3695 |
||
3696 |
If the integer is negative, the character representation is prefixed by a |
|
3697 |
minus sign. |
|
3698 |
||
3699 |
@param aVal The 64-bit signed integer value. |
|
3700 |
*/ |
|
3701 |
{ |
|
3702 |
||
3703 |
if (aVal<0) |
|
3704 |
{ |
|
3705 |
Append('-'); |
|
3706 |
aVal=-aVal; |
|
3707 |
} |
|
3708 |
AppendNum(static_cast<TUint64>(aVal), EDecimal); |
|
3709 |
} |
|
3710 |
||
3711 |
void TDes16::DoAppendNum(TUint64 aVal, TRadix aRadix, TUint aA, TInt aW) |
|
3712 |
// |
|
3713 |
// Convert a TUint64 into the descriptor. |
|
3714 |
// |
|
3715 |
{ |
|
3716 |
||
3717 |
TUint16 buf[APPEND_BUF_SIZE_64]; |
|
3718 |
TUint8* p = (TUint8*)(buf + APPEND_BUF_SIZE_64); |
|
3719 |
TInt l = __DoConvertNum(aVal, aRadix, aA|256, p); |
|
3720 |
// coverity[overrun-local] |
|
3721 |
DoPadAppendNum(l, aW, p); |
|
3722 |
} |
|
3723 |
||
3724 |
EXPORT_C void TDes16::AppendNum(TUint64 aVal, TRadix aRadix) |
|
3725 |
/** |
|
3726 |
Converts the specified 64 bit integer into a character representation |
|
3727 |
based on the specified number system and appends the conversion onto the end |
|
3728 |
of this descriptor's data. |
|
3729 |
||
3730 |
The length of this descriptor is incremented to reflect the new content. |
|
3731 |
||
3732 |
When a hexadecimal conversion is specified, hexadecimal characters are in |
|
3733 |
lower case. |
|
3734 |
||
3735 |
@param aVal The 64 bit integer value. This is always treated as an unsigned |
|
3736 |
value. |
|
3737 |
@param aRadix The number system representation for the 64 bit integer. |
|
3738 |
*/ |
|
3739 |
{ |
|
3740 |
DoAppendNum(aVal, aRadix, 'a', 0); |
|
3741 |
} |
|
3742 |
||
3743 |
EXPORT_C void TDes16::AppendNumUC(TUint64 aVal,TRadix aRadix) |
|
3744 |
/** |
|
3745 |
Converts the specified 64 bit integer into a character representation |
|
3746 |
based on the specified number system and appends the conversion onto the end |
|
3747 |
of this descriptor's data. |
|
3748 |
||
3749 |
The length of this descriptor is incremented to reflect the new content. |
|
3750 |
||
3751 |
When a hexadecimal conversion is specified, hexadecimal characters are in |
|
3752 |
upper case. |
|
3753 |
||
3754 |
@param aVal The 64 bit integer value. This is always treated as an unsigned |
|
3755 |
value. |
|
3756 |
@param aRadix The number system representation for the 64 bit integer. If no |
|
3757 |
explicit value is specified, then EDecimal is the default. |
|
3758 |
*/ |
|
3759 |
||
3760 |
{ |
|
3761 |
DoAppendNum(aVal, aRadix, 'A', 0); |
|
3762 |
} |
|
3763 |
||
3764 |
EXPORT_C void TDes16::Format(TRefByValue<const TDesC16> aFmt,...) |
|
3765 |
/** |
|
3766 |
Formats and copies text into this descriptor, replacing any existing data. |
|
3767 |
||
3768 |
The length of this descriptor is set to reflect the new data. |
|
3769 |
||
3770 |
The function takes a format string and a variable number of arguments. |
|
3771 |
The format string contains literal text embedded with directives for converting |
|
3772 |
the trailing list of arguments into text. |
|
3773 |
||
3774 |
The embedded directives are character sequences prefixed with the '%' character. |
|
3775 |
The literal text is simply copied into this descriptor unaltered while |
|
3776 |
the '%' directives are used to convert successive arguments from the |
|
3777 |
trailing list. |
|
3778 |
||
3779 |
The resulting stream of literal text and converted arguments is copied into |
|
3780 |
this descriptor. |
|
3781 |
||
3782 |
The syntax of the embedded directives follows one of four general patterns. |
|
3783 |
||
3784 |
Note that formatting of single numerical values can be achieved more |
|
3785 |
conveniently using the Num() and NumUC() member functions of this class. |
|
3786 |
||
3787 |
The full description of the syntax of a format string cannot be included here. |
|
3788 |
For full details, navigate to the Symbian OS guide, and follow the hierarchy of links: |
|
3789 |
||
3790 |
@code |
|
3791 |
Symbian OS Guide |
|
3792 |
Base |
|
3793 |
Using User Library (E32) |
|
3794 |
Buffers and Strings |
|
3795 |
Using Descriptors |
|
3796 |
How to Use Descriptors |
|
3797 |
Format string syntax |
|
3798 |
@endcode |
|
3799 |
||
3800 |
@param aFmt The descriptor containing the format string. |
|
3801 |
The TRefByValue class provides a constructor which takes a |
|
3802 |
TDesC8 type. |
|
3803 |
||
3804 |
@param ... A variable number of arguments to be converted to text as |
|
3805 |
dictated by the format string. |
|
3806 |
||
3807 |
@panic USER 11 if the resulting length of text in this descriptor exceeds |
|
3808 |
the descriptor's maximum length. |
|
3809 |
@panic USER 12 if the format string has incorrect syntax. |
|
3810 |
||
3811 |
@see TDes16::Num() |
|
3812 |
@see TDes16::NumUC() |
|
3813 |
*/ |
|
3814 |
{ |
|
3815 |
||
3816 |
VA_LIST list; |
|
3817 |
VA_START(list,aFmt); |
|
3818 |
// coverity[uninit_use_in_call] |
|
3819 |
FormatList(aFmt,list); |
|
3820 |
} |
|
3821 |
||
3822 |
EXPORT_C void TDes16::FormatList(const TDesC16 &aFmt,VA_LIST aList) |
|
3823 |
/** |
|
3824 |
Formats and copies text into this descriptor, replacing any existing data. |
|
3825 |
||
3826 |
The length of this descriptor is set to reflect the new data. |
|
3827 |
||
3828 |
The behaviour of this function is the same as Format(). In practice, it is |
|
3829 |
better and easier to use Format(), passing a variable number of arguments |
|
3830 |
as required by the format string. |
|
3831 |
||
3832 |
@param aFmt The descriptor containing the format string. |
|
3833 |
@param aList A pointer to an argument list. |
|
3834 |
||
3835 |
@see TDes16::Format() |
|
3836 |
@see VA_LIST |
|
3837 |
*/ |
|
3838 |
{ |
|
3839 |
||
3840 |
Zero(); |
|
3841 |
AppendFormatList(aFmt,aList); |
|
3842 |
} |
|
3843 |
||
3844 |
EXPORT_C void TDes16::AppendFormat(TRefByValue<const TDesC16> aFmt,TDes16Overflow *aOverflowHandler,...) |
|
3845 |
/** |
|
3846 |
Formats and appends text onto the end of this descriptor's data. |
|
3847 |
||
3848 |
The length of this descriptor is incremented to reflect the new content. |
|
3849 |
||
3850 |
The function takes a format string and a variable number of arguments. |
|
3851 |
The format string contains literal text, embedded with directives, |
|
3852 |
for converting the trailing list of arguments into text. |
|
3853 |
||
3854 |
The embedded directives are character sequences prefixed with the '%' character. |
|
3855 |
The literal text is simply copied into this descriptor unaltered while |
|
3856 |
the '%' directives are used to convert successive arguments from the |
|
3857 |
trailing list. See the description of the Format() function. |
|
3858 |
||
3859 |
Literal text is appended on a character by character basis. |
|
3860 |
If it results in the length of this descriptor exceeding its maximum length, |
|
3861 |
then the function: |
|
3862 |
||
3863 |
1. calls the Overflow() member function of the overflow handler, if an overflow |
|
3864 |
handler is supplied |
|
3865 |
2 raises a USER 11 panic, if no overflow handler is supplied. |
|
3866 |
||
3867 |
As much literal text as possible will have been copied into this descriptor |
|
3868 |
and this descriptor will have reached its maximum length. |
|
3869 |
||
3870 |
Text converted from a trailing argument is appended as a complete string. |
|
3871 |
If an attempt to append this string fails because the resulting length |
|
3872 |
of this descriptor would exceed its maximum length, then the function: |
|
3873 |
||
3874 |
1. calls the Overflow() member function of the overflow handler, if an overflow |
|
3875 |
handler is supplied |
|
3876 |
||
3877 |
2 raises a USER 11 panic, if no overflow handler is supplied. |
|
3878 |
||
3879 |
None of the generated text is appended and length of this descriptor |
|
3880 |
may be less than the maximum. |
|
3881 |
||
3882 |
@param aFmt The 16-bit non-modifiable descriptor containing the |
|
3883 |
format string. The TRefByValue class provides a |
|
3884 |
constructor which takes a TDesC16 type. |
|
3885 |
||
3886 |
@param aOverflowHandler A pointer to the overflow handler. |
|
3887 |
||
3888 |
@param ... A variable number of arguments to be converted to text |
|
3889 |
as dictated by the format string. |
|
3890 |
||
3891 |
@panic USER 11 if the length of the descriptor exceeds its maximum length and |
|
3892 |
no overflow handler has been supplied. |
|
3893 |
@panic USER 12 if the format string has incorrect syntax. |
|
3894 |
||
3895 |
@see TDes16::Format() |
|
3896 |
@see TDes16Overflow::Overflow() |
|
3897 |
*/ |
|
3898 |
{ |
|
3899 |
||
3900 |
VA_LIST list; |
|
3901 |
VA_START(list, aOverflowHandler); |
|
3902 |
// coverity[uninit_use_in_call] |
|
3903 |
AppendFormatList(aFmt,list,aOverflowHandler); |
|
3904 |
} |
|
3905 |
||
3906 |
EXPORT_C void TDes16::AppendFormat(TRefByValue<const TDesC16> aFmt,...) |
|
3907 |
/** |
|
3908 |
Formats and appends text onto the end of this descriptor's data. |
|
3909 |
||
3910 |
The length of this descriptor is incremented to reflect the new content. |
|
3911 |
||
3912 |
The function takes a format string and a variable number of arguments. |
|
3913 |
The format string contains literal text, embedded with directives, |
|
3914 |
for converting the trailing list of arguments into text. |
|
3915 |
||
3916 |
The embedded directives are character sequences prefixed with the '%' character. |
|
3917 |
The literal text is simply copied into this descriptor unaltered while |
|
3918 |
the '%' directives are used to convert successive arguments from the |
|
3919 |
trailing list. See the description of the Format() function. |
|
3920 |
||
3921 |
Literal text is appended on a character by character basis. |
|
3922 |
||
3923 |
Text converted from a trailing argument is appended as a complete string. |
|
3924 |
||
3925 |
@param aFmt The 16-bit non-modifiable descriptor containing the |
|
3926 |
format string. The TRefByValue class provides a |
|
3927 |
constructor which takes a TDesC16 type. |
|
3928 |
||
3929 |
@param ... A variable number of arguments to be converted to text |
|
3930 |
as dictated by the format string. |
|
3931 |
||
3932 |
@panic USER 11 if the resulting length of text in this descriptor exceeds |
|
3933 |
the descriptor's maximum length. |
|
3934 |
@panic USER 12 if the format string has incorrect syntax. |
|
3935 |
||
3936 |
@see TDes16::Format() |
|
3937 |
*/ |
|
3938 |
{ |
|
3939 |
||
3940 |
VA_LIST list; |
|
3941 |
VA_START(list,aFmt); |
|
3942 |
AppendFormatList(aFmt,list); |
|
3943 |
} |
|
3944 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3945 |
EXPORT_C void TDes16::Append2(TChar aChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3946 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3947 |
The surrogate aware version of Append(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3948 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3949 |
Appends data onto the end of this descriptor's data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3950 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3951 |
The length of this descriptor is incremented to reflect the new content. The |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3952 |
length will be increased by 1 if aChar is inside BMP or 2 if aChar is outside |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3953 |
BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3954 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3955 |
@param aChar A single character to be appended. Can be inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3956 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3957 |
@panic USER 11 if the resulting new length of this descriptor is greater than |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3958 |
its maximum length. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3959 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3960 |
@panic USER 217 if corrupt surrogate found in aChar. This functions will not |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3961 |
validate already existing surrogate in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3962 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3963 |
@see TDes16::Append() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3964 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3965 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3966 |
__ASSERT_ALWAYS(TChar::IsSupplementary(aChar) || !TChar::IsSurrogate((TText16)aChar), Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3967 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3968 |
TInt len = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3969 |
TUint16 *pB = WPtr() + len; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3970 |
if (TChar::IsSupplementary(aChar)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3971 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3972 |
SetLength(len + 2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3973 |
*pB++ = TChar::GetHighSurrogate(aChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3974 |
*pB = TChar::GetLowSurrogate(aChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3975 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3976 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3977 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3978 |
SetLength(len + 1); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3979 |
*pB = (TText16)aChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3980 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3981 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3982 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3983 |
EXPORT_C void TDes16::Fill2(TChar aChar) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3984 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3985 |
The surrogate aware version of Fill(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3986 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3987 |
Fills the descriptor's data area with the specified character, replacing any |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3988 |
existing data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3989 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3990 |
The descriptor is filled from the beginning up to its current length. The |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3991 |
descriptor's length does not change. It is not filled to its maximum length. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3992 |
If aChar is supplementary character, and available space to fill is odd in |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3993 |
16-bit unit, then the last 16-bit unit will be left unchanged, and the length |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3994 |
will keep unchanged. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3995 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3996 |
@param aChar The fill character. Can be inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3997 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3998 |
@see TDes16::Fill() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3999 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4000 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4001 |
TUint16 *pB = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4002 |
TUint16 *pE = pB + Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4003 |
if (!TChar::IsSupplementary(aChar)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4004 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4005 |
while (pB < pE) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4006 |
*pB++ = (TUint16)aChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4007 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4008 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4009 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4010 |
while (pB < pE - 1) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4011 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4012 |
*pB++ = TChar::GetHighSurrogate(aChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4013 |
*pB++ = TChar::GetLowSurrogate(aChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4014 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4015 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4016 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4017 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4018 |
EXPORT_C void TDes16::Fill2(TChar aChar, TInt aLength) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4019 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4020 |
The surrogate aware version of Fill(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4021 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4022 |
Fills the descriptor's data area with the specified character, replacing any |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4023 |
existing data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4024 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4025 |
The descriptor is filled with the specified number of characters, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4026 |
and its length is changed to reflect this. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4027 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4028 |
If aChar is supplementary character, and available space to fill is odd in |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4029 |
16-bit unit, then the last 16-bit unit will be left unchanged. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4030 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4031 |
@param aChar The fill character. Can be inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4032 |
@param aLength The new length of the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4033 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4034 |
@panic USER 11 if aLength is negative or is greater than the maximum length |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4035 |
of this descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4036 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4037 |
@panic USER 217 if corrupt surrogate found in aChar. These functions will not |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4038 |
validate already existing surrogate in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4039 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4040 |
@see TDes16::Fill() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4041 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4042 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4043 |
__ASSERT_ALWAYS(TChar::IsSupplementary(aChar) || !TChar::IsSurrogate((TText16)aChar), Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4044 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4045 |
SetLength(aLength); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4046 |
Fill2(aChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4047 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4048 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4049 |
EXPORT_C void TDes16::AppendFill2(TChar aChar, TInt aLength) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4050 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4051 |
The surrogate aware version of AppendFill(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4052 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4053 |
Appends and fills this descriptor with the specified character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4054 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4055 |
The descriptor is appended with the specified number of characters, and its |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4056 |
length is changed to reflect this. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4057 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4058 |
If aChar is supplementary character, and available space to fill is odd in |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4059 |
16-bit unit, then the last 16-bit unit will be left unchanged. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4060 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4061 |
@param aChar The fill character. Can be inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4062 |
@param aLength The length of additional space to append into. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4063 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4064 |
@panic USER 11 if aLength is negative, or the resulting length of this |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4065 |
descriptor is greater than its maximum length. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4066 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4067 |
@panic USER 217 if corrupt surrogate found in aChar. These functions will not |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4068 |
validate already existing surrogate in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4069 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4070 |
@see TDes16::AppendFill() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4071 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4072 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4073 |
__ASSERT_ALWAYS(TChar::IsSupplementary(aChar) || !TChar::IsSurrogate((TText16)aChar), Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4074 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4075 |
TInt len=Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4076 |
TUint16 *pB=WPtr()+len; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4077 |
SetLength(len+aLength); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4078 |
TUint16 *pE=pB+aLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4079 |
if (!TChar::IsSupplementary(aChar)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4080 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4081 |
while (pB < pE) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4082 |
*pB++ = (TUint16)aChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4083 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4084 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4085 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4086 |
while (pB < pE - 1) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4087 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4088 |
*pB++ = TChar::GetHighSurrogate(aChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4089 |
*pB++ = TChar::GetLowSurrogate(aChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4090 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4091 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4092 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4093 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4094 |
EXPORT_C void TDes16::Justify2(const TDesC16 &aDes, TInt aWidth, TAlign anAlignment, TChar aFill) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4095 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4096 |
The surrogate aware version of Justify(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4097 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4098 |
Copies data into this descriptor and justifies it, replacing any existing data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4099 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4100 |
The length of this descriptor is set to reflect the new data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4101 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4102 |
The target area is considered to be an area of specified width positioned at |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4103 |
the beginning of this descriptor's data area. Source data is copied into, and |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4104 |
aligned within this target area according to the specified alignment |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4105 |
instruction. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4106 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4107 |
If the length of the target area is larger than the length of the source, then |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4108 |
spare space within the target area is padded with the fill character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4109 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4110 |
@param aDes A 16-bit non-modifiable descriptor containing the source data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4111 |
The length of the data to be copied is the smaller of: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4112 |
the length of the source descriptor, and |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4113 |
the width of the target area (only if this is not the |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4114 |
explicit negative value KDefaultJustifyWidth). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4115 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4116 |
@param aWidth The width of the target area. If this has the specific |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4117 |
negative value KDefaultJustifyWidth, then the width is |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4118 |
re-set to the length of the data source. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4119 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4120 |
@param anAlignment The alignment of the data within the target area |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4121 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4122 |
@param aFill The fill character used to pad the target area. Can be |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4123 |
inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4124 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4125 |
@panic USER 11 if the resulting length of this descriptor is greater than |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4126 |
its maximum length or aWidth has a negative value other |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4127 |
than KDefaultJustifyWidth. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4128 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4129 |
@panic USER 217 if corrupt surrogate found in the parameters or in the |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4130 |
descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4131 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4132 |
@see TDes16::Justify() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4133 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4134 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4135 |
Zero(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4136 |
AppendJustify2(aDes.Ptr(),aDes.Length(),aWidth,anAlignment,aFill); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4137 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4138 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4139 |
EXPORT_C void TDes16::AppendJustify2(const TDesC16 &aDes, TInt aWidth, TAlign anAlignment, TChar aFill) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4140 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4141 |
The surrogate aware version of AppendJustify. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4142 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4143 |
Appends data onto the end of this descriptor's data and justifies it. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4144 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4145 |
The source of the appended data is an existing descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4146 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4147 |
The target area is considered to be an area of specified width, immediately |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4148 |
following this descriptor's existing data. Source data is copied into, and |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4149 |
aligned within this target area according to the specified alignment instruction. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4150 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4151 |
If the length of the target area is larger than the length of the source, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4152 |
then spare space within the target area is padded with the fill character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4153 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4154 |
@param aDes A 16-bit non-modifiable descriptor containing the source |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4155 |
data. The length of the data to be copied is the smaller of: |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4156 |
the length of the source descriptor, and |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4157 |
the width of the target area (only if this is not the |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4158 |
explicit negative value KDefaultJustifyWidth). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4159 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4160 |
@param aWidth The width of the target area. If this has the specific |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4161 |
negative value KDefaultJustifyWidth, then the width is |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4162 |
re-set to the length of the data source. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4163 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4164 |
@param anAlignment The alignment of the data within the target area. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4165 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4166 |
@param aFill The fill character used to pad the target area. Can be |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4167 |
inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4168 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4169 |
@panic USER 11 if the resulting length of this descriptor is greater than |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4170 |
its maximum length or aWidth has a negative value other |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4171 |
than KDefaultJustifyWidth. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4172 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4173 |
@panic USER 217 if corrupt surrogate found in the parameters or in the |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4174 |
descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4175 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4176 |
@see TDes16::AppendJustify() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4177 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4178 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4179 |
AppendJustify2(aDes.Ptr(),aDes.Length(),aWidth,anAlignment,aFill); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4180 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4181 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4182 |
EXPORT_C void TDes16::AppendJustify2(const TDesC16 &aDes, TInt aLength, TInt aWidth, TAlign anAlignment, TChar aFill) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4183 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4184 |
The surrogate aware version of AppendJustify. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4185 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4186 |
Appends data onto the end of this descriptor's data and justifies it. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4187 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4188 |
The source of the appended data is an existing descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4189 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4190 |
The target area is considered to be an area of specified width, immediately |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4191 |
following this descriptor's existing data. Source data is copied into, and |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4192 |
aligned within this target area according to the specified alignment instruction. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4193 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4194 |
If the length of the target area is larger than the length of the source, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4195 |
then spare space within the target area is padded with the fill character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4196 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4197 |
@param aDes An 8-bit non-modifiable descriptor containing the source data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4198 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4199 |
@param aLength The length of data to be copied from the source descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4200 |
If this is greater than the width of the target area, then |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4201 |
the length of data copied is limited to the width. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4202 |
The length of data to be copied must not be greater than |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4203 |
the length of the source descriptor. Note that this |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4204 |
condition is not automatically tested. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4205 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4206 |
@param aWidth The width of the target area. If this has the specific negative |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4207 |
value KDefaultJustifyWidth, then the width is |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4208 |
re-set to the length of the data source. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4209 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4210 |
@param anAlignment The alignment of the data within the target area. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4211 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4212 |
@param aFill The fill character used to pad the target area. Can be |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4213 |
inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4214 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4215 |
@panic USER 11 if the resulting length of this descriptor is greater than |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4216 |
its maximum length or aWidth has a negative value other |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4217 |
than KDefaultJustifyWidth. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4218 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4219 |
@panic USER 217 if corrupt surrogate found in the parameters or in the |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4220 |
descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4221 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4222 |
@see TDes16::AppendJustify() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4223 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4224 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4225 |
AppendJustify2(aDes.Ptr(),aLength,aWidth,anAlignment,aFill); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4226 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4227 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4228 |
EXPORT_C void TDes16::AppendJustify2(const TUint16 *aString, TInt aWidth, TAlign anAlignment, TChar aFill) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4229 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4230 |
The surrogate aware version of AppendJustify. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4231 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4232 |
Appends a zero terminated string onto the end of this descriptor's data and |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4233 |
justifies it. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4234 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4235 |
The zero terminator is not copied. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4236 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4237 |
The target area is considered to be an area of specified width, immediately |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4238 |
following this descriptor's existing data. Source data is copied into, and |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4239 |
aligned within, this target area according to the specified alignment instruction. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4240 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4241 |
If the length of the target area is larger than the length of the source, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4242 |
then spare space within the target area is padded with the fill character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4243 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4244 |
@param aString A pointer to a zero terminated string The length of the data |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4245 |
to be copied is the smaller of: the length of the string (excluding the zero |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4246 |
terminator), the width of the target area (only if this is not the explicit |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4247 |
negative value KDefaultJustifyWidth). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4248 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4249 |
@param aWidth The width of the target area. If this has the specific negative |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4250 |
value KDefaultJustifyWidth, then the width is re-set to the length of the |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4251 |
zero terminated string (excluding the zero terminator). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4252 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4253 |
@param anAlignment The alignment of the data within the target area. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4254 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4255 |
@param aFill The fill character used to pad the target area. Can be |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4256 |
inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4257 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4258 |
@panic USER 11 if the resulting length of this descriptor is greater than |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4259 |
its maximum length or aWidth has a negative value other |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4260 |
than KDefaultJustifyWidth. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4261 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4262 |
@panic USER 217 if corrupt surrogate found in the parameters or in the |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4263 |
descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4264 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4265 |
@see TDes16::AppendJustify() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4266 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4267 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4268 |
__CHECK_ALIGNMENT(aString,ETDes16AppendJustify1); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4269 |
AppendJustify2(aString,STRING_LENGTH_16(aString),aWidth,anAlignment,aFill); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4270 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4271 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4272 |
EXPORT_C void TDes16::AppendJustify2(const TUint16 *aString, TInt aLength, TInt aWidth, TAlign anAlignment, TChar aFill) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4273 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4274 |
The surrogate aware version of AppendJustify. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4275 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4276 |
Appends data onto the end of this descriptor's data and justifies it. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4277 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4278 |
The source of the appended data is a memory location. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4279 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4280 |
The target area is considered to be an area of specified width, immediately |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4281 |
following this descriptor's existing data. Source data is copied into, and |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4282 |
aligned within, this target area according to the specified alignment instruction. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4283 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4284 |
If the length of the target area is larger than the length of the source, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4285 |
then spare space within the target area is padded with the fill character. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4286 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4287 |
@param aString A pointer to a source memory location. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4288 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4289 |
@param aLength The length of data to be copied. If this is greater than the |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4290 |
width of the target area, then the length of data copied is |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4291 |
limited to the width. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4292 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4293 |
@param aWidth The width of the target area. If this has the specific negative |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4294 |
value KDefaultJustifyWidth, then the width is |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4295 |
re-set to the length of the data source. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4296 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4297 |
@param anAlignment The alignment of the data within the target area. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4298 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4299 |
@param aFill The fill character used to pad the target area. Can be |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4300 |
inside or outside BMP. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4301 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4302 |
@panic USER 11 if the resulting length of this descriptor is greater than |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4303 |
its maximum length or aWidth has a negative value other |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4304 |
than KDefaultJustifyWidth. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4305 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4306 |
@panic USER 17 if aLength is negative. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4307 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4308 |
@panic USER 217 if corrupt surrogate found in the parameters or in the |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4309 |
descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4310 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4311 |
@see TDes16::AppendJustify() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4312 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4313 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4314 |
__ASSERT_ALWAYS(aLength>=0,Panic(ETDes16LengthNegative)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4315 |
__CHECK_ALIGNMENT(aString,ETDes16AppendJustify2); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4316 |
if (aWidth==KDefaultJustifyWidth) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4317 |
aWidth=aLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4318 |
if (aLength>aWidth) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4319 |
aLength=aWidth; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4320 |
TInt offset=Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4321 |
AppendFill2(aFill,aWidth); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4322 |
TInt r=aWidth-aLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4323 |
if (anAlignment==ECenter) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4324 |
r>>=1; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4325 |
else if (anAlignment==ELeft) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4326 |
r=0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4327 |
memCopy(WPtr()+offset+r,aString,aLength); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4328 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4329 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4330 |
EXPORT_C void TDes16::Fold2() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4331 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4332 |
The surrogate aware version of Fold(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4333 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4334 |
Performs folding on the content of this descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4335 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4336 |
Note that folding is locale-independent behaviour. It is also important to |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4337 |
note that there can be no guarantee that folding is in any way culturally |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4338 |
appropriate, and should not be used when dealing with strings in natural |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4339 |
language. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4340 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4341 |
@panic USER 217 if corrupt surrogate found in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4342 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4343 |
@see TDes16::Fold() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4344 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4345 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4346 |
TInt strLength = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4347 |
TText16* start = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4348 |
const TText16* end = Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4349 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4350 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4351 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4352 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4353 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4354 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4355 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4356 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4357 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4358 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4359 |
TCharF c(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4360 |
// at present, c and currentChar always in the same plane |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4361 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4362 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4363 |
start[int16Index] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4364 |
start[int16Index+1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4365 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4366 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4367 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4368 |
start[int16Index] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4369 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4370 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4371 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4372 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4373 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4374 |
EXPORT_C void TDes16::Collate2() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4375 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4376 |
The surrogate aware version of Collate(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4377 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4378 |
Performs collation on the content of this descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4379 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4380 |
@panic USER 217 if corrupt surrogate found in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4381 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4382 |
@see TDes16::Collate() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4383 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4384 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4385 |
TInt strLength = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4386 |
TText16* start = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4387 |
const TText16* end = Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4388 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4389 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4390 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4391 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4392 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4393 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4394 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4395 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4396 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4397 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4398 |
TChar c = User::Collate(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4399 |
// at present, c and currentChar always in the same plane |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4400 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4401 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4402 |
start[int16Index] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4403 |
start[int16Index+1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4404 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4405 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4406 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4407 |
start[int16Index] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4408 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4409 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4410 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4411 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4412 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4413 |
EXPORT_C void TDes16::LowerCase2() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4414 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4415 |
The surrogate aware version of LowerCase(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4416 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4417 |
Converts the content of this descriptor to lower case. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4418 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4419 |
Conversion is implemented as appropriate to the current locale. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4420 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4421 |
@panic USER 217 if corrupt surrogate found in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4422 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4423 |
@see TDes16::LowerCase() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4424 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4425 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4426 |
TInt strLength = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4427 |
TText16* start = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4428 |
const TText16* end = Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4429 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4430 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4431 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4432 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4433 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4434 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4435 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4436 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4437 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4438 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4439 |
TCharLC c(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4440 |
// at present, c and currentChar always in the same plane |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4441 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4442 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4443 |
start[int16Index] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4444 |
start[int16Index+1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4445 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4446 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4447 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4448 |
start[int16Index] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4449 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4450 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4451 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4452 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4453 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4454 |
EXPORT_C void TDes16::UpperCase2() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4455 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4456 |
The surrogate aware version of UpperCase(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4457 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4458 |
Converts the content of this descriptor to upper case. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4459 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4460 |
Conversion is implemented as appropriate to the current locale. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4461 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4462 |
@panic USER 217 if corrupt surrogate found in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4463 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4464 |
@see TDes16::UpperCase() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4465 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4466 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4467 |
TInt strLength = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4468 |
TText16* start = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4469 |
const TText16* end = Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4470 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4471 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4472 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4473 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4474 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4475 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4476 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4477 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4478 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4479 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4480 |
TCharUC c(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4481 |
// at present, c and currentChar always in the same plane |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4482 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4483 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4484 |
start[int16Index] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4485 |
start[int16Index+1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4486 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4487 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4488 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4489 |
start[int16Index] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4490 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4491 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4492 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4493 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4494 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4495 |
EXPORT_C void TDes16::Capitalize2() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4496 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4497 |
The surrogate aware version of Capitalize(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4498 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4499 |
Capitalises the content of this descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4500 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4501 |
Capitalisation is implemented as appropriate to the current locale. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4502 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4503 |
@panic USER 217 if corrupt surrogate found in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4504 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4505 |
@see TDes16::Capitalize() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4506 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4507 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4508 |
TInt strLength = Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4509 |
TText16* start = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4510 |
const TText16* end = Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4511 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4512 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4513 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4514 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4515 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4516 |
// the first character: title case |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4517 |
status = ::ProceedOneCharacter(start, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4518 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4519 |
TChar c = User::TitleCase(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4520 |
// at present, c and currentChar always in the same plane |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4521 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4522 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4523 |
start[0] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4524 |
start[1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4525 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4526 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4527 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4528 |
start[0] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4529 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4530 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4531 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4532 |
// following characters: lower case |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4533 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4534 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4535 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4536 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4537 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4538 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4539 |
TChar c = User::LowerCase(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4540 |
// at present, c and currentChar always in the same plane |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4541 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4542 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4543 |
start[int16Index] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4544 |
start[int16Index+1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4545 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4546 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4547 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4548 |
start[int16Index] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4549 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4550 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4551 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4552 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4553 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4554 |
EXPORT_C void TDes16::CopyF2(const TDesC16 &aDes) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4555 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4556 |
The surrogate aware version of CopyF(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4557 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4558 |
Copies and folds data from the specified descriptor into this descriptor replacing |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4559 |
any existing data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4560 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4561 |
The length of this descriptor is set to reflect the new |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4562 |
data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4563 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4564 |
Note that folding is locale-independent behaviour. It is also important to |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4565 |
note that there can be no guarantee that folding is in any way culturally |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4566 |
appropriate, and should not be used when dealing with strings in natural |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4567 |
language. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4568 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4569 |
@param aDes A 16-bit non-modifiable descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4570 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4571 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4572 |
this target descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4573 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4574 |
@panic USER 217 if corrupt surrogate found in aDes or in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4575 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4576 |
@see TDes16::CopyF() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4577 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4578 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4579 |
TText16* pT = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4580 |
TInt len = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4581 |
const TInt maxLen = MaxLength(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4582 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4583 |
// iterate through aDes |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4584 |
TInt strLength = aDes.Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4585 |
const TText16* start = aDes.Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4586 |
const TText16* end = aDes.Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4587 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4588 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4589 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4590 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4591 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4592 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4593 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4594 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4595 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4596 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4597 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4598 |
TCharF c(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4599 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4600 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4601 |
len += 2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4602 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4603 |
pT[len-2] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4604 |
pT[len-1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4605 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4606 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4607 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4608 |
++len; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4609 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4610 |
pT[len-1] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4611 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4612 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4613 |
SetLength(len); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4614 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4615 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4616 |
EXPORT_C void TDes16::CopyC2(const TDesC16 &aDes) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4617 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4618 |
The surrogate aware version of CopyC(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4619 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4620 |
Copies and collates data from the specified descriptor |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4621 |
into this descriptor replacing any existing data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4622 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4623 |
The length of this descriptor is set to reflect the new data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4624 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4625 |
@param aDes A 16-bit non-modifiable descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4626 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4627 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4628 |
this target descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4629 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4630 |
@panic USER 217 if corrupt surrogate found in aDes or in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4631 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4632 |
@see TDes16::CopyC() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4633 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4634 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4635 |
TText16* pT = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4636 |
TInt len = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4637 |
const TInt maxLen = MaxLength(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4638 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4639 |
// iterate through aDes |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4640 |
TInt strLength = aDes.Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4641 |
const TText16* start = aDes.Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4642 |
const TText16* end = aDes.Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4643 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4644 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4645 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4646 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4647 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4648 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4649 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4650 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4651 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4652 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4653 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4654 |
TChar c = User::Collate(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4655 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4656 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4657 |
len += 2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4658 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4659 |
pT[len-2] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4660 |
pT[len-1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4661 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4662 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4663 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4664 |
++len; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4665 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4666 |
pT[len-1] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4667 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4668 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4669 |
SetLength(len); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4670 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4671 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4672 |
EXPORT_C void TDes16::CopyLC2(const TDesC16 &aDes) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4673 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4674 |
The surrogate aware version of CopyLC(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4675 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4676 |
Copies text from the specified descriptor and converts it to lower case before |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4677 |
putting it into this descriptor, replacing any existing data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4678 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4679 |
The length of this descriptor is set to reflect the new data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4680 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4681 |
Conversion to lower case is implemented as appropriate to the current locale. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4682 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4683 |
@param aDes A 16-bit non modifiable descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4684 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4685 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4686 |
this target descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4687 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4688 |
@panic USER 217 if corrupt surrogate found in aDes or in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4689 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4690 |
@see TDes16::CopyLC() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4691 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4692 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4693 |
TText16* pT = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4694 |
TInt len = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4695 |
const TInt maxLen = MaxLength(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4696 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4697 |
// iterate through aDes |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4698 |
TInt strLength = aDes.Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4699 |
const TText16* start = aDes.Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4700 |
const TText16* end = aDes.Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4701 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4702 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4703 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4704 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4705 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4706 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4707 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4708 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4709 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4710 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4711 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4712 |
TCharLC c(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4713 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4714 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4715 |
len += 2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4716 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4717 |
pT[len-2] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4718 |
pT[len-1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4719 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4720 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4721 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4722 |
++len; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4723 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4724 |
pT[len-1] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4725 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4726 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4727 |
SetLength(len); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4728 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4729 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4730 |
EXPORT_C void TDes16::CopyUC2(const TDesC16 &aDes) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4731 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4732 |
The surrogate aware version of CopyUC(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4733 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4734 |
Copies text from the specified descriptor and converts it to upper case before |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4735 |
putting it into this descriptor, replacing any existing data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4736 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4737 |
The length of this descriptor is set to reflect the new data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4738 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4739 |
Conversion to upper case is implemented as appropriate to the current locale. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4740 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4741 |
@param aDes A 16-bit non modifiable descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4742 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4743 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4744 |
this target descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4745 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4746 |
@panic USER 217 if corrupt surrogate found in aDes or in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4747 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4748 |
@see TDes16::CopyUC() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4749 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4750 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4751 |
TText16* pT = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4752 |
TInt len = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4753 |
const TInt maxLen = MaxLength(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4754 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4755 |
// iterate through aDes |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4756 |
TInt strLength = aDes.Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4757 |
const TText16* start = aDes.Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4758 |
const TText16* end = aDes.Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4759 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4760 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4761 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4762 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4763 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4764 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4765 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4766 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4767 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4768 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4769 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4770 |
TCharUC c(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4771 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4772 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4773 |
len += 2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4774 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4775 |
pT[len-2] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4776 |
pT[len-1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4777 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4778 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4779 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4780 |
++len; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4781 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4782 |
pT[len-1] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4783 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4784 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4785 |
SetLength(len); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4786 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4787 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4788 |
EXPORT_C void TDes16::CopyCP2(const TDesC16 &aDes) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4789 |
/** |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4790 |
The surrogate aware version of CopyCP(). |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4791 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4792 |
Copies text from the specified descriptor and capitalises it before putting |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4793 |
it into this descriptor, replacing any existing data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4794 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4795 |
The length of this descriptor is set to reflect the new data. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4796 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4797 |
Capitalisation is implemented as appropriate to the current locale. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4798 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4799 |
@param aDes A 16-bit non-modifiable descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4800 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4801 |
@panic USER 11 if the length of aDes is greater than the maximum length of |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4802 |
this target descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4803 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4804 |
@panic USER 217 if corrupt surrogate found in aDes or in the descriptor. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4805 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4806 |
@see TDes16::CopyCP() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4807 |
*/ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4808 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4809 |
TText16* pT = WPtr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4810 |
TInt len = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4811 |
const TInt maxLen = MaxLength(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4812 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4813 |
// iterate through aDes |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4814 |
TInt strLength = aDes.Length(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4815 |
const TText16* start = aDes.Ptr(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4816 |
const TText16* end = aDes.Ptr() + strLength; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4817 |
TText16* next; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4818 |
TUint currentChar; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4819 |
TInt int16Index = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4820 |
TInt status = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4821 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4822 |
// first character: title case |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4823 |
status = ::ProceedOneCharacter(start, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4824 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4825 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4826 |
TChar c(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4827 |
c.TitleCase(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4828 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4829 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4830 |
len += 2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4831 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4832 |
pT[len-2] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4833 |
pT[len-1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4834 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4835 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4836 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4837 |
++len; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4838 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4839 |
pT[len-1] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4840 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4841 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4842 |
// following characters: lower case |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4843 |
FOREVER |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4844 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4845 |
status = ::ProceedOneCharacter(start+int16Index, end, next, currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4846 |
__ASSERT_ALWAYS(status != KErrCorruptSurrogateFound, Panic(ECorruptSurrogateFound)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4847 |
if (status == KErrNotFound) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4848 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4849 |
int16Index = (next - start); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4850 |
TCharLC c(currentChar); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4851 |
if (TChar::IsSupplementary(c)) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4852 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4853 |
len += 2; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4854 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4855 |
pT[len-2] = TChar::GetHighSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4856 |
pT[len-1] = TChar::GetLowSurrogate(c); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4857 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4858 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4859 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4860 |
++len; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4861 |
__ASSERT_ALWAYS(len<=maxLen, Panic(ETDes16Overflow)); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4862 |
pT[len-1] = (TText16)c; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4863 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4864 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4865 |
SetLength(len); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4866 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4867 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4868 |
|
0 | 4869 |
#if !defined(__DES16_MACHINE_CODED__) | defined(__EABI_CTORS__) |
4870 |
EXPORT_C TPtrC16::TPtrC16() |
|
4871 |
: TDesC16(EPtrC,0),iPtr(0) |
|
4872 |
/** |
|
4873 |
Constructs an empty 16-bit non-modifiable pointer descriptor. |
|
4874 |
||
4875 |
It represents no data and its length is zero. |
|
4876 |
||
4877 |
The non-modifiable pointer descriptor can, subsequently, be set to represent |
|
4878 |
data. |
|
4879 |
||
4880 |
@see TPtrC16::Set() |
|
4881 |
*/ |
|
4882 |
{} |
|
4883 |
||
4884 |
EXPORT_C TPtrC16::TPtrC16(const TDesC16 &aDes) |
|
4885 |
: TDesC16(EPtrC,aDes.Length()),iPtr(aDes.Ptr()) |
|
4886 |
/** |
|
4887 |
Constructs the 16-bit non-modifiable pointer descriptor from any existing |
|
4888 |
descriptor. |
|
4889 |
||
4890 |
It is set to point to the same data and is given the same length as the source |
|
4891 |
descriptor. |
|
4892 |
||
4893 |
@param aDes A reference to a 16-bit non-modifiable descriptor. |
|
4894 |
*/ |
|
4895 |
{} |
|
4896 |
#endif |
|
4897 |
||
4898 |
#if !defined(__DES16_MACHINE_CODED_HWORD__) | defined(__EABI_CTORS__) |
|
4899 |
EXPORT_C TPtrC16::TPtrC16(const TUint16 *aString) |
|
4900 |
: TDesC16(EPtrC,STRING_LENGTH_16(aString)),iPtr(aString) |
|
4901 |
/** |
|
4902 |
Constructs the 16-bit non-modifiable pointer descriptor to point to a zero |
|
4903 |
terminated string, whether in RAM or ROM. |
|
4904 |
||
4905 |
The length of the descriptor is set to the length of the zero terminated string, |
|
4906 |
excluding the zero terminator. |
|
4907 |
||
4908 |
@param aString A pointer to a zero terminated string. |
|
4909 |
*/ |
|
4910 |
{ |
|
4911 |
__CHECK_ALIGNMENT(aString,ETDesC16ConstructCString); |
|
4912 |
} |
|
4913 |
#endif |
|
4914 |
||
4915 |
#if !defined(__DES16_MACHINE_CODED__) | defined(__EABI_CTORS__) |
|
4916 |
EXPORT_C TPtrC16::TPtrC16(const TUint16 *aBuf,TInt aLength) |
|
4917 |
: TDesC16(EPtrC,aLength),iPtr(aBuf) |
|
4918 |
/** |
|
4919 |
Constructs the 16-bit non-modifiable pointer descriptor to point to the |
|
4920 |
specified location in memory, whether in RAM or ROM. |
|
4921 |
||
4922 |
The length of the descriptor is set to the specified length. |
|
4923 |
||
4924 |
@param aBuf A pointer to the location that the descriptor is to represent. |
|
4925 |
@param aLength The length of the descriptor.This value must be non-negative. |
|
4926 |
||
4927 |
@panic USER 17 if aLength is negative. |
|
4928 |
*/ |
|
4929 |
{ |
|
4930 |
__ASSERT_ALWAYS(aLength>=0,Panic(ETDes16LengthNegative)); |
|
4931 |
__CHECK_ALIGNMENT(aBuf,ETDesC16ConstructBufLength); |
|
4932 |
} |
|
4933 |
||
4934 |
EXPORT_C TPtr16::TPtr16(TUint16 *aBuf,TInt aMaxLength) |
|
4935 |
: TDes16(EPtr,0,aMaxLength),iPtr(aBuf) |
|
4936 |
/** |
|
4937 |
Constructs the 16-bit modifiable pointer descriptor to point to the specified |
|
4938 |
location in memory, whether in RAM or ROM. |
|
4939 |
||
4940 |
The length of the descriptor is set to zero, and its maximum length is set to |
|
4941 |
the specified value. |
|
4942 |
||
4943 |
@param aBuf A pointer to the location that the descriptor is to represent. |
|
4944 |
@param aMaxLength The maximum length of the descriptor. |
|
4945 |
||
4946 |
@panic USER 18 if aMaxLength is negative. |
|
4947 |
*/ |
|
4948 |
{ |
|
4949 |
__ASSERT_ALWAYS(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
4950 |
__CHECK_ALIGNMENT(aBuf,ETDesC16ConstructBufLengthMax); |
|
4951 |
} |
|
4952 |
||
4953 |
EXPORT_C TPtr16::TPtr16(TUint16 *aBuf,TInt aLength,TInt aMaxLength) |
|
4954 |
: TDes16(EPtr,aLength,aMaxLength),iPtr(aBuf) |
|
4955 |
/** |
|
4956 |
Constructs the 16-bit modifiable pointer descriptor to point to the specified |
|
4957 |
location in memory, whether in RAM or ROM. |
|
4958 |
||
4959 |
The length of the descriptor and its maximum length are set to the specified |
|
4960 |
values. |
|
4961 |
||
4962 |
@param aBuf A pointer to the location that the descriptor is to represent. |
|
4963 |
@param aLength The length of the descriptor. |
|
4964 |
@param aMaxLength The maximum length of the descriptor. |
|
4965 |
||
4966 |
@panic USER 8 if aLength is negative, or is greater than the descriptor's |
|
4967 |
maximum length, |
|
4968 |
||
4969 |
@panic USER 18 if aMaxLength is negative. |
|
4970 |
*/ |
|
4971 |
{ |
|
4972 |
__ASSERT_ALWAYS(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
4973 |
__ASSERT_ALWAYS(TUint(aLength)<=TUint(aMaxLength),Panic(ETDes16LengthOutOfRange)); |
|
4974 |
__CHECK_ALIGNMENT(aBuf,ETDesC16ConstructBufLengthMax); |
|
4975 |
} |
|
4976 |
||
4977 |
EXPORT_C TBufBase16::TBufBase16(TInt aMaxLength) |
|
4978 |
:TDes16(EBuf,0,aMaxLength) |
|
4979 |
{ |
|
4980 |
__ASSERT_DEBUG(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
4981 |
} |
|
4982 |
||
4983 |
EXPORT_C TBufBase16::TBufBase16(TInt aLength,TInt aMaxLength) |
|
4984 |
:TDes16(EBuf,aLength,aMaxLength) |
|
4985 |
{ |
|
4986 |
__ASSERT_DEBUG(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
4987 |
__ASSERT_ALWAYS(TUint(aLength)<=TUint(aMaxLength),Panic(ETDes16LengthOutOfRange)); |
|
4988 |
} |
|
4989 |
#endif |
|
4990 |
||
4991 |
#if !defined( __DES16_MACHINE_CODED_HWORD__) | defined(__EABI_CTORS__) |
|
4992 |
EXPORT_C TBufBase16::TBufBase16(const TUint16* aString,TInt aMaxLength) |
|
4993 |
:TDes16(EBuf,0,aMaxLength) |
|
4994 |
{ |
|
4995 |
__ASSERT_DEBUG(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
4996 |
Copy(aString); |
|
4997 |
} |
|
4998 |
#endif |
|
4999 |
||
5000 |
#if !defined( __DES16_MACHINE_CODED__) | defined(__EABI_CTORS__) |
|
5001 |
EXPORT_C TBufBase16::TBufBase16(const TDesC16& aDes,TInt aMaxLength) |
|
5002 |
:TDes16(EBuf,0,aMaxLength) |
|
5003 |
{ |
|
5004 |
__ASSERT_DEBUG(aMaxLength>=0,Panic(ETDes16MaxLengthNegative)); |
|
5005 |
Copy(aDes); |
|
5006 |
} |
|
5007 |
#endif |
|
5008 |
||
5009 |
EXPORT_C void TDesC16::__DbgTestInvariant() const |
|
5010 |
// |
|
5011 |
// Test that the class obeys its invariant. |
|
5012 |
// |
|
5013 |
{ |
|
5014 |
||
5015 |
#if defined(_DEBUG) |
|
5016 |
switch (Type()) |
|
5017 |
{ |
|
5018 |
case EBufC: |
|
5019 |
case EPtrC: |
|
5020 |
case EPtr: |
|
5021 |
case EBuf: |
|
5022 |
case EBufCPtr: |
|
5023 |
break; |
|
5024 |
default: |
|
5025 |
User::Invariant(); |
|
5026 |
} |
|
5027 |
if (Ptr() != NULL) // TPtr and TPtrC can be null |
|
5028 |
__CHECK_ALIGNMENT(Ptr(),ETDesC16Invariant); |
|
5029 |
#endif |
|
5030 |
} |
|
5031 |
||
5032 |
EXPORT_C void TPtrC16::__DbgTestInvariant() const |
|
5033 |
// |
|
5034 |
// Test that the class obeys its invariant. |
|
5035 |
// |
|
5036 |
{ |
|
5037 |
||
5038 |
#if defined(_DEBUG) |
|
5039 |
TDesC16::__DbgTestInvariant(); // Test base class |
|
5040 |
if (Type()!=EPtrC) |
|
5041 |
User::Invariant(); |
|
5042 |
#endif |
|
5043 |
} |
|
5044 |
||
5045 |
EXPORT_C void TDes16::__DbgTestInvariant() const |
|
5046 |
// |
|
5047 |
// Test that the class obeys its invariant. |
|
5048 |
// |
|
5049 |
{ |
|
5050 |
||
5051 |
#if defined(_DEBUG) |
|
5052 |
TDesC16::__DbgTestInvariant(); // Test base class |
|
5053 |
if (Length()>MaxLength() || !(Type()==EPtr || Type()==EBufCPtr || Type()==EBuf)) |
|
5054 |
User::Invariant(); |
|
5055 |
#endif |
|
5056 |
} |
|
5057 |
||
5058 |
EXPORT_C void HBufC16::__DbgTestInvariant() const |
|
5059 |
// |
|
5060 |
// Test that the class obeys its invariant. |
|
5061 |
// |
|
5062 |
{ |
|
5063 |
||
5064 |
#if defined(_DEBUG) |
|
5065 |
TDesC16::__DbgTestInvariant(); // Test base class |
|
5066 |
if (Length()>(TInt)(STD_CLASS::AllocLen(this)-sizeof(TDesC16)) || Type()!=EBufC) |
|
5067 |
User::Invariant(); |
|
5068 |
#endif |
|
5069 |
} |
|
5070 |
||
5071 |
EXPORT_C void TPtr16::__DbgTestInvariant() const |
|
5072 |
// |
|
5073 |
// Test that the class obeys its invariant. |
|
5074 |
// |
|
5075 |
{ |
|
5076 |
||
5077 |
#if defined(_DEBUG) |
|
5078 |
TDes16::__DbgTestInvariant(); // Test base class |
|
5079 |
if (!(Type()==EPtr || Type()==EBufCPtr)) |
|
5080 |
User::Invariant(); |
|
5081 |
#endif |
|
5082 |
} |
|
5083 |
||
5084 |
/** Collapse all characters from 16 to 8 bits |
|
5085 |
||
5086 |
@return 8-bit pointer descriptor to transformed text |
|
5087 |
*/ |
|
5088 |
EXPORT_C TPtr8 TDes16::Collapse() |
|
5089 |
{ |
|
5090 |
TInt l = Length(); |
|
5091 |
TInt ml = MaxLength(); |
|
5092 |
TText8* d = (TText8*)Ptr(); |
|
5093 |
TText8* d0 = d; |
|
5094 |
const TText16* s = (const TText16*)d; |
|
5095 |
const TText16* sE = s + l; |
|
5096 |
while (s < sE) |
|
5097 |
*d++ = (TText8)*s++; |
|
5098 |
return TPtr8(d0, l, ml*sizeof(TText)); |
|
5099 |
} |
|
5100 |
||
5101 |
// Truncate literal string to fit into descriptor |
|
5102 |
EXPORT_C void TDes16IgnoreOverflow::Overflow(TDes16& /*aDes*/) |
|
5103 |
{} |
|
5104 |
||
5105 |
#ifndef __KERNEL_MODE__ |
|
5106 |
||
5107 |
/** |
|
5108 |
Default constructor. |
|
5109 |
||
5110 |
Constructs a zero-length 16-bit resizable buffer descriptor. |
|
5111 |
||
5112 |
Note that the object owns no allocated memory. |
|
5113 |
*/ |
|
5114 |
EXPORT_C RBuf16::RBuf16() |
|
5115 |
:TDes16(EPtr,0,0),iEPtrType(NULL) |
|
5116 |
{ |
|
5117 |
// Zero-length RBuf16 is of type EPtr with NULL pointer. |
|
5118 |
} |
|
5119 |
||
5120 |
||
5121 |
||
5122 |
||
5123 |
/** |
|
5124 |
Constructor. |
|
5125 |
||
5126 |
Constructs a 16-bit resizable buffer descriptor, transferring ownership of the |
|
5127 |
specified heap descriptor to this object. |
|
5128 |
||
5129 |
@param aHBuf The heap descriptor to be transferred to this object. This pointer |
|
5130 |
can be NULL, which means that a zero length 16-bit resizable |
|
5131 |
buffer descriptor is constructed, and the object will not own any |
|
5132 |
allocated memory. |
|
5133 |
*/ |
|
5134 |
EXPORT_C RBuf16::RBuf16(HBufC16* aHBuf) |
|
5135 |
{ |
|
5136 |
if(aHBuf) |
|
5137 |
//Create EBufCPtr type descriptor that points to aHBuf |
|
5138 |
new(this) TPtr16(aHBuf->Des()); |
|
5139 |
else |
|
5140 |
//Create zero-length RBuf16. It is EPtr type of descriptor that points to NULL. |
|
5141 |
new(this) RBuf16(); |
|
5142 |
} |
|
5143 |
||
5144 |
||
5145 |
||
5146 |
||
5147 |
/** |
|
5148 |
Protected constructor. |
|
5149 |
*/ |
|
5150 |
EXPORT_C RBuf16::RBuf16(TInt aType,TInt aLength,TInt aMaxLength) |
|
5151 |
:TDes16(aType,aLength,aMaxLength) |
|
5152 |
{ |
|
5153 |
} |
|
5154 |
||
5155 |
||
5156 |
||
5157 |
||
5158 |
/** |
|
5159 |
Transfers ownership of the specified 16-bit resizable buffer descriptor's |
|
5160 |
buffer to this object. |
|
5161 |
||
5162 |
Note that the function assumes that this descriptor does not already own any |
|
5163 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5164 |
allocated memory. If this descriptor does already own allocated memory, |
|
5165 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5166 |
invoked. |
|
5167 |
||
5168 |
@param aRBuf The source 16-bit resizable buffer. The ownership of this |
|
5169 |
object's buffer is to be transferred. |
|
5170 |
||
5171 |
@see RBuf16::Close() |
|
5172 |
*/ |
|
5173 |
EXPORT_C void RBuf16::Assign(const RBuf16& aRBuf) |
|
5174 |
{ |
|
5175 |
Mem::Copy(this, &aRBuf, sizeof(*this)); |
|
5176 |
__TEST_INVARIANT; |
|
5177 |
} |
|
5178 |
||
5179 |
||
5180 |
||
5181 |
||
5182 |
/** |
|
5183 |
Assigns ownership of the specified allocated memory to this object. |
|
5184 |
||
5185 |
The allocated memory forms the buffer for this descriptor. The current length |
|
5186 |
of the descriptor is set to zero. |
|
5187 |
||
5188 |
Note that the function assumes that this descriptor does not already own any |
|
5189 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5190 |
allocated memory. If this descriptor does already own allocated memory, |
|
5191 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5192 |
invoked. |
|
5193 |
||
5194 |
@param aHeapCell The allocated memory to be assigned to this object. This |
|
5195 |
pointer can be NULL, which means that a zero length 16-bit |
|
5196 |
resizable buffer descriptor is created. |
|
5197 |
@param aMaxLength The maximum length of the descriptor. |
|
5198 |
||
5199 |
@panic USER 8 If the specified maximum length is greater then the size of |
|
5200 |
the allocated heap cell, or the specified maximum length |
|
5201 |
is NOT zero when the pointer to the heap cell is NULL. |
|
5202 |
||
5203 |
@see TDesC16::Length() |
|
5204 |
@see TDes16::MaxLength() |
|
5205 |
@see RBuf16::Close() |
|
5206 |
*/ |
|
5207 |
EXPORT_C void RBuf16::Assign(TUint16 *aHeapCell,TInt aMaxLength) |
|
5208 |
{ |
|
5209 |
Assign(aHeapCell,0,aMaxLength); |
|
5210 |
} |
|
5211 |
||
5212 |
||
5213 |
||
5214 |
||
5215 |
/** |
|
5216 |
Assigns ownership of the specified allocated memory to this object. |
|
5217 |
||
5218 |
The allocated memory forms the buffer for this descriptor. The current length |
|
5219 |
of the descriptor is set to the value of the second parameter. |
|
5220 |
||
5221 |
Note that the function assumes that this descriptor does not already own any |
|
5222 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5223 |
allocated memory. If this descriptor does already own allocated memory, |
|
5224 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5225 |
invoked. |
|
5226 |
||
5227 |
@param aHeapCell The allocated memory to be assigned to this object. |
|
5228 |
@param aLength The length of the descriptor. |
|
5229 |
@param aMaxLength The maximum length of the descriptor. |
|
5230 |
||
5231 |
@panic USER 8 If the specified maximum length is greater then the size of |
|
5232 |
the allocated heap cell, or the specified length is greater then |
|
5233 |
the specified maximum length, or the specified maximum length |
|
5234 |
is NOT zero when the pointer to the heap cell is NULL. |
|
5235 |
||
5236 |
@see TDesC16::Length() |
|
5237 |
@see TDes16::MaxLength() |
|
5238 |
@see RBuf16::Close() |
|
5239 |
*/ |
|
5240 |
EXPORT_C void RBuf16::Assign(TUint16 *aHeapCell,TInt aLength,TInt aMaxLength) |
|
5241 |
{ |
|
5242 |
__ASSERT_ALWAYS(aLength<=aMaxLength, Panic(ETDes16LengthOutOfRange)); |
|
5243 |
if(aHeapCell) |
|
5244 |
{ |
|
5245 |
__ASSERT_ALWAYS(User::AllocLen(aHeapCell) >= aMaxLength * (TInt)sizeof(TUint16), Panic(ETDes16LengthOutOfRange)); |
|
5246 |
//Create EPtr type descriptor that points to aHeapCell |
|
5247 |
new(this) TPtr16(aHeapCell,aLength,aMaxLength); |
|
5248 |
} |
|
5249 |
else |
|
5250 |
{ |
|
5251 |
__ASSERT_ALWAYS(aMaxLength == 0, Panic(ETDes16LengthOutOfRange)); |
|
5252 |
//Create zero-length RBuf. It is EPtr type of descriptor that points to NULL. |
|
5253 |
new(this) RBuf16(); |
|
5254 |
} |
|
5255 |
__TEST_INVARIANT; |
|
5256 |
} |
|
5257 |
||
5258 |
||
5259 |
||
5260 |
||
5261 |
/** |
|
5262 |
Transfers ownership of the specified heap descriptor to this object. |
|
5263 |
||
5264 |
Note that the function assumes that this descriptor does not already own any |
|
5265 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5266 |
allocated memory. If this descriptor does already own allocated memory, |
|
5267 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5268 |
invoked. |
|
5269 |
||
5270 |
@param aHBuf The heap descriptor to be transferred to this object. |
|
5271 |
This pointer can be NULL, which means that a zero length |
|
5272 |
16-bit resizable buffer descriptor is created. |
|
5273 |
||
5274 |
@see RBuf16::Close() |
|
5275 |
*/ |
|
5276 |
EXPORT_C void RBuf16::Assign(HBufC16* aHBuf) |
|
5277 |
{ |
|
5278 |
new(this) RBuf16(aHBuf); |
|
5279 |
} |
|
5280 |
||
5281 |
||
5282 |
||
5283 |
||
5284 |
/** |
|
5285 |
Swaps the content of two 16-bit resizable buffer descriptors. |
|
5286 |
||
5287 |
@param aRBuf The 16-bit resizable buffer descriptor whose contents are to be |
|
5288 |
swapped with this one. |
|
5289 |
*/ |
|
5290 |
EXPORT_C void RBuf16::Swap(RBuf16& aRBuf) |
|
5291 |
{ |
|
5292 |
Mem::Swap(this,&aRBuf,sizeof(*this)); |
|
5293 |
} |
|
5294 |
||
5295 |
||
5296 |
||
5297 |
||
5298 |
/** |
|
5299 |
Creates a 16-bit resizable buffer descriptor. |
|
5300 |
||
5301 |
The function allocates sufficient memory to contain descriptor data up to |
|
5302 |
the specified maximum length. |
|
5303 |
||
5304 |
The current length of the descriptor is set to zero. The maximum length of |
|
5305 |
the descriptor is set to the specified value. |
|
5306 |
||
5307 |
Note that the function assumes that this descriptor does not already own any |
|
5308 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5309 |
allocated memory. If this descriptor does already own allocated memory, |
|
5310 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5311 |
invoked. |
|
5312 |
||
5313 |
@param aMaxLength The maximum length of the descriptor. |
|
5314 |
||
5315 |
@return KErrNone, if successful; KErrNoMemory, if there is insufficient memory. |
|
5316 |
||
5317 |
@see TDesC16::Length() |
|
5318 |
@see TDes16::MaxLength() |
|
5319 |
@see RBuf16::Close() |
|
5320 |
*/ |
|
5321 |
EXPORT_C TInt RBuf16::Create(TInt aMaxLength) |
|
5322 |
{ |
|
5323 |
if (aMaxLength) |
|
5324 |
{ |
|
5325 |
//Allocate memory |
|
5326 |
TUint16* buf=(TUint16*)User::Alloc(aMaxLength*sizeof(TUint16)); |
|
5327 |
if(!buf) return KErrNoMemory; |
|
5328 |
iEPtrType = buf; |
|
5329 |
} |
|
5330 |
else |
|
5331 |
iEPtrType = NULL; //Zero-length descriptor. |
|
5332 |
||
5333 |
||
5334 |
//Create EPtr type descriptor. |
|
5335 |
new(this) RBuf16(EPtr,0,aMaxLength); |
|
5336 |
__TEST_INVARIANT; |
|
5337 |
return KErrNone; |
|
5338 |
} |
|
5339 |
||
5340 |
||
5341 |
||
5342 |
||
5343 |
/** |
|
5344 |
Creates 16-bit resizable buffer descriptor, and leaves on failure. |
|
5345 |
||
5346 |
The function allocates sufficient memory to contain descriptor data up to |
|
5347 |
the specified maximum length. |
|
5348 |
||
5349 |
The current length of the descriptor is set to zero. The maximum length of |
|
5350 |
the descriptor is set to the specified value. |
|
5351 |
||
5352 |
Note that the function assumes that this descriptor does not already own any |
|
5353 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5354 |
allocated memory. If this descriptor does already own allocated memory, |
|
5355 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5356 |
invoked. |
|
5357 |
||
5358 |
@param aMaxLength The maximum length of the descriptor. |
|
5359 |
||
5360 |
@leave KErrNoMemory If there is insufficient memory. |
|
5361 |
||
5362 |
@see TDesC16::Length() |
|
5363 |
@see TDes16::MaxLength() |
|
5364 |
@see RBuf16::Close() |
|
5365 |
*/ |
|
5366 |
EXPORT_C void RBuf16::CreateL(TInt aMaxLength) |
|
5367 |
{ |
|
5368 |
User::LeaveIfError(Create(aMaxLength)); |
|
5369 |
} |
|
5370 |
||
5371 |
||
5372 |
||
5373 |
||
5374 |
/** |
|
5375 |
Creates a 16-bit resizable buffer descriptor. |
|
5376 |
||
5377 |
The function allocates sufficient memory to contain descriptor data up to |
|
5378 |
the specified maximum length. |
|
5379 |
||
5380 |
Both the current length and the maximum length of the descriptor are set to |
|
5381 |
the specified value. |
|
5382 |
||
5383 |
Note that the function assumes that this descriptor does not already own any |
|
5384 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5385 |
allocated memory. If this descriptor does already own allocated memory, |
|
5386 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5387 |
invoked. |
|
5388 |
||
5389 |
@param aMaxLength The length and the maximum length of the descriptor. |
|
5390 |
||
5391 |
@return KErrNone, if successful; KErrNoMemory, if there is insufficient memory. |
|
5392 |
||
5393 |
@see RBuf16::Close() |
|
5394 |
*/ |
|
5395 |
EXPORT_C TInt RBuf16::CreateMax(TInt aMaxLength) |
|
5396 |
{ |
|
5397 |
TInt err=Create(aMaxLength); |
|
5398 |
if(err==KErrNone) |
|
5399 |
SetMax(); |
|
5400 |
return err; |
|
5401 |
} |
|
5402 |
||
5403 |
||
5404 |
||
5405 |
||
5406 |
/** |
|
5407 |
Creates a 16-bit resizable buffer descriptor, and leaves on failure. |
|
5408 |
||
5409 |
The function allocates sufficient memory to contain descriptor data up to |
|
5410 |
the specified maximum length. |
|
5411 |
||
5412 |
Both the current length and the maximum length of the descriptor are set to |
|
5413 |
the specified value. |
|
5414 |
||
5415 |
Note that the function assumes that this descriptor does not already own any |
|
5416 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5417 |
allocated memory. If this descriptor does already own allocated memory, |
|
5418 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5419 |
invoked. |
|
5420 |
||
5421 |
@param aMaxLength The length and the maximum length of the descriptor. |
|
5422 |
||
5423 |
@leave KErrNoMemory If there is insufficient memory. |
|
5424 |
||
5425 |
@see TDesC16::Length() |
|
5426 |
@see TDes16::MaxLength() |
|
5427 |
@see RBuf16::Close() |
|
5428 |
*/ |
|
5429 |
EXPORT_C void RBuf16::CreateMaxL(TInt aMaxLength) |
|
5430 |
{ |
|
5431 |
User::LeaveIfError(CreateMax(aMaxLength)); |
|
5432 |
} |
|
5433 |
||
5434 |
||
5435 |
||
5436 |
||
5437 |
/** |
|
5438 |
Creates a 16-bit resizable buffer descriptor to contain a copy of the |
|
5439 |
specified (source) descriptor. |
|
5440 |
||
5441 |
The function allocates sufficient memory so that this descriptor's maximum |
|
5442 |
length is the same as the length of the source descriptor. Both the current |
|
5443 |
length and the maximum length of this descriptor are set to |
|
5444 |
the length of the source descriptor. |
|
5445 |
||
5446 |
The data contained in the source descriptor is copied into this |
|
5447 |
descriptor. |
|
5448 |
||
5449 |
Note that the function assumes that this descriptor does not |
|
5450 |
already own any allocated memory. It does not check, nor does it free any |
|
5451 |
pre-existing owned allocated memory. If this descriptor does already own |
|
5452 |
allocated memory, RBuf16::Close() should be invoked on this descriptor before |
|
5453 |
this function is invoked. |
|
5454 |
||
5455 |
@param aDes Source descriptor to be copied into this object. |
|
5456 |
||
5457 |
@return KErrNone, if successful; KErrNoMemory, if there is insufficient memory. |
|
5458 |
||
5459 |
@see TDesC16::Length() |
|
5460 |
@see TDes16::MaxLength() |
|
5461 |
@see TDes16::Copy() |
|
5462 |
@see RBuf16::Close() |
|
5463 |
*/ |
|
5464 |
EXPORT_C TInt RBuf16::Create(const TDesC16& aDes) |
|
5465 |
{ |
|
5466 |
return Create(aDes,aDes.Length()); |
|
5467 |
} |
|
5468 |
||
5469 |
||
5470 |
||
5471 |
||
5472 |
||
5473 |
/** |
|
5474 |
Creates a 16-bit resizable buffer descriptor to contain a copy of the specified |
|
5475 |
(source) descriptor, and leaves on failure. |
|
5476 |
||
5477 |
The function allocates sufficient memory so that this descriptor's maximum |
|
5478 |
length is the same as the length of the source descriptor.Both the current |
|
5479 |
length and the maximum length of this descriptor are set to the length |
|
5480 |
of the source descriptor. |
|
5481 |
||
5482 |
The data contained in the source descriptor is copied into this descriptor. |
|
5483 |
||
5484 |
Note that the function assumes that this descriptor does not already own any |
|
5485 |
allocated memory. It does not check, nor does it free any |
|
5486 |
pre-existing owned allocated memory. If this descriptor does already own |
|
5487 |
allocated memory, RBuf16::Close() should be invoked on this descriptor before |
|
5488 |
this function is invoked. |
|
5489 |
||
5490 |
@param aDes Source descriptor to be copied into this object. |
|
5491 |
||
5492 |
@leave KErrNoMemory If there is insufficient memory. |
|
5493 |
||
5494 |
@see TDesC16::Length() |
|
5495 |
@see TDes16::MaxLength() |
|
5496 |
@see TDes16::Copy() |
|
5497 |
@see RBuf16::Close() |
|
5498 |
*/ |
|
5499 |
EXPORT_C void RBuf16::CreateL(const TDesC16& aDes) |
|
5500 |
{ |
|
5501 |
CreateL(aDes,aDes.Length()); |
|
5502 |
} |
|
5503 |
||
5504 |
||
5505 |
||
5506 |
||
5507 |
/** |
|
5508 |
Creates a 16-bit resizable buffer descriptor to contain a copy of the |
|
5509 |
specified (source) descriptor. |
|
5510 |
||
5511 |
The function allocates sufficient memory so that this descriptor's maximum length |
|
5512 |
is the same as the value of the aMaxLength parameter. |
|
5513 |
||
5514 |
The data contained in the source descriptor is copied into this descriptor. |
|
5515 |
The length of data copied is either |
|
5516 |
||
5517 |
- the length of the source descriptor aDes |
|
5518 |
||
5519 |
or |
|
5520 |
||
5521 |
- the value of the aMaxLength parameter |
|
5522 |
||
5523 |
whichever is the smaller value. The current length of this descriptor is also |
|
5524 |
set to the smaller value. |
|
5525 |
||
5526 |
Note that the function assumes that this descriptor does not already own any |
|
5527 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5528 |
allocated memory. If this descriptor does already own allocated memory, |
|
5529 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5530 |
invoked. |
|
5531 |
||
5532 |
@param aDes Source descriptor to be copied into this object. |
|
5533 |
||
5534 |
@param aMaxLength The maximum length of this descriptor. |
|
5535 |
||
5536 |
@return KErrNone, if successful; KErrNoMemory, if there is insufficient memory. |
|
5537 |
||
5538 |
@see TDesC16::Length() |
|
5539 |
@see TDes16::MaxLength() |
|
5540 |
@see TDes16::Copy() |
|
5541 |
@see RBuf16::Close() |
|
5542 |
*/ |
|
5543 |
EXPORT_C TInt RBuf16::Create(const TDesC16& aDes,TInt aMaxLength) |
|
5544 |
{ |
|
5545 |
TInt err=Create(aMaxLength); |
|
5546 |
if(err==KErrNone) |
|
5547 |
Copy(aDes.Left(aMaxLength)); |
|
5548 |
return err; |
|
5549 |
} |
|
5550 |
||
5551 |
||
5552 |
||
5553 |
||
5554 |
/** |
|
5555 |
Creates a 16-bit resizable buffer descriptor to contain a copy of the specified |
|
5556 |
(source) descriptor, and leaves on failure. |
|
5557 |
||
5558 |
The function allocates sufficient memory so that this descriptor's maximum |
|
5559 |
length is the same as the value of the aMaxLength parameter. |
|
5560 |
||
5561 |
The data contained in the source descriptor is copied into this descriptor. |
|
5562 |
The length of data copied is either |
|
5563 |
||
5564 |
- the length of the source descriptor aDes |
|
5565 |
||
5566 |
or |
|
5567 |
||
5568 |
- the value of the aMaxLength parameter |
|
5569 |
||
5570 |
whichever is the smaller value. The current length of this descriptor is also |
|
5571 |
set to the smaller value. |
|
5572 |
||
5573 |
Note that the function assumes that this descriptor does not already own any |
|
5574 |
allocated memory. It does not check, nor does it free any pre-existing owned |
|
5575 |
allocated memory. If this descriptor does already own allocated memory, |
|
5576 |
RBuf16::Close() should be invoked on this descriptor before this function is |
|
5577 |
invoked. |
|
5578 |
||
5579 |
@param aDes Source descriptor to be copied into this object. |
|
5580 |
||
5581 |
@param aMaxLength The maximum length of this descriptor. |
|
5582 |
||
5583 |
@leave KErrNoMemory If there is insufficient memory. |
|
5584 |
||
5585 |
@see TDesC16::Length() |
|
5586 |
@see TDes16::MaxLength() |
|
5587 |
@see TDes16::Copy() |
|
5588 |
@see RBuf16::Close() |
|
5589 |
*/ |
|
5590 |
EXPORT_C void RBuf16::CreateL(const TDesC16& aDes,TInt aMaxLength) |
|
5591 |
{ |
|
5592 |
CreateL(aMaxLength); |
|
5593 |
Copy(aDes.Left(aMaxLength)); |
|
5594 |
} |
|
5595 |
||
5596 |
||
5597 |
||
5598 |
||
5599 |
/** |
|
5600 |
Resizes this 16-bit resizable buffer descriptor. |
|
5601 |
||
5602 |
The length and contents of the descriptor are unchanged. |
|
5603 |
||
5604 |
If the buffer descriptor was created from a zero-length heap descriptor |
|
5605 |
HBufC, this method might leak memory (the heap descriptor is not freed). |
|
5606 |
It is possible to avoid this by calling the Close() method prior to ReAlloc(), |
|
5607 |
but this should be done only in this situation (otherwise the buffer contents |
|
5608 |
will be lost). |
|
5609 |
||
5610 |
For example, add |
|
5611 |
@code |
|
5612 |
if (desc.MaxLength() == 0) desc.Close(); |
|
5613 |
@endcode |
|
5614 |
before the call to ReAlloc(). |
|
5615 |
||
5616 |
@param aMaxLength The new maximum length of the descriptor. This can be zero, |
|
5617 |
which results in a descriptor with zero maximum length and no |
|
5618 |
allocated memory. |
|
5619 |
||
5620 |
@return KErrNone, if successful; KErrNoMemory, if there is insufficient memory. |
|
5621 |
||
5622 |
@panic USER 14 If the new maximum length is less then the current descriptor length. |
|
5623 |
*/ |
|
5624 |
EXPORT_C TInt RBuf16::ReAlloc(TInt aMaxLength) |
|
5625 |
{ |
|
5626 |
__ASSERT_ALWAYS(Length()<=aMaxLength, Panic(ETDes16ReAllocTooSmall)); |
|
5627 |
__TEST_INVARIANT; |
|
5628 |
||
5629 |
if (!aMaxLength) //Reallocation to zero length |
|
5630 |
{ |
|
5631 |
User::Free(iEPtrType); //Free memory |
|
5632 |
new (this) RBuf16(); //Create zero-length RBuf |
|
5633 |
return KErrNone; |
|
5634 |
} |
|
5635 |
||
5636 |
if (!iMaxLength) //Reallocation from zero length |
|
5637 |
return Create(aMaxLength); |
|
5638 |
||
5639 |
switch(Type()) |
|
5640 |
{ |
|
5641 |
case EPtr: |
|
5642 |
{ |
|
5643 |
TUint16* buf = (TUint16*)User::ReAlloc(iEPtrType,aMaxLength*sizeof(TUint16)); |
|
5644 |
if(!buf) return KErrNoMemory; |
|
5645 |
iEPtrType = buf; |
|
5646 |
iMaxLength = aMaxLength; |
|
5647 |
break; |
|
5648 |
} |
|
5649 |
case EBufCPtr: |
|
5650 |
{ |
|
5651 |
HBufC16* hbufc = iEBufCPtrType->ReAlloc(aMaxLength); |
|
5652 |
if(!hbufc) return KErrNoMemory; |
|
5653 |
Assign(hbufc); |
|
5654 |
break; |
|
5655 |
} |
|
5656 |
} |
|
5657 |
||
5658 |
__TEST_INVARIANT; |
|
5659 |
return KErrNone; |
|
5660 |
} |
|
5661 |
||
5662 |
||
5663 |
||
5664 |
||
5665 |
/** |
|
5666 |
Resizes this 16-bit resizable buffer descriptor, leaving on failure. |
|
5667 |
||
5668 |
The length and contents of the descriptor are unchanged. |
|
5669 |
||
5670 |
If the buffer descriptor was created from a zero-length heap descriptor |
|
5671 |
HBufC, this method might leak memory (the heap descriptor is not freed). |
|
5672 |
It is possible to avoid this by calling the Close() method prior to ReAllocL(), |
|
5673 |
but this should be done only in this situation (otherwise the buffer contents |
|
5674 |
will be lost). |
|
5675 |
||
5676 |
For example, add |
|
5677 |
@code |
|
5678 |
if (desc.MaxLength() == 0) desc.Close(); |
|
5679 |
@endcode |
|
5680 |
before the call to ReAlloc(). |
|
5681 |
||
5682 |
@param aMaxLength The new maximum length of the descriptor. This can be zero, |
|
5683 |
which results in a descriptor with zero maximum length and no |
|
5684 |
allocated memory. |
|
5685 |
||
5686 |
@return KErrNone, if successful; KErrNoMemory, if there is insufficient memory. |
|
5687 |
||
5688 |
@panic USER 14 If the new maximum length is less then the current descriptor length. |
|
5689 |
*/ |
|
5690 |
EXPORT_C void RBuf16::ReAllocL(TInt aMaxLength) |
|
5691 |
{ |
|
5692 |
User::LeaveIfError(ReAlloc(aMaxLength)); |
|
5693 |
} |
|
5694 |
||
5695 |
||
5696 |
||
5697 |
||
5698 |
/** |
|
5699 |
Deallocates memory assigned to this object, and re-initializes the object as |
|
5700 |
a zero-length descriptor. |
|
5701 |
*/ |
|
5702 |
EXPORT_C void RBuf16::Close() |
|
5703 |
{ |
|
5704 |
User::Free(iEPtrType); |
|
5705 |
//Create zero-length RBuf. It is EPtr type of descriptor that points to NULL. |
|
5706 |
new(this) RBuf16(); |
|
5707 |
} |
|
5708 |
||
5709 |
||
5710 |
||
5711 |
||
5712 |
/** |
|
5713 |
Pushes a cleanup item for this object onto the cleanup stack. |
|
5714 |
||
5715 |
The effect of this is to cause Close() to be called on this 16-bit resizable |
|
5716 |
buffer descriptor, when CleanupStack::PopAndDestroy() is called at some later time. |
|
5717 |
||
5718 |
@code |
|
5719 |
... |
|
5720 |
RBuf16 x; |
|
5721 |
.... |
|
5722 |
x.CleanupClosePushL(); |
|
5723 |
... |
|
5724 |
CleanupStack::PopAndDestroy(); |
|
5725 |
... |
|
5726 |
@endcode |
|
5727 |
||
5728 |
@see RBuf16::Close() |
|
5729 |
*/ |
|
5730 |
EXPORT_C void RBuf16::CleanupClosePushL() |
|
5731 |
{ |
|
5732 |
::CleanupClosePushL(*this); |
|
5733 |
} |
|
5734 |
||
5735 |
||
5736 |
||
5737 |
||
5738 |
/** |
|
5739 |
Tests that the class obeys its invariant. |
|
5740 |
*/ |
|
5741 |
EXPORT_C void RBuf16::__DbgTestInvariant() const |
|
5742 |
{ |
|
5743 |
#ifdef _DEBUG |
|
5744 |
TDes16::__DbgTestInvariant(); |
|
5745 |
switch(Type()) |
|
5746 |
{ |
|
5747 |
case EPtr: |
|
5748 |
if (iEPtrType) |
|
5749 |
{ |
|
5750 |
__ASSERT_DEBUG(User::AllocLen(iEPtrType) >= iMaxLength*(TInt)sizeof(TUint16), Panic(EInvariantFalse)); |
|
5751 |
} |
|
5752 |
break; |
|
5753 |
case EBufCPtr: |
|
5754 |
iEBufCPtrType->__DbgTestInvariant(); |
|
5755 |
__ASSERT_DEBUG(iEBufCPtrType->Des().MaxLength() == iMaxLength, Panic(EInvariantFalse)); |
|
5756 |
__ASSERT_DEBUG(iEBufCPtrType->Length() == Length(), Panic(EInvariantFalse)); |
|
5757 |
break; |
|
5758 |
default: |
|
5759 |
User::Invariant(); |
|
5760 |
} |
|
5761 |
#endif // _DEBUG |
|
5762 |
} |
|
5763 |
||
5764 |
#endif // __KERNEL_MODE__ |
|
5765 |
||
5766 |
||
5767 |
#if defined(__DES16_MACHINE_CODED__) || defined(__EABI__) |
|
5768 |
GLDEF_C void Des16PanicBadDesType() |
|
5769 |
{ |
|
5770 |
Panic(ETDes16BadDescriptorType); |
|
5771 |
} |
|
5772 |
||
5773 |
GLDEF_C void Des16PanicPosOutOfRange() |
|
5774 |
{ |
|
5775 |
Panic(ETDes16PosOutOfRange); |
|
5776 |
} |
|
5777 |
#endif |
|
5778 |
||
5779 |
#ifdef __DES16_MACHINE_CODED__ |
|
5780 |
GLDEF_C void Des16PanicLengthNegative() |
|
5781 |
{ |
|
5782 |
Panic(ETDes16LengthNegative); |
|
5783 |
} |
|
5784 |
||
5785 |
GLDEF_C void Des16PanicMaxLengthNegative() |
|
5786 |
{ |
|
5787 |
Panic(ETDes16MaxLengthNegative); |
|
5788 |
} |
|
5789 |
||
5790 |
GLDEF_C void Des16PanicLengthOutOfRange() |
|
5791 |
{ |
|
5792 |
Panic(ETDes16LengthOutOfRange); |
|
5793 |
} |
|
5794 |
||
5795 |
GLDEF_C void Des16PanicDesOverflow() |
|
5796 |
{ |
|
5797 |
Panic(ETDes16Overflow); |
|
5798 |
} |
|
5799 |
||
5800 |
GLDEF_C void Des16PanicDesIndexOutOfRange() |
|
5801 |
{ |
|
5802 |
Panic(ETDes16IndexOutOfRange); |
|
5803 |
} |
|
5804 |
#endif |
|
5805 |