os/kernelhwsrv/kernel/eka/euser/us_des.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
parent 0 bde4ae8d615e
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\euser\us_des.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "us_std.h"
sl@0
    19
sl@0
    20
// Terrible hack. Surely we should use VA_START instead of the below?
sl@0
    21
#if defined(__EABI__) || (defined(__X86__) && defined(__GCC32__))
sl@0
    22
#define EABI_STYLE_VA_LISTS
sl@0
    23
#endif
sl@0
    24
sl@0
    25
const TInt KNoPrecision=-1;
sl@0
    26
const TInt KDefaultPrecision=6;
sl@0
    27
const TInt KMaxRealWidth=0x20;
sl@0
    28
sl@0
    29
// TFormatedText8 and TFormatedText16
sl@0
    30
sl@0
    31
class TFormatedText8
sl@0
    32
	{
sl@0
    33
public:
sl@0
    34
	TBuf8<0x40> iBuffer;
sl@0
    35
	const TUint8* iText;
sl@0
    36
	TInt iTextLength;
sl@0
    37
	TInt iWidth;
sl@0
    38
	TAlign iJustify;
sl@0
    39
	TChar iFill;
sl@0
    40
	};
sl@0
    41
sl@0
    42
class TFormatedText16
sl@0
    43
	{
sl@0
    44
public:
sl@0
    45
	TBuf16<0x40> iBuffer;
sl@0
    46
	const TUint16* iText;
sl@0
    47
	TInt iTextLength;
sl@0
    48
	TInt iWidth;
sl@0
    49
	TAlign iJustify;
sl@0
    50
	TChar iFill;
sl@0
    51
	};
sl@0
    52
sl@0
    53
// TPanicker8 and TPanicker16
sl@0
    54
sl@0
    55
class TPanicker8
sl@0
    56
	{
sl@0
    57
public:
sl@0
    58
	static inline void Panic_BadFormatDescriptor() {Panic(ETDes8BadFormatDescriptor);}
sl@0
    59
	static inline void Panic_BadFormatParams() {Panic(ETDes8BadFormatParams);}
sl@0
    60
	};
sl@0
    61
sl@0
    62
class TPanicker16
sl@0
    63
	{
sl@0
    64
public:
sl@0
    65
	static inline void Panic_BadFormatDescriptor() {Panic(ETDes16BadFormatDescriptor);}
sl@0
    66
	static inline void Panic_BadFormatParams() {Panic(ETDes16BadFormatParams);}
sl@0
    67
	};
sl@0
    68
sl@0
    69
// TFormatDirective
sl@0
    70
sl@0
    71
class TFormatDirective // basically a sort of array of parameters where the size of each parameter is stored (no more than 4 parameters are possible per format-directive) - it also knows whether the format directive it represents has an explicit index, and if so, what that index is
sl@0
    72
	{
sl@0
    73
public:
sl@0
    74
	inline TFormatDirective() :iSizesOfParametersInBytes(0), iFormatDirectiveIndex(EImplicitFormatDirectiveIndex) {}
sl@0
    75
	void AppendParameter(TInt aSizeOfParameterInBytes,TInt aParameterAlignment);
sl@0
    76
	inline void FormatDirectiveHasExplicitIndex(TInt aFormatDirectiveIndex) {iFormatDirectiveIndex=aFormatDirectiveIndex;}
sl@0
    77
private:
sl@0
    78
	friend class TParameterManager;
sl@0
    79
private:
sl@0
    80
	enum {EImplicitFormatDirectiveIndex=-1};
sl@0
    81
	enum
sl@0
    82
		{
sl@0
    83
		EShiftToNumberOfParameters=28,
sl@0
    84
		ENumberOfBitsPerParameter=5,
sl@0
    85
		EMaskForSingleParameter=(1<<ENumberOfBitsPerParameter)-1,
sl@0
    86
		EMaskForAlignmentShift=3,
sl@0
    87
		EMaskForParameterSize=EMaskForSingleParameter&~EMaskForAlignmentShift,
sl@0
    88
		EMaximumNumberOfParameters=EShiftToNumberOfParameters/ENumberOfBitsPerParameter
sl@0
    89
		};
sl@0
    90
private: // these functions are used by the TParameterManager class
sl@0
    91
	inline TInt NumberOfParameters() const {return iSizesOfParametersInBytes>>EShiftToNumberOfParameters;}
sl@0
    92
	TInt SizeOfParameter(TInt aIndex) const;
sl@0
    93
	TUint8* CalculateDataPointer(const TUint8* aDataPtr,TInt aIndex) const;
sl@0
    94
private:
sl@0
    95
	TUint iSizesOfParametersInBytes; // a compactly stored array
sl@0
    96
	TInt iFormatDirectiveIndex;
sl@0
    97
	};
sl@0
    98
sl@0
    99
void TFormatDirective::AppendParameter(TInt aSizeOfParameterInBytes, TInt aParameterAlignment)
sl@0
   100
	{
sl@0
   101
	const TInt numberOfParameters=NumberOfParameters();
sl@0
   102
	__ASSERT_DEBUG(numberOfParameters<EMaximumNumberOfParameters, Panic(ENumberOfParametersExceedsMaximum));
sl@0
   103
	__ASSERT_DEBUG((aSizeOfParameterInBytes&EMaskForParameterSize)==aSizeOfParameterInBytes, Panic(ESizeOfParameterTooBig));
sl@0
   104
	iSizesOfParametersInBytes+=(1<<EShiftToNumberOfParameters); // increment the count
sl@0
   105
sl@0
   106
	switch(aParameterAlignment)
sl@0
   107
		{
sl@0
   108
	case 4:
sl@0
   109
		// aSizeOfParameterInBytes |= 0;
sl@0
   110
		break;
sl@0
   111
	case 8:
sl@0
   112
		aSizeOfParameterInBytes |= 1;
sl@0
   113
		break;
sl@0
   114
	default:
sl@0
   115
		__ASSERT_DEBUG(0, Panic(EUnexpectedError3));
sl@0
   116
		}
sl@0
   117
sl@0
   118
	iSizesOfParametersInBytes|=(aSizeOfParameterInBytes<<(numberOfParameters*ENumberOfBitsPerParameter)); // store aSizeOfParameterInBytes
sl@0
   119
	}
sl@0
   120
sl@0
   121
TInt TFormatDirective::SizeOfParameter(TInt aIndex) const
sl@0
   122
	{
sl@0
   123
	__ASSERT_DEBUG(aIndex<NumberOfParameters(), Panic(EParameterIndexOutOfRange1));
sl@0
   124
	return (iSizesOfParametersInBytes>>(aIndex*ENumberOfBitsPerParameter))&EMaskForParameterSize;
sl@0
   125
	}
sl@0
   126
sl@0
   127
TUint8* TFormatDirective::CalculateDataPointer(const TUint8* aDataPtr,TInt aIndex) const
sl@0
   128
	{
sl@0
   129
	TInt numParams = NumberOfParameters();
sl@0
   130
	__ASSERT_DEBUG(aIndex<=numParams, Panic(EParameterIndexOutOfRange1));
sl@0
   131
	TInt paramInfo = iSizesOfParametersInBytes;
sl@0
   132
	while(numParams--)
sl@0
   133
		{
sl@0
   134
		TInt alignMask = (4<<(paramInfo&EMaskForAlignmentShift))-1;
sl@0
   135
		aDataPtr = (TUint8*)(((TInt)aDataPtr+alignMask)&~alignMask);
sl@0
   136
		if(!aIndex--)
sl@0
   137
			break;
sl@0
   138
		aDataPtr += paramInfo&EMaskForParameterSize;
sl@0
   139
		paramInfo >>= ENumberOfBitsPerParameter;
sl@0
   140
		}
sl@0
   141
	return const_cast<TUint8*>(aDataPtr);
sl@0
   142
	}
sl@0
   143
sl@0
   144
// TParameterManager
sl@0
   145
sl@0
   146
class TParameterManager
sl@0
   147
	{
sl@0
   148
public:
sl@0
   149
	TParameterManager();
sl@0
   150
	void AddFormatDirective(const TFormatDirective& aFormatDirective);
sl@0
   151
	TInt PrepareToExtractNextParameter(VA_LIST aList); // returns either KErrNone or KErrNotReady
sl@0
   152
	void PrepareToExtractParameters(VA_LIST aList);
sl@0
   153
	TInt ExtractParameter(TAny* aTarget, TInt aSizeOfParameterInBytes, TInt aFormatDirectiveIndex, TInt aParameterIndexWithinFormatDirective, const TFormatDirective* aNextFormatDirective);
sl@0
   154
private:
sl@0
   155
	enum
sl@0
   156
		{
sl@0
   157
		EMaximumNumberOfFormatDirectives=40,
sl@0
   158
		ENumberOfBytesInBitArray=(EMaximumNumberOfFormatDirectives+7)/8
sl@0
   159
		};
sl@0
   160
private:
sl@0
   161
	inline TBool FormatDirectiveIsSet(TInt aIndex) const {return iFormatDirectivesSet[aIndex/8]&(1<<(aIndex%8));}
sl@0
   162
	inline void MarkFormatDirectiveAsSet(TInt aIndex) {iFormatDirectivesSet[aIndex/8]|=(1<<(aIndex%8)); __ASSERT_DEBUG(FormatDirectiveIsSet(aIndex), Panic(EFormatDirectiveAlreadySet1));}
sl@0
   163
private:
sl@0
   164
	TInt iNumberOfFormatDirectives;
sl@0
   165
	TFixedArray<TUint8, ENumberOfBytesInBitArray> iFormatDirectivesSet;
sl@0
   166
	TFixedArray<TFormatDirective, EMaximumNumberOfFormatDirectives> iFormatDirectives;
sl@0
   167
	TFixedArray<const TUint8*, EMaximumNumberOfFormatDirectives> iFormatDirectiveDataPointers;
sl@0
   168
	};
sl@0
   169
sl@0
   170
TParameterManager::TParameterManager()
sl@0
   171
	:iNumberOfFormatDirectives(0)
sl@0
   172
	{
sl@0
   173
	TInt i;
sl@0
   174
	for (i=0; i<ENumberOfBytesInBitArray; ++i)
sl@0
   175
		{
sl@0
   176
		iFormatDirectivesSet[i]=0;
sl@0
   177
		}
sl@0
   178
	for (i=0; i<EMaximumNumberOfFormatDirectives; ++i)
sl@0
   179
		{
sl@0
   180
		iFormatDirectiveDataPointers[i]=NULL;
sl@0
   181
		}
sl@0
   182
	}
sl@0
   183
sl@0
   184
void TParameterManager::AddFormatDirective(const TFormatDirective& aFormatDirective)
sl@0
   185
	{
sl@0
   186
	__ASSERT_ALWAYS(iNumberOfFormatDirectives<EMaximumNumberOfFormatDirectives, Panic(ENumberOfFormatDirectivesExceedsMaximum));
sl@0
   187
	const TInt index=(aFormatDirective.iFormatDirectiveIndex>=0)? aFormatDirective.iFormatDirectiveIndex: iNumberOfFormatDirectives;
sl@0
   188
	__ASSERT_ALWAYS(!FormatDirectiveIsSet(index), Panic(EFormatDirectiveAlreadySet2));
sl@0
   189
	MarkFormatDirectiveAsSet(index);
sl@0
   190
	iFormatDirectives[index]=aFormatDirective;
sl@0
   191
	++iNumberOfFormatDirectives;
sl@0
   192
	}
sl@0
   193
sl@0
   194
TInt TParameterManager::PrepareToExtractNextParameter(VA_LIST aList)
sl@0
   195
	{
sl@0
   196
	if (iNumberOfFormatDirectives==0)
sl@0
   197
		{
sl@0
   198
#ifdef EABI_STYLE_VA_LISTS
sl@0
   199
		// NB under the EABI we are passing va_list (a struct) by value. 
sl@0
   200
		// We could extract the pointer using aList.__ap under RVCT, but I don't believe the EABI 
sl@0
   201
		// extends to the name of the field. So I think the 'nasty' cast is likely to be more
sl@0
   202
		// portable.
sl@0
   203
		const TUint8 ** aL = (const TUint8**)&aList;
sl@0
   204
		iFormatDirectiveDataPointers[iNumberOfFormatDirectives] = aL[0];
sl@0
   205
#else
sl@0
   206
		// The horrible cast is there because you can't assume aList is of 'array' type   
sl@0
   207
		iFormatDirectiveDataPointers[iNumberOfFormatDirectives] = (const TUint8*)(*(TInt*)aList);
sl@0
   208
#endif
sl@0
   209
		}
sl@0
   210
	else
sl@0
   211
		{
sl@0
   212
		const TInt previousFormatDirective=iNumberOfFormatDirectives-1;
sl@0
   213
		const TUint8* dataPointer=iFormatDirectiveDataPointers[previousFormatDirective];
sl@0
   214
		if ((dataPointer==NULL) || !FormatDirectiveIsSet(previousFormatDirective))
sl@0
   215
			{
sl@0
   216
			return KErrNotReady;
sl@0
   217
			}
sl@0
   218
		const TFormatDirective& formatDirective=iFormatDirectives[previousFormatDirective];
sl@0
   219
		dataPointer = formatDirective.CalculateDataPointer(dataPointer,formatDirective.NumberOfParameters());
sl@0
   220
		iFormatDirectiveDataPointers[iNumberOfFormatDirectives]=dataPointer;
sl@0
   221
		}
sl@0
   222
	return KErrNone;
sl@0
   223
	}
sl@0
   224
sl@0
   225
void TParameterManager::PrepareToExtractParameters(VA_LIST aList)
sl@0
   226
	{
sl@0
   227
#ifdef EABI_STYLE_VA_LISTS
sl@0
   228
	// NB under the EABI we are passing va_list (a struct) by value. 
sl@0
   229
	// We could extract the pointer using aList.__ap under RVCT, but I don't believe the EABI 
sl@0
   230
	// extends to the name of the field. So I think the 'nasty' cast is likely to be more
sl@0
   231
	// portable.
sl@0
   232
	const TUint8 ** aL = (const TUint8**)&aList;
sl@0
   233
	const TUint8* dataPointer = aL[0];
sl@0
   234
#else
sl@0
   235
	// The horrible cast is there because you can't assume aList is of 'array' type   
sl@0
   236
	const TUint8* dataPointer = (const TUint8*)(*(TInt*)aList);
sl@0
   237
#endif
sl@0
   238
	if (iNumberOfFormatDirectives>0)
sl@0
   239
		{
sl@0
   240
		for (TInt i=0; ; ++i)
sl@0
   241
			{
sl@0
   242
			__ASSERT_ALWAYS(FormatDirectiveIsSet(i), Panic(EFormatDirectiveNotYetSet));
sl@0
   243
			__ASSERT_DEBUG((iFormatDirectiveDataPointers[i]==NULL) || (iFormatDirectiveDataPointers[i]==dataPointer), Panic(EBadFormatDirectiveDataPointer));
sl@0
   244
			iFormatDirectiveDataPointers[i]=dataPointer;
sl@0
   245
			if (i+1>=iNumberOfFormatDirectives)
sl@0
   246
				{
sl@0
   247
				break;
sl@0
   248
				}
sl@0
   249
			const TFormatDirective& formatDirective=iFormatDirectives[i];
sl@0
   250
			dataPointer = formatDirective.CalculateDataPointer(dataPointer,formatDirective.NumberOfParameters());
sl@0
   251
			}
sl@0
   252
		}
sl@0
   253
	}
sl@0
   254
sl@0
   255
TInt TParameterManager::ExtractParameter(TAny* aTarget, TInt aSizeOfParameterInBytes, TInt aFormatDirectiveIndex, TInt aParameterIndexWithinFormatDirective, const TFormatDirective* aNextFormatDirective)
sl@0
   256
	{
sl@0
   257
	__ASSERT_DEBUG(aFormatDirectiveIndex<EMaximumNumberOfFormatDirectives, Panic(EFormatDirectiveIndexOutOfRange));
sl@0
   258
	const TFormatDirective* formatDirective=NULL;
sl@0
   259
	if (aFormatDirectiveIndex<iNumberOfFormatDirectives)
sl@0
   260
		{
sl@0
   261
		if (!FormatDirectiveIsSet(aFormatDirectiveIndex))
sl@0
   262
			{
sl@0
   263
			return KErrNotReady;
sl@0
   264
			}
sl@0
   265
		formatDirective=&iFormatDirectives[aFormatDirectiveIndex];
sl@0
   266
		}
sl@0
   267
	else
sl@0
   268
		{
sl@0
   269
		__ASSERT_DEBUG(aNextFormatDirective!=NULL, Panic(ENotOnFirstPassOfFormatDescriptor1)); // the above condition (aFormatDirectiveIndex>=iNumberOfFormatDirectives) can only be the case on a first pass of the format descriptor, so assert that we're on the first pass
sl@0
   270
		if (aFormatDirectiveIndex>iNumberOfFormatDirectives)
sl@0
   271
			{
sl@0
   272
			return KErrNotReady;
sl@0
   273
			}
sl@0
   274
		formatDirective=aNextFormatDirective;
sl@0
   275
		}
sl@0
   276
	__ASSERT_DEBUG(aSizeOfParameterInBytes==formatDirective->SizeOfParameter(aParameterIndexWithinFormatDirective), Panic(EInconsistentSizeOfParameter));
sl@0
   277
	const TUint8* dataPointer=iFormatDirectiveDataPointers[aFormatDirectiveIndex];
sl@0
   278
	if (dataPointer==NULL)
sl@0
   279
		{
sl@0
   280
		__ASSERT_DEBUG(aNextFormatDirective!=NULL, Panic(ENotOnFirstPassOfFormatDescriptor2)); // the above condition (dataPointer==NULL) can only be the case on a first pass of the format descriptor, so assert that we're on the first pass
sl@0
   281
		return KErrNotReady;
sl@0
   282
		}
sl@0
   283
	__ASSERT_DEBUG(aParameterIndexWithinFormatDirective<formatDirective->NumberOfParameters(), Panic(EParameterIndexOutOfRange2));
sl@0
   284
	dataPointer = formatDirective->CalculateDataPointer(dataPointer,aParameterIndexWithinFormatDirective);
sl@0
   285
	Mem::Copy(aTarget, dataPointer, aSizeOfParameterInBytes);
sl@0
   286
	return KErrNone;
sl@0
   287
	}
sl@0
   288
sl@0
   289
// TParameterHandler
sl@0
   290
sl@0
   291
class TParameterHandler
sl@0
   292
	{
sl@0
   293
public:
sl@0
   294
	enum TAction
sl@0
   295
		{
sl@0
   296
		EParameterNotExtracted,
sl@0
   297
		EParameterExtracted
sl@0
   298
		};
sl@0
   299
public:
sl@0
   300
	inline TParameterHandler(TInt aImplicitFormatDirectiveIndex, TParameterManager& aParameterManager, TFormatDirective& aFormatDirective) :iFormatDirectiveIndex(aImplicitFormatDirectiveIndex), iParameterIndex(0), iFormatDirective(&aFormatDirective), iParameterManager(aParameterManager) {} // for the first pass
sl@0
   301
	inline TParameterHandler(TInt aImplicitFormatDirectiveIndex, TParameterManager& aParameterManager) :iFormatDirectiveIndex(aImplicitFormatDirectiveIndex), iParameterIndex(0), iFormatDirective(NULL), iParameterManager(aParameterManager) {} // for the second pass
sl@0
   302
	TAction HandleParameter(TAny* aTarget, TInt aSizeOfParameterInBytes, TInt aParameterAlignment=4);
sl@0
   303
	void FormatDirectiveHasExplicitIndex(TInt aFormatDirectiveIndex);
sl@0
   304
private:
sl@0
   305
	TInt iFormatDirectiveIndex;
sl@0
   306
	TInt iParameterIndex;
sl@0
   307
	TFormatDirective* iFormatDirective;
sl@0
   308
	TParameterManager& iParameterManager;
sl@0
   309
	};
sl@0
   310
sl@0
   311
TParameterHandler::TAction TParameterHandler::HandleParameter(TAny* aTarget, TInt aSizeOfParameterInBytes, TInt aParameterAlignment)
sl@0
   312
// Increments iParameterIndex each time it is called.
sl@0
   313
// This is conceptually a sort of virtual function (i.e. it's behaviour depends on the way the object was constructed), although it is not implemented like that.
sl@0
   314
	{
sl@0
   315
	__ASSERT_DEBUG(aTarget!=NULL, Panic(ENullTargetPointer));
sl@0
   316
	__ASSERT_DEBUG(aSizeOfParameterInBytes>=0, Panic(ENegativeSizeOfParameter));
sl@0
   317
	const TUint machineWordAlignmentConstant=sizeof(TUint)-1;
sl@0
   318
	aSizeOfParameterInBytes+=machineWordAlignmentConstant;
sl@0
   319
	aSizeOfParameterInBytes&=~machineWordAlignmentConstant;
sl@0
   320
sl@0
   321
	if (iFormatDirective!=NULL)
sl@0
   322
		{
sl@0
   323
		iFormatDirective->AppendParameter(aSizeOfParameterInBytes,aParameterAlignment);
sl@0
   324
		}
sl@0
   325
	const TInt error=iParameterManager.ExtractParameter(aTarget, aSizeOfParameterInBytes, iFormatDirectiveIndex, iParameterIndex, iFormatDirective);
sl@0
   326
#if defined(_DEBUG)
sl@0
   327
	if (iFormatDirective==NULL) // if we're on the second pass...
sl@0
   328
		{
sl@0
   329
		__ASSERT_DEBUG(error==KErrNone, Panic(EErrorOnSecondPassOfFormatDescriptor));
sl@0
   330
		}
sl@0
   331
	else
sl@0
   332
		{
sl@0
   333
		__ASSERT_DEBUG(error==KErrNone || error==KErrNotReady, Panic(EUnexpectedError1));
sl@0
   334
		}
sl@0
   335
#endif
sl@0
   336
	++iParameterIndex;
sl@0
   337
	return (error==KErrNone)? EParameterExtracted: EParameterNotExtracted;
sl@0
   338
	}
sl@0
   339
sl@0
   340
void TParameterHandler::FormatDirectiveHasExplicitIndex(TInt aFormatDirectiveIndex)
sl@0
   341
	{
sl@0
   342
	if (iFormatDirective!=NULL)
sl@0
   343
		{
sl@0
   344
		iFormatDirective->FormatDirectiveHasExplicitIndex(aFormatDirectiveIndex);
sl@0
   345
		}
sl@0
   346
	iFormatDirectiveIndex=aFormatDirectiveIndex;
sl@0
   347
	}
sl@0
   348
sl@0
   349
template <class XDesC, class XFormatedText, class XLex, class XPanicker, TInt XItemSize>
sl@0
   350
void HandleFormatDirective(TParameterHandler& aParameterHandler, XFormatedText& aFormatedText, XLex& aFmt)
sl@0
   351
//
sl@0
   352
// Handle a single format directive, i.e. sequence starting with a '%', (although the initial '%' will have been consumed by this point).
sl@0
   353
//
sl@0
   354
	{
sl@0
   355
sl@0
   356
// Determine alignment of various types on the stack. The FOFF approach 
sl@0
   357
// does not work for GCC 3.4.4 on X86 so we use hardcoded constants instead.
sl@0
   358
#if defined(__GCC32__) && defined(__X86__) 
sl@0
   359
	const TInt KAlignTReal = 4;
sl@0
   360
	const TInt KAlignTRealX = 4;
sl@0
   361
	const TInt KAlignTInt64 = 4;
sl@0
   362
#else
sl@1
   363
 #ifndef __VC32__ // MSVC generates an internal compiler error with the following code
sl@0
   364
	struct TReal_align {char c; TReal a;};
sl@0
   365
	const TInt KAlignTReal = _FOFF(TReal_align,a);
sl@1
   366
sl@0
   367
	struct TRealX_align {char c; TRealX a;};
sl@0
   368
	const TInt KAlignTRealX = _FOFF(TRealX_align,a);
sl@0
   369
sl@0
   370
	struct TInt64_align {char c; TInt64 a;};
sl@0
   371
	const TInt KAlignTInt64 = _FOFF(TInt64_align,a);
sl@0
   372
 #else
sl@1
   373
	//SL: Now also hardcoding KAlignTReal
sl@1
   374
	const TInt KAlignTReal = 4;
sl@0
   375
	const TInt KAlignTRealX = 4;	// Hard code value for MSVC
sl@0
   376
	const TInt KAlignTInt64 = 4;	// Hard code value for MSVC
sl@0
   377
 #endif
sl@0
   378
#endif
sl@0
   379
sl@0
   380
	aFormatedText.iJustify=ERight; // Default is justify right
sl@0
   381
	aFormatedText.iFill=KNoChar; // Default fill character is space
sl@0
   382
	// After a % may come +,-,= or space
sl@0
   383
	if (aFmt.Eos())
sl@0
   384
		XPanicker::Panic_BadFormatDescriptor();
sl@0
   385
	TChar c=aFmt.Get();
sl@0
   386
sl@0
   387
	if (c=='$')
sl@0
   388
		{
sl@0
   389
		TInt formatDirectiveIndex;
sl@0
   390
		if (aFmt.Val(formatDirectiveIndex)!=0)
sl@0
   391
			XPanicker::Panic_BadFormatDescriptor();
sl@0
   392
		aParameterHandler.FormatDirectiveHasExplicitIndex(formatDirectiveIndex-1);
sl@0
   393
		if (aFmt.Get()!='$')
sl@0
   394
			XPanicker::Panic_BadFormatDescriptor();
sl@0
   395
		c=aFmt.Get();
sl@0
   396
		}
sl@0
   397
sl@0
   398
	switch (c)
sl@0
   399
		{
sl@0
   400
	case ' ':
sl@0
   401
		aFormatedText.iFill=' ';
sl@0
   402
		break;
sl@0
   403
	case '-':
sl@0
   404
		aFormatedText.iJustify=ELeft;
sl@0
   405
		goto getFill;
sl@0
   406
	case '=':
sl@0
   407
		aFormatedText.iJustify=ECenter;
sl@0
   408
		goto getFill;
sl@0
   409
	case '+':
sl@0
   410
getFill:
sl@0
   411
		if (aFmt.Eos())
sl@0
   412
			XPanicker::Panic_BadFormatDescriptor();
sl@0
   413
		if (!aFmt.Peek().IsDigit())
sl@0
   414
			{
sl@0
   415
			aFormatedText.iFill=aFmt.Get(); // assigning aFormatedText.iFill to something other than KNoChar is necessary as the aParameterHandler.HandleParameter call a couple of lines below will not necessarily set its first parameter (i.e. aFormatedText.iFill) - aFormatedText.iFill is tested against KNoChar ten or so lines below
sl@0
   416
			if (aFormatedText.iFill=='*') // If*  take it from the arguments
sl@0
   417
				aParameterHandler.HandleParameter(&aFormatedText.iFill, sizeof(TUint));
sl@0
   418
			}
sl@0
   419
		break;
sl@0
   420
	default:
sl@0
   421
		aFmt.UnGet();
sl@0
   422
		}
sl@0
   423
sl@0
   424
	aFormatedText.iWidth=KDefaultJustifyWidth; // Default width is whatever the conversion takes
sl@0
   425
	if (aFmt.Peek().IsDigit())
sl@0
   426
		{
sl@0
   427
		// If it starts with 0 and the fill character has not been
sl@0
   428
		// specified then the fill character will be a 0
sl@0
   429
		// For compatibility with standard C libraries
sl@0
   430
		if (aFmt.Peek()=='0' && aFormatedText.iFill==KNoChar)
sl@0
   431
			{
sl@0
   432
			aFormatedText.iFill='0';
sl@0
   433
			aFmt.Inc();
sl@0
   434
			}
sl@0
   435
		if (aFmt.Peek()!='*')
sl@0
   436
			if (aFmt.Val(aFormatedText.iWidth)) // Convert field width value
sl@0
   437
				XPanicker::Panic_BadFormatDescriptor();
sl@0
   438
		}
sl@0
   439
	if (aFmt.Peek()=='*' && aFormatedText.iWidth==KDefaultJustifyWidth) // If a * then get width from arguments
sl@0
   440
		{
sl@0
   441
		aParameterHandler.HandleParameter(&aFormatedText.iWidth, sizeof(TInt));
sl@0
   442
		aFmt.Inc();
sl@0
   443
		}
sl@0
   444
	// Get precision setting if given
sl@0
   445
	TInt precision=KNoPrecision;
sl@0
   446
	if (aFmt.Peek()=='.')
sl@0
   447
		{
sl@0
   448
		aFmt.Inc();
sl@0
   449
		if (aFmt.Peek()=='*')
sl@0
   450
			{
sl@0
   451
			aParameterHandler.HandleParameter(&precision, sizeof(TInt));
sl@0
   452
			aFmt.Inc();
sl@0
   453
			}
sl@0
   454
		else if (aFmt.Val(precision))
sl@0
   455
			XPanicker::Panic_BadFormatDescriptor();
sl@0
   456
		}
sl@0
   457
	if (aFormatedText.iFill==KNoChar) // If still default fill character make it space
sl@0
   458
		aFormatedText.iFill=' ';
sl@0
   459
	if (aFmt.Eos())
sl@0
   460
		XPanicker::Panic_BadFormatDescriptor();
sl@0
   461
	TChar selector;
sl@0
   462
	TBool lng=EFalse;
sl@0
   463
	TCharUC f=aFmt.Peek();
sl@0
   464
	if (f=='L') // If l set selector for longs
sl@0
   465
		{
sl@0
   466
		aFmt.Inc();
sl@0
   467
		lng=ETrue;
sl@0
   468
		}
sl@0
   469
	selector=aFmt.Get(); // Get the selector in upper case
sl@0
   470
	aFormatedText.iText=aFormatedText.iBuffer.Ptr();
sl@0
   471
	aFormatedText.iTextLength=1;
sl@0
   472
	TRadix radix=EDecimal;
sl@0
   473
	TUint uVal=0;
sl@0
   474
	TReal rVal=0;
sl@0
   475
	TRealX rValX=0;
sl@0
   476
	TInt realFormatType=KRealFormatFixed;
sl@0
   477
	switch (selector)
sl@0
   478
		{
sl@0
   479
	case 'S': // String conversion
sl@0
   480
		{
sl@0
   481
		const XDesC* pB;
sl@0
   482
		if (aParameterHandler.HandleParameter(&pB, sizeof(const TAny*))==TParameterHandler::EParameterExtracted)
sl@0
   483
			{
sl@0
   484
			__ASSERT_DEBUG(pB!=0,XPanicker::Panic_BadFormatParams());
sl@0
   485
			aFormatedText.iTextLength=pB->Length();
sl@0
   486
			if (precision!=KNoPrecision && precision<aFormatedText.iTextLength)
sl@0
   487
				aFormatedText.iTextLength=precision;
sl@0
   488
			aFormatedText.iText=pB->Ptr();
sl@0
   489
			}
sl@0
   490
		}
sl@0
   491
		break;
sl@0
   492
	case 's':
sl@0
   493
		if (aParameterHandler.HandleParameter(&aFormatedText.iText, sizeof(const TAny*))==TParameterHandler::EParameterExtracted)
sl@0
   494
			{
sl@0
   495
			__ASSERT_DEBUG(aFormatedText.iText!=0,XPanicker::Panic_BadFormatParams());
sl@0
   496
			if (precision!=KNoPrecision)
sl@0
   497
				aFormatedText.iTextLength=precision;
sl@0
   498
			else
sl@0
   499
				aFormatedText.iTextLength=User::StringLength(aFormatedText.iText);
sl@0
   500
			}
sl@0
   501
		break;
sl@0
   502
	case 'O':
sl@0
   503
	case 'o':
sl@0
   504
		radix=EOctal;
sl@0
   505
		goto lConv;
sl@0
   506
	case 'X':
sl@0
   507
	case 'x':
sl@0
   508
		radix=EHex;
sl@0
   509
		goto lConv;
sl@0
   510
	case 'B': // Binary conversion
sl@0
   511
	case 'b':
sl@0
   512
		radix=EBinary;
sl@0
   513
		// Fall-through to lConv
sl@0
   514
	case 'U':
sl@0
   515
	case 'u':
sl@0
   516
lConv:
sl@0
   517
		if (lng)
sl@0
   518
			{
sl@0
   519
			TInt64 uVal64 = 0;
sl@0
   520
			if (aParameterHandler.HandleParameter(&uVal64, sizeof(TInt64), KAlignTInt64)==TParameterHandler::EParameterExtracted)
sl@0
   521
				{
sl@0
   522
				if (selector=='X')
sl@0
   523
					aFormatedText.iBuffer.NumUC(uVal64,radix);
sl@0
   524
				else
sl@0
   525
					aFormatedText.iBuffer.Num(uVal64,radix);
sl@0
   526
				}
sl@0
   527
			}
sl@0
   528
		else
sl@0
   529
			{
sl@0
   530
			if (aParameterHandler.HandleParameter(&uVal, sizeof(TUint))==TParameterHandler::EParameterExtracted)
sl@0
   531
				{
sl@0
   532
				if (selector=='X')
sl@0
   533
					aFormatedText.iBuffer.NumUC(uVal,radix);
sl@0
   534
				else
sl@0
   535
					aFormatedText.iBuffer.Num(uVal,radix);
sl@0
   536
				}
sl@0
   537
			}
sl@0
   538
		aFormatedText.iTextLength=aFormatedText.iBuffer.Length();
sl@0
   539
		break;
sl@0
   540
	case 'D': // Decimal conversion
sl@0
   541
	case 'd':
sl@0
   542
	case 'I':
sl@0
   543
	case 'i':
sl@0
   544
		if (lng)
sl@0
   545
			{
sl@0
   546
			TInt64 iVal64=0;
sl@0
   547
			if (aParameterHandler.HandleParameter(&iVal64, sizeof(TInt64),KAlignTInt64)==TParameterHandler::EParameterExtracted)
sl@0
   548
				{
sl@0
   549
				aFormatedText.iBuffer.Num(iVal64);
sl@0
   550
				}
sl@0
   551
			}
sl@0
   552
		else
sl@0
   553
			{
sl@0
   554
			TInt iVal=0;
sl@0
   555
			if (aParameterHandler.HandleParameter(&iVal, sizeof(TInt))==TParameterHandler::EParameterExtracted)
sl@0
   556
				{
sl@0
   557
				aFormatedText.iBuffer.Num(iVal);
sl@0
   558
				}
sl@0
   559
			}
sl@0
   560
		aFormatedText.iTextLength=aFormatedText.iBuffer.Length();
sl@0
   561
		break;
sl@0
   562
	case 'P': // Padded conversion
sl@0
   563
	case 'p':
sl@0
   564
		aFormatedText.iTextLength=0;
sl@0
   565
		break;
sl@0
   566
	case 'C':
sl@0
   567
	case 'c': // Ascii character conversion
sl@0
   568
		if (aParameterHandler.HandleParameter(&uVal, sizeof(TUint))==TParameterHandler::EParameterExtracted)
sl@0
   569
			{
sl@0
   570
			aFormatedText.iBuffer.Append(uVal);
sl@0
   571
			}
sl@0
   572
		break;
sl@0
   573
	case 'W': // SLONG binary lsb first conversion
sl@0
   574
	case 'M': // SLONG binary msb first conversion
sl@0
   575
		if (aParameterHandler.HandleParameter(&uVal, sizeof(TUint))!=TParameterHandler::EParameterExtracted)
sl@0
   576
			{
sl@0
   577
			break;
sl@0
   578
			}
sl@0
   579
		aFormatedText.iTextLength=4/XItemSize;
sl@0
   580
		goto doBinary;
sl@0
   581
	case 'w': // SWORD binary lsb first conversion
sl@0
   582
	case 'm': // SWORD binary msb first conversion
sl@0
   583
		if (aParameterHandler.HandleParameter(&uVal, sizeof(TUint))!=TParameterHandler::EParameterExtracted)
sl@0
   584
			{
sl@0
   585
			break;
sl@0
   586
			}
sl@0
   587
		aFormatedText.iTextLength=2/XItemSize;
sl@0
   588
		//goto doBinary;
sl@0
   589
doBinary:
sl@0
   590
		{
sl@0
   591
		TUint8* pC;
sl@0
   592
		TInt increment;
sl@0
   593
		if (selector=='m' || selector=='M')
sl@0
   594
			{
sl@0
   595
			pC=((TUint8*)(aFormatedText.iText+aFormatedText.iTextLength))-1;
sl@0
   596
			increment=(-1);
sl@0
   597
			}
sl@0
   598
		else
sl@0
   599
			{
sl@0
   600
			pC=(TUint8*)aFormatedText.iText;
sl@0
   601
			increment=1;
sl@0
   602
			}
sl@0
   603
		for (TInt k=aFormatedText.iTextLength*sizeof(*aFormatedText.iText);k>0;--k)
sl@0
   604
			{
sl@0
   605
			*pC=(TUint8)uVal;
sl@0
   606
			pC+=increment;
sl@0
   607
			uVal>>=8;
sl@0
   608
			}
sl@0
   609
		}
sl@0
   610
		break;
sl@0
   611
	case 'F': // TRealX conversion
sl@0
   612
		if (aParameterHandler.HandleParameter(&rValX, sizeof(TRealX), KAlignTRealX)!=TParameterHandler::EParameterExtracted)
sl@0
   613
			{
sl@0
   614
			break;
sl@0
   615
			}
sl@0
   616
		rVal=rValX;
sl@0
   617
		goto doReal;
sl@0
   618
	case 'f': // TReal conversion
sl@0
   619
		if (aParameterHandler.HandleParameter(&rVal, sizeof(TReal), KAlignTReal)!=TParameterHandler::EParameterExtracted)
sl@0
   620
			{
sl@0
   621
			break;
sl@0
   622
			}
sl@0
   623
		goto doReal;
sl@0
   624
	case 'E':
sl@0
   625
		if (aParameterHandler.HandleParameter(&rValX, sizeof(TRealX), KAlignTRealX)!=TParameterHandler::EParameterExtracted)
sl@0
   626
			{
sl@0
   627
			break;
sl@0
   628
			}
sl@0
   629
		rVal=rValX;
sl@0
   630
		realFormatType=KRealFormatExponent|KAllowThreeDigitExp; 	// AnnW - changed from EExponent
sl@0
   631
		goto doReal;
sl@0
   632
	case 'e':
sl@0
   633
		if (aParameterHandler.HandleParameter(&rVal, sizeof(TReal), KAlignTReal)!=TParameterHandler::EParameterExtracted)
sl@0
   634
			{
sl@0
   635
			break;
sl@0
   636
			}
sl@0
   637
		realFormatType=KRealFormatExponent|KAllowThreeDigitExp; 	// AnnW - changed from EExponent
sl@0
   638
		//goto doReal;
sl@0
   639
doReal:
sl@0
   640
		{
sl@0
   641
		if (precision==KNoPrecision)
sl@0
   642
			precision=KDefaultPrecision;
sl@0
   643
		TRealFormat realFormat(KMaxRealWidth, precision);
sl@0
   644
		realFormat.iType=realFormatType;
sl@0
   645
		aFormatedText.iTextLength=aFormatedText.iBuffer.Num(rVal, realFormat);
sl@0
   646
		if (aFormatedText.iTextLength<0)
sl@0
   647
			{
sl@0
   648
			if (aFormatedText.iTextLength==KErrGeneral)
sl@0
   649
				XPanicker::Panic_BadFormatDescriptor();
sl@0
   650
			else
sl@0
   651
				aFormatedText.iTextLength=aFormatedText.iBuffer.Length();
sl@0
   652
			}
sl@0
   653
		if (aFormatedText.iWidth!=KDefaultJustifyWidth && aFormatedText.iTextLength>aFormatedText.iWidth)
sl@0
   654
			aFormatedText.iWidth=aFormatedText.iTextLength;
sl@0
   655
		}
sl@0
   656
		break;
sl@0
   657
	case 'G':
sl@0
   658
		if (aParameterHandler.HandleParameter(&rValX, sizeof(TRealX), KAlignTRealX)!=TParameterHandler::EParameterExtracted)
sl@0
   659
			{
sl@0
   660
			break;
sl@0
   661
			}
sl@0
   662
		rVal=rValX;
sl@0
   663
		goto doGReal;
sl@0
   664
	case 'g':
sl@0
   665
		if (aParameterHandler.HandleParameter(&rVal, sizeof(TReal), KAlignTReal)!=TParameterHandler::EParameterExtracted)
sl@0
   666
			{
sl@0
   667
			break;
sl@0
   668
			}
sl@0
   669
		//goto doGReal;
sl@0
   670
doGReal:
sl@0
   671
		{
sl@0
   672
		if (precision==KNoPrecision)
sl@0
   673
			precision=KDefaultPrecision;
sl@0
   674
sl@0
   675
		// aFormatedText.iBuffer must be >= KMaxRealWidth
sl@0
   676
		TRealFormat realFormat(KMaxRealWidth, precision);	// Changed from 'width' to KMaxRealWidth
sl@0
   677
		realFormat.iType=KRealFormatGeneral|KAllowThreeDigitExp;	// AnnW - changed from EGeneral
sl@0
   678
		aFormatedText.iTextLength=aFormatedText.iBuffer.Num(rVal, realFormat);
sl@0
   679
		if (aFormatedText.iTextLength<0)
sl@0
   680
			{
sl@0
   681
			// Doesn't fit in given width
sl@0
   682
			realFormat.iWidth=KDefaultRealWidth;
sl@0
   683
			aFormatedText.iTextLength=aFormatedText.iBuffer.Num(rVal, realFormat);
sl@0
   684
			}
sl@0
   685
		if (aFormatedText.iTextLength<0)
sl@0
   686
			{
sl@0
   687
			if (aFormatedText.iTextLength==KErrGeneral)
sl@0
   688
				XPanicker::Panic_BadFormatDescriptor();
sl@0
   689
			else
sl@0
   690
				aFormatedText.iTextLength=aFormatedText.iBuffer.Length();
sl@0
   691
			}
sl@0
   692
		if (aFormatedText.iWidth!=KDefaultJustifyWidth && aFormatedText.iTextLength>aFormatedText.iWidth)
sl@0
   693
			aFormatedText.iWidth=aFormatedText.iTextLength;
sl@0
   694
		}
sl@0
   695
		break;
sl@0
   696
	default: // Not recognized - output % something
sl@0
   697
		XPanicker::Panic_BadFormatDescriptor();
sl@0
   698
		}
sl@0
   699
	// Justify result of conversion
sl@0
   700
	if (aFormatedText.iWidth==KDefaultJustifyWidth)
sl@0
   701
		aFormatedText.iWidth=aFormatedText.iTextLength;
sl@0
   702
	if (aFormatedText.iTextLength>aFormatedText.iWidth)
sl@0
   703
		aFormatedText.iTextLength=aFormatedText.iWidth;
sl@0
   704
	}
sl@0
   705
sl@0
   706
template <class XDes, class XDesOverflow, class XDesC, class XFormatedText, class XLex, class XPanicker, TInt XItemSize>
sl@0
   707
void DoAppendFormatList(XDes& aThis,const XDesC& aFormat,VA_LIST aList,XDesOverflow* aOverflowHandler)
sl@0
   708
//
sl@0
   709
// Convert the argument list, using the format descriptor.
sl@0
   710
//
sl@0
   711
	{
sl@0
   712
sl@0
   713
	const TInt overflowLength=aOverflowHandler? aThis.MaxLength(): KMaxTInt;
sl@0
   714
	const TInt originalLength=aThis.Length();
sl@0
   715
	TBool needSecondPass=EFalse;
sl@0
   716
	TParameterManager parameterManager;
sl@0
   717
	XLex format(aFormat);
sl@0
   718
	TInt implicitFormatDirectiveIndex=0;
sl@0
   719
	FOREVER
sl@0
   720
		{
sl@0
   721
		if (format.Eos())
sl@0
   722
			{
sl@0
   723
			break;
sl@0
   724
			}
sl@0
   725
		const TChar character=format.Get();
sl@0
   726
		if (character!='%')
sl@0
   727
			{
sl@0
   728
			if (!needSecondPass)
sl@0
   729
				{
sl@0
   730
				if (aThis.Length()>=overflowLength)
sl@0
   731
					{
sl@0
   732
					aOverflowHandler->Overflow(aThis);
sl@0
   733
					return;
sl@0
   734
					}
sl@0
   735
				aThis.Append(character);
sl@0
   736
				}
sl@0
   737
			}
sl@0
   738
		else if (format.Peek()=='%')
sl@0
   739
			{
sl@0
   740
			if (!needSecondPass)
sl@0
   741
				{
sl@0
   742
				if (aThis.Length()>=overflowLength)
sl@0
   743
					{
sl@0
   744
					aOverflowHandler->Overflow(aThis);
sl@0
   745
					return;
sl@0
   746
					}
sl@0
   747
				aThis.Append(character);
sl@0
   748
				}
sl@0
   749
			format.Inc();
sl@0
   750
			}
sl@0
   751
		else
sl@0
   752
			{
sl@0
   753
			TFormatDirective formatDirective;
sl@0
   754
			TParameterHandler parameterHandler(implicitFormatDirectiveIndex, parameterManager, formatDirective);
sl@0
   755
			XFormatedText formatedText;
sl@0
   756
			const TInt error=parameterManager.PrepareToExtractNextParameter(aList);
sl@0
   757
			if (error!=KErrNone)
sl@0
   758
				{
sl@0
   759
				__ASSERT_DEBUG(error==KErrNotReady, Panic(EUnexpectedError2));
sl@0
   760
				needSecondPass=ETrue;
sl@0
   761
				}
sl@0
   762
			HandleFormatDirective<XDesC, XFormatedText, XLex, XPanicker, XItemSize>(parameterHandler, formatedText, format);
sl@0
   763
			parameterManager.AddFormatDirective(formatDirective);
sl@0
   764
			if (!needSecondPass)
sl@0
   765
				{
sl@0
   766
				if ((aThis.Length()+formatedText.iWidth)>overflowLength)
sl@0
   767
					{
sl@0
   768
					aOverflowHandler->Overflow(aThis);
sl@0
   769
					return;
sl@0
   770
					}
sl@0
   771
				aThis.AppendJustify(formatedText.iText, formatedText.iTextLength, formatedText.iWidth, formatedText.iJustify, formatedText.iFill);
sl@0
   772
				}
sl@0
   773
			++implicitFormatDirectiveIndex;
sl@0
   774
			}
sl@0
   775
		}
sl@0
   776
	if (needSecondPass)
sl@0
   777
		{
sl@0
   778
		aThis.SetLength(originalLength);
sl@0
   779
		parameterManager.PrepareToExtractParameters(aList);
sl@0
   780
		format=aFormat;
sl@0
   781
		implicitFormatDirectiveIndex=0;
sl@0
   782
		FOREVER
sl@0
   783
			{
sl@0
   784
			if (format.Eos())
sl@0
   785
				{
sl@0
   786
				break;
sl@0
   787
				}
sl@0
   788
			const TChar character=format.Get();
sl@0
   789
			if (character!='%')
sl@0
   790
				{
sl@0
   791
				if (aThis.Length()>=overflowLength)
sl@0
   792
					{
sl@0
   793
					aOverflowHandler->Overflow(aThis);
sl@0
   794
					return;
sl@0
   795
					}
sl@0
   796
				aThis.Append(character);
sl@0
   797
				}
sl@0
   798
			else if (format.Peek()=='%')
sl@0
   799
				{
sl@0
   800
				if (aThis.Length()>=overflowLength)
sl@0
   801
					{
sl@0
   802
					aOverflowHandler->Overflow(aThis);
sl@0
   803
					return;
sl@0
   804
					}
sl@0
   805
				aThis.Append(character);
sl@0
   806
				format.Inc();
sl@0
   807
				}
sl@0
   808
			else
sl@0
   809
				{
sl@0
   810
				TParameterHandler parameterHandler(implicitFormatDirectiveIndex, parameterManager);
sl@0
   811
				XFormatedText formatedText;
sl@0
   812
				HandleFormatDirective<XDesC, XFormatedText, XLex, XPanicker, XItemSize>(parameterHandler, formatedText, format);
sl@0
   813
				if ((aThis.Length()+formatedText.iWidth)>overflowLength)
sl@0
   814
					{
sl@0
   815
					aOverflowHandler->Overflow(aThis);
sl@0
   816
					return;
sl@0
   817
					}
sl@0
   818
				aThis.AppendJustify(formatedText.iText, formatedText.iTextLength, formatedText.iWidth, formatedText.iJustify, formatedText.iFill);
sl@0
   819
				++implicitFormatDirectiveIndex;
sl@0
   820
				}
sl@0
   821
			}
sl@0
   822
		}
sl@0
   823
	}
sl@0
   824
sl@0
   825
sl@0
   826
sl@0
   827
sl@0
   828
/**
sl@0
   829
Formats and appends text onto the end of this descriptor's data.
sl@0
   830
	
sl@0
   831
The length of this descriptor is incremented to reflect the new content.
sl@0
   832
	
sl@0
   833
The behaviour of this function is the same as
sl@0
   834
AppendFormat(TRefByValue<const TDesC8> aFmt,TDes8Overflow *aOverflowHandler,...).
sl@0
   835
In practice, it is better and easier to use AppendFormat(), passing a variable number of 
sl@0
   836
arguments as required by the format string.
sl@0
   837
	
sl@0
   838
@param aFormat          The descriptor containing the format string.
sl@0
   839
@param aList            A pointer to an argument list.
sl@0
   840
@param aOverflowHandler If supplied, a pointer to the overflow handler.
sl@0
   841
sl@0
   842
@see TDes8::AppendFormat
sl@0
   843
@see VA_LIST 
sl@0
   844
*/
sl@0
   845
EXPORT_C void TDes8::AppendFormatList(const TDesC8 &aFormat,VA_LIST aList,TDes8Overflow *aOverflowHandler)
sl@0
   846
	{
sl@0
   847
sl@0
   848
	DoAppendFormatList<TDes8, TDes8Overflow, TDesC8, TFormatedText8, TLex8, TPanicker8, sizeof(TUint8)>(*this,aFormat,aList,aOverflowHandler);
sl@0
   849
	}
sl@0
   850
sl@0
   851
sl@0
   852
sl@0
   853
/**
sl@0
   854
Formats and appends text onto the end of this descriptor's data.
sl@0
   855
	
sl@0
   856
The length of this descriptor is incremented to reflect the new content.
sl@0
   857
	
sl@0
   858
The behaviour of this function is the same as
sl@0
   859
AppendFormat(TRefByValue<const TDesC16> aFmt,TDes16Overflow *aOverflowHandler,...).
sl@0
   860
In practice, it is better and easier to use AppendFormat(), passing a variable number of 
sl@0
   861
arguments as required by the format string.
sl@0
   862
	
sl@0
   863
@param aFormat          The descriptor containing the format string.
sl@0
   864
@param aList            A pointer to an argument list.
sl@0
   865
@param aOverflowHandler If supplied, a pointer to the overflow handler.
sl@0
   866
sl@0
   867
@see TDes16::AppendFormat
sl@0
   868
@see VA_LIST 
sl@0
   869
*/
sl@0
   870
EXPORT_C void TDes16::AppendFormatList(const TDesC16 &aFormat,VA_LIST aList,TDes16Overflow *aOverflowHandler)
sl@0
   871
	{
sl@0
   872
sl@0
   873
	DoAppendFormatList<TDes16, TDes16Overflow, TDesC16, TFormatedText16, TLex16, TPanicker16, sizeof(TUint16)>(*this,aFormat,aList,aOverflowHandler);
sl@0
   874
	}
sl@0
   875