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