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\e32des16.h williamr@2: // williamr@2: // williamr@2: williamr@2: #ifndef __E32DES16_H__ williamr@2: #define __E32DES16_H__ williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: const TUint KMaskDesLength16=0xfffffff; williamr@2: williamr@2: class TBufCBase16; williamr@2: class TDes16; williamr@2: class TPtrC16; williamr@2: class TPtr16; williamr@2: struct TCollationMethod; williamr@2: class HBufC16; williamr@2: class HBufC8; williamr@2: williamr@2: class TDesC16 williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Abstract base class for 16-bit descriptors. williamr@2: williamr@2: The class encapsulates the data member containing the length of data williamr@2: represented by a 16-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 16-bit (i.e. williamr@2: double 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 TPtrC16 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** williamr@2: A value returned by a call to HasPrefixC(). williamr@2: williamr@2: @see TDesC16::HasPrefixC williamr@2: */ williamr@2: enum TPrefix { williamr@2: /** williamr@2: Indicates that a supplied prefix can be extended to williamr@2: be equivalent to the text at the start of a descriptor. williamr@2: */ williamr@2: EIsPrefix = 0, williamr@2: /** williamr@2: Indicates that a supplied prefix does not seem to be a williamr@2: prefix, but it is possible that it could be extended to williamr@2: become equivalent to text at the start of this descriptor. williamr@2: */ williamr@2: EMightBePrefix = 1, williamr@2: /** williamr@2: Indicates that a supplied prefix cannot be extended to be williamr@2: equivalent to the text at the start of a descriptor. williamr@2: */ williamr@2: EIsNotPrefix = 2 williamr@2: }; williamr@2: public: williamr@2: inline TBool operator<(const TDesC16 &aDes) const; williamr@2: inline TBool operator<=(const TDesC16 &aDes) const; williamr@2: inline TBool operator>(const TDesC16 &aDes) const; williamr@2: inline TBool operator>=(const TDesC16 &aDes) const; williamr@2: inline TBool operator==(const TDesC16 &aDes) const; williamr@2: inline TBool operator!=(const TDesC16 &aDes) const; williamr@2: inline const TUint16 &operator[](TInt anIndex) const; williamr@2: inline TInt Length() const; williamr@2: inline TInt Size() const; williamr@2: IMPORT_C const TUint16 *Ptr() const; williamr@2: IMPORT_C TInt Compare(const TDesC16 &aDes) const; williamr@2: IMPORT_C TInt CompareF(const TDesC16 &aDes) const; williamr@2: IMPORT_C TInt CompareC(const TDesC16 &aDes) const; williamr@2: IMPORT_C TInt CompareC(const TDesC16& aDes,TInt aMaxLevel,const TCollationMethod* aCollationMethod) const; williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: IMPORT_C HBufC16* GetNormalizedDecomposedFormL() const; williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: IMPORT_C HBufC16* GetFoldedDecomposedFormL() const; williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: IMPORT_C HBufC8* GetCollationKeysL(TInt aMaxLevel,const TCollationMethod* aCollationMethod) const; williamr@2: IMPORT_C TInt Match(const TDesC16 &aDes) const; williamr@2: IMPORT_C TInt MatchF(const TDesC16 &aDes) const; williamr@2: IMPORT_C TInt MatchC(const TDesC16 &aDes) const; williamr@2: IMPORT_C TInt MatchC(const TDesC16 &aPattern, TInt aWildChar, TInt aWildSequenceChar, williamr@2: TInt aEscapeChar, TInt aMaxLevel = 3, const TCollationMethod* aCollationMethod = NULL) const; williamr@2: IMPORT_C TInt MatchC(const TDesC16 &aPattern, const TCollationMethod* aCollationMethod, williamr@2: TInt aMaxLevel = 3, TInt aWildChar = '?', TInt aWildSequenceChar = '*', TInt aEscapeChar = 0) 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 TDesC16 &aDes) const; williamr@2: IMPORT_C TInt Find(const TUint16 *aBuf,TInt aLen) const; williamr@2: IMPORT_C TPrefix HasPrefixC(const TDesC16& aPossiblePrefix, TInt aLevel, const TCollationMethod* aCollationMethod) const; williamr@2: IMPORT_C TPtrC16 Left(TInt aLength) const; williamr@2: IMPORT_C TPtrC16 Right(TInt aLength) const; williamr@2: IMPORT_C TPtrC16 Mid(TInt aPos) const; williamr@2: IMPORT_C TPtrC16 Mid(TInt aPos,TInt aLength) 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 TDesC16 &aDes) const; williamr@2: IMPORT_C TInt FindF(const TUint16 *aBuf,TInt aLen) const; williamr@2: IMPORT_C TInt FindC(const TDesC16 &aDes) const; williamr@2: IMPORT_C TInt FindC(const TUint16 *aBuf,TInt aLen) const; williamr@2: IMPORT_C TInt FindC(const TUint16 *aText,TInt aLength, TInt aMaxLevel) const; williamr@2: IMPORT_C TInt FindC(const TDesC16 &aDes,TInt &aLengthFound, const TCollationMethod &aMethod,TInt aMaxLevel) const; williamr@2: IMPORT_C HBufC16 *Alloc() const; williamr@2: IMPORT_C HBufC16 *AllocL() const; williamr@2: IMPORT_C HBufC16 *AllocLC() const; williamr@2: protected: williamr@2: inline TDesC16() {} williamr@2: inline TDesC16(TInt aType,TInt aLength); williamr@2: // delay this for a while williamr@2: #ifdef SYMBIAN_FIX_TDESC_CONSTRUCTORS williamr@2: inline TDesC16( const TDesC16& aOther) : iLength(aOther.iLength) {} williamr@2: #endif williamr@2: // inline ~TDesC16() {} 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 TUint16 &AtC(TInt anIndex) const; williamr@2: private: williamr@2: TUint iLength; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: // williamr@2: class TPtrC16 : public TDesC16 williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: 16-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 16-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 TPtr16 williamr@2: @see TDesC16 williamr@2: @see TDes16 williamr@2: @see TBufC16 williamr@2: @see TBuf16 williamr@2: @see HBufC16 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TPtrC16(); williamr@2: IMPORT_C TPtrC16(const TDesC16 &aDes); williamr@2: IMPORT_C TPtrC16(const TUint16 *aString); williamr@2: IMPORT_C TPtrC16(const TUint16 *aBuf,TInt aLength); williamr@2: inline void Set(const TUint16 *aBuf,TInt aLength); williamr@2: inline void Set(const TDesC16 &aDes); williamr@2: inline void Set(const TPtrC16 &aPtr); williamr@2: private: williamr@2: TPtrC16& operator=(const TPtrC16 &aDes); williamr@2: protected: williamr@2: const TUint16 *iPtr; williamr@2: private: williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: // williamr@2: class TDes16Overflow williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: An interface that defines an overflow handler for a 16-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 function. 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 TDes16::AppendFormat() williamr@2: variant that takes an overflow handler argument, fails. williamr@2: williamr@2: @param aDes The 16-bit modifiable descriptor whose overflow results in the williamr@2: call to this overflow handler. williamr@2: */ williamr@2: virtual void Overflow(TDes16 &aDes)=0; williamr@2: }; williamr@2: // williamr@2: class TDes16IgnoreOverflow : public TDes16Overflow 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 TDes16::AppendFormat() williamr@2: variant that takes an overflow handler argument, fails. williamr@2: williamr@2: @param aDes The 16-bit modifiable descriptor whose overflow results in the williamr@2: call to this overflow handler. williamr@2: */ williamr@2: IMPORT_C virtual void Overflow(TDes16 &aDes); williamr@2: }; williamr@2: // williamr@2: class TRealFormat; williamr@2: class TDes16 : public TDesC16 williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Abstract base class for 16-bit modifiable descriptors. williamr@2: williamr@2: The class encapsulates the data member containing the maximum length of data williamr@2: represented by a 16-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 TDesC16. 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 TDes16& operator=(const TUint16 *aString); williamr@2: inline TDes16& operator=(const TDesC16 &aDes); williamr@2: inline TDes16& operator=(const TDes16 &aDes); williamr@2: inline TInt MaxLength() const; williamr@2: inline TInt MaxSize() const; williamr@2: inline const TUint16 &operator[](TInt anIndex) const; williamr@2: inline TUint16 &operator[](TInt anIndex); williamr@2: inline TDes16 &operator+=(const TDesC16 &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 TDesC16 &aDes); williamr@2: IMPORT_C void Copy(const TUint16 *aBuf,TInt aLength); williamr@2: IMPORT_C void Copy(const TUint16 *aString); williamr@2: IMPORT_C void Append(TChar aChar); williamr@2: IMPORT_C void Append(const TDesC16 &aDes); williamr@2: IMPORT_C void Append(const TUint16 *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 NumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth); williamr@2: IMPORT_C void AppendNumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth); williamr@2: IMPORT_C TPtr16 LeftTPtr(TInt aLength) const; williamr@2: IMPORT_C TPtr16 RightTPtr(TInt aLength) const; williamr@2: IMPORT_C TPtr16 MidTPtr(TInt aPos) const; williamr@2: IMPORT_C TPtr16 MidTPtr(TInt aPos,TInt aLength) const; williamr@2: IMPORT_C const TUint16 *PtrZ(); williamr@2: IMPORT_C void CopyF(const TDesC16 &aDes); williamr@2: IMPORT_C void CopyC(const TDesC16 &aDes); williamr@2: IMPORT_C void CopyLC(const TDesC16 &aDes); williamr@2: IMPORT_C void CopyUC(const TDesC16 &aDes); williamr@2: IMPORT_C void CopyCP(const TDesC16 &aDes); williamr@2: IMPORT_C void AppendFill(TChar aChar,TInt aLength); williamr@2: IMPORT_C void ZeroTerminate(); williamr@2: IMPORT_C void Swap(TDes16 &aDes); 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 TDesC16 &aDes); williamr@2: IMPORT_C void Repeat(const TUint16 *aBuf,TInt aLength); 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 TDesC16 &aDes); williamr@2: IMPORT_C void Delete(TInt aPos,TInt aLength); williamr@2: IMPORT_C void Replace(TInt aPos,TInt aLength,const TDesC16 &aDes); williamr@2: IMPORT_C void Justify(const TDesC16 &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 Num(TInt64 aVal); williamr@2: IMPORT_C void Num(TUint64 aVal, TRadix aRadix); williamr@2: IMPORT_C void Format(TRefByValue aFmt,...); williamr@2: IMPORT_C void FormatList(const TDesC16 &aFmt,VA_LIST aList); williamr@2: IMPORT_C void AppendJustify(const TDesC16 &Des,TInt aWidth,TAlign anAlignment,TChar aFill); williamr@2: IMPORT_C void AppendJustify(const TDesC16 &Des,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill); williamr@2: IMPORT_C void AppendJustify(const TUint16 *aString,TInt aWidth,TAlign anAlignment,TChar aFill); williamr@2: IMPORT_C void AppendJustify(const TUint16 *aString,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill); williamr@2: IMPORT_C void AppendNumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth); williamr@2: IMPORT_C void AppendNumUC(TUint64 aVal, TRadix aRadix=EDecimal); williamr@2: IMPORT_C TInt AppendNum(TReal aVal,const TRealFormat &aFormat) __SOFTFP; williamr@2: IMPORT_C void AppendNum(TInt64 aVal); williamr@2: IMPORT_C void AppendNum(TUint64 aVal, TRadix aRadix); williamr@2: IMPORT_C void AppendFormat(TRefByValue aFmt,TDes16Overflow *aOverflowHandler,...); williamr@2: IMPORT_C void AppendFormat(TRefByValue aFmt,...); williamr@2: IMPORT_C void AppendFormatList(const TDesC16 &aFmt,VA_LIST aList,TDes16Overflow *aOverflowHandler=NULL); williamr@2: IMPORT_C TPtr8 Collapse(); williamr@2: protected: williamr@2: inline TDes16() {} williamr@2: inline TDes16(TInt aType,TInt aLength,TInt aMaxLength); williamr@2: // delay this for a while williamr@2: #ifdef SYMBIAN_FIX_TDESC_CONSTRUCTORS williamr@2: inline TDes16(const TDes16& aOther) : TDesC16(aOther), iMaxLength(aOther.iMaxLength) {} williamr@2: #endif williamr@2: inline TUint16 *WPtr() const; 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 TPtr16 : public TDes16 williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: 16-bit modifiable pointer descriptor williamr@2: williamr@2: This is a descriptor class intended for instantiation and encapsulates a williamr@2: pointer to the 16-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 TPtrC16 williamr@2: @see TDesC16 williamr@2: @see TDes16 williamr@2: @see TBufC16 williamr@2: @see TBuf16 williamr@2: @see HBufC16 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TPtr16(TUint16 *aBuf,TInt aMaxLength); williamr@2: IMPORT_C TPtr16(TUint16 *aBuf,TInt aLength,TInt aMaxLength); williamr@2: inline TPtr16& operator=(const TUint16 *aString); williamr@2: inline TPtr16& operator=(const TDesC16& aDes); williamr@2: inline TPtr16& operator=(const TPtr16& aDes); williamr@2: inline void Set(TUint16 *aBuf,TInt aLength,TInt aMaxLength); williamr@2: inline void Set(const TPtr16 &aPtr); williamr@2: private: williamr@2: IMPORT_C TPtr16(TBufCBase16 &aLcb,TInt aMaxLength); williamr@2: protected: williamr@2: TUint16 *iPtr; williamr@2: private: williamr@2: friend class TBufCBase16; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: // williamr@2: class TBufCBase16 : public TDesC16 williamr@2: /** williamr@2: @internalAll williamr@2: */ williamr@2: { williamr@2: protected: williamr@2: IMPORT_C TBufCBase16(); williamr@2: inline TBufCBase16(TInt aLength); williamr@2: IMPORT_C TBufCBase16(const TUint16 *aString,TInt aMaxLength); williamr@2: IMPORT_C TBufCBase16(const TDesC16 &aDes,TInt aMaxLength); williamr@2: IMPORT_C void Copy(const TUint16 *aString,TInt aMaxLength); williamr@2: IMPORT_C void Copy(const TDesC16 &aDes,TInt aMaxLength); williamr@2: inline TPtr16 DoDes(TInt aMaxLength); williamr@2: inline TUint16 *WPtr() const; williamr@2: }; williamr@2: // williamr@2: class RReadStream; williamr@2: class HBufC16 : public TBufCBase16 williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: 16-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, reallocation williamr@2: is not done automatically. williamr@2: williamr@2: Data is intended to be accessed, but not modified; however, it can be completely williamr@2: replaced using the assignment operators of this class. The base class (TDesC16) provides williamr@2: the functions through which the data is accessed. williamr@2: williamr@2: The descriptor is hosted by a heap cell, and the 16-bit data that the descriptor williamr@2: represents is part of the descriptor object itself. The size of the cell depends williamr@2: on the requested maximum length of the descriptor buffer when the descriptor williamr@2: 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 TPtr16 williamr@2: @see TDesC16 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C static HBufC16 *New(TInt aMaxLength); williamr@2: IMPORT_C static HBufC16 *NewL(TInt aMaxLength); williamr@2: IMPORT_C static HBufC16 *NewLC(TInt aMaxLength); williamr@2: IMPORT_C static HBufC16 *NewMax(TInt aMaxLength); williamr@2: IMPORT_C static HBufC16 *NewMaxL(TInt aMaxLength); williamr@2: IMPORT_C static HBufC16 *NewMaxLC(TInt aMaxLength); williamr@2: IMPORT_C static HBufC16 *NewL(RReadStream &aStream,TInt aMaxLength); williamr@2: IMPORT_C static HBufC16 *NewLC(RReadStream &aStream,TInt aMaxLength); williamr@2: IMPORT_C HBufC16& operator=(const TUint16 *aString); williamr@2: IMPORT_C HBufC16& operator=(const TDesC16 &aDes); williamr@2: inline HBufC16& operator=(const HBufC16 &aLcb); williamr@2: IMPORT_C HBufC16 *ReAlloc(TInt aMaxLength); williamr@2: IMPORT_C HBufC16 *ReAllocL(TInt aMaxLength); williamr@2: IMPORT_C TPtr16 Des(); williamr@2: private: williamr@2: inline HBufC16(TInt aLength); williamr@2: private: williamr@2: TText16 iBuf[1]; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: // williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: #define __Size16 (sizeof(TInt)/sizeof(TInt16)) williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: #define __Align16(s) ((((s)+__Size16-1)/__Size16)*__Size16) williamr@2: // williamr@2: template williamr@2: class TBufC16 : public TBufCBase16 williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: 16-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 TUint16 data. williamr@2: williamr@2: The class intended for instantiation. The 16-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 TDesC16 williamr@2: @see TPtr16 williamr@2: @see TUint16 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: inline TBufC16(); williamr@2: inline TBufC16(const TUint16 *aString); williamr@2: inline TBufC16(const TDesC16 &aDes); williamr@2: inline TBufC16 &operator=(const TUint16 *aString); williamr@2: inline TBufC16 &operator=(const TDesC16 &aDes); williamr@2: inline TPtr16 Des(); williamr@2: protected: williamr@2: TUint16 iBuf[__Align16(S)]; williamr@2: }; williamr@2: // williamr@2: class TBufBase16 : public TDes16 williamr@2: /** williamr@2: @internalAll williamr@2: */ williamr@2: { williamr@2: protected: williamr@2: IMPORT_C TBufBase16(TInt aMaxLength); williamr@2: IMPORT_C TBufBase16(TInt aLength,TInt aMaxLength); williamr@2: IMPORT_C TBufBase16(const TUint16* aString,TInt aMaxLength); williamr@2: IMPORT_C TBufBase16(const TDesC16& aDes,TInt aMaxLength); williamr@2: }; williamr@2: // williamr@2: template williamr@2: class TBuf16 : public TBufBase16 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 TUint16 data. williamr@2: williamr@2: The class is intended for instantiation. The 16-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 TDesC16 williamr@2: @see TDes16 williamr@2: @see TPtr16 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: inline TBuf16(); williamr@2: inline explicit TBuf16(TInt aLength); williamr@2: inline TBuf16(const TUint16* aString); williamr@2: inline TBuf16(const TDesC16& aDes); williamr@2: inline TBuf16& operator=(const TUint16* aString); williamr@2: inline TBuf16& operator=(const TDesC16& aDes); williamr@2: inline TBuf16& operator=(const TBuf16& aDes); williamr@2: protected: williamr@2: TUint16 iBuf[__Align16(S)]; williamr@2: }; williamr@2: williamr@2: williamr@2: #ifndef __KERNEL_MODE__ williamr@2: williamr@2: class RBuf16 : public TDes16 williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: 16 bit resizable buffer descriptor. williamr@2: williamr@2: The class provides a buffer that contains, accesses and manipulates williamr@2: TUint16 data. The buffer itself is on the heap, and is managed by the class. williamr@2: williamr@2: Internally, RBuf16 behaves in one of two ways: williamr@2: williamr@2: - as a TPtr16 descriptor type, where the buffer just contains data williamr@2: - as a pointer to a heap descriptor, an HBufC16* 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 RBuf16 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 RBuf16 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 TDes16, 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 RBuf16 object can be passed to any function that is williamr@2: prototyped to take a TDes16 or a TDesC16 type. williamr@2: williamr@2: @see TBuf16 williamr@2: @see TPtr16 williamr@2: @see HBufC16 williamr@2: @see TDesC16 williamr@2: @see TDes16 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C RBuf16(); williamr@2: IMPORT_C explicit RBuf16(HBufC16* aHBuf); williamr@2: inline RBuf16& operator=(const TUint16* aString); williamr@2: inline RBuf16& operator=(const TDesC16& aDes); williamr@2: inline RBuf16& operator=(const RBuf16& aDes); williamr@2: IMPORT_C void Assign(const RBuf16& aRBuf); williamr@2: IMPORT_C void Assign(TUint16 *aHeapCell,TInt aMaxLength); williamr@2: IMPORT_C void Assign(TUint16 *aHeapCell,TInt aLength,TInt aMaxLength); williamr@2: IMPORT_C void Assign(HBufC16* aHBuf); williamr@2: IMPORT_C void Swap(RBuf16& 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 TDesC16& aDes); williamr@2: IMPORT_C void CreateL(const TDesC16& aDes); williamr@2: IMPORT_C TInt Create(const TDesC16& aDes,TInt aMaxLength); williamr@2: IMPORT_C void CreateL(const TDesC16& 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 RBuf16(TInt aType,TInt aLength,TInt aMaxLength); williamr@2: RBuf16(const RBuf16&); // Outlaw copy construction williamr@2: union williamr@2: { williamr@2: TUint16* iEPtrType; //Pointer to data used when RBuf is of EPtr type williamr@2: HBufC16* iEBufCPtrType; //Pointer to data used when RBuf is of EBufCPtr type williamr@2: }; williamr@2: __DECLARE_TEST; williamr@2: }; williamr@2: williamr@2: #endif //__KERNEL_MODE__ williamr@2: williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: Value reference used in operator TLitC16::__TRefDesC16() williamr@2: williamr@2: @see TRefByValue williamr@2: */ williamr@2: typedef TRefByValue __TRefDesC16; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: template williamr@2: class TLitC16 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 _LIT16 macro. williamr@2: williamr@2: This class is build independent; i.e. an explicit 16-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 _LIT16 williamr@2: */ williamr@2: { williamr@2: public: williamr@2: inline const TDesC16* operator&() const; williamr@2: inline operator const TDesC16&() const; williamr@2: inline const TDesC16& operator()() const; williamr@2: inline operator const __TRefDesC16() const; williamr@2: public: williamr@2: #if defined(__GCC32__) williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: typedef wchar_t __TText; williamr@2: #elif defined(__VC32__) williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: typedef TUint16 __TText; williamr@2: #elif defined(__CW32__) williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: typedef TUint16 __TText; williamr@2: #elif !defined(__TText_defined) williamr@2: #error no typedef for __TText williamr@2: #endif 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: __TText iBuf[__Align16(S)]; williamr@2: }; williamr@2: williamr@4: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS williamr@4: #include williamr@2: #endif williamr@4: williamr@4: #endif