Symbian
 Developer Library

DEVELOPER LIBRARY

[Index] [Glossary] [Previous] [Next]



Location: CFragmentedString.h
Link against: bnf.lib

Class CFragmentedString

class CFragmentedString : protected CArrayPtrFlat<HBufC>

Support

Supported from 6.0

Description

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.

Derivation

CArrayFixA thin templated base class for arrays of fixed length objects
CArrayFixBaseBase class for arrays of fixed length objects
CArrayPtrA thin templated base class for arrays of pointers to objects
CArrayPtrFlatArray of pointers to objects implemented using a flat dynamic buffer
CBaseBase class for all classes to be instantiated on the heap
CFragmentedStringUtility that allows a single string to be built from an array of consecutive sub-strings

Defined in CFragmentedString:
AddStringL(), AddStringL(), CFragmentedString(), CMarkStack, ConsumeMatched(), ContentL(), DeleteMark(), DeleteToMark(), DoMatchSelect(), EInsufficientData, EMatch, ENoMatch, FindNextMatchChar(), InsertStringL(), InsertStringToL(), Length(), Mark(), MarkedL(), MarkedWithInitialTextL(), Match(), MatchNotSelect(), MatchRange(), MatchSelect(), ReplaceMarkedAndSkipL(), ReplaceMarkedL(), Reset(), ResetToMark(), StartMatch(), StringL(), StringL(), TStringMark, TStringMatch, iCurrentCharacter, iCurrentIndex, iMarkStack, iMatched, iMatchedToCharacter, iMatchedToIndex, ~CFragmentedString()

Inherited from CArrayFix:
AppendL(), AppendL()Append, Array(), At(), Back(), End(), ExpandL(), ExtendL(), Find(), FindIsq(), InsertIsqAllowDuplicatesL(), InsertIsqL(), InsertL(), ResizeL(), operator[]

Inherited from CArrayFixBase:
Compress(), Count(), Delete(), Sort()

Inherited from CArrayPtr:
ResetAndDestroy()

Inherited from CArrayPtrFlat:
SetReserveL()

Inherited from CBase:
operator new()


Construction and destruction


CFragmentedString()

CFragmentedString();

Description

Constructor.


~CFragmentedString()

~CFragmentedString();

Description

Destructor.

This resets and destroys the HBufC array.

[Top]


Member functions


AddStringL()

void AddStringL(HBufC* aString);

Description

Appends a sub-string to the string.

Parameters

HBufC* aString

Sub-string to append


AddStringL()

void AddStringL(const TDesC& aString);

Description

Copies a sub-string and then appends the copy to the string.

Parameters

const TDesC& aString

Sub-string to copy then append


Length()

TInt Length() const;

Description

Gets the length of the string.

Return value

TInt

String length


StringL()

HBufC* StringL() const;

Description

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.

Return value

HBufC*

String containing all sub-strings after the current position in a newly-allocated buffer


ContentL()

HBufC* ContentL() const;

Description

Gets the entire string in a newly-allocated buffer.

It is the caller's responsibility to clean up the returned string.

Return value

HBufC*

Entire string in a newly-allocated buffer


Reset()

void Reset();

Description

Resets the string.

This resets and destroys the HBufC array, and clears all indexes and marks.


Match()

TStringMatch Match(const TDesC& aString);

Description

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.

Parameters

const TDesC& aString

String to attempt to match

Return value

TStringMatch

Match result


MatchRange()

TStringMatch MatchRange(const TUint aLower, const TUint aUpper);

Description

Tests if the character at the current position is within a specified character code range.

Parameters

const TUint aLower

Lower range (inclusive) for a match

const TUint aUpper

Upper range (inclusive) for a match

Return value

TStringMatch

Match result


MatchSelect()

TStringMatch MatchSelect(const TDesC& aSelection);

Description

Tests if the character at the current position matches any character in a specified string.

Parameters

const TDesC& aSelection

String specifying one or more characters, any of which will result in a successful match

Return value

TStringMatch

Match result


MatchNotSelect()

TStringMatch MatchNotSelect(const TDesC& aSelection);

Description

Tests if the character at the current position does not match any character in a specified string.

Parameters

const TDesC& aSelection

String specifying one or more characters, any of which will result in a failed match

Return value

TStringMatch

Match result


ConsumeMatched()

void ConsumeMatched();

Description

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.


MarkedL()

HBufC* MarkedL();

Description

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.

Return value

HBufC*

New string containing marked contents


MarkedWithInitialTextL()

HBufC* MarkedWithInitialTextL(const TDesC& aInitialText);

Description

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.

Parameters

const TDesC& aInitialText

String to prepend to the result

Return value

HBufC*

New string containing aInitialText and then the marked contents


Mark()

void Mark();

Description

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.


DeleteMark()

void DeleteMark();

Description

Deletes the head mark.


ResetToMark()

void ResetToMark();

Description

Moves the current index position to the head mark.


ReplaceMarkedL()

void ReplaceMarkedL(HBufC* aString);

Description

Replaces the string contents to the head mark with a specified string.

Parameters

HBufC* aString

Replacment string


ReplaceMarkedAndSkipL()

void ReplaceMarkedAndSkipL(HBufC* aString);

Description

Replaces the string contents to the head mark with a specified string, and then advances the current index position to the next sub-string.

Parameters

HBufC* aString

Replacment string


InsertStringL()

void InsertStringL(HBufC* aString);

Description

Inserts a specified string at the current index position.

Parameters

HBufC* aString

String to insert


DeleteToMark()

protected: void DeleteToMark(const TStringMark& aStringMark);

Description

Deletes from the current index position to the specified mark.

Parameters

const TStringMark& aStringMark

Mark to delete to


InsertStringToL()

protected: void InsertStringToL(HBufC* aString, TInt aStringIndex, TInt aLengthIntoString);

Description

Inserts a string at a specified position.

Parameters

HBufC* aString

String to insert

TInt aStringIndex

Array index of the sub-string at which to insert

TInt aLengthIntoString

Character position within the sub-string at which to insert

[Top]


Member classes


Class TStringMark

class TStringMark

Description

A mark at a string position.

Defined in CFragmentedString::TStringMark:
TStringMark(), iMarkCharacter, iMarkIndex

Construction and destruction


TStringMark()

TStringMark(TInt aIndex, TInt aCharacter);

Description

Constructor.

Parameters

TInt aIndex

Array index of the marked sub-string

TInt aCharacter

Character position within the sub-string for the mark

Member data


iMarkIndex

TInt iMarkIndex;

Description

Array index of the marked sub-string.


iMarkCharacter

TInt iMarkCharacter;

Description

Character position within the sub-string for the mark.

[Top]


Member enumerations


Enum TStringMatch

TStringMatch

Description

Defines possible results of a string matching operation for this class.

ENoMatch

There was no match.

EMatch

There was a complete match.

EInsufficientData

String contained insufficient data to perform the match operation.

This can mean that the start of the target string was matched, but the string being searched ended before a complete match was found.

[Top]


Member typedefs


Typedef CMarkStack

protected: typedef CStack<TStringMark, ETrue> CMarkStack;

Description

A stack of string position marks.

[Top]


Member data


iMatched

protected: TStringMatch iMatched;

Description

Result of the last match operation.


iMatchedToIndex

protected: TInt iMatchedToIndex;

Description

Array index of the sub-string found in the last match operation.


iMatchedToCharacter

protected: TInt iMatchedToCharacter;

Description

Current character position within the iMatchedToIndex sub-string found in the last match operation.


iCurrentIndex

protected: TInt iCurrentIndex;

Description

Array index of the current sub-string.


iCurrentCharacter

protected: TInt iCurrentCharacter;

Description

Current character position within the current sub-string.


iMarkStack

protected: CMarkStack iMarkStack;

Description

Stack of marks in the string.

Mark() pushes a mark on the stack; DeleteMark() pops one off.

[Top]


Internal members


StringL()

protected: HBufC* StringL(TInt aStartIndex, TInt aStartCharacter, TInt aEndIndex, TInt aEndCharacter, const TDesC* aInitialText=NULL) const;

Description

This member is internal and not intended for use.


StartMatch()

protected: void StartMatch();

Description

This member is internal and not intended for use.


DoMatchSelect()

protected: CFragmentedString::TStringMatch DoMatchSelect(const TDesC& aSelection, TBool aInSelection);

Description

This member is internal and not intended for use.


FindNextMatchChar()

protected: TBool FindNextMatchChar(TUint& aChar);

Description

This member is internal and not intended for use.