RBuf16 Class Reference

#include <e32des16.h>

class RBuf16 : public TDes16

Inherits from

Public Attributes
HBufC16 *iEBufCPtrType
TUint16 *iEPtrType
Protected Attributes
union RBuf16::@6@7
__DECLARE_TEST
Public Member Functions
RBuf16()
RBuf16(HBufC16 *)
IMPORT_C voidAssign(const RBuf16 &)
IMPORT_C voidAssign(TUint16 *, TInt)
IMPORT_C voidAssign(TUint16 *, TInt, TInt)
IMPORT_C voidAssign(HBufC16 *)
IMPORT_C voidCleanupClosePushL()
IMPORT_C voidClose()
IMPORT_C TIntCreate(TInt)
IMPORT_C TIntCreate(const TDesC16 &)
IMPORT_C TIntCreate(const TDesC16 &, TInt)
IMPORT_C voidCreateL(TInt)
voidCreateL(RReadStream &, TInt)
IMPORT_C voidCreateL(const TDesC16 &)
IMPORT_C voidCreateL(const TDesC16 &, TInt)
IMPORT_C TIntCreateMax(TInt)
IMPORT_C voidCreateMaxL(TInt)
IMPORT_C TIntReAlloc(TInt)
IMPORT_C voidReAllocL(TInt)
IMPORT_C voidSwap(RBuf16 &)
RBuf16 &operator=(const TUint16 *)
RBuf16 &operator=(const TDesC16 &)
RBuf16 &operator=(const RBuf16 &)
Protected Member Functions
RBuf16(TInt, TInt, TInt)
RBuf16(const RBuf16 &)
Inherited Attributes
TDes16::iMaxLength
Inherited Enumerations
TDesC16:TPrefix
Inherited Functions
TDes16::Append(TChar)
TDes16::Append(const TDesC16 &)
TDes16::Append(const TUint16 *,TInt)
TDes16::AppendFill(TChar,TInt)
TDes16::AppendFormat(TRefByValue< const TDesC16 >,...)
TDes16::AppendFormat(TRefByValue< const TDesC16 >,TDes16Overflow *,...)
TDes16::AppendFormatList(const TDesC16 &,VA_LIST,TDes16Overflow *)
TDes16::AppendJustify(const TDesC16 &,TInt,TAlign,TChar)
TDes16::AppendJustify(const TDesC16 &,TInt,TInt,TAlign,TChar)
TDes16::AppendJustify(const TUint16 *,TInt,TAlign,TChar)
TDes16::AppendJustify(const TUint16 *,TInt,TInt,TAlign,TChar)
TDes16::AppendNum(TInt64)
TDes16::AppendNum(TReal,const TRealFormat &)
TDes16::AppendNum(TUint64,TRadix)
TDes16::AppendNumFixedWidth(TUint,TRadix,TInt)
TDes16::AppendNumFixedWidthUC(TUint,TRadix,TInt)
TDes16::AppendNumUC(TUint64,TRadix)
TDes16::Capitalize()
TDes16::Collapse()
TDes16::Collate()
TDes16::Copy(const TDesC16 &)
TDes16::Copy(const TDesC8 &)
TDes16::Copy(const TUint16 *)
TDes16::Copy(const TUint16 *,TInt)
TDes16::CopyC(const TDesC16 &)
TDes16::CopyCP(const TDesC16 &)
TDes16::CopyF(const TDesC16 &)
TDes16::CopyLC(const TDesC16 &)
TDes16::CopyUC(const TDesC16 &)
TDes16::Delete(TInt,TInt)
TDes16::DoAppendNum(TUint64,TRadix,TUint,TInt)
TDes16::DoPadAppendNum(TInt,TInt,const TUint8 *)
TDes16::Fill(TChar)
TDes16::Fill(TChar,TInt)
TDes16::FillZ()
TDes16::FillZ(TInt)
TDes16::Fold()
TDes16::Format(TRefByValue< const TDesC16 >,...)
TDes16::FormatList(const TDesC16 &,VA_LIST)
TDes16::Insert(TInt,const TDesC16 &)
TDes16::Justify(const TDesC16 &,TInt,TAlign,TChar)
TDes16::LeftTPtr(TInt)const
TDes16::LowerCase()
TDes16::MaxLength()const
TDes16::MaxSize()const
TDes16::MidTPtr(TInt)const
TDes16::MidTPtr(TInt,TInt)const
TDes16::Num(TInt64)
TDes16::Num(TReal,const TRealFormat &)
TDes16::Num(TUint64,TRadix)
TDes16::NumFixedWidth(TUint,TRadix,TInt)
TDes16::NumFixedWidthUC(TUint,TRadix,TInt)
TDes16::NumUC(TUint64,TRadix)
TDes16::PtrZ()
TDes16::Repeat(const TDesC16 &)
TDes16::Repeat(const TUint16 *,TInt)
TDes16::Replace(TInt,TInt,const TDesC16 &)
TDes16::RightTPtr(TInt)const
TDes16::SetLength(TInt)
TDes16::SetMax()
TDes16::Swap(TDes16 &)
TDes16::TDes16()
TDes16::TDes16(TInt,TInt,TInt)
TDes16::Trim()
TDes16::TrimAll()
TDes16::TrimLeft()
TDes16::TrimRight()
TDes16::UpperCase()
TDes16::WPtr()const
TDes16::Zero()
TDes16::ZeroTerminate()
TDes16::operator+=(const TDesC16 &)
TDes16::operator=(const TDes16 &)
TDes16::operator[](TInt)
TDes16::operator[](TInt)const
TDesC16::Alloc()const
TDesC16::AllocL()const
TDesC16::AllocLC()const
TDesC16::AtC(TInt)const
TDesC16::Compare(const TDesC16 &)const
TDesC16::CompareC(const TDesC16 &)const
TDesC16::CompareC(const TDesC16 &,TInt,const TCollationMethod *)const
TDesC16::CompareF(const TDesC16 &)const
TDesC16::DoSetLength(TInt)
TDesC16::Find(const TDesC16 &)const
TDesC16::Find(const TUint16 *,TInt)const
TDesC16::FindC(const TDesC16 &)const
TDesC16::FindC(const TDesC16 &,TInt &,const TCollationMethod &,TInt)const
TDesC16::FindC(const TUint16 *,TInt)const
TDesC16::FindC(const TUint16 *,TInt,TInt)const
TDesC16::FindF(const TDesC16 &)const
TDesC16::FindF(const TUint16 *,TInt)const
TDesC16::GetCollationKeysL(TInt,const TCollationMethod *)const
TDesC16::GetFoldedDecomposedFormL()const
TDesC16::GetNormalizedDecomposedFormL()const
TDesC16::HasPrefixC(const TDesC16 &,TInt,const TCollationMethod *)const
TDesC16::Left(TInt)const
TDesC16::Length()const
TDesC16::Locate(TChar)const
TDesC16::LocateF(TChar)const
TDesC16::LocateReverse(TChar)const
TDesC16::LocateReverseF(TChar)const
TDesC16::Match(const TDesC16 &)const
TDesC16::MatchC(const TDesC16 &)const
TDesC16::MatchC(const TDesC16 &,TInt,TInt,TInt,TInt,const TCollationMethod *)const
TDesC16::MatchC(const TDesC16 &,const TCollationMethod *,TInt,TInt,TInt,TInt)const
TDesC16::MatchF(const TDesC16 &)const
TDesC16::Mid(TInt)const
TDesC16::Mid(TInt,TInt)const
TDesC16::Ptr()const
TDesC16::Right(TInt)const
TDesC16::Size()const
TDesC16::TDesC16()
TDesC16::TDesC16(TInt,TInt)
TDesC16::Type()const
TDesC16::operator!=(const TDesC16 &)const
TDesC16::operator<(const TDesC16 &)const
TDesC16::operator<=(const TDesC16 &)const
TDesC16::operator==(const TDesC16 &)const
TDesC16::operator>(const TDesC16 &)const
TDesC16::operator>=(const TDesC16 &)const

Detailed Description

16 bit resizable buffer descriptor.

The class provides a buffer that contains, accesses and manipulates TUint16 data. The buffer itself is on the heap, and is managed by the class.

Internally, RBuf16 behaves in one of two ways:

  • as a TPtr16 descriptor type, where the buffer just contains data

  • as a pointer to a heap descriptor, an HBufC16* type, where the buffer contains both descriptor information and the data.

Note that the handling of the distinction is hidden from view.

An RBuf16 object can allocate its own buffer. Alternatively, it can take ownership of a pre-existing section of allocated memory, or it can take ownership of a pre-existing heap descriptor. It can also reallocate the buffer to resize it. Regardless of the way in which the buffer has been allocated, the RBuf16 object is responsible for freeing memory when the object itself is closed.

The class is intended for instantiation.

The class is derived from TDes16, which means that data can be both accessed and modified. The base classes provide the functions through which the data is accessed. In addition, an RBuf16 object can be passed to any function that is prototyped to take a TDes16 or a TDesC16 type.

See also: TBuf16 TPtr16 HBufC16 TDesC16 TDes16

Member Attribute Documentation

@7

union RBuf16::@6@7[protected]

__DECLARE_TEST

__DECLARE_TEST[protected]

iEBufCPtrType

HBufC16 *iEBufCPtrType

iEPtrType

TUint16 *iEPtrType

Constructor & Destructor Documentation

RBuf16 ( )

IMPORT_CRBuf16()

Default constructor.

Constructs a zero-length 16-bit resizable buffer descriptor.

Note that the object owns no allocated memory.

RBuf16 ( HBufC16 * )

IMPORT_CRBuf16(HBufC16 *aHBuf)[explicit]

Constructor.

Constructs a 16-bit resizable buffer descriptor, transferring ownership of the specified heap descriptor to this object.

ParameterDescription
aHBufThe heap descriptor to be transferred to this object. This pointer can be NULL, which means that a zero length 16-bit resizable buffer descriptor is constructed, and the object will not own any allocated memory.

RBuf16 ( TInt, TInt, TInt )

IMPORT_CRBuf16(TIntaType,
TIntaLength,
TIntaMaxLength
)[protected]

Protected constructor.

RBuf16 ( const RBuf16 & )

RBuf16(const RBuf16 &)[protected]

Member Function Documentation

Assign ( const RBuf16 & )

IMPORT_C voidAssign(const RBuf16 &aRBuf)

Transfers ownership of the specified 16-bit resizable buffer descriptor's buffer to this object.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

See also: RBuf16::Close()

ParameterDescription
aRBufThe source 16-bit resizable buffer. The ownership of this object's buffer is to be transferred.

Assign ( TUint16 *, TInt )

IMPORT_C voidAssign(TUint16 *aHeapCell,
TIntaMaxLength
)

Assigns ownership of the specified allocated memory to this object.

The allocated memory forms the buffer for this descriptor. The current length of the descriptor is set to zero.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

panic
USER 8 If the specified maximum length is greater then the size of the allocated heap cell, or the specified maximum length is NOT zero when the pointer to the heap cell is NULL.

See also: TDesC16::Length() TDes16::MaxLength() RBuf16::Close()

ParameterDescription
aHeapCellThe allocated memory to be assigned to this object. This pointer can be NULL, which means that a zero length 16-bit resizable buffer descriptor is created.
aMaxLengthThe maximum length of the descriptor.

Assign ( TUint16 *, TInt, TInt )

IMPORT_C voidAssign(TUint16 *aHeapCell,
TIntaLength,
TIntaMaxLength
)

Assigns ownership of the specified allocated memory to this object.

The allocated memory forms the buffer for this descriptor. The current length of the descriptor is set to the value of the second parameter.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

panic
USER 8 If the specified maximum length is greater then the size of the allocated heap cell, or the specified length is greater then the specified maximum length, or the specified maximum length is NOT zero when the pointer to the heap cell is NULL.

See also: TDesC16::Length() TDes16::MaxLength() RBuf16::Close()

ParameterDescription
aHeapCellThe allocated memory to be assigned to this object.
aLengthThe length of the descriptor.
aMaxLengthThe maximum length of the descriptor.

Assign ( HBufC16 * )

IMPORT_C voidAssign(HBufC16 *aHBuf)

Transfers ownership of the specified heap descriptor to this object.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

See also: RBuf16::Close()

ParameterDescription
aHBufThe heap descriptor to be transferred to this object. This pointer can be NULL, which means that a zero length 16-bit resizable buffer descriptor is created.

CleanupClosePushL ( )

IMPORT_C voidCleanupClosePushL()

Pushes a cleanup item for this object onto the cleanup stack.

The effect of this is to cause Close() to be called on this 16-bit resizable buffer descriptor, when CleanupStack::PopAndDestroy() is called at some later time.

...
RBuf16 x;
....
x.CleanupClosePushL();
...
CleanupStack::PopAndDestroy();
...

See also: RBuf16::Close()

Close ( )

IMPORT_C voidClose()

Deallocates memory assigned to this object, and re-initializes the object as a zero-length descriptor.

Create ( TInt )

IMPORT_C TIntCreate(TIntaMaxLength)

Creates a 16-bit resizable buffer descriptor.

The function allocates sufficient memory to contain descriptor data up to the specified maximum length.

The current length of the descriptor is set to zero. The maximum length of the descriptor is set to the specified value.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

See also: TDesC16::Length() TDes16::MaxLength() RBuf16::Close()

ParameterDescription
aMaxLengthThe maximum length of the descriptor.

Returns: KErrNone, if successful; KErrNoMemory, if there is insufficient memory.

Create ( const TDesC16 & )

IMPORT_C TIntCreate(const TDesC16 &aDes)

Creates a 16-bit resizable buffer descriptor to contain a copy of the specified (source) descriptor.

The function allocates sufficient memory so that this descriptor's maximum length is the same as the length of the source descriptor. Both the current length and the maximum length of this descriptor are set to the length of the source descriptor.

The data contained in the source descriptor is copied into this descriptor.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

See also: TDesC16::Length() TDes16::MaxLength() TDes16::Copy() RBuf16::Close()

ParameterDescription
aDesSource descriptor to be copied into this object.

Returns: KErrNone, if successful; KErrNoMemory, if there is insufficient memory.

Create ( const TDesC16 &, TInt )

IMPORT_C TIntCreate(const TDesC16 &aDes,
TIntaMaxLength
)

Creates a 16-bit resizable buffer descriptor to contain a copy of the specified (source) descriptor.

The function allocates sufficient memory so that this descriptor's maximum length is the same as the value of the aMaxLength parameter.

The data contained in the source descriptor is copied into this descriptor. The length of data copied is either

  • the length of the source descriptor aDes

or

  • the value of the aMaxLength parameter

whichever is the smaller value. The current length of this descriptor is also set to the smaller value.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

See also: TDesC16::Length() TDes16::MaxLength() TDes16::Copy() RBuf16::Close()

ParameterDescription
aDesSource descriptor to be copied into this object.
aMaxLengthThe maximum length of this descriptor.

Returns: KErrNone, if successful; KErrNoMemory, if there is insufficient memory.

CreateL ( TInt )

IMPORT_C voidCreateL(TIntaMaxLength)

Creates 16-bit resizable buffer descriptor, and leaves on failure.

The function allocates sufficient memory to contain descriptor data up to the specified maximum length.

The current length of the descriptor is set to zero. The maximum length of the descriptor is set to the specified value.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

leave
KErrNoMemory If there is insufficient memory.

See also: TDesC16::Length() TDes16::MaxLength() RBuf16::Close()

ParameterDescription
aMaxLengthThe maximum length of the descriptor.

CreateL ( RReadStream &, TInt )

voidCreateL(RReadStream &aStream,
TIntaMaxLength
)[inline]

Creates a 16-bit resizable buffer descriptor that has been initialised with data from the specified read stream; leaves on failure.

Data is assigned to the new descriptor from the specified stream. This variant assumes that the stream contains the length of the data followed by the data itself.

The function is implemented by calling the HBufC16::NewL(RReadStream&,TInt) variant and then assigning the resulting heap descriptor using the RBuf16::Assign(HBufC16*) variant. The comments that describe the HBufC16::NewL() variant also apply to this RBuf16::CreateL() function.

The function may leave with one of the system-wide error codes, specifically KErrOverflow, if the length of the data as read from the stream is greater than the upper limit as specified by the aMaxLength parameter.

ParameterDescription
aStreamThe stream from which the data length and the data to be assigned to the new descriptor, are taken.
aMaxLengthThe upper limit on the length of data that the descriptor is to represent. The value of this parameter must be non-negative otherwise the underlying function will panic.

CreateL ( const TDesC16 & )

IMPORT_C voidCreateL(const TDesC16 &aDes)

Creates a 16-bit resizable buffer descriptor to contain a copy of the specified (source) descriptor, and leaves on failure.

The function allocates sufficient memory so that this descriptor's maximum length is the same as the length of the source descriptor.Both the current length and the maximum length of this descriptor are set to the length of the source descriptor.

The data contained in the source descriptor is copied into this descriptor.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

leave
KErrNoMemory If there is insufficient memory.

See also: TDesC16::Length() TDes16::MaxLength() TDes16::Copy() RBuf16::Close()

ParameterDescription
aDesSource descriptor to be copied into this object.

CreateL ( const TDesC16 &, TInt )

IMPORT_C voidCreateL(const TDesC16 &aDes,
TIntaMaxLength
)

Creates a 16-bit resizable buffer descriptor to contain a copy of the specified (source) descriptor, and leaves on failure.

The function allocates sufficient memory so that this descriptor's maximum length is the same as the value of the aMaxLength parameter.

The data contained in the source descriptor is copied into this descriptor. The length of data copied is either

  • the length of the source descriptor aDes

or

  • the value of the aMaxLength parameter

whichever is the smaller value. The current length of this descriptor is also set to the smaller value.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

leave
KErrNoMemory If there is insufficient memory.

See also: TDesC16::Length() TDes16::MaxLength() TDes16::Copy() RBuf16::Close()

ParameterDescription
aDesSource descriptor to be copied into this object.
aMaxLengthThe maximum length of this descriptor.

CreateMax ( TInt )

IMPORT_C TIntCreateMax(TIntaMaxLength)

Creates a 16-bit resizable buffer descriptor.

The function allocates sufficient memory to contain descriptor data up to the specified maximum length.

Both the current length and the maximum length of the descriptor are set to the specified value.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

See also: RBuf16::Close()

ParameterDescription
aMaxLengthThe length and the maximum length of the descriptor.

Returns: KErrNone, if successful; KErrNoMemory, if there is insufficient memory.

CreateMaxL ( TInt )

IMPORT_C voidCreateMaxL(TIntaMaxLength)

Creates a 16-bit resizable buffer descriptor, and leaves on failure.

The function allocates sufficient memory to contain descriptor data up to the specified maximum length.

Both the current length and the maximum length of the descriptor are set to the specified value.

Note that the function assumes that this descriptor does not already own any allocated memory. It does not check, nor does it free any pre-existing owned allocated memory. If this descriptor does already own allocated memory, RBuf16::Close() should be invoked on this descriptor before this function is invoked.

leave
KErrNoMemory If there is insufficient memory.

See also: TDesC16::Length() TDes16::MaxLength() RBuf16::Close()

ParameterDescription
aMaxLengthThe length and the maximum length of the descriptor.

ReAlloc ( TInt )

IMPORT_C TIntReAlloc(TIntaMaxLength)

Resizes this 16-bit resizable buffer descriptor.

The length and contents of the descriptor are unchanged.

If the buffer descriptor was created from a zero-length heap descriptor HBufC, this method might leak memory (the heap descriptor is not freed). It is possible to avoid this by calling the Close() method prior to ReAlloc(), but this should be done only in this situation (otherwise the buffer contents will be lost).

For example, add
    if (desc.MaxLength() == 0) desc.Close();
before the call to ReAlloc().
panic
USER 14 If the new maximum length is less then the current descriptor length.
ParameterDescription
aMaxLengthThe new maximum length of the descriptor. This can be zero, which results in a descriptor with zero maximum length and no allocated memory.

Returns: KErrNone, if successful; KErrNoMemory, if there is insufficient memory.

ReAllocL ( TInt )

IMPORT_C voidReAllocL(TIntaMaxLength)

Resizes this 16-bit resizable buffer descriptor, leaving on failure.

The length and contents of the descriptor are unchanged.

If the buffer descriptor was created from a zero-length heap descriptor HBufC, this method might leak memory (the heap descriptor is not freed). It is possible to avoid this by calling the Close() method prior to ReAllocL(), but this should be done only in this situation (otherwise the buffer contents will be lost).

For example, add
    if (desc.MaxLength() == 0) desc.Close();
before the call to ReAlloc().
panic
USER 14 If the new maximum length is less then the current descriptor length.
ParameterDescription
aMaxLengthThe new maximum length of the descriptor. This can be zero, which results in a descriptor with zero maximum length and no allocated memory.

Returns: KErrNone, if successful; KErrNoMemory, if there is insufficient memory.

Swap ( RBuf16 & )

IMPORT_C voidSwap(RBuf16 &aRBuf)

Swaps the content of two 16-bit resizable buffer descriptors.

ParameterDescription
aRBufThe 16-bit resizable buffer descriptor whose contents are to be swapped with this one.

operator= ( const TUint16 * )

RBuf16 &operator=(const TUint16 *aString)[inline]

Copies data into this descriptor replacing any existing data.

The length of this descriptor is set to reflect the new data.

panic
USER 11, if the length of the string, excluding the zero terminator, is greater than the maximum length of this (target) descriptor.
ParameterDescription
aStringA pointer to a zero-terminated string.

Returns: A reference to this, the target descriptor.

operator= ( const TDesC16 & )

RBuf16 &operator=(const TDesC16 &aDes)[inline]

Copies data into this descriptor replacing any existing data.

The length of this descriptor is set to reflect the new data.

panic
USER 11, if the length of the descriptor aDes is greater than the maximum length of this (target) descriptor.
ParameterDescription
aDesA 16-bit non-modifiable descriptor.

Returns: A reference to this, the target descriptor.

operator= ( const RBuf16 & )

RBuf16 &operator=(const RBuf16 &aDes)[inline]

Copies data into this descriptor replacing any existing data.

The length of this descriptor is set to reflect the new data.

panic
USER 11, if the length of the descriptor aDes is greater than the maximum length of this (target) descriptor.
ParameterDescription
aDesA 16-bit buffer descriptor.

Returns: A reference to this, the target descriptor.