class TDesC16 |
Abstract base class for 16-bit descriptors.
The class encapsulates the data member containing the length of data represented by a 16-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 16-bit (i.e. double 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.
Protected Member Functions | |
---|---|
TDesC16 () | |
TDesC16 ( TInt , TInt ) | |
IMPORT_C const TUint16 & | AtC ( TInt ) |
void | DoSetLength ( TInt ) |
TInt | Type () |
Public Member Enumerations | |
---|---|
enum | TPrefix { EIsPrefix = 0, EMightBePrefix = 1, EIsNotPrefix = 2 } |
Private Attributes | |
---|---|
__DECLARE_TEST | |
TUint | iLength |
IMPORT_C HBufC16 * | Alloc | ( | ) | const |
Creates a new 16-bit heap descriptor and initialises it with a copy of this descriptor's data.
IMPORT_C HBufC16 * | AllocL | ( | ) | const |
Creates a new 16-bit heap descriptor and initialises it with a copy of this descriptor's data.
The function leaves, if creation of the descriptor fails.
IMPORT_C HBufC16 * | AllocLC | ( | ) | const |
Creates a new 16-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.
IMPORT_C TInt | Compare | ( | const TDesC16 & | aDes | ) | const |
Compares this descriptor's data with the specified descriptor's data.
The comparison proceeds on a double-byte for double byte basis. The result of the comparison is based on the difference of the first pair of 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.
const TDesC16 & aDes | The 16-bit non-modifable descriptor whose data is to be compared with this descriptor's data. |
IMPORT_C TInt | CompareC | ( | const TDesC16 & | aDes | ) | const |
Compares this descriptor's data with the specified descriptor's data using the standard collation method appropriate to the current locale.
const TDesC16 & aDes | The 16-bit non-modifable descriptor whose data is to be compared with this descriptor's data. |
IMPORT_C TInt | CompareC | ( | const TDesC16 & | aDes, |
TInt | aMaxLevel, | |||
const TCollationMethod * | aCollationMethod | |||
) | const |
Compares this descriptor's data with the specified descriptor's data to the specified maximum collation level and using the specified collation method.
If no collation method is supplied, a default method is used that uses a locale-independent collation table. This means that sorting and matching will not be based on the current locale.
This function is only defined for 16-bit (Unicode) build variants. This means that the function is not defined for 8-bit build variants, even when an explicit 16-bit descriptor is used.
Strings may match even if the lengths of their respective descriptors are different.
Mem::CollationMethodByIndex() Mem::CollationMethodById() TDesC16::Compare()
const TDesC16 & aDes | The 16-bit non-modifable descriptor whose data is to be compared with this descriptor's data. |
TInt aMaxLevel | The maximum collation level. This is an integer with values: 0, 1, 2 or 3, which, effectively, determines how 'tight' the matching should be. Level 3 is always used if the aim is to sort strings. |
const TCollationMethod * aCollationMethod | A pointer to the collation method or NULL. Collation methods can be retrieved by calls to Mem::CollationMethodByIndex() and Mem::CollationMethodById(). Specifying NULL means that the default method is used. |
IMPORT_C TInt | CompareF | ( | const TDesC16 & | 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.
const TDesC16 & aDes | The 16-bit non-modifable descriptor whose data is to be compared with this descriptor's data. |
IMPORT_C TInt | Find | ( | const TDesC16 & | 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.
const TDesC16 & aDes | The 16-bit non-modifiable descriptor containing the data sequence to be searched for. |
IMPORT_C TInt | Find | ( | const TUint16 * | aBuf, |
TInt | aLen | |||
) | 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.
IMPORT_C TInt | FindC | ( | const TDesC16 & | 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 appropriate to the current locale.
const TDesC16 & aDes | The 16-bit non-modifable descriptor containing the data sequence to be searched for. |
IMPORT_C TInt | FindC | ( | const TUint16 * | aBuf, |
TInt | aLen | |||
) | 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 appropriate to the current locale.
IMPORT_C TInt | FindC | ( | const TUint16 * | aText, |
TInt | aLength, | |||
TInt | aMaxLevel | |||
) | const |
Searches for the first occurrence of the specified collated data sequence within this descriptor's collated data to the specified maximum collation level.
const TUint16 * aText | A pointer to a location containing the data sequence to be searched for. |
TInt aLength | The length of the data sequence to be searched for. |
TInt aMaxLevel | The maximum collation level. This is an integer with values: 0, 1, 2 or 3, which, effectively, determines how 'tight' the matching should be. Level 3 is always used if the aim is to sort strings. |
IMPORT_C TInt | FindC | ( | const TDesC16 & | aDes, |
TInt & | aLengthFound, | |||
const TCollationMethod & | aMethod, | |||
TInt | aMaxLevel | |||
) | 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 appropriate to the current locale.
const TDesC16 & aDes | The 16-bit non-modifable descriptor containing the data sequence to be searched for. |
TInt & aLengthFound | A refernce to the maximal length of the match found in the candidate string. KErrNotFound, if the data sequence cannot be found. |
const TCollationMethod & aMethod | |
TInt aMaxLevel | The maximum collation level. This is an integer with values: 0, 1, 2 or 3, which, effectively, determines how 'tight' the matching should be. Level 3 is always used if the aim is to sort strings. |
IMPORT_C TInt | FindF | ( | const TDesC16 & | 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.
const TDesC16 & aDes | The 16-bit non-modifable descriptor containing the data sequence to be searched for. |
IMPORT_C TInt | FindF | ( | const TUint16 * | aBuf, |
TInt | aLen | |||
) | 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.
IMPORT_C HBufC8 * | GetCollationKeysL | ( | TInt | aMaxLevel, |
const TCollationMethod * | aCollationMethod | |||
) | const |
TInt aMaxLevel | The maximum collation level. This is an integer with values: 0, 1, 2 or 3. Level 3 is always used if the aim is to sort strings. |
const TCollationMethod * aCollationMethod | A pointer to the collation method or NULL. Collation methods can be retrieved by calls to Mem::CollationMethodByIndex() and Mem::CollationMethodById(). Specifying NULL means that the default method is used. |
IMPORT_C HBufC16 * | GetFoldedDecomposedFormL | ( | ) | const |
IMPORT_C HBufC16 * | GetNormalizedDecomposedFormL | ( | ) | const |
IMPORT_C TPrefix | HasPrefixC | ( | const TDesC16 & | aPossiblePrefix, |
TInt | aLevel, | |||
const TCollationMethod * | aCollationMethod | |||
) | const |
Compares aPossiblePrefix against the start of the descriptor, using a collated comparison.
0: Only check character identities.
1: Check accents as well.
2: Check case as well.
3: Check Unicode values.
Currently only level 0 is supported.
const TDesC16 & aPossiblePrefix | |
TInt aLevel | The maximum level at which to perform the collation. |
const TCollationMethod * aCollationMethod | The collation method to be used for the matching. |
IMPORT_C TPtrC16 | Left | ( | TInt | aLength | ) | 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.
TInt aLength | The 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. |
TInt | Length | ( | ) | const [inline] |
Gets the length of the data.
This is the number of 16-bit values or data items represented by the descriptor.
IMPORT_C TInt | Locate | ( | TChar | aChar | ) | 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.
TChar aChar | The character to be found. |
IMPORT_C TInt | LocateF | ( | TChar | aChar | ) | 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.
TChar aChar | The character to be found. |
IMPORT_C TInt | LocateReverse | ( | TChar | aChar | ) | 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.
TChar aChar | The character to be found. |
IMPORT_C TInt | LocateReverseF | ( | TChar | aChar | ) | 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.
TChar aChar | The character to be found |
IMPORT_C TInt | Match | ( | const TDesC16 & | 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.
const TDesC16 & aDes | A 16-bit non-modifable descriptor containing the match pattern. |
IMPORT_C TInt | MatchC | ( | const TDesC16 & | 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 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.
const TDesC16 & aDes | A 16-bit non-modifable descriptor containing the match pattern. |
IMPORT_C TInt | MatchC | ( | const TDesC16 & | aPattern, |
TInt | aWildChar, | |||
TInt | aWildSequenceChar, | |||
TInt | aEscapeChar, | |||
TInt | aMaxLevel = 3, | |||
const TCollationMethod * | aCollationMethod = NULL | |||
) | 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 appropriate to the current locale.
The match pattern can contain the wildcard characters specified by aWildChar and aWildSequenceChar parameters, where aWildSequenceChar matches zero or more consecutive occurrences of any character and aWildChar matches a single occurrence of any character.
const TDesC16 & aPattern | A 16-bit non-modifable descriptor containing the match pattern. |
TInt aWildChar | Wild card character which may be specified for aSearchTerm. |
TInt aWildSequenceChar | Wild card sequence character which may be specified for aSearchTerm. |
TInt aEscapeChar | The escape character, or 0 if there is to be none. The escape character removes any special meaning from the subsequent character. For example, if the escape, wild card and wild sequence characters are \, ? And * respectively, the search term "\?\*\\" matches only the candidate string "?*\"; |
TInt aMaxLevel = 3 | Determines the tightness of the collation. At level 0, only character identities are distinguished. At level 1 accents are distinguished as well. At level 2 case is distinguishes as well. At level 3 all valid different Unicode characters are considered different. |
const TCollationMethod * aCollationMethod = NULL | A pointer to the collation method or NULL. Collation methods can be retrieved by calls to Mem::CollationMethodByIndex() and Mem::CollationMethodById(). Specifying NULL means that the default method is used. |
IMPORT_C TInt | MatchC | ( | const TDesC16 & | aPattern, |
const TCollationMethod * | aCollationMethod, | |||
TInt | aMaxLevel = 3, | |||
TInt | aWildChar = '?', | |||
TInt | aWildSequenceChar = '*', | |||
TInt | aEscapeChar = 0 | |||
) | 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 appropriate to the current locale.
The match pattern can contain the wildcard characters specified by aWildChar and aWildSequenceChar parameters, where aWildSequenceChar matches zero or more consecutive occurrences of any character and aWildChar matches a single occurrence of any character.
TCollationFlag TCollationMethod
const TDesC16 & aPattern | A 16-bit non-modifable descriptor containing the match pattern. |
const TCollationMethod * aCollationMethod | A pointer to the collation method. Collation methods can be retrieved by calls to Mem::CollationMethodByIndex(), Mem::CollationMethodById() or by custom defined name. Flags can be set on definition of the custom TCollationMethod, or by const_cast-ing the returned pointer and setting the iFlags field directly. |
TInt aMaxLevel = 3 | Determines the tightness of the collation. Defaulted to 3 if omitted. At level 0, only character identities are distinguished. At level 1 accents are distinguished as well. At level 2 case is distinguishes as well. At level 3 all valid different Unicode characters are considered different. |
TInt aWildChar = '?' | Wild card character which may be specified for aSearchTerm. Defaulted to '?' if omitted. |
TInt aWildSequenceChar = '*' | Wild card sequence character which may be specified for aSearchTerm. Defaulted to '*' if omitted. |
TInt aEscapeChar = 0 | The escape character, or 0 if there is to be none. The escape character removes any special meaning from the subsequent character. For example, if the escape, wild card and wild sequence characters are \, ? And * respectively, the search term "\?\*\\" matches only the candidate string "?*\". Defaulted to 0 if omitted. |
IMPORT_C TInt | MatchF | ( | const TDesC16 & | 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.
const TDesC16 & aDes | A 16-bit non-modifable descriptor containing the match pattern. |
IMPORT_C TPtrC16 | Mid | ( | TInt | aPos | ) | 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.
TInt aPos | The starting position of the data to be extracted. This is an offset value; a zero value refers to the leftmost data position. |
IMPORT_C TPtrC16 | Mid | ( | TInt | aPos, |
TInt | aLength | |||
) | 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.
IMPORT_C const TUint16 * | Ptr | ( | ) | const |
Gets a pointer to the data represented by the descriptor.
The data cannot be changed through the returned pointer.
IMPORT_C TPtrC16 | Right | ( | TInt | aLength | ) | 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.
TInt aLength | The 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. |
TInt | Size | ( | ) | const [inline] |
Gets the size of the data.
This is the number of bytes occupied by the data represented by the descriptor.
TBool | operator!= | ( | const TDesC16 & | 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.
const TDesC16 & aDes | The 16-bit non-modifiable descriptor whose data is to be compared with this descriptor's data. |
TBool | operator< | ( | const TDesC16 & | 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.
const TDesC16 & aDes | The 16-bit non-modifable descriptor whose data is to be compared with this descriptor's data. |
TBool | operator<= | ( | const TDesC16 & | 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.
const TDesC16 & aDes | The 16-bit non- modifiable descriptor whose data is to be compared with this descriptor's data. |
TBool | operator== | ( | const TDesC16 & | 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.
const TDesC16 & aDes | The 16-bit non-modifiable descriptor whose data is to be compared with this descriptor's data. |
TBool | operator> | ( | const TDesC16 & | 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.
const TDesC16 & aDes | The 16-bit non-modifiable descriptor whose data is to be compared with this descriptor's data. |
TBool | operator>= | ( | const TDesC16 & | 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.
const TDesC16 & aDes | The 16-bit non-modifiable descriptor whose data is to be compared with this descriptor's data. |
const TUint16 & | operator[] | ( | TInt | anIndex | ) | const [inline] |
Gets a reference to a single data item within this descriptor's data.
TInt anIndex | The 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. |
A value returned by a call to HasPrefixC() .
EIsPrefix = 0 |
Indicates that a supplied prefix can be extended to be equivalent to the text at the start of a descriptor. |
EMightBePrefix = 1 |
Indicates that a supplied prefix does not seem to be a prefix, but it is possible that it could be extended to become equivalent to text at the start of this descriptor. |
EIsNotPrefix = 2 |
Indicates that a supplied prefix cannot be extended to be equivalent to the text at the start of a descriptor. |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.