#include <mw/cfragmentedstring.h>
class CFragmentedString : protected CArrayPtrFlat< HBufC > |
Protected Member Type Definitions | |
---|---|
typedef | CStack< TStringMark, ETrue > CMarkStack |
Protected Attributes | |
---|---|
TInt | iCurrentCharacter |
TInt | iCurrentIndex |
CMarkStack | iMarkStack |
TStringMatch | iMatched |
TInt | iMatchedToCharacter |
TInt | iMatchedToIndex |
Public Member Enumerations | |
---|---|
enum | TStringMatch { ENoMatch, EMatch, EInsufficientData } |
Public Member Functions | |
---|---|
CFragmentedString() | |
~CFragmentedString() | |
IMPORT_C void | AddStringL(HBufC *) |
IMPORT_C void | AddStringL(const TDesC &) |
IMPORT_C void | ConsumeMatched() |
IMPORT_C HBufC * | ContentL() |
IMPORT_C void | DeleteMark() |
IMPORT_C void | InsertStringL(HBufC *) |
IMPORT_C TInt | Length() |
IMPORT_C void | Mark() |
IMPORT_C HBufC * | MarkedL() |
IMPORT_C HBufC * | MarkedWithInitialTextL(const TDesC &) |
IMPORT_C TStringMatch | Match(const TDesC &) |
IMPORT_C TStringMatch | MatchNotSelect(const TDesC &) |
IMPORT_C TStringMatch | MatchRange(const TUint, const TUint) |
IMPORT_C TStringMatch | MatchSelect(const TDesC &) |
IMPORT_C void | ReplaceMarkedAndSkipL(HBufC *) |
IMPORT_C void | ReplaceMarkedL(HBufC *) |
IMPORT_C void | Reset() |
IMPORT_C void | ResetToMark() |
IMPORT_C HBufC * | StringL() |
Protected Member Functions | |
---|---|
IMPORT_C void | DeleteToMark(const TStringMark &) |
CFragmentedString::TStringMatch | DoMatchSelect(const TDesC &, TBool) |
TBool | FindNextMatchChar(TUint &) |
IMPORT_C void | InsertStringToL(HBufC *, TInt, TInt) |
void | StartMatch() |
HBufC * | StringL(TInt, TInt, TInt, TInt, const TDesC *) |
Utility that allows a single string to be built from an array of consecutive sub-strings.
The sub-strings can be inserted by reference or copied.
The object maintains information that points to a current position within the string. A typical use is to test the contents of the string using one of the Match...() functions, and then use ConsumeMatched() to advance past the matched area.
The class also supports inserting an unlimited number of marks in the string, and performing operations relative to the head (i.e. last inserted) mark. Deprecated
typedef CStack< TStringMark, ETrue > | CMarkStack | [protected] |
A stack of string position marks.
TInt | iCurrentCharacter | [protected] |
Current character position within the current sub-string.
CMarkStack | iMarkStack | [protected] |
Stack of marks in the string.
Mark() pushes a mark on the stack; DeleteMark() pops one off.
TInt | iMatchedToCharacter | [protected] |
Current character position within the iMatchedToIndex sub-string found in the last match operation.
TInt | iMatchedToIndex | [protected] |
Array index of the sub-string found in the last match operation.
Defines possible results of a string matching operation for this class.
IMPORT_C | ~CFragmentedString | ( | ) |
Destructor.
This resets and destroys the HBufC array.
IMPORT_C void | AddStringL | ( | HBufC * | aString | ) |
Appends a sub-string to the string.
Parameter | Description |
---|---|
aString | Sub-string to append |
IMPORT_C void | AddStringL | ( | const TDesC & | aString | ) |
Copies a sub-string and then appends the copy to the string.
Parameter | Description |
---|---|
aString | Sub-string to append |
IMPORT_C void | ConsumeMatched | ( | ) |
Removes and deletes all sub-strings occurring before the position of the last successful match.
Any sub-strings at or after a mark are not deleted, regardless of the last successful match position.
IMPORT_C HBufC * | ContentL | ( | ) | const |
Gets the entire string in a newly-allocated buffer.
It is the caller's responsibility to clean up the returned string.
Returns: Entire string in a newly-allocated buffer
IMPORT_C void | DeleteToMark | ( | const TStringMark & | aStringMark | ) | [protected] |
Deletes from the current index position to the specified mark.
Parameter | Description |
---|---|
aStringMark | Mark to delete to |
CFragmentedString::TStringMatch | DoMatchSelect | ( | const TDesC & | aSelection, |
TBool | aInSelection | |||
) | [protected] |
IMPORT_C void | InsertStringL | ( | HBufC * | aString | ) |
Inserts a specified string at the current index position.
Parameter | Description |
---|---|
aString | String to insert |
Inserts a string at a specified position.
1. if aLengthIntoString is 0, the function inserts a new sub-string at array position aStringIndex
2. if aLengthIntoString is equal to the length of the sub-string at aStringIndex, then it inserts a new sub-string at array position aStringIndex+1.
3. If aLengthIntoString is in the middle of theaStringIndex sub-string, then it:
a) inserts a new sub-string at aStringIndex+1 holdingaString
b) inserts a new sub-string at aStringIndex+2 holding the data from aStringIndex after aLengthIntoString
c) truncates the original aStringIndex to hold only the data before aLengthIntoString
Parameter | Description |
---|---|
aString | String to insert |
aStringIndex | Array index of the sub-string at which to insert |
aLengthIntoString | Character position within the sub-string at which to insert |
IMPORT_C TInt | Length | ( | ) | const |
Reimplemented from CArrayFixBase::Length()const
Gets the length of the string.
Returns: String length
IMPORT_C void | Mark | ( | ) |
Adds a mark at the current index position.
This mark becomes the head mark.
Note this function can leave with an out of memory error.
IMPORT_C HBufC * | MarkedL | ( | ) |
Gets a new string containing the string contents from the head mark to the current index position.
It is the caller's responsibility to clean up the returned string.
Returns: New string containing marked contents
Gets a new string containing the string contents from the head mark to the current index position, prepended with a specified string.
It is the caller's responsibility to clean up the returned string.
Parameter | Description |
---|---|
aInitialText | String to prepend to the result |
Returns: New string containing aInitialText and then the marked contents
IMPORT_C TStringMatch | Match | ( | const TDesC & | aString | ) |
Tests if a specified target string occurs at the current position.
The function does a byte-for-byte comparison of the string contents from the current position against aString.
Parameter | Description |
---|---|
aString | String to attempt to match |
Returns: Match result
IMPORT_C TStringMatch | MatchNotSelect | ( | const TDesC & | aSelection | ) |
Tests if the character at the current position does not match any character in a specified string.
Parameter | Description |
---|---|
aSelection | String specifying one or more characters, any of which will result in a failed match |
Returns: Match result
IMPORT_C TStringMatch | MatchRange | ( | const TUint | aLower, |
const TUint | aUpper | |||
) |
Tests if the character at the current position is within a specified character code range.
Parameter | Description |
---|---|
aLower | Lower range (inclusive) for a match |
aUpper | Upper range (inclusive) for a match |
Returns: Match result
IMPORT_C TStringMatch | MatchSelect | ( | const TDesC & | aSelection | ) |
Tests if the character at the current position matches any character in a specified string.
Parameter | Description |
---|---|
aSelection | String specifying one or more characters, any of which will result in a successful match |
Returns: Match result
IMPORT_C void | ReplaceMarkedAndSkipL | ( | HBufC * | aString | ) |
Replaces the string contents to the head mark with a specified string, and then advances the current index position to the next sub-string.
Parameter | Description |
---|---|
aString | Replacment string |
IMPORT_C void | ReplaceMarkedL | ( | HBufC * | aString | ) |
Replaces the string contents to the head mark with a specified string.
Parameter | Description |
---|---|
aString | Replacment string |
IMPORT_C void | Reset | ( | ) |
Reimplemented from CArrayFixBase::Reset()
Resets the string.
This resets and destroys the HBufC array, and clears all indexes and marks.
IMPORT_C HBufC * | StringL | ( | ) | const |
Gets a string containing all sub-strings after the current position in a newly-allocated buffer.
It is the caller's responsibility to clean up the returned string.
Returns: String containing all sub-strings after the current position in a newly-allocated buffer