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