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