»
Symbian OS v6.1 Edition for C++ »
API Reference »
Descriptors »
TDesC8
Location:
e32des8.h
Link against: euser.lib
TDesC8
Support
Supported from 5.0
Description
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.
Defined in TDesC8
:
Alloc()
, AllocL()
, AllocLC()
, Compare()
, CompareC()
, CompareF()
, Find()
, FindC()
, FindF()
, Left()
, Length()
, Locate()
, LocateF()
, LocateReverse()
, LocateReverseF()
, Match()
, MatchC()
, MatchF()
, Mid()
, Ptr()
, Right()
, Size()
, operator!=()
, operator<()
, operator<=()
, operator==()
, operator>()
, operator>=()
, operator[]()
See also:
Data characteristics
TInt Length() const;
Description
Gets the length of the data. This is the number of 8 bit values
or data items represented by the descriptor.
Return value
TInt |
The length of the data represented by the descriptor. |
|
TInt Size() const;
Description
Gets the size of the data. This is the number of bytes occupied
by the data represented by the descriptor.
Return value
TInt |
The size of the data represented by the descriptor. |
|
Direct access to the data
const TUint8* Ptr() const;
Description
Gets a pointer to the data represented by the descriptor. The
data cannot be changed through the returned pointer.
Return value
TUint8* |
A pointer to the data |
|
TPtrC8 Left(TInt aLength) const;
Description
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.
Parameters
TInt aLength |
The length of the data to be extracted. This value cannot be
negative, otherwise the function raises a USER 22 panic. If this value is
greater than the length of the descriptor, the function extracts the whole of
the descriptor. In EPOC Release 5, if aLength was greater than the
descriptor's length, the function raised a USER 22 panic. |
|
Return value
TPtrC8 |
The 8 bit non-modifiable pointer descriptor representing the
leftmost part of the data. |
|
See also:
TPtrC8 Right(TInt aLength) const;
Description
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.
Parameters
TInt aLength |
The length of data to be extracted. This value cannot be
negative, otherwise the function raises a USER 22 panic. If this value is
greater than the length of the descriptor, the function extracts the whole of
the descriptor. In EPOC Release 5, if aLength was greater than the
descriptor's length, the function raised a USER 22 panic. |
|
Return value
TPtrC8 |
The 8 bit non-modifiable pointer descriptor representing the
rightmost part of the data. |
|
See also:
TPtrC8 Mid(TInt aPos) const;
TPtrC8 Mid(TInt aPos,TInt aLength) const;
Description
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. If identified by position alone, the implied length is the length of
the remainder of the data starting from the specified position.
Parameters
TInt aPos |
The starting position of the data to be extracted. This is an
offset; a zero value refers to the leftmost data position. |
TInt aLength |
If specified, the length of data to be extracted. If not
specified, the implied length is the length of the remainder of the data
starting from the specified position. |
|
Return value
TPtrC8 |
The 8 bit non-modifiable pointer descriptor representing the
specified portion of the data. |
|
See also:
const TUint8& operator[](TInt anIndex) const;
Description
Gets a reference to a single data item within this descriptor's
data.
Parameters
TInt anIndex |
The position of the individual data item within the
descriptor's data. This is an offset; a zero value refers to the leftmost data
position. This value must be non-negative and less than the current length of
the descriptor otherwise the operation raises a USER 21 panic. |
|
Return value
TUint8& |
A reference to the data item. |
|
See also:
Create a heap descriptor (HBufC)
HBufC8* Alloc() const;
Description
Creates a new 8 bit heap descriptor and initialises it with a
copy of this descriptor's data.
Return value
HBufC8* |
A pointer to the new 8 bit heap descriptor, if creation is
successful. NULL, if creation of the descriptor fails. |
|
HBufC8* AllocL() const;
Description
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.
Return value
HBufC8* |
A pointer to the 8 bit heap descriptor, if creation is
successful. |
|
See also:
HBufC8* AllocLC() const;
Description
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.
Return value
HBufC8* |
A pointer to the 8 bit heap descriptor, if creation is
successful. The pointer is also put onto the cleanup stack. |
|
Comparison of descriptor data
TInt Compare(const TDesC8& aDes) const;
Description
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& aDes |
The 8 bit non modifable descriptor whose data is to be
compared with this descriptor's data. |
|
Return value
TInt |
Positive, if this descriptor is greater than the specified
descriptor. Negative, if this descriptor is less than the specified descriptor.
Zero, if both descriptors have the same length and the their contents are the
same. |
|
See also:
TInt CompareC(const TDesC8& aDes) const;
Description
Compares this descriptor's data with the specified descriptor's
data using the standard collation method for narrow text appropriate to the
current locale.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor whose data is to be
compared with this descriptor's data. |
|
Return value
TInt |
Positive, if this descriptor is greater than the specified
descriptor. Negative, if this descriptor is less than the specified descriptor.
Zero, if both descriptors have the same length and the their contents are the
same. |
|
See also:
TInt CompareF(const TDesC8& aDes) const;
Description
Compares this descriptor's folded data with the specified
descriptor's folded data. The function uses the standard folding method for
narrow text appropriate to the current locale.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor whose data is to be
compared with this descriptor's data. |
|
Return value
TInt |
Positive, if this descriptor is greater than the specified
descriptor. Negative, if this descriptor is less than the specified descriptor.
Zero, if both descriptors have the same length and the their contents are the
same. |
|
See also:
TInt operator==(const TDesC8& aDes) const;
Description
Determines whether this descriptor's data is equal to the
specified descriptor's data.
The comparison is implemented using the Compare()
member function.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor whose data is to be
compared with this descriptor's data. |
|
Return value
TInt |
True if equal, false otherwise. |
|
See also:
TInt operator!=(const TDesC8& aDes) const;
Description
Determines whether this descriptor's data is not equal to the
specified descriptor's data.
The comparison is implemented using the Compare()
member function.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor whose data is to be
compared with this descriptor's data. |
|
Return value
TInt |
True if not equal, false otherwise. |
|
See also:
TInt operator<(const TDesC8& aDes) const;
Description
Determines whether this descriptor's data is less than the
specified descriptor's data.
The comparison is implemented using the Compare()
member function.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor whose data is to be
compared with this descriptor's data. |
|
Return value
TInt |
True if less than, false otherwise. |
|
See also:
TInt operator<=(const TDesC8& aDes) const;
Description
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.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor whose data is to be
compared with this descriptor's data. |
|
Return value
TInt |
True if less than or equal, false otherwise. |
|
See also:
TInt operator>(const TDesC8& aDes) const;
Description
Determines whether this descriptor's data is greater than the
specified descriptor's data.
The comparison is implemented using the Compare()
member function.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor whose data is to be
compared with this descriptor's data. |
|
Return value
TInt |
True if greater than, false otherwise. |
|
See also:
TInt operator>=(const TDesC8& aDes) const;
Description
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.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor whose data is to be
compared with this descriptor's data. |
|
Return value
TInt |
True if greater than, false otherwise. |
|
See also:
TInt Locate(TChar aChar) const;
Description
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 aChar |
The character to be found. |
|
Return value
TInt |
The offset of the character position from the beginning of the
data.KErrNotFound , if no matching character can be found. |
|
See also:
TInt LocateF(TChar aChar) const;
Description
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. The function uses the standard folding method
for narrow text appropriate to the current locale.
Parameters
TChar aChar |
The character to be found. |
|
Return value
TInt |
The offset of the character position from the beginning of the
data.KErrNotFound , if no matching character can be found. |
|
TInt LocateReverse(TChar aChar) const;
Description
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 aChar |
The character to be found |
|
Return value
TInt |
The offset of the character position from the beginning of the
data.KErrNotFound , if no matching character can be found. |
|
TInt LocateReverseF(TChar aChar) const;
Description
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. The function uses the standard folding method
for narrow text appropriate to the current locale.
Parameters
TChar aChar |
The character to be found |
|
Return value
TInt |
The offset of the character position from the beginning of the
data.KErrNotFound , if no matching character can be found |
|
TInt Find(const TDesC8& aDes) const;
TInt Find(const TUint8* pS,TInt aLenS) const;
Description
Searches for the first occurrence of the specified data
sequence within this descriptor. Searching always starts at the beginning of
this descriptor's data.
The search data can be defined within another descriptor or it
may be defined as a pointer and length pair.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor containing the data
sequence to be searched for. |
const TUint8* pS |
A pointer to a location containing the data sequence to be
searched for. |
TInt aLenS |
The length of the data sequence to be searched for. This value
must not be negative, otherwise the function raises a USER 29 panic. |
|
Return value
TInt |
The offset of the data sequence from the beginning of this
descriptor's data. KErrNotFound , if the data sequence cannot be
found. |
|
See also:
TInt FindC(const TDesC8& aDes) const;
TInt FindC(const TUint8* pS,TInt aLenS) const;
Description
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.
The search data can be defined within another descriptor or it
may be defined as a pointer and length pair.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor containing the data
sequence to be searched for. |
const TUint8* pS |
A pointer to a location containing the data sequence to be
searched for. |
TInt aLenS |
The length of the data sequence to be searched for. This value
must not be negative, otherwise the function raises a USER 29 panic. |
|
Return value
TInt |
The offset of the data sequence from the beginning of this
descriptor's data. KErrNotFound , if the data sequence cannot be
found. |
|
TInt FindF(const TDesC8& aDes) const;
TInt FindF(const TUint8* pS,TInt aLenS) const;
Description
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. The function uses the standard folding
method for narrow text appropriate to the current locale.
The search data can be defined within another descriptor or it
may be defined as a pointer and length pair.
Parameters
const TDesC8& aDes |
The 8 bit non modifable descriptor containing the data
sequence to be searched for. |
const TUint8* pS |
A pointer to a location containing the data sequence to be
searched for. |
TInt aLenS |
The length of the data sequence to be searched for. This value
must not be negative, otherwise the function raises a USER 29 panic. |
|
Return value
TInt |
The offset of the data sequence from the beginning of this
descriptor's data. KErrNotFound , if the data sequence cannot be
found. |
|
TInt Match(const TDesC8& aDes) const;
Description
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.
Parameters
const TDesC8& aDes |
An 8 bit non modifable descriptor containing the match
pattern. |
|
Return value
TInt |
If a match is found, the offset within this descriptor's data
where the match first occurs. KErrNotFound , if there is no match.
|
|
See also:
TInt MatchC(const TDesC8& aDes) const;
Description
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.
Parameters
const TDesC8& aDes |
An 8 bit non modifable descriptor containing the match
pattern. |
|
Return value
TInt |
If a match is found, the offset within this descriptor's data
where the match first occurs. KErrNotFound , if there is no match.
|
|
TInt MatchF(const TDesC8& aDes) const;
Description
Searches this descriptor's folded data for a match with the
folded match pattern supplied in the specified descriptor. The function uses
the standard folding 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.
Parameters
const TDesC8& aDes |
An8 bit non modifable descriptor containing the match pattern.
|
|
Return value
TInt |
If a match is found, the offset within this descriptor's data
where the match first occurs. KErrNotFound , if there is no match.
|
|