CFragmentedString Class Reference

#include <mw/cfragmentedstring.h>

Link against: bnf.lib

class CFragmentedString : protected CArrayPtrFlat< HBufC >

Nested Classes and Structures

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
enumTStringMatch { ENoMatch, EMatch, EInsufficientData }
Public Member Functions
CFragmentedString()
~CFragmentedString()
IMPORT_C voidAddStringL(HBufC *)
IMPORT_C voidAddStringL(const TDesC &)
IMPORT_C voidConsumeMatched()
IMPORT_C HBufC *ContentL()
IMPORT_C voidDeleteMark()
IMPORT_C voidInsertStringL(HBufC *)
IMPORT_C TIntLength()
IMPORT_C voidMark()
IMPORT_C HBufC *MarkedL()
IMPORT_C HBufC *MarkedWithInitialTextL(const TDesC &)
IMPORT_C TStringMatchMatch(const TDesC &)
IMPORT_C TStringMatchMatchNotSelect(const TDesC &)
IMPORT_C TStringMatchMatchRange(const TUint, const TUint)
IMPORT_C TStringMatchMatchSelect(const TDesC &)
IMPORT_C voidReplaceMarkedAndSkipL(HBufC *)
IMPORT_C voidReplaceMarkedL(HBufC *)
IMPORT_C voidReset()
IMPORT_C voidResetToMark()
IMPORT_C HBufC *StringL()
Protected Member Functions
IMPORT_C voidDeleteToMark(const TStringMark &)
CFragmentedString::TStringMatch DoMatchSelect(const TDesC &, TBool)
TBool FindNextMatchChar(TUint &)
IMPORT_C voidInsertStringToL(HBufC *, TInt, TInt)
voidStartMatch()
HBufC *StringL(TInt, TInt, TInt, TInt, const TDesC *)
Inherited Functions
CArrayFix< HBufC * >::AppendL(const HBufC *&)
CArrayFix< HBufC * >::AppendL(const HBufC *&,TInt)
CArrayFix< HBufC * >::AppendL(const HBufC **,TInt)
CArrayFix< HBufC * >::Array()const
CArrayFix< HBufC * >::At(TInt)
CArrayFix< HBufC * >::At(TInt)const
CArrayFix< HBufC * >::Back(TInt)
CArrayFix< HBufC * >::Back(TInt)const
CArrayFix< HBufC * >::CArrayFix(TBufRep,TInt)
CArrayFix< HBufC * >::End(TInt)
CArrayFix< HBufC * >::End(TInt)const
CArrayFix< HBufC * >::ExpandL(TInt)
CArrayFix< HBufC * >::ExtendL()
CArrayFix< HBufC * >::Find(const HBufC *&,TKeyArrayFix &,TInt &)const
CArrayFix< HBufC * >::FindIsq(const HBufC *&,TKeyArrayFix &,TInt &)const
CArrayFix< HBufC * >::InsertIsqAllowDuplicatesL(const HBufC *&,TKeyArrayFix &)
CArrayFix< HBufC * >::InsertIsqL(const HBufC *&,TKeyArrayFix &)
CArrayFix< HBufC * >::InsertL(TInt,const HBufC *&)
CArrayFix< HBufC * >::InsertL(TInt,const HBufC *&,TInt)
CArrayFix< HBufC * >::InsertL(TInt,const HBufC **,TInt)
CArrayFix< HBufC * >::ResizeL(TInt)
CArrayFix< HBufC * >::ResizeL(TInt,const HBufC *&)
CArrayFix< HBufC * >::operator[](TInt)
CArrayFix< HBufC * >::operator[](TInt)const
CArrayFixBase::AtR(const CBase *,TInt)
CArrayFixBase::CArrayFixBase(TBufRep,TInt,TInt)
CArrayFixBase::Compress()
CArrayFixBase::Count()const
CArrayFixBase::CountR(const CBase *)
CArrayFixBase::Delete(TInt)
CArrayFixBase::Delete(TInt,TInt)
CArrayFixBase::Find(const TAny *,TKeyArrayFix &,TInt &)const
CArrayFixBase::FindIsq(const TAny *,TKeyArrayFix &,TInt &)const
CArrayFixBase::InsertIsqAllowDuplicatesL(const TAny *,TKeyArrayFix &)
CArrayFixBase::InsertIsqL(const TAny *,TKeyArrayFix &)
CArrayFixBase::InsertL(TInt,const TAny *)
CArrayFixBase::InsertL(TInt,const TAny *,TInt)
CArrayFixBase::InsertRepL(TInt,const TAny *,TInt)
CArrayFixBase::ResizeL(TInt,const TAny *)
CArrayFixBase::SetKey(TKeyArrayFix &)const
CArrayFixBase::SetReserveFlatL(TInt)
CArrayFixBase::Sort(TKeyArrayFix &)
CArrayFixBase::~CArrayFixBase()
CArrayPtr< HBufC >::CArrayPtr(TBufRep,TInt)
CArrayPtr< HBufC >::ResetAndDestroy()
CArrayPtrFlat< HBufC >::CArrayPtrFlat(TInt)
CArrayPtrFlat< HBufC >::SetReserveL(TInt)
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()

Detailed 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. Deprecated

Member Type Definition Documentation

Typedef CMarkStack

typedef CStack< TStringMark, ETrue >CMarkStack[protected]

A stack of string position marks.

Member Attribute Documentation

iCurrentCharacter

TInt iCurrentCharacter[protected]

Current character position within the current sub-string.

iCurrentIndex

TInt iCurrentIndex[protected]

Array index of the current sub-string.

iMarkStack

CMarkStack iMarkStack[protected]

Stack of marks in the string.

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

iMatched

TStringMatch iMatched[protected]

Result of the last match operation.

iMatchedToCharacter

TInt iMatchedToCharacter[protected]

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

iMatchedToIndex

TInt iMatchedToIndex[protected]

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

Member Enumeration Documentation

Enum TStringMatch

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

EnumeratorValueDescription
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.

Constructor & Destructor Documentation

CFragmentedString ( )

IMPORT_CCFragmentedString()

Constructor

~CFragmentedString ( )

IMPORT_C~CFragmentedString()

Destructor.

This resets and destroys the HBufC array.

Member Function Documentation

AddStringL ( HBufC * )

IMPORT_C voidAddStringL(HBufC *aString)

Appends a sub-string to the string.

Parameters
aStringSub-string to append

AddStringL ( const TDesC & )

IMPORT_C voidAddStringL(const TDesC &aString)

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

Parameters
aStringSub-string to append

ConsumeMatched ( )

IMPORT_C voidConsumeMatched()

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.

ContentL ( )

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.

Return Value
Entire string in a newly-allocated buffer

DeleteMark ( )

IMPORT_C voidDeleteMark()

Deletes the head mark.

DeleteToMark ( const TStringMark & )

IMPORT_C voidDeleteToMark(const TStringMark &aStringMark)[protected]

Deletes from the current index position to the specified mark.

Parameters
aStringMarkMark to delete to

DoMatchSelect ( const TDesC &, TBool )

CFragmentedString::TStringMatch DoMatchSelect(const TDesC &aSelection,
TBoolaInSelection
)[protected]

FindNextMatchChar ( TUint & )

TBool FindNextMatchChar(TUint &aChar)[protected]

InsertStringL ( HBufC * )

IMPORT_C voidInsertStringL(HBufC *aString)

Inserts a specified string at the current index position.

Parameters
aStringString to insert

InsertStringToL ( HBufC *, TInt, TInt )

IMPORT_C voidInsertStringToL(HBufC *aString,
TIntaStringIndex,
TIntaLengthIntoString
)[protected]

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

Parameters
aStringString to insert
aStringIndexArray index of the sub-string at which to insert
aLengthIntoStringCharacter position within the sub-string at which to insert

Length ( )

IMPORT_C TIntLength()const

Reimplemented from CArrayFixBase::Length()const

Gets the length of the string.

Return Value
String length

Mark ( )

IMPORT_C voidMark()

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.

MarkedL ( )

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.

Return Value
New string containing marked contents

MarkedWithInitialTextL ( const TDesC & )

IMPORT_C HBufC *MarkedWithInitialTextL(const TDesC &aInitialText)

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
aInitialTextString to prepend to the result
Return Value
New string containing aInitialText and then the marked contents

Match ( const TDesC & )

IMPORT_C TStringMatchMatch(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.

Parameters
aStringString to attempt to match
Return Value
Match result

MatchNotSelect ( const TDesC & )

IMPORT_C TStringMatchMatchNotSelect(const TDesC &aSelection)

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

Parameters
aSelectionString specifying one or more characters, any of which will result in a failed match
Return Value
Match result

MatchRange ( const TUint, const TUint )

IMPORT_C TStringMatchMatchRange(const TUintaLower,
const TUintaUpper
)

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

Parameters
aLowerLower range (inclusive) for a match
aUpperUpper range (inclusive) for a match
Return Value
Match result

MatchSelect ( const TDesC & )

IMPORT_C TStringMatchMatchSelect(const TDesC &aSelection)

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

Parameters
aSelectionString specifying one or more characters, any of which will result in a successful match
Return Value
Match result

ReplaceMarkedAndSkipL ( HBufC * )

IMPORT_C voidReplaceMarkedAndSkipL(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.

Parameters
aStringReplacment string

ReplaceMarkedL ( HBufC * )

IMPORT_C voidReplaceMarkedL(HBufC *aString)

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

Parameters
aStringReplacment string

Reset ( )

IMPORT_C voidReset()

Reimplemented from CArrayFixBase::Reset()

Resets the string.

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

ResetToMark ( )

IMPORT_C voidResetToMark()

Moves the current index position to the head mark.

StartMatch ( )

voidStartMatch()[protected]

StringL ( )

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.

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

StringL ( TInt, TInt, TInt, TInt, const TDesC * )

HBufC *StringL(TIntaStartIndex,
TIntaStartCharacter,
TIntaEndIndex,
TIntaEndCharacter,
const TDesC *aInitialText = NULL
)const [protected]