CartoType C++ API 7.8.2, 2022-03-25
for Windows, Linux, Qt and other platforms supporting C++ development
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
CartoType::MString Class Referenceabstract

#include <cartotype_string.h>

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

Public Member Functions

virtual ~MString ()
 
template<typename T >
MStringoperator= (const T &aText)
 
template<typename T >
MStringoperator+= (const T &aText)
 
size_t Length () const
 
bool IsEmpty () const
 
virtual const uint16_t * Text () const =0
 
void Delete (size_t aStart, size_t aEnd)
 
void Clear ()
 
void SetLengthToZero ()
 
std::basic_string< uint16_t > CreateUtf16String () const
 
std::string CreateUtf8String () const
 
 operator std::string () const
 
uint16_t operator[] (size_t aIndex) const
 
TText First (size_t aLength) const
 
TText Last (size_t aLength) const
 
void DeletePrefix (const MString &aPrefix)
 
void DeleteSuffix (const MString &aSuffix)
 
void SetCase (TLetterCase aCase, const CStringTypeDictionary *aTitleCaseDictionary=0)
 
void SetSentenceCase ()
 
int32_t Compare (MIter< int32_t > &aIter, TStringMatchMethod aStringMatchMethod) const noexcept
 
TResult Replace (size_t aStart, size_t aEnd, MIter< int32_t > &aText, size_t aMaxLength)
 
int32_t Compare (const MString &aString) const
 
int32_t Compare (const MString &aString, TStringMatchMethod aStringMatchMethod) const noexcept
 
size_t Find (const MString &aString, TStringMatchMethod aStringMatchMethod=TStringMatchMethod::Exact, size_t *aEndPos=nullptr) const noexcept
 
void Replace (size_t aStart, size_t aEnd, const MString &aString)
 
void Insert (size_t aIndex, const MString &aString)
 
void Append (const MString &aString)
 
void AppendCommaSeparated (const CString &aLabel, const CString &aText, size_t &aItems, size_t aMaxItems=SIZE_MAX)
 
void Set (const MString &aString)
 
int32_t Compare (const uint16_t *aText) const
 
int32_t Compare (const uint16_t *aText, size_t aLength) const
 
int32_t Compare (const char16_t *aText, size_t aLength=npos) const
 
int32_t Compare (const uint16_t *aText, size_t aLength, TStringMatchMethod aStringMatchMethod) const noexcept
 
void Replace (size_t aStart, size_t aEnd, const uint16_t *aText, size_t aLength=npos)
 
void Insert (size_t aIndex, const uint16_t *aText, size_t aLength=npos)
 
void Append (const uint16_t *aText, size_t aLength=npos)
 
void Set (const uint16_t *aText, size_t aLength=npos)
 
int32_t Compare (const char *aText, size_t aLength=npos, TStringMatchMethod aStringMatchMethod=TStringMatchMethod::Exact) const noexcept
 
int32_t CompareExact (const char *aText, size_t aLength=npos) const noexcept
 
int32_t CompareFoldCase (const char *aText, size_t aLength=npos) const noexcept
 
void Replace (size_t aStart, size_t aEnd, const char *aText, size_t aLength=npos, int32_t aCodePage=0)
 
bool operator== (const char *aText) const noexcept
 
bool operator% (const char *aText) const noexcept
 
bool operator!= (const char *aText) const
 
void Insert (size_t aIndex, const char *aText, size_t aLength=npos, int32_t aCodePage=0)
 
void Append (const char *aText, size_t aLength=npos, int32_t aCodePage=0)
 
template<typename T >
void Append (const std::basic_string< T > aString)
 
template<typename T >
void Set (const std::basic_string< T > aString)
 
void Set (const char *aText, size_t aLength=npos)
 
void Set (const char *aText, size_t aLength, int32_t aCodePage)
 
void Replace (size_t aStart, size_t aEnd, uint16_t aChar)
 
void Insert (size_t aIndex, uint16_t aChar)
 
void Append (uint16_t aChar)
 
void Set (uint16_t aChar)
 
void Trim ()
 
bool operator== (const MString &aString) const
 
bool operator== (const uint16_t *aText) const
 
bool operator== (const char16_t *aText) const
 
bool operator!= (const MString &aString) const
 
bool operator!= (const uint16_t *aText) const
 
bool operator!= (const char16_t *aText) const
 
bool operator% (const MString &aString) const
 
bool operator% (const uint16_t *aText) const
 
bool WildMatch (const MString &aWildText) const noexcept
 
bool WildMatch (const char *aWildText) const noexcept
 
bool LayerMatch (const MString &aWildText) const
 
bool LayerMatch (const char *aWildText) const noexcept
 
template<class T >
bool operator< (const T &aOther) const
 
template<class T >
bool operator<= (const T &aOther) const
 
template<class T >
bool operator> (const T &aOther) const
 
template<class T >
bool operator>= (const T &aOther) const
 
int32_t ToInt32 (size_t *aLengthUsed=nullptr, int32_t aBase=10) const noexcept
 
int64_t ToInt64 (size_t *aLengthUsed=nullptr, int32_t aBase=10) const noexcept
 
uint32_t ToUint32 (size_t *aLengthUsed=nullptr, int32_t aBase=10) const noexcept
 
double ToDouble (size_t *aLengthUsed=nullptr) const noexcept
 
double ToDimension (size_t *aLengthUsed=nullptr) const noexcept
 
void Shape (TBidiParDir aParDir, CBidiEngine *aBidiEngine, bool aParStart, bool aReorderFontSelectors)
 
void Abbreviate (const CAbbreviationDictionary &aDictionary)
 
void Transliterate (const CStringTypeDictionary *aTitleCaseDictionary=nullptr, const char *aLocale=nullptr)
 
bool IsLineBreak (size_t aPos) const noexcept
 
size_t LineBreakBefore (size_t aPos) const noexcept
 
size_t LineBreakAfter (size_t aPos) const noexcept
 
void SetAttribute (const MString &aKey, const MString &aValue)
 
void SetAttribute (const CString &aKey, const CString &aValue)
 
TText GetAttribute (const MString &aKey) const noexcept
 
TText GetAttribute (const CString &aKey) const noexcept
 
bool NextAttribute (size_t &aPos, TText &aKey, TText &aValue) const noexcept
 

Static Public Member Functions

static int32_t Compare (MIter< int32_t > &aIter1, MIter< int32_t > &aIter2, TStringMatchMethod aStringMatchMethod) noexcept
 
static bool FuzzyMatch (MIter< int32_t > &aIter1, MIter< int32_t > &aIter2, int32_t aMaxDistance) noexcept
 
static bool FuzzyMatch (const char *aText1, const char *aText2, int32_t aMaxDistance) noexcept
 
static int32_t ToInt32 (const uint8_t *aText, size_t aLength, size_t *aLengthUsed=nullptr, int32_t aBase=10) noexcept
 

Static Public Attributes

static constexpr int KMaxFuzzyDistance = 4
 

Protected Member Functions

 MString ()
 
 MString (size_t aLength)
 

Protected Attributes

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

Constructor & Destructor Documentation

◆ ~MString()

virtual CartoType::MString::~MString ( )
inlinevirtual

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.

◆ MString() [1/2]

CartoType::MString::MString ( )
inlineprotected

Constructs the MString base class part of a string and gives it zero length.

◆ MString() [2/2]

CartoType::MString::MString ( size_t  aLength)
inlineprotected

Constructs the MString base class part of a string and gives it a specified length.

Member Function Documentation

◆ Abbreviate()

void CartoType::MString::Abbreviate ( const CAbbreviationDictionary 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.

◆ Append() [1/5]

void CartoType::MString::Append ( const char *  aText,
size_t  aLength = npos,
int32_t  aCodePage = 0 
)
inline

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

◆ Append() [2/5]

void CartoType::MString::Append ( const MString aString)
inline

Appends aString.

◆ Append() [3/5]

template<typename T >
void CartoType::MString::Append ( const std::basic_string< T >  aString)
inline

Appends a standard string.

◆ Append() [4/5]

void CartoType::MString::Append ( const uint16_t *  aText,
size_t  aLength = npos 
)
inline

Appends aText. If aLength is npos the text must be null-terminated, otherwise the length is aLength.

◆ Append() [5/5]

void CartoType::MString::Append ( uint16_t  aChar)
inline

Appends aChar.

◆ AppendCommaSeparated()

void CartoType::MString::AppendCommaSeparated ( const CString aLabel,
const CString aText,
size_t &  aItems,
size_t  aMaxItems = SIZE_MAX 
)

Append aText, prefixing it with a comma and a space if aItems is greater than zero. and prefixing it with aLabel and an equals sign if aLabel is not empty, then increment aItems. Append the text only if aItems is less than aMaxItems.

◆ Clear()

void CartoType::MString::Clear ( )
inline

Deletes all the text.

◆ Compare() [1/9]

int32_t CartoType::MString::Compare ( const char *  aText,
size_t  aLength = npos,
TStringMatchMethod  aStringMatchMethod = TStringMatchMethod::Exact 
) const
noexcept

Compares two strings lexicographically.

◆ Compare() [2/9]

int32_t CartoType::MString::Compare ( const char16_t *  aText,
size_t  aLength = npos 
) const
inline

Compares UTF16 text with a specified length with this string lexicographically. If aLength is npos (the default) the text is assumed to be null-terminated.

Returns 0 if the strings are equal, otherwise:

returns -2 if this string is less than aText and not a prefix of aText; returns -1 if this string is a prefix of aText; returns 1 if aText is a prefix of this string; returns 2 if aText is less than this string and not a prefix of it.

◆ Compare() [3/9]

int32_t CartoType::MString::Compare ( const MString aString) const
inline

Compares two strings lexicographically.

Returns 0 if the strings are equal, otherwise:

returns -2 if this string is less than aString and not a prefix of aString; returns -1 if this string is a prefix of aString; returns 1 if aString is a prefix of this string; returns 2 if aString is less than this string and not a prefix of it.

◆ Compare() [4/9]

int32_t CartoType::MString::Compare ( const MString aString,
TStringMatchMethod  aStringMatchMethod 
) const
noexcept

Compares two strings lexicographically using a specified string match method.

Returns 0 if the strings are equal, or TStringMatchMethodFlag::Prefix is set and aString is a prefix of this string; otherwise:

returns -2 if this string is less than aString and not a prefix of aString; returns -1 if this string is a prefix of aString; returns 1 if aString is a prefix of this string; returns 2 if aString is less than this string and not a prefix of it.

◆ Compare() [5/9]

int32_t CartoType::MString::Compare ( const uint16_t *  aText) const
inline

Compares null-terminated UTF16 text with this string lexicographically.

Returns 0 if the strings are equal, otherwise:

returns -2 if this string is less than aText and not a prefix of aText; returns -1 if this string is a prefix of aText; returns 1 if aText is a prefix of this string; returns 2 if aText is less than this string and not a prefix of it.

◆ Compare() [6/9]

int32_t CartoType::MString::Compare ( const uint16_t *  aText,
size_t  aLength 
) const
inline

Compares UTF16 text with a specified length with this string lexicographically. If aLength is npos the text is assumed to be null-terminated.

Returns 0 if the strings are equal, otherwise:

returns -2 if this string is less than aText and not a prefix of aText; returns -1 if this string is a prefix of aText; returns 1 if aText is a prefix of this string; returns 2 if aText is less than this string and not a prefix of it.

◆ Compare() [7/9]

int32_t CartoType::MString::Compare ( const uint16_t *  aText,
size_t  aLength,
TStringMatchMethod  aStringMatchMethod 
) const
noexcept

Compares two strings lexicographically.

◆ Compare() [8/9]

int32_t CartoType::MString::Compare ( MIter< int32_t > &  aIter,
TStringMatchMethod  aStringMatchMethod 
) const
noexcept

Compares two strings lexicographically.

◆ Compare() [9/9]

int32_t CartoType::MString::Compare ( MIter< int32_t > &  aIter1,
MIter< int32_t > &  aIter2,
TStringMatchMethod  aStringMatchMethod 
)
staticnoexcept

A static function to compare two strings taken from iterators lexicographically using a specified string matching method.

If the method includes the flag TStringMatchMethodFlag::Prefix, excess characters in aIter1 are ignored after all the characters of aIter2 have been used: the test is whether aIter2 is a prefix of, or equal to, aIter1.

Return 0 if the strings are equal, or TStringMatchMethodFlag::Prefix is set and aIter2 is a prefix of aIter1; otherwise:

-2 if aIter1 is less than aIter2 and not a prefix of aIter2, -1 if aIter1 is a prefix of aIter2, 1 if aIter2 is a prefix of aIter1, 2 if aIter2 is less than aIter1 and not a prefix of it

but if fuzzy matching is used, the values 0 (equal) and 1 (unequal) only are returned.

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

◆ CompareExact()

int32_t CartoType::MString::CompareExact ( const char *  aText,
size_t  aLength = npos 
) const
noexcept

Compares two strings lexicographically, ignoring differences in letter case.

◆ CompareFoldCase()

int32_t CartoType::MString::CompareFoldCase ( const char *  aText,
size_t  aLength = npos 
) const
noexcept

Compares two strings lexicographically, ignoring differences in letter case.

◆ CreateUtf16String()

std::basic_string< uint16_t > CartoType::MString::CreateUtf16String ( ) const

Create a UTF-16 copy of a string.

◆ CreateUtf8String()

std::string CartoType::MString::CreateUtf8String ( ) const

Create a UTF8 copy of a string.

◆ Delete()

void CartoType::MString::Delete ( size_t  aStart,
size_t  aEnd 
)
inline

Deletes the text in the range aStart...aEnd.

◆ DeletePrefix()

void CartoType::MString::DeletePrefix ( const MString aPrefix)

Deletes aPrefix if it occurs at the start of the string.

◆ DeleteSuffix()

void CartoType::MString::DeleteSuffix ( const MString aSuffix)

Deletes aSuffix if it occurs at the end of the string.

◆ Find()

size_t CartoType::MString::Find ( const MString aString,
TStringMatchMethod  aStringMatchMethod = TStringMatchMethod::Exact,
size_t *  aEndPos = nullptr 
) const
noexcept

Find the first instance of aString in this string and return its start position. Return npos if not found.

If aEndPos is non-null it is used to return the end position of the found string in this string.

Strings are compared using the specified string match method, ignoring TStringMatchMethodFlag::Prefix, which is not relevant.

The returned start and end positions are maximal if non-alphanumeric characters are ignored. For example, if the search is for "x" in " (x) " the positions returned are 0 and 5. Therefore if the start and end positions are 0 and the length of this string, the target matches the whole string.

◆ First()

TText CartoType::MString::First ( size_t  aLength) const

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

◆ FuzzyMatch() [1/2]

bool CartoType::MString::FuzzyMatch ( const char *  aText1,
const char *  aText2,
int32_t  aMaxDistance 
)
staticnoexcept

Performs a fuzzy match on the two UTF-8 strings. Returns true if the strings are equal within an edit distance of less than aMaxDistance, which cannot be greater than MString::KMaxFuzzyDistance.

◆ FuzzyMatch() [2/2]

bool CartoType::MString::FuzzyMatch ( MIter< int32_t > &  aIter1,
MIter< int32_t > &  aIter2,
int32_t  aMaxDistance 
)
staticnoexcept

Performs a fuzzy match on the strings provided by the two iterators. Returns true if the strings are equal within an edit distance of less than aMaxDistance, which cannot be greater than MString::KMaxFuzzyDistance.

◆ GetAttribute() [1/2]

TText CartoType::MString::GetAttribute ( const CString aKey) const
noexcept

An overload of GetAttribute that takes CString, and hence can take const char* and std::string.

◆ GetAttribute() [2/2]

TText CartoType::MString::GetAttribute ( const MString aKey) const
noexcept

Treating a string as a set of map object attributes of the form label|key1=value1|key2=value2| ... |keyN=valueN, where | is character code 0, get a named attribute. An empty name refers to the label. If the return value is empty the attribute does not exist in the string.

◆ Insert() [1/4]

void CartoType::MString::Insert ( size_t  aIndex,
const char *  aText,
size_t  aLength = npos,
int32_t  aCodePage = 0 
)
inline

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

◆ Insert() [2/4]

void CartoType::MString::Insert ( size_t  aIndex,
const MString aString 
)
inline

Inserts aString at aIndex.

◆ Insert() [3/4]

void CartoType::MString::Insert ( size_t  aIndex,
const uint16_t *  aText,
size_t  aLength = npos 
)
inline

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

◆ Insert() [4/4]

void CartoType::MString::Insert ( size_t  aIndex,
uint16_t  aChar 
)
inline

Inserts aChar at aIndex.

◆ IsEmpty()

bool CartoType::MString::IsEmpty ( ) const
inline

Returns true if the text is empty.

◆ IsLineBreak()

bool CartoType::MString::IsLineBreak ( size_t  aPos) const
noexcept

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.

◆ Last()

TText CartoType::MString::Last ( size_t  aLength) const

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

◆ LayerMatch() [1/2]

bool CartoType::MString::LayerMatch ( const char *  aWildText) const
noexcept

A special wild-card matching function for map layers with a structure like that of file paths separated by '/' characters. A final '/' matches both the string without '/', and the string with '*' appended. So the pattern 'road/' matches 'road' and 'road/major' but not 'road2' or 'road/'.

◆ LayerMatch() [2/2]

bool CartoType::MString::LayerMatch ( const MString aWildText) const

A special wild-card matching function for map layers with a structure like that of file paths separated by '/' characters. A final '/' matches both the string without '/', and the string with '*' appended. So the pattern 'road/' matches 'road' and 'road/major' but not 'road2' or 'road/'.

◆ Length()

size_t CartoType::MString::Length ( ) const
inline

Returns the length of the text.

◆ LineBreakAfter()

size_t CartoType::MString::LineBreakAfter ( size_t  aPos) const
noexcept

Find the first line break at or after the specified position. Return npos if no break is found, which happens only if aPos is after the end of the text.

◆ LineBreakBefore()

size_t CartoType::MString::LineBreakBefore ( size_t  aPos) const
noexcept

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

◆ NextAttribute()

bool CartoType::MString::NextAttribute ( size_t &  aPos,
TText aKey,
TText aValue 
) const
noexcept

Treating a string as a set of map object attributes of the form label|key1=value1|key2=value2| ... |keyN=valueN, where | is character code 0, get the next key-value pair, updating aPos.

To use this function call it with aPos=0, then keep calling it till it returns false, meaning that no key-value pair has been found.

The first key-value pair returned always has an empty key, the value being the label.

◆ operator std::string()

CartoType::MString::operator std::string ( ) const
inline

A conversion operator to convert a string to a UTF-8 string.

◆ operator!=() [1/4]

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

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

◆ operator!=() [2/4]

bool CartoType::MString::operator!= ( const char16_t *  aText) const
inline

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

◆ operator!=() [3/4]

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

The inequality operator.

◆ operator!=() [4/4]

bool CartoType::MString::operator!= ( const uint16_t *  aText) const
inline

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

◆ operator%() [1/3]

bool CartoType::MString::operator% ( const char *  aText) const
noexcept

The equality operator, ignoring case, for comparing MString objects with null-terminated UTF8 strings. The % operator was chosen so that its precedence was not lower than ==, so that

"if (condition || string1 % string2)"

has the same order of evaluation as

"if (condition || string1 == string2)."

Use with care nevertheless.

◆ operator%() [2/3]

bool CartoType::MString::operator% ( const MString aString) const
inline

The equality operator, ignoring case.

◆ operator%() [3/3]

bool CartoType::MString::operator% ( const uint16_t *  aText) const
inline

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

◆ operator+=()

template<typename T >
MString & CartoType::MString::operator+= ( const T &  aText)
inline

Appends aText to this string.

◆ operator<()

template<class T >
bool CartoType::MString::operator< ( const T &  aOther) const
inline

The less-than operator.

◆ operator<=()

template<class T >
bool CartoType::MString::operator<= ( const T &  aOther) const
inline

The less-than-or-equals operator.

◆ operator=()

template<typename T >
MString & CartoType::MString::operator= ( const T &  aText)
inline

The assignment operator.

◆ operator==() [1/4]

bool CartoType::MString::operator== ( const char *  aText) const
noexcept

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

◆ operator==() [2/4]

bool CartoType::MString::operator== ( const char16_t *  aText) const
inline

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

◆ operator==() [3/4]

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

The equality operator.

◆ operator==() [4/4]

bool CartoType::MString::operator== ( const uint16_t *  aText) const
inline

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

◆ operator>()

template<class T >
bool CartoType::MString::operator> ( const T &  aOther) const
inline

The greater-than operator.

◆ operator>=()

template<class T >
bool CartoType::MString::operator>= ( const T &  aOther) const
inline

The greater-than-or-equals operator.

◆ operator[]()

uint16_t CartoType::MString::operator[] ( size_t  aIndex) const
inline

Gets the character at the position aIndex.

◆ Replace() [1/5]

void CartoType::MString::Replace ( size_t  aStart,
size_t  aEnd,
const char *  aText,
size_t  aLength = npos,
int32_t  aCodePage = 0 
)

Replace the text from aStart to aEnd with the 8-bit text starting at aText. If aLength is npos 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.

◆ Replace() [2/5]

void CartoType::MString::Replace ( size_t  aStart,
size_t  aEnd,
const MString aString 
)
inline

Replaces the text aStart...aEnd with aString.

◆ Replace() [3/5]

void CartoType::MString::Replace ( size_t  aStart,
size_t  aEnd,
const uint16_t *  aText,
size_t  aLength = npos 
)

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

◆ Replace() [4/5]

TResult CartoType::MString::Replace ( size_t  aStart,
size_t  aEnd,
MIter< int32_t > &  aText,
size_t  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.

◆ Replace() [5/5]

void CartoType::MString::Replace ( size_t  aStart,
size_t  aEnd,
uint16_t  aChar 
)
inline

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

◆ Set() [1/6]

void CartoType::MString::Set ( const char *  aText,
size_t  aLength,
int32_t  aCodePage 
)
inline

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

◆ Set() [2/6]

void CartoType::MString::Set ( const char *  aText,
size_t  aLength = npos 
)

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

◆ Set() [3/6]

void CartoType::MString::Set ( const MString aString)
inline

Sets the string to aString.

◆ Set() [4/6]

template<typename T >
void CartoType::MString::Set ( const std::basic_string< T >  aString)
inline

Sets the text to a standard string.

◆ Set() [5/6]

void CartoType::MString::Set ( const uint16_t *  aText,
size_t  aLength = npos 
)
inline

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

◆ Set() [6/6]

void CartoType::MString::Set ( uint16_t  aChar)
inline

Sets the entire text to aChar.

◆ SetAttribute() [1/2]

void CartoType::MString::SetAttribute ( const CString aKey,
const CString aValue 
)

An overload of SetAttribute that takes CString arguments, and hence can take const char* and std::string.

◆ SetAttribute() [2/2]

void CartoType::MString::SetAttribute ( const MString aKey,
const MString aValue 
)

Treating a string as a set of map object attributes of the form label|key1=value1|key2=value2| ... |keyN=valueN, where | is character code 0, set a named attribute. An empty or zero-length key sets the label. An empty value deletes a key-value pair.

◆ SetCase()

void CartoType::MString::SetCase ( TLetterCase  aCase,
const CStringTypeDictionary aTitleCaseDictionary = 0 
)

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

◆ SetLengthToZero()

void CartoType::MString::SetLengthToZero ( )
inline

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

◆ SetSentenceCase()

void CartoType::MString::SetSentenceCase ( )

Convert the string into sentence case: that is, set the first letter to title case unless it is already a capital or title case, or has no case.

◆ Shape()

void CartoType::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.

◆ Text()

virtual const uint16_t * CartoType::MString::Text ( ) const
pure virtual

Returns a constant pointer to Unicode text stored in UTF16 format.

Implemented in CartoType::TWritableText, CartoType::TTextBuffer< aMaxLength >, CartoType::TText, and CartoType::CString.

◆ ToDimension()

double CartoType::MString::ToDimension ( size_t *  aLengthUsed = nullptr) const
noexcept

Converts the string to a floating point dimension; meters are assumed, but ' and " can be used for feet and inches, or ft, in, km, mi, nmi (nautical miles). For OSM dimension attributes.

◆ ToDouble()

double CartoType::MString::ToDouble ( size_t *  aLengthUsed = nullptr) const
noexcept

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

◆ ToInt32() [1/2]

int32_t CartoType::MString::ToInt32 ( const uint8_t *  aText,
size_t  aLength,
size_t *  aLengthUsed = nullptr,
int32_t  aBase = 10 
)
staticnoexcept

Converts 8-bit text to an integer value and returns 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.

◆ ToInt32() [2/2]

int32_t CartoType::MString::ToInt32 ( size_t *  aLengthUsed = nullptr,
int32_t  aBase = 10 
) const
noexcept

Convert the string to a 32-bit integer value and optionally 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.

◆ ToInt64()

int64_t CartoType::MString::ToInt64 ( size_t *  aLengthUsed = nullptr,
int32_t  aBase = 10 
) const
noexcept

Convert the string to a 64-bit integer and optionally 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.

◆ ToUint32()

uint32_t CartoType::MString::ToUint32 ( size_t *  aLengthUsed = nullptr,
int32_t  aBase = 10 
) const
noexcept

Convert the string to an unsigned 32-bit integer and optionally 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.

◆ Transliterate()

void CartoType::MString::Transliterate ( const CStringTypeDictionary aTitleCaseDictionary = nullptr,
const char *  aLocale = nullptr 
)

Transliterate a string from a non-Latin script to the Latin script. Transliteration is performed only if all letters in non-Latin scripts are transliteratable.

If transliteration is impossible or unsupported the error KErrorUntransliterable is returned.

◆ Trim()

void CartoType::MString::Trim ( )

Strips ASCII whitespace from the start and end of the string, but preserves any private-use characters used as font selectors, etc., even if they are outside leading or trailing whitespace.

◆ WildMatch() [1/2]

bool CartoType::MString::WildMatch ( const char *  aWildText) const
noexcept

Return true if this string matches aWildText, which may contain the wild-card characters '?', meaning any character, and '*', meaning any sequence of zero or more characters.

◆ WildMatch() [2/2]

bool CartoType::MString::WildMatch ( const MString aWildText) const
noexcept

Return true if this string matches aWildText, which may contain the wild-card characters '?', meaning any character, and '*', meaning any sequence of zero or more characters.

Member Data Documentation

◆ iLength

size_t CartoType::MString::iLength
protected

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

◆ KMaxFuzzyDistance

constexpr int CartoType::MString::KMaxFuzzyDistance = 4
staticconstexpr

Maximum edit distance allowed by fuzzy matching: the maximum value for aMaxDistance in MString::FuzzyMatch().


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