sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\e32des8.h sl@0: // sl@0: // sl@0: sl@0: #ifndef __E32DES8_H__ sl@0: #define __E32DES8_H__ sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: const TUint KMaskDesLength8=0xfffffff; sl@0: sl@0: class TBufCBase8; sl@0: class TDes8; sl@0: class TPtrC8; sl@0: class TPtr8; sl@0: class TPtr16; sl@0: #ifndef __KERNEL_MODE__ sl@0: class HBufC8; sl@0: #endif sl@0: class TDesC8 sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: Abstract base class for 8-bit non-modifiable descriptors. sl@0: sl@0: The class encapsulates the data member containing the length of data sl@0: represented by an 8-bit descriptor. It also provides member functions through sl@0: which the data can be accessed, but not modified. sl@0: sl@0: Data represented by this class is treated as a contiguous set of 8-bit (i.e. sl@0: single byte) values or data items. sl@0: sl@0: This class cannot be instantiated as it is intended to form part of a class sl@0: hierarchy; it provides a well defined part of descriptor behaviour. It can, sl@0: however, be passed as an argument type for functions which want access to sl@0: descriptor data but do not need to modify that data. sl@0: sl@0: @see TDesC sl@0: @see TPtrC8 sl@0: */ sl@0: { sl@0: public: sl@0: inline TBool operator<(const TDesC8 &aDes) const; sl@0: inline TBool operator<=(const TDesC8 &aDes) const; sl@0: inline TBool operator>(const TDesC8 &aDes) const; sl@0: inline TBool operator>=(const TDesC8 &aDes) const; sl@0: inline TBool operator==(const TDesC8 &aDes) const; sl@0: inline TBool operator!=(const TDesC8 &aDes) const; sl@0: inline const TUint8 &operator[](TInt anIndex) const; sl@0: inline TInt Length() const; sl@0: inline TInt Size() const; sl@0: IMPORT_C const TUint8 *Ptr() const; sl@0: IMPORT_C TInt Compare(const TDesC8 &aDes) const; sl@0: IMPORT_C TInt Match(const TDesC8 &aDes) const; sl@0: IMPORT_C TInt MatchF(const TDesC8 &aDes) const; sl@0: IMPORT_C TInt MatchC(const TDesC8 &aDes) const; sl@0: IMPORT_C TInt Locate(TChar aChar) const; sl@0: IMPORT_C TInt LocateReverse(TChar aChar) const; sl@0: IMPORT_C TInt Find(const TDesC8 &aDes) const; sl@0: IMPORT_C TInt Find(const TUint8 *pS,TInt aLenS) const; sl@0: IMPORT_C TPtrC8 Left(TInt aLength) const; sl@0: IMPORT_C TPtrC8 Right(TInt aLength) const; sl@0: IMPORT_C TPtrC8 Mid(TInt aPos) const; sl@0: IMPORT_C TPtrC8 Mid(TInt aPos,TInt aLength) const; sl@0: IMPORT_C TInt CompareF(const TDesC8 &aDes) const; sl@0: #ifndef __KERNEL_MODE__ sl@0: IMPORT_C TInt CompareC(const TDesC8 &aDes) const; sl@0: IMPORT_C TInt LocateF(TChar aChar) const; sl@0: IMPORT_C TInt LocateReverseF(TChar aChar) const; sl@0: IMPORT_C TInt FindF(const TDesC8 &aDes) const; sl@0: IMPORT_C TInt FindF(const TUint8 *pS,TInt aLenS) const; sl@0: IMPORT_C TInt FindC(const TDesC8 &aDes) const; sl@0: IMPORT_C TInt FindC(const TUint8 *pS,TInt aLenS) const; sl@0: IMPORT_C HBufC8 *Alloc() const; sl@0: IMPORT_C HBufC8 *AllocL() const; sl@0: IMPORT_C HBufC8 *AllocLC() const; sl@0: #endif sl@0: protected: sl@0: inline TDesC8(TInt aType,TInt aLength); sl@0: inline TDesC8() {} sl@0: // delay this for a while sl@0: #ifdef SYMBIAN_FIX_TDESC_CONSTRUCTORS sl@0: inline TDesC8( const TDesC8& aOther) : iLength(aOther.iLength) {} sl@0: #endif sl@0: // inline ~TDesC8() {} Commented out for the moment since it breaks code sl@0: inline TInt Type() const; sl@0: inline void DoSetLength(TInt aLength); sl@0: IMPORT_C const TUint8 &AtC(TInt anIndex) const; sl@0: private: sl@0: TUint iLength; sl@0: __DECLARE_TEST; sl@0: }; sl@0: // sl@0: class TPtrC8 : public TDesC8 sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: 8-bit non-modifiable pointer descriptor. sl@0: sl@0: This is a descriptor class intended for instantiation and encapsulates a sl@0: pointer to the 8-bit data that it represents. The data can live in ROM or RAM sl@0: and this location is separate from the descriptor object itself. sl@0: sl@0: The data is intended to be accessed, but not changed, through this descriptor. sl@0: The base class provides the functions through which data is accessed. sl@0: sl@0: @see TPtr8 sl@0: @see TDesC8 sl@0: @see TDes8 sl@0: @see TBufC8 sl@0: @see TBuf8 sl@0: @see HBufC8 sl@0: */ sl@0: { sl@0: public: sl@0: IMPORT_C TPtrC8(); sl@0: IMPORT_C TPtrC8(const TDesC8 &aDes); sl@0: IMPORT_C TPtrC8(const TUint8 *aString); sl@0: IMPORT_C TPtrC8(const TUint8 *aBuf,TInt aLength); sl@0: inline void Set(const TUint8 *aBuf,TInt aLength); sl@0: inline void Set(const TDesC8 &aDes); sl@0: inline void Set(const TPtrC8& aPtr); sl@0: private: sl@0: TPtrC8& operator=(const TPtrC8 &aDes); sl@0: protected: sl@0: const TUint8 *iPtr; sl@0: private: sl@0: __DECLARE_TEST; sl@0: }; sl@0: // sl@0: class TDes8Overflow sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: An interface that defines an overflow handler for an 8-bit descriptor. sl@0: sl@0: The interface encapsulates a function that is called when an attempt to append sl@0: formatted text fails because the descriptor is already at its maximum length. sl@0: sl@0: A derived class must provide an implementation for the Overflow() member sl@0: function. sl@0: sl@0: @see TDes8::AppendFormat sl@0: */ sl@0: { sl@0: public: sl@0: /** sl@0: Handles the overflow. sl@0: sl@0: This function is called when the TDes8::AppendFormat() variant that takes sl@0: an overflow handler argument, fails. sl@0: sl@0: @param aDes The 8-bit modifiable descriptor whose overflow results in the sl@0: call to this overflow handler. sl@0: */ sl@0: virtual void Overflow(TDes8 &aDes)=0; sl@0: }; sl@0: // sl@0: class TDes8IgnoreOverflow : public TDes8Overflow sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: A derived class which provides an implementation for the Overflow() member function sl@0: where truncation is required. sl@0: sl@0: @see TDes16::AppendFormat sl@0: */ sl@0: { sl@0: public: sl@0: /** sl@0: Handles the overflow. sl@0: sl@0: This function is called when the TDes8::AppendFormat() sl@0: variant that takes an overflow handler argument, fails. sl@0: sl@0: @param aDes The 8-bit modifiable descriptor whose overflow results in the sl@0: call to this overflow handler. sl@0: */ sl@0: IMPORT_C virtual void Overflow(TDes8 &aDes); sl@0: }; sl@0: // sl@0: class TDesC16; sl@0: class TRealFormat; sl@0: class TDes8 : public TDesC8 sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: Abstract base class for 8-bit modifiable descriptors. sl@0: sl@0: The class encapsulates the data member containing the maximum length of data sl@0: represented by an 8-bit descriptor. It also provides member functions through sl@0: which the data can be modified. sl@0: sl@0: The class adds to the behaviour provided by TDesC8. sl@0: sl@0: This class cannot be instantiated as it is intended to form part of a class sl@0: hierarchy; it provides a well defined part of descriptor behaviour. It can, sl@0: however, be passed as an argument type for functions which need to both modify sl@0: and access descriptor data. sl@0: sl@0: @see TDes sl@0: @see TDesC8 sl@0: @see TDesC16 sl@0: */ sl@0: { sl@0: public: sl@0: inline TDes8& operator=(const TUint8 *aString); sl@0: inline TDes8& operator=(const TDesC8 &aDes); sl@0: inline TDes8& operator=(const TDes8 &aDes); sl@0: inline TInt MaxLength() const; sl@0: inline TInt MaxSize() const; sl@0: inline const TUint8 &operator[](TInt anIndex) const; sl@0: inline TUint8 &operator[](TInt anIndex); sl@0: inline TDes8 &operator+=(const TDesC8 &aDes); sl@0: IMPORT_C void Zero(); sl@0: IMPORT_C void SetLength(TInt aLength); sl@0: IMPORT_C void SetMax(); sl@0: IMPORT_C void Copy(const TDesC8 &aDes); sl@0: IMPORT_C void Copy(const TUint8 *aBuf,TInt aLength); sl@0: IMPORT_C void Copy(const TUint8 *aString); sl@0: IMPORT_C void Copy(const TDesC16 &aDes); sl@0: IMPORT_C void Append(TChar aChar); sl@0: IMPORT_C void Append(const TDesC8 &aDes); sl@0: IMPORT_C void Append(const TDesC16 &aDes); sl@0: IMPORT_C void Append(const TUint8 *aBuf,TInt aLength); sl@0: IMPORT_C void Fill(TChar aChar); sl@0: IMPORT_C void Fill(TChar aChar,TInt aLength); sl@0: IMPORT_C void FillZ(); sl@0: IMPORT_C void FillZ(TInt aLength); sl@0: IMPORT_C void Num(TInt64 aVal); sl@0: IMPORT_C void Num(TUint64 aVal, TRadix aRadix); sl@0: IMPORT_C void NumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth); sl@0: IMPORT_C void AppendNum(TInt64 aVal); sl@0: IMPORT_C void AppendNum(TUint64 aVal, TRadix aRadix); sl@0: IMPORT_C void AppendNumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth); sl@0: #ifndef __KERNEL_MODE__ sl@0: IMPORT_C TPtr8 LeftTPtr(TInt aLength) const; sl@0: IMPORT_C TPtr8 RightTPtr(TInt aLength) const; sl@0: IMPORT_C TPtr8 MidTPtr(TInt aPos) const; sl@0: IMPORT_C TPtr8 MidTPtr(TInt aPos,TInt aLength) const; sl@0: IMPORT_C const TUint8 *PtrZ(); sl@0: IMPORT_C void CopyF(const TDesC8 &aDes); sl@0: IMPORT_C void CopyC(const TDesC8 &aDes); sl@0: IMPORT_C void CopyLC(const TDesC8 &aDes); sl@0: IMPORT_C void CopyUC(const TDesC8 &aDes); sl@0: IMPORT_C void CopyCP(const TDesC8 &aDes); sl@0: IMPORT_C void Swap(TDes8 &aDes); sl@0: IMPORT_C void AppendFill(TChar aChar,TInt aLength); sl@0: IMPORT_C void ZeroTerminate(); sl@0: IMPORT_C void Fold(); sl@0: IMPORT_C void Collate(); sl@0: IMPORT_C void LowerCase(); sl@0: IMPORT_C void UpperCase(); sl@0: IMPORT_C void Capitalize(); sl@0: IMPORT_C void Repeat(const TUint8 *aBuf,TInt aLength); sl@0: IMPORT_C void Repeat(const TDesC8 &aDes); sl@0: IMPORT_C void Trim(); sl@0: IMPORT_C void TrimAll(); sl@0: IMPORT_C void TrimLeft(); sl@0: IMPORT_C void TrimRight(); sl@0: IMPORT_C void Insert(TInt aPos,const TDesC8 &aDes); sl@0: IMPORT_C void Delete(TInt aPos,TInt aLength); sl@0: IMPORT_C void Replace(TInt aPos,TInt aLength,const TDesC8 &aDes); sl@0: IMPORT_C void Justify(const TDesC8 &aDes,TInt aWidth,TAlign anAlignment,TChar aFill); sl@0: IMPORT_C void NumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth); sl@0: IMPORT_C void NumUC(TUint64 aVal, TRadix aRadix=EDecimal); sl@0: IMPORT_C TInt Num(TReal aVal,const TRealFormat &aFormat) __SOFTFP; sl@0: IMPORT_C void AppendNumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth); sl@0: IMPORT_C TInt AppendNum(TReal aVal,const TRealFormat &aFormat) __SOFTFP; sl@0: IMPORT_C void AppendNumUC(TUint64 aVal,TRadix aRadix=EDecimal); sl@0: IMPORT_C void Format(TRefByValue aFmt,...); sl@0: IMPORT_C void FormatList(const TDesC8 &aFmt,VA_LIST aList); sl@0: IMPORT_C void AppendJustify(const TDesC8 &Des,TInt aWidth,TAlign anAlignment,TChar aFill); sl@0: IMPORT_C void AppendJustify(const TDesC8 &Des,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill); sl@0: IMPORT_C void AppendJustify(const TUint8 *aString,TInt aWidth,TAlign anAlignment,TChar aFill); sl@0: IMPORT_C void AppendJustify(const TUint8 *aString,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill); sl@0: IMPORT_C void AppendFormat(TRefByValue aFmt,TDes8Overflow *aOverflowHandler,...); sl@0: IMPORT_C void AppendFormat(TRefByValue aFmt,...); sl@0: IMPORT_C void AppendFormatList(const TDesC8 &aFmt,VA_LIST aList,TDes8Overflow *aOverflowHandler=NULL); sl@0: IMPORT_C TPtr16 Expand(); sl@0: IMPORT_C void Collapse(); sl@0: #endif //__KERNEL_MODE__ sl@0: protected: sl@0: inline TDes8(TInt aType,TInt aLength,TInt aMaxLength); sl@0: inline TUint8 *WPtr() const; sl@0: inline TDes8() {} sl@0: // delay this for a while sl@0: #ifdef SYMBIAN_FIX_TDESC_CONSTRUCTORS sl@0: inline TDes8(const TDes8& aOther) : TDesC8(aOther), iMaxLength(aOther.iMaxLength) {} sl@0: #endif sl@0: void DoAppendNum(TUint64 aVal, TRadix aRadix, TUint aA, TInt aW); sl@0: void DoPadAppendNum(TInt aLength, TInt aW, const TUint8* aBuf); sl@0: protected: sl@0: TInt iMaxLength; sl@0: __DECLARE_TEST; sl@0: }; sl@0: // sl@0: class TPtr8 : public TDes8 sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: 8-bit modifiable pointer descriptor. sl@0: sl@0: This is a descriptor class intended for instantiation and encapsulates a sl@0: pointer to the 8-bit data that it represents. The data can live in ROM or sl@0: RAM and this location is separate from the descriptor object itself. sl@0: sl@0: The data is intended to be accessed and modified through this descriptor. sl@0: The base classes provide the functions through which the data can be sl@0: manipulated. sl@0: sl@0: @see TPtr sl@0: @see TPtrC8 sl@0: @see TDesC8 sl@0: @see TDes8 sl@0: @see TBufC8 sl@0: @see TBuf8 sl@0: @see HBufC8 sl@0: */ sl@0: { sl@0: public: sl@0: IMPORT_C TPtr8(TUint8 *aBuf,TInt aMaxLength); sl@0: IMPORT_C TPtr8(TUint8 *aBuf,TInt aLength,TInt aMaxLength); sl@0: inline TPtr8& operator=(const TUint8 *aString); sl@0: inline TPtr8& operator=(const TDesC8& aDes); sl@0: inline TPtr8& operator=(const TPtr8& aPtr); sl@0: inline void Set(TUint8 *aBuf,TInt aLength,TInt aMaxLength); sl@0: inline void Set(const TPtr8 &aPtr); sl@0: private: sl@0: IMPORT_C TPtr8(TBufCBase8 &aLcb,TInt aMaxLength); sl@0: protected: sl@0: TUint8 *iPtr; sl@0: private: sl@0: friend class TBufCBase8; sl@0: __DECLARE_TEST; sl@0: }; sl@0: // sl@0: class TBufCBase8 : public TDesC8 sl@0: /** sl@0: @internalAll sl@0: */ sl@0: { sl@0: protected: sl@0: IMPORT_C TBufCBase8(); sl@0: inline TBufCBase8(TInt aLength); sl@0: IMPORT_C TBufCBase8(const TUint8 *aString,TInt aMaxLength); sl@0: IMPORT_C TBufCBase8(const TDesC8 &aDes,TInt aMaxLength); sl@0: IMPORT_C void Copy(const TUint8 *aString,TInt aMaxLength); sl@0: IMPORT_C void Copy(const TDesC8 &aDes,TInt aMaxLength); sl@0: inline TPtr8 DoDes(TInt aMaxLength); sl@0: inline TUint8 *WPtr() const; sl@0: }; sl@0: // sl@0: #ifndef __KERNEL_MODE__ sl@0: class RReadStream; sl@0: class HBufC8 : public TBufCBase8 sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: 8-bit heap descriptor. sl@0: sl@0: This is a descriptor class which provides a buffer of fixed length, allocated sl@0: on the heap, for containing and accessing data. sl@0: sl@0: The class is intended for instantiation. sl@0: sl@0: Heap descriptors have the important property that they can be made larger sl@0: or smaller, changing the size of the descriptor buffer. This is achieved by sl@0: reallocating the descriptor. Unlike the behaviour of dynamic buffers, sl@0: reallocation is not done automatically. sl@0: sl@0: Data is intended to be accessed, but not modified; however, it can be sl@0: completely replaced using the assignment operators of this class. The base sl@0: class (TDesC8) provides the functions through which the data is accessed. sl@0: sl@0: The descriptor is hosted by a heap cell, and the 8-bit data that the sl@0: descriptor represents is part of the descriptor object itself. The size of the sl@0: cell depends on the requested maximum length of the descriptor buffer when the sl@0: descriptor is created or re-allocated. sl@0: sl@0: It is important to note that the size of the allocated cell, and, therefore, sl@0: the resulting maximum length of the descriptor, may be larger than requested sl@0: due to the way memory is allocated in Symbian OS. The amount by which this sl@0: may be rounded up depends on the platform and build type. sl@0: sl@0: @see HBufC sl@0: @see TPtr8 sl@0: @see TDesC8 sl@0: */ sl@0: { sl@0: public: sl@0: IMPORT_C static HBufC8 *New(TInt aMaxLength); sl@0: IMPORT_C static HBufC8 *NewL(TInt aMaxLength); sl@0: IMPORT_C static HBufC8 *NewLC(TInt aMaxLength); sl@0: IMPORT_C static HBufC8 *NewMax(TInt aMaxLength); sl@0: IMPORT_C static HBufC8 *NewMaxL(TInt aMaxLength); sl@0: IMPORT_C static HBufC8 *NewMaxLC(TInt aMaxLength); sl@0: IMPORT_C static HBufC8 *NewL(RReadStream &aStream,TInt aMaxLength); sl@0: IMPORT_C static HBufC8 *NewLC(RReadStream &aStream,TInt aMaxLength); sl@0: IMPORT_C HBufC8& operator=(const TUint8 *aString); sl@0: IMPORT_C HBufC8& operator=(const TDesC8 &aDes); sl@0: inline HBufC8& operator=(const HBufC8 &aLcb); sl@0: IMPORT_C HBufC8 *ReAlloc(TInt aMaxLength); sl@0: IMPORT_C HBufC8 *ReAllocL(TInt aMaxLength); sl@0: IMPORT_C TPtr8 Des(); sl@0: private: sl@0: inline HBufC8(TInt aLength); sl@0: private: sl@0: TText8 iBuf[1]; sl@0: __DECLARE_TEST; sl@0: }; sl@0: #endif sl@0: // sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: #define __Size8 (sizeof(TInt)/sizeof(TInt8)) sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: #define __Align8(s) ((((s)+__Size8-1)/__Size8)*__Size8) sl@0: // sl@0: template sl@0: class TBufC8 : public TBufCBase8 sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: 8-bit non-modifiable buffer descriptor. sl@0: sl@0: This is a descriptor class which provides a buffer of fixed length for sl@0: containing and accessing TUint8 data. sl@0: sl@0: The class intended for instantiation. The 8-bit data that the descriptor sl@0: represents is part of the descriptor object itself. sl@0: sl@0: The class is templated, based on an integer value which defines the size of sl@0: the descriptor's data area. sl@0: sl@0: The data is intended to be accessed, but not modified; however, it can be sl@0: completely replaced using the assignment operators of this class. The base sl@0: class provides the functions through which the data is accessed. sl@0: sl@0: @see TBufC sl@0: @see TDesC8 sl@0: @see TPtr8 sl@0: @see TUint8 sl@0: */ sl@0: { sl@0: public: sl@0: inline TBufC8(); sl@0: inline TBufC8(const TUint8 *aString); sl@0: inline TBufC8(const TDesC8 &aDes); sl@0: inline TBufC8 &operator=(const TUint8 *aString); sl@0: inline TBufC8 &operator=(const TDesC8 &aDes); sl@0: inline TPtr8 Des(); sl@0: protected: sl@0: TUint8 iBuf[__Align8(S)]; sl@0: }; sl@0: // sl@0: class TBufBase8 : public TDes8 sl@0: /** sl@0: @internalAll sl@0: */ sl@0: { sl@0: protected: sl@0: IMPORT_C TBufBase8(TInt aMaxLength); sl@0: IMPORT_C TBufBase8(TInt aLength,TInt aMaxLength); sl@0: IMPORT_C TBufBase8(const TUint8* aString,TInt aMaxLength); sl@0: IMPORT_C TBufBase8(const TDesC8& aDes,TInt aMaxLength); sl@0: }; sl@0: // sl@0: template sl@0: class TBuf8 : public TBufBase8 sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: A descriptor class which provides a buffer of fixed length for sl@0: containing, accessing and manipulating TUint8 data. sl@0: sl@0: The class is intended for instantiation. The 8-bit data that the descriptor sl@0: represents is part of the descriptor object itself. sl@0: sl@0: The class is templated, based on an integer value which determines the size sl@0: of the data area which is created as part of the buffer descriptor object; sl@0: this is also the maximum length of the descriptor. sl@0: sl@0: The data is intended to be both accessed and modified. The base classes provide sl@0: the functions through which the data is accessed. sl@0: sl@0: @see TBuf sl@0: @see TDesC8 sl@0: @see TDes8 sl@0: @see TPtr8 sl@0: */ sl@0: { sl@0: public: sl@0: inline TBuf8(); sl@0: inline explicit TBuf8(TInt aLength); sl@0: inline TBuf8(const TUint8* aString); sl@0: inline TBuf8(const TDesC8& aDes); sl@0: inline TBuf8& operator=(const TUint8* aString); sl@0: inline TBuf8& operator=(const TDesC8& aDes); sl@0: inline TBuf8& operator=(const TBuf8& aBuf); sl@0: protected: sl@0: TUint8 iBuf[__Align8(S)]; sl@0: }; sl@0: sl@0: // sl@0: template sl@0: class TAlignedBuf8 : public TBufBase8 sl@0: /** sl@0: @internalComponent sl@0: sl@0: A descriptor class functionally identical to TBuf8, the only sl@0: difference from it being that TAlignedBuf8's internal buffer sl@0: is guaranteed to be 64-bit aligned. sl@0: sl@0: At present this class is not intended for general use. It exists sl@0: solely to support TPckgBuf which derives from it. sl@0: sl@0: @see TBuf8 sl@0: @see TPckgBuf sl@0: */ sl@0: { sl@0: public: sl@0: inline TAlignedBuf8(); sl@0: inline explicit TAlignedBuf8(TInt aLength); sl@0: inline TAlignedBuf8(const TUint8* aString); sl@0: inline TAlignedBuf8(const TDesC8& aDes); sl@0: inline TAlignedBuf8& operator=(const TUint8* aString); sl@0: inline TAlignedBuf8& operator=(const TDesC8& aDes); sl@0: inline TAlignedBuf8& operator=(const TAlignedBuf8& aBuf); sl@0: protected: sl@0: union { sl@0: double only_here_to_force_8byte_alignment; sl@0: TUint8 iBuf[__Align8(S)]; sl@0: }; sl@0: }; sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: sl@0: class RBuf8 : public TDes8 sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: 8 bit resizable buffer descriptor. sl@0: sl@0: The class provides a buffer that contains, accesses and manipulates sl@0: TUint8 data. The buffer itself is on the heap, and is managed by the class. sl@0: sl@0: Internally, RBuf8 behaves in one of two ways: sl@0: sl@0: - as a TPtr8 descriptor type, where the buffer just contains data sl@0: - as a pointer to a heap descriptor, an HBufC8* type, where the buffer sl@0: contains both descriptor information and the data. sl@0: sl@0: Note that the handling of the distinction is hidden from view. sl@0: sl@0: An RBuf8 object can allocate its own buffer. Alternatively, it can take sl@0: ownership of a pre-existing section of allocated memory, or it can take sl@0: ownership of a pre-existing heap descriptor. It can also reallocate the buffer sl@0: to resize it. Regardless of the way in which the buffer has been allocated, sl@0: the RBuf8 object is responsible for freeing memory when the object itself is closed. sl@0: sl@0: The class is intended for instantiation. sl@0: sl@0: The class is derived from TDes8, which means that data can be both accessed sl@0: and modified. The base classes provide the functions through which the data is sl@0: accessed. In addition, an RBuf8 object can be passed to any function that is sl@0: prototyped to take a TDes8 or a TDesC8 type. sl@0: sl@0: @see TBuf8 sl@0: @see TPtr8 sl@0: @see HBufC8 sl@0: @see TDesC8 sl@0: @see TDes8 sl@0: */ sl@0: { sl@0: public: sl@0: IMPORT_C RBuf8(); sl@0: IMPORT_C explicit RBuf8(HBufC8* aHBuf); sl@0: inline RBuf8& operator=(const TUint8* aString); sl@0: inline RBuf8& operator=(const TDesC8& aDes); sl@0: inline RBuf8& operator=(const RBuf8& aDes); sl@0: IMPORT_C void Assign(const RBuf8& aRBuf); sl@0: IMPORT_C void Assign(TUint8 *aHeapCell,TInt aMaxLength); sl@0: IMPORT_C void Assign(TUint8 *aHeapCell,TInt aLength,TInt aMaxLength); sl@0: IMPORT_C void Assign(HBufC8* aHBuf); sl@0: IMPORT_C void Swap(RBuf8& aRBuf); sl@0: IMPORT_C TInt Create(TInt aMaxLength); sl@0: IMPORT_C void CreateL(TInt aMaxLength); sl@0: IMPORT_C TInt CreateMax(TInt aMaxLength); sl@0: IMPORT_C void CreateMaxL(TInt aMaxLength); sl@0: inline void CreateL(RReadStream &aStream,TInt aMaxLength); sl@0: IMPORT_C TInt Create(const TDesC8& aDes); sl@0: IMPORT_C void CreateL(const TDesC8& aDes); sl@0: IMPORT_C TInt Create(const TDesC8& aDes,TInt aMaxLength); sl@0: IMPORT_C void CreateL(const TDesC8& aDes,TInt aMaxLength); sl@0: IMPORT_C TInt ReAlloc(TInt aMaxLength); sl@0: IMPORT_C void ReAllocL(TInt aMaxLength); sl@0: IMPORT_C void Close(); sl@0: IMPORT_C void CleanupClosePushL(); sl@0: sl@0: protected: sl@0: IMPORT_C RBuf8(TInt aType,TInt aLength,TInt aMaxLength); sl@0: RBuf8(const RBuf8&); // Outlaw copy construction sl@0: union sl@0: { sl@0: TUint8* iEPtrType; //Pointer to data used when RBuf is of EPtr type sl@0: HBufC8* iEBufCPtrType; //Pointer to data used when RBuf is of EBufCPtr type sl@0: }; sl@0: __DECLARE_TEST; sl@0: }; sl@0: sl@0: #endif sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: Value reference used in operator TLitC8::__TRefDesC8() sl@0: sl@0: @see TRefByValue sl@0: */ sl@0: typedef TRefByValue __TRefDesC8; sl@0: sl@0: sl@0: sl@0: sl@0: template sl@0: class TLitC8 sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: Encapsulates literal text. sl@0: sl@0: This is always constructed using an _LIT8 macro. sl@0: sl@0: This class is build independent; i.e. an explicit 8-bit build variant sl@0: is generated for both a non-Unicode build and a Unicode build. sl@0: sl@0: The class has no explicit constructors. sl@0: sl@0: @see _LIT8 sl@0: */ sl@0: { sl@0: public: sl@0: inline const TDesC8* operator&() const; sl@0: inline operator const TDesC8&() const; sl@0: inline const TDesC8& operator()() const; sl@0: inline operator const __TRefDesC8() const; sl@0: public: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: TUint iTypeLength; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: TText8 iBuf[__Align8(S)]; sl@0: }; sl@0: sl@0: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: sl@0: #endif