CartoType API
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
CartoType::MString Class Reference

#include <cartotype_string.h>

Inheritance diagram for CartoType::MString:
CartoType::CString CartoType::TText CartoType::TTextBuffer< aMaxLength >

List of all members.

Public Types

enum  { EStandardTitleCase = 0, ELowerTitleCase, EUpperTitleCase }

Public Member Functions

virtual ~MString ()
int32 Length () const
virtual const uint16 * Text () const =0
TResult Delete (int32 aStart, int32 aEnd)
TResult Clear ()
void SetLengthToZero ()
CT_IMPORT uint16 * CreateNullTerminatedUtf16String () const
CT_IMPORT char * CreateNullTerminatedUtf8String () const
CT_IMPORT char * CreateUtf8String (int32 &aLength) const
CT_IMPORT TText First (int32 aLength) const
CT_IMPORT TText Last (int32 aLength) const
CT_IMPORT TResult SetCase (TLetterCase aCase, const MDictionary< MString, int32 > *aTitleCaseDictionary=0)
CT_IMPORT int32 Compare (MIter< int32 > &aIter, bool aFoldCase) const
CT_IMPORT TResult Replace (int32 aStart, int32 aEnd, MIter< int32 > &aText, int32 aMaxLength)
CT_IMPORT int32 Compare (const MString &aString, bool aFoldCase=false) const
TResult Replace (int32 aStart, int32 aEnd, const MString &aString)
TResult Insert (int32 aIndex, const MString &aString)
TResult Append (const MString &aString)
TResult Set (const MString &aString)
CT_IMPORT int32 Compare (const uint16 *aText, int32 aLength=-1, bool aFoldCase=false) const
CT_IMPORT TResult Replace (int32 aStart, int32 aEnd, const uint16 *aText, int32 aLength=-1)
TResult Insert (int32 aIndex, const uint16 *aText, int32 aLength=-1)
TResult Append (const uint16 *aText, int32 aLength=-1)
TResult Set (const uint16 *aText, int32 aLength=-1)
CT_IMPORT int32 Compare (const char *aText, int32 aLength=-1, bool aFoldCase=false) const
CT_IMPORT TResult Replace (int32 aStart, int32 aEnd, const char *aText, int32 aLength=-1, int32 aCodePage=0)
CT_IMPORT bool operator== (const char *aText) const
bool operator!= (const char *aText) const
TResult Insert (int32 aIndex, const char *aText, int32 aLength=-1, int32 aCodePage=0)
TResult Append (const char *aText, int32 aLength=-1, int32 aCodePage=0)
TResult Set (const char *aText, int32 aLength=-1)
TResult Set (const char *aText, int32 aLength, int32 aCodePage)
TResult Replace (int32 aStart, int32 aEnd, uint16 aChar)
TResult Insert (int32 aIndex, uint16 aChar)
TResult Append (uint16 aChar)
TResult Set (uint16 aChar)
bool operator== (const MString &aString) const
bool operator== (const uint16 *aText) const
bool operator!= (const MString &aString) const
bool operator!= (const uint16 *aText) const
CT_IMPORT TResult ToInt32 (int32 &aValue, int32 &aLengthUsed, int32 aBase=10) const
CT_IMPORT TResult ToFixed (TFixed &aValue, int32 &aLengthUsed) const
CT_IMPORT TResult ToDouble (double &aValue, int32 &aLengthUsed) const
CT_IMPORT TResult Shape (TBidiParDir aParDir, CBidiEngine *aBidiEngine, bool aParStart, bool aReorderFontSelectors)
CT_IMPORT TResult Abbreviate (const MPointerDictionary< MString, MString > &aDictionary)
CT_IMPORT bool IsLineBreak (int32 aPos) const
CT_IMPORT int32 LineBreakBefore (int32 aPos) const
CT_IMPORT int32 LineBreakAfter (int32 aPos) const

Static Public Member Functions

static CT_IMPORT int32 Compare (MIter< int32 > &aIter1, MIter< int32 > &aIter2, bool aFoldCase)
static CT_IMPORT TResult ToInt32 (const uint8 *aText, int32 aLength, int32 &aValue, int32 &aLengthUsed, int32 aBase=10)

Protected Member Functions

 MString (int32 aLength)

Protected Attributes

int32 iLength

Detailed Description

The string interface class. All strings implement this interface. The private part of the interface allows completely general compare, append, insert, delete and replace functions to be implemented in MString.

Although the M prefix of MString implies that this class is a pure mix-in with no data, it has one data item, the length, which was moved to the base class for efficiency reasons after profiling indicated a bottleneck accessing the various virtual Length functions of derived classes.


Member Enumeration Documentation

anonymous enum

Constants used in the title case dictionary passed to SetCase that specifies exceptions to ordinary case conversion when converting to title case.

Enumerator:
EStandardTitleCase 

No special title case treatment. This constant must be zero.

ELowerTitleCase 

When setting text to title case, do not capitalize the first letter unless the word is initial. Used for particles like 'on', 'of', etc. and their upper-case variants.

EUpperTitleCase 

When setting text to title case, leave these strings as they are (they are already upper-case). Used for acronyms like US, roman numerals like II, etc.


Constructor & Destructor Documentation

virtual CartoType::MString::~MString ( ) [inline, virtual]

A virtual destructor. Provided so that templated collection classes can be created using MString as the template class, while still being able to own the strings.


Member Function Documentation

CT_EXPORT TResult MString::Abbreviate ( const MPointerDictionary< MString, MString > &  aDictionary)

Abbreviate a string by replacing words according to the entries in aDictionary. Replacements are made only if the abbreviation is shorter than the original word.

TResult CartoType::MString::Append ( const MString aString) [inline]

Append aString.

TResult CartoType::MString::Append ( const uint16 *  aText,
int32  aLength = -1 
) [inline]

Append aText. If aLength is -1 the text must be null-terminated, otherwise the length is aLength.

TResult CartoType::MString::Append ( const char *  aText,
int32  aLength = -1,
int32  aCodePage = 0 
) [inline]

Append the eight-bit string aText. If aLength is -1 the text must be null-terminated, otherwise the length is aLength. A code page of 0 (the default) implies UTF-8.

TResult CartoType::MString::Append ( uint16  aChar) [inline]

Append aChar.

TResult CartoType::MString::Clear ( ) [inline]

Delete all the text.

CT_EXPORT int32 MString::Compare ( MIter< int32 > &  aIter1,
MIter< int32 > &  aIter2,
bool  aFoldCase 
) [static]

A static function to compare two strings taken from iterators lexicographically using the same simple method as strcmp.

If aFoldCase is true character are converted to lower case before the comparison.

Return 0 if they are equal, some value less than zero if "this" is less than aString, or some value greater than zero if "this" is greater than aString.

The Next functions of the iterators must be guaranteed to either return no error or KErrorEndOfData.

CT_EXPORT int32 MString::Compare ( MIter< int32 > &  aIter,
bool  aFoldCase 
) const

Compare two strings lexicographically. Identical to "int32 MString::Compare(const MString& aString,bool aFoldCase)" except that the string argument is an iterator.

CT_EXPORT int32 MString::Compare ( const MString aString,
bool  aFoldCase = false 
) const

Compare two strings lexicographically, using the same simple method as strcmp.

If aFoldCase is true the letters 'A...Z' are converted to 'a...z' before the comparison. No other letters are affected by case folding.

Return 0 if they are equal, some value less than zero if "this" is less than aString, or some value greater than zero if "this" is greater than aString.

CT_EXPORT int32 MString::Compare ( const uint16 *  aText,
int32  aLength = -1,
bool  aFoldCase = false 
) const

Compare two strings lexicographically. Identical to "int32 MString::Compare(const MString& aString,bool aFoldCase)" except that the second string is represented by a 16-bit pointer and a length.

CT_EXPORT int32 MString::Compare ( const char *  aText,
int32  aLength = -1,
bool  aFoldCase = false 
) const

Compare two strings lexicographically. Identical to "int32 MString::Compare(const MString& aString,bool aFoldCase)" except that the second string is represented by an 8-bit pointer and a length.

CT_EXPORT uint16 * MString::CreateNullTerminatedUtf16String ( ) const

Create a null-terminated UTF16 copy of a string on the heap. Ownership is transferred to the caller, which must eventually delete it.

CT_EXPORT char * MString::CreateNullTerminatedUtf8String ( ) const

Create a null-terminated UTF8 copy of a string on the heap. Ownership is transferred to the caller, which must eventually delete it.

CT_EXPORT char * MString::CreateUtf8String ( int32 &  aLength) const

Create a UTF8 copy of a string on the heap, returning the length of the UTF8 string in bytes in aLength. Ownership is transferred to the caller, which must eventually delete it.

TResult CartoType::MString::Delete ( int32  aStart,
int32  aEnd 
) [inline]

Delete the text in the range aStart...aEnd.

CT_EXPORT TText MString::First ( int32  aLength) const

Return a TText object referring to the first aLength characters of a string, or the entire string, whichever is less.

TResult CartoType::MString::Insert ( int32  aIndex,
const MString aString 
) [inline]

Insert aString at aIndex.

TResult CartoType::MString::Insert ( int32  aIndex,
const uint16 *  aText,
int32  aLength = -1 
) [inline]

Insert aText at aIndex. If aLength is -1 the text must be null-terminated, otherwise the length is aLength.

TResult CartoType::MString::Insert ( int32  aIndex,
const char *  aText,
int32  aLength = -1,
int32  aCodePage = 0 
) [inline]

Insert the eight-bit string aText at aIndex. If aLength is -1 the text must be null-terminated, otherwise the length is aLength. A code page of 0 (the default) implies UTF-8.

TResult CartoType::MString::Insert ( int32  aIndex,
uint16  aChar 
) [inline]

Insert aChar at aIndex.

CT_EXPORT bool MString::IsLineBreak ( int32  aPos) const

Determine whether a position in a string is a possible line break. Positions at or before the start of the string return false. Positions after the end of the string return false. The end of the string returns true if the string is not empty.

This function does not yet implement the Unicode Standard for line breaking. It breaks lines before spaces, after hyphens, line feeds, line breaks and paragraph breaks, and between ideographic characters.

CT_EXPORT TText MString::Last ( int32  aLength) const

Return a TText object referring to the last aLength characters of a string, or the entire string, whichever is less.

int32 CartoType::MString::Length ( ) const [inline]

Return the length of the text.

CT_EXPORT int32 MString::LineBreakAfter ( int32  aPos) const

Find the first line break at or after the specified position. Return -1 if no break is found, which happens only if aPos is less than zero or after the end of the text, or the text is empty.

CT_EXPORT int32 MString::LineBreakBefore ( int32  aPos) const

Find the first line break at or before the specified position. Return -1 if no break is found.

bool CartoType::MString::operator!= ( const char *  aText) const [inline]

The inequality operator for comparing MString objects with null-terminated UTF8 strings

bool CartoType::MString::operator!= ( const MString aString) const [inline]

The inequality operator.

bool CartoType::MString::operator!= ( const uint16 *  aText) const [inline]

The inequality operator for comparing MString objects with null-terminated UTF16 strings

CT_EXPORT bool MString::operator== ( const char *  aText) const

The equality operator for comparing MString objects with null-terminated UTF8 strings

bool CartoType::MString::operator== ( const MString aString) const [inline]

The equality operator.

bool CartoType::MString::operator== ( const uint16 *  aText) const [inline]

The equality operator for comparing MString objects with null-terminated UTF16 strings

CT_EXPORT TResult MString::Replace ( int32  aStart,
int32  aEnd,
MIter< int32 > &  aText,
int32  aMaxLength 
)

Replace the text from aStart to aEnd with a maximum of aMaxLength UTF32 characters from aText, or up to the end of the data, whichever comes first.

TResult CartoType::MString::Replace ( int32  aStart,
int32  aEnd,
const MString aString 
) [inline]

Replace the text aStart...aEnd with aString.

CT_EXPORT TResult MString::Replace ( int32  aStart,
int32  aEnd,
const uint16 *  aText,
int32  aLength = -1 
)

Replace the text from aStart to aEnd with the UTF16 text starting at aText. If aLength is < 0 aText must point to null-terminated text.

CT_EXPORT TResult MString::Replace ( int32  aStart,
int32  aEnd,
const char *  aText,
int32  aLength = -1,
int32  aCodePage = 0 
)

Replace the text from aStart to aEnd with the 8-bit text starting at aText. If aLength is less than zero aText must point to null-terminated text. If aCodePage is zero the text is UTF-8, otherwise it is in the specified Windows code page.

TResult CartoType::MString::Replace ( int32  aStart,
int32  aEnd,
uint16  aChar 
) [inline]

Replace the range aStart...aEnd with the single character aChar.

TResult CartoType::MString::Set ( const MString aString) [inline]

Set the string to aString.

TResult CartoType::MString::Set ( const uint16 *  aText,
int32  aLength = -1 
) [inline]

Set the string to aText. If aLength is -1 the text must be null-terminated, otherwise the length is aLength.

TResult CartoType::MString::Set ( const char *  aText,
int32  aLength = -1 
) [inline]

Set the string to the UTF-8 string aText. If aLength is -1 the text must be null-terminated, otherwise the length is aLength.

TResult CartoType::MString::Set ( const char *  aText,
int32  aLength,
int32  aCodePage 
) [inline]

Set the string to the eight-bit string aText. If aLength is -1 the text must be null-terminated, otherwise the length is aLength. A code page of 0 implies UTF-8.

TResult CartoType::MString::Set ( uint16  aChar) [inline]

Set the entire text to aChar.

CT_EXPORT TResult MString::SetCase ( TLetterCase  aCase,
const MDictionary< MString, int32 > *  aTitleCaseDictionary = 0 
)

Set the case of all the tokens in the string in the specified way. If aCase is ETitleCase the optional word case dictionary specifies words like 'of', 'in', 'US', 'IV', etc., that require special treatment.

void CartoType::MString::SetLengthToZero ( ) [inline]

Set the length of the string to zero without discarding reserved memory if any.

CT_EXPORT TResult MString::Shape ( TBidiParDir  aParDir,
CBidiEngine aBidiEngine,
bool  aParStart,
bool  aReorderFontSelectors 
)

Perform shaping; that is, convert a string to its presentation form by performing bidirectional reordering, so that text in Arabic, Hebrew and other right-to-left languages is ordered correctly; converting directional right-to-left characters with mirror equivalents to their mirror images; and performing contextual shaping for Arabic.

If aBidiEngine is non-null, use the supplied bidirectional engine to provide the current state, and start a new paragraph if aParStart is true. If not, always start a new paragraph.

If aReorderFontSelectors is true, reorder any embedded font selector characters to preserve the original fonts.

virtual const uint16* CartoType::MString::Text ( ) const [pure virtual]
CT_EXPORT TResult MString::ToDouble ( double &  aValue,
int32 &  aLengthUsed 
) const

Convert the string to a floating point value and return the length of the text used for the conversion. Return 0 if no conversion can be done.

CT_EXPORT TResult MString::ToFixed ( TFixed aValue,
int32 &  aLengthUsed 
) const

Convert the string to a fixed point value and return the length of the text used for the conversion.

CT_EXPORT TResult MString::ToInt32 ( const uint8 *  aText,
int32  aLength,
int32 &  aValue,
int32 &  aLengthUsed,
int32  aBase = 10 
) [static]

Convert 8-bit text to an integer value and return the length of the text used for the conversion. The optional argument aBase, which has the default value 10, allows bases from 2 to 16 to be used.

CT_EXPORT TResult MString::ToInt32 ( int32 &  aValue,
int32 &  aLengthUsed,
int32  aBase = 10 
) const

Convert the string to an int32 value and return the length of the text used for the conversion. The optional argument aBase, which has the default value 10, allows bases from 2 to 16 to be used.


Member Data Documentation

int32 CartoType::MString::iLength [protected]

The length of the text in 16-bit UTF16 values.


The documentation for this class was generated from the following files: