TDesC8 Class Reference

class TDesC8

Abstract base class for 8-bit non-modifiable descriptors.

The class encapsulates the data member containing the length of data represented by an 8-bit descriptor. It also provides member functions through which the data can be accessed, but not modified.

Data represented by this class is treated as a contiguous set of 8-bit (i.e. single byte) values or data items.

This class cannot be instantiated as it is intended to form part of a class hierarchy; it provides a well defined part of descriptor behaviour. It can, however, be passed as an argument type for functions which want access to descriptor data but do not need to modify that data.

TDesC TPtrC8

Public Member Functions
IMPORT_C HBufC8 *Alloc()
IMPORT_C HBufC8 *AllocL()
IMPORT_C HBufC8 *AllocLC()
IMPORT_C TIntCompare(const TDesC8 &)
IMPORT_C TIntCompareC(const TDesC8 &)
IMPORT_C TIntCompareF(const TDesC8 &)
IMPORT_C TIntFind(const TDesC8 &)
IMPORT_C TIntFind(const TUint8 *, TInt)
IMPORT_C TIntFindC(const TDesC8 &)
IMPORT_C TIntFindC(const TUint8 *, TInt)
IMPORT_C TIntFindF(const TDesC8 &)
IMPORT_C TIntFindF(const TUint8 *, TInt)
IMPORT_C TPtrC8Left(TInt)
TInt Length()
IMPORT_C TIntLocate(TChar)
IMPORT_C TIntLocateF(TChar)
IMPORT_C TIntLocateReverse(TChar)
IMPORT_C TIntLocateReverseF(TChar)
IMPORT_C TIntMatch(const TDesC8 &)
IMPORT_C TIntMatchC(const TDesC8 &)
IMPORT_C TIntMatchF(const TDesC8 &)
IMPORT_C TPtrC8Mid(TInt)
IMPORT_C TPtrC8Mid(TInt, TInt)
IMPORT_C const TUint8 *Ptr()
IMPORT_C TPtrC8Right(TInt)
TInt Size()
TBool operator!=(const TDesC8 &)
TBool operator<(const TDesC8 &)
TBool operator<=(const TDesC8 &)
TBool operator==(const TDesC8 &)
TBool operator>(const TDesC8 &)
TBool operator>=(const TDesC8 &)
const TUint8 &operator[](TInt)
Protected Member Functions
TDesC8(TInt, TInt)
TDesC8()
IMPORT_C const TUint8 &AtC(TInt)
voidDoSetLength(TInt)
TInt Type()
Private Attributes
__DECLARE_TEST
TUint iLength

Constructor & Destructor Documentation

TDesC8(TInt, TInt)

TDesC8(TIntaType,
TIntaLength
)[protected, inline]

Parameters

TInt aType
TInt aLength

TDesC8()

TDesC8()[protected, inline]

Member Functions Documentation

Alloc()

IMPORT_C HBufC8 *Alloc()const

Creates a new 8-bit heap descriptor and initialises it with a copy of this descriptor's data.

AllocL()

IMPORT_C HBufC8 *AllocL()const

Creates a new 8-bit heap descriptor and initialises it with a copy of this descriptor's data.

The function leaves, if creation of the descriptor fails.

AllocLC()

IMPORT_C HBufC8 *AllocLC()const

Creates a new 8-bit heap descriptor, initialises it with a copy of this descriptor's data, and puts a pointer to the descriptor onto the cleanup stack.

The function leaves, if creation of the descriptor fails.

AtC(TInt)

IMPORT_C const TUint8 &AtC(TIntanIndex)const [protected]

Parameters

TInt anIndex

Compare(const TDesC8 &)

IMPORT_C TIntCompare(const TDesC8 &aDes)const

Compares this descriptor's data with the specified descriptor's data.

The comparison proceeds on a byte for byte basis. The result of the comparison is based on the difference of the first bytes to disagree.

Two descriptors are equal if they have the same length and content. Where two descriptors have different lengths and the shorter descriptor's data matches the first part of the longer descriptor's data, the shorter is considered to be less than the longer.

Parameters

const TDesC8 & aDesThe 8-bit non-modifable descriptor whose data is to be compared with this descriptor's data.

CompareC(const TDesC8 &)

IMPORT_C TIntCompareC(const TDesC8 &aDes)const

Compares this descriptor's data with the specified descriptor's data using the standard collation method for narrow text appropriate to the current locale.

TDesC8::Compare()

Parameters

const TDesC8 & aDesThe 8-bit non modifable descriptor whose data is to be compared with this descriptor's data.

CompareF(const TDesC8 &)

IMPORT_C TIntCompareF(const TDesC8 &aDes)const

Compares this descriptor's folded data with the specified descriptor's folded data.

Note that folding is locale-independent behaviour. It is also important to note that there can be no guarantee that folding is in any way culturally appropriate, and should not be used for comparing strings in natural language; use CompareC() for this.

TDesC8::Compare()

Parameters

const TDesC8 & aDesThe 8-bit non modifable descriptor whose data is to be compared with this descriptor's data.

DoSetLength(TInt)

voidDoSetLength(TIntaLength)[protected, inline]

Parameters

TInt aLength

Find(const TDesC8 &)

IMPORT_C TIntFind(const TDesC8 &aDes)const

Searches for the first occurrence of the specified data sequence within this descriptor.

Searching always starts at the beginning of this descriptor's data.

Parameters

const TDesC8 & aDesThe 8-bit non modifable descriptor containing the data sequence to be searched for.

Find(const TUint8 *, TInt)

IMPORT_C TIntFind(const TUint8 *pS,
TIntaLenS
)const

Searches for the first occurrence of the specified data sequence within this descriptor.

Searching always starts at the beginning of this descriptor's data.

panic
USER 29 if aLenS is negative.

Parameters

const TUint8 * pSA pointer to a location containing the data sequence to be searched for.
TInt aLenSThe length of the data sequence to be searched for. This value must not be negative, otherwise the function raises a panic.

FindC(const TDesC8 &)

IMPORT_C TIntFindC(const TDesC8 &aDes)const

Searches for the first occurrence of the specified collated data sequence within this descriptor's collated data.

Searching always starts at the beginning of this descriptor's data. The function uses the standard collation method for narrow text appropriate to the current locale.

Parameters

const TDesC8 & aDesThe 8-bit non-modifable descriptor containing the data sequence to be searched for.

FindC(const TUint8 *, TInt)

IMPORT_C TIntFindC(const TUint8 *pS,
TIntaLenS
)const

Searches for the first occurrence of the specified collated data sequence within this descriptor's collated data.

Searching always starts at the beginning of this descriptor's data. The function uses the standard collation method for narrow text appropriate to the current locale.

panic
USER 29 if aLength is negative.

Parameters

const TUint8 * pSA pointer to a location containing the data sequence to be searched for.
TInt aLenSThe length of the data sequence to be searched for.

FindF(const TDesC8 &)

IMPORT_C TIntFindF(const TDesC8 &aDes)const

Searches for the first occurrence of the specified folded data sequence within this descriptor's folded data.

Searching always starts at the beginning of this descriptor's data.

Note that folding is locale-independent behaviour. It is also important to note that there can be no guarantee that folding is in any way culturally appropriate, and should not be used for finding strings in natural language; use FindC() for this.

TDesC8::FindC()

Parameters

const TDesC8 & aDesThe 8-bit non-modifable descriptor containing the data sequence to be searched for.

FindF(const TUint8 *, TInt)

IMPORT_C TIntFindF(const TUint8 *pS,
TIntaLenS
)const

Searches for the first occurrence of the specified folded data sequence within this descriptor's folded data.

Searching always starts at the beginning of this descriptor's data.

Note that folding is locale-independent behaviour. It is also important to note that there can be no guarantee that folding is in any way culturally appropriate, and should not be used for finding strings in natural language; use FindC() for this.

panic
USER 29 if aLenS is negative
TDesC8::FindC()

Parameters

const TUint8 * pSA pointer to a location containing the data sequence to be searched for.
TInt aLenSThe length of the data sequence to be searched for. This value must not be negative, otherwise the function raises a panic.

Left(TInt)

IMPORT_C TPtrC8Left(TIntaLength)const

Extracts the leftmost part of the data.

The function does not cut or remove any data but constructs a non-modifiable pointer descriptor to represent the leftmost part of the data.

panic
USER 22 if aLength is negative.

Parameters

TInt aLengthThe length of the data to be extracted. If this value is greater than the length of the descriptor, the function extracts the whole of the descriptor.

Length()

TInt Length()const [inline]

Gets the length of the data.

This is the number of 8-bit values or data items represented by the descriptor.

Locate(TChar)

IMPORT_C TIntLocate(TCharaChar)const

Searches for the first occurrence of a character within this descriptor's data.

The search starts at the beginning of the data, i.e. at the leftmost position.

Parameters

TChar aCharThe character to be found.

LocateF(TChar)

IMPORT_C TIntLocateF(TCharaChar)const

Searches for the first occurrence of a folded character within this descriptor's folded data.

The search starts at the beginning of the data,i.e. at the leftmost position.

Note that folding is locale-independent behaviour. It is also important to note that there can be no guarantee that folding is in any way culturally appropriate, and should not be used for searching strings in natural language.

Parameters

TChar aCharThe character to be found.

LocateReverse(TChar)

IMPORT_C TIntLocateReverse(TCharaChar)const

Searches for the first occurrence of a character within this descriptor's data, searching from the end of the data.

The search starts at the rightmost position.

Parameters

TChar aCharThe character to be found.

LocateReverseF(TChar)

IMPORT_C TIntLocateReverseF(TCharaChar)const

Searches for the first occurrence of a folded character within this descriptor's folded data, searching from the end of the data.

The search starts at the rightmost position.

Note that folding is locale-independent behaviour. It is also important to note that there can be no guarantee that folding is in any way culturally appropriate, and should not be used for searching strings in natural language.

Parameters

TChar aCharThe character to be found

Match(const TDesC8 &)

IMPORT_C TIntMatch(const TDesC8 &aDes)const

Searches this descriptor's data for a match with the match pattern supplied in the specified descriptor.

The match pattern can contain the wildcard characters "*" and "?", where "*" matches zero or more consecutive occurrences of any character and "?" matches a single occurrence of any character.

Note that there is no 'escape character', which means that it is not possible to match either the "*" character itself or the "?" character itself using this function.

Parameters

const TDesC8 & aDesAn 8-bit non-modifable descriptor containing the match pattern.

MatchC(const TDesC8 &)

IMPORT_C TIntMatchC(const TDesC8 &aDes)const

Searches this descriptor's collated data for a match with the collated match pattern supplied in the specified descriptor.

The function uses the standard collation method for narrow text appropriate to the current locale.

The match pattern can contain the wildcard characters "*" and "?", where "*" matches zero or more consecutive occurrences of any character and "?" matches a single occurrence of any character.

Note that there is no 'escape character', which means that it is not possible to match either the "*" character itself or the "?" character itself using this function.

Parameters

const TDesC8 & aDesAn 8-bit non-modifable descriptor containing the match pattern.

MatchF(const TDesC8 &)

IMPORT_C TIntMatchF(const TDesC8 &aDes)const

Searches this descriptor's folded data for a match with the folded match pattern supplied in the specified descriptor.

The match pattern can contain the wildcard characters "*" and "?", where "*" matches zero or more consecutive occurrences of any character and "?" matches a single occurrence of any character.

Note that folding is locale-independent behaviour. It is also important to note that there can be no guarantee that folding is in any way culturally appropriate, and should not be used for matching strings in natural language; use MatchC() for this.

Note that there is no 'escape character', which means that it is not possible to match either the "*" character itself or the "?" character itself using this function.

TDesC8::MatchC()

Parameters

const TDesC8 & aDesAn 8-bit non-modifable descriptor containing the match pattern.

Mid(TInt)

IMPORT_C TPtrC8Mid(TIntaPos)const

Extracts a portion of the data.

The function does not cut or remove any data but constructs a non-modifiable pointer descriptor to represent the defined portion.

The portion is identified by its starting position and by the length of the remainder of the data starting from the specified position.

panic
USER 22 if aPos is negative or aPos is greater than the length of the descriptor.

Parameters

TInt aPosThe starting position of the data to be extracted. This is an offset value; a zero value refers to the leftmost data position.

Mid(TInt, TInt)

IMPORT_C TPtrC8Mid(TIntaPos,
TIntaLength
)const

Extracts a portion of the data.

The function does not cut or remove any data but constructs a non-modifiable pointer descriptor to represent the defined portion.

The portion is identified by its starting position and by its length.

panic
USER 22 if aPos is negative or aPos plus aLength is greater than the length of the descriptor.

Parameters

TInt aPosThe starting position of the data to be extracted. This is an offset value; a zero value refers to the leftmost data position.
TInt aLengthThe length of data to be extracted.

Ptr()

IMPORT_C const TUint8 *Ptr()const

Gets a pointer to the data represented by the descriptor.

The data cannot be changed through the returned pointer.

Right(TInt)

IMPORT_C TPtrC8Right(TIntaLength)const

Extracts the rightmost part of the data.

The function does not cut or remove any data but constructs a non-modifiable pointer descriptor to represent the rightmost part of the data.

panic
USER 22 if aLength is negative.

Parameters

TInt aLengthThe length of data to be extracted. If this value is greater than the length of the descriptor, the function extracts the whole of the descriptor.

Size()

TInt Size()const [inline]

Gets the size of the data.

This is the number of bytes occupied by the data represented by the descriptor.

Type()

TInt Type()const [protected, inline]

operator!=(const TDesC8 &)

TBool operator!=(const TDesC8 &aDes)const [inline]

Determines whether this descriptor's data is not equal to the specified descriptor's data.

The comparison is implemented using the Compare() member function.

TDesC8::Compare

Parameters

const TDesC8 & aDesThe 8-bit non-modifable descriptor whose data is to be compared with this descriptor's data.

operator<(const TDesC8 &)

TBool operator<(const TDesC8 &aDes)const [inline]

Determines whether this descriptor's data is less than the specified descriptor's data.

The comparison is implemented using the Compare() member function.

TDesC8::Compare

Parameters

const TDesC8 & aDesThe 8-bit non-modifable descriptor whose data is to be compared with this descriptor's data.

operator<=(const TDesC8 &)

TBool operator<=(const TDesC8 &aDes)const [inline]

Determines whether this descriptor's data is less than or equal to the specified descriptor's data.

The comparison is implemented using the Compare() member function.

TDesC8::Compare

Parameters

const TDesC8 & aDesThe 8-bit non-modifable descriptor whose data is to be compared with this descriptor's data.

operator==(const TDesC8 &)

TBool operator==(const TDesC8 &aDes)const [inline]

Determines whether this descriptor's data is equal to the specified descriptor's data.

The comparison is implemented using the Compare() member function.

TDesC8::Compare

Parameters

const TDesC8 & aDesThe 8-bit non-modifable descriptor whose data is to be compared with this descriptor's data.

operator>(const TDesC8 &)

TBool operator>(const TDesC8 &aDes)const [inline]

Determines whether this descriptor's data is greater than the specified descriptor's data.

The comparison is implemented using the Compare() member function.

TDesC8::Compare

Parameters

const TDesC8 & aDesThe 8-bit non-modifable descriptor whose data is to be compared with this descriptor's data.

operator>=(const TDesC8 &)

TBool operator>=(const TDesC8 &aDes)const [inline]

Determines whether this descriptor's data is greater than or equal to the specified descriptor's data.

The comparison is implemented using the Compare() member function.

TDesC8::Compare

Parameters

const TDesC8 & aDesThe 8-bit non-modifable descriptor whose data is to be compared with this descriptor's data.

operator[](TInt)

const TUint8 &operator[](TIntanIndex)const [inline]

Gets a reference to a single data item within this descriptor's data.

panic
USER 21, if anIndex is negative or greater than or equal to the current length of the descriptor.

Parameters

TInt anIndexThe position of the individual data item within the descriptor's data. This is an offset value; a zero value refers to the leftmost data position.

Member Data Documentation

__DECLARE_TEST

__DECLARE_TEST[private]

TUint iLength

TUint iLength[private]