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