CartoType C++ API 8.8-7-gb35e4dc71
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
CartoTypeCore::MString Class Referenceabstract

#include <cartotype_string.h>

Inheritance diagram for CartoTypeCore::MString:
CartoTypeCore::String CartoTypeCore::Text CartoTypeCore::TextBuffer< aMaxLength > CartoTypeCore::WritableTextView

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 * Data () 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
 
Text First (size_t aLength) const
 
Text Last (size_t aLength) const
 
Text Substring (size_t aStart, size_t aLength) const
 
String Token (size_t aIndex, const MString *aSeparators=nullptr, const MString *aSingleCharacterTokens=nullptr) const
 
void DeletePrefix (const MString &aPrefix)
 
void DeleteSuffix (const MString &aSuffix)
 
void SetCase (LetterCase aCase, const StringTypeDictionary *aTitleCaseDictionary=0)
 
void SetSentenceCase ()
 
int32_t Compare (MIter< int32_t > &aIter, StringMatchMethod aStringMatchMethod) const noexcept
 
Result 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, StringMatchMethod aStringMatchMethod) const noexcept
 
size_t Find (const MString &aString, StringMatchMethod aStringMatchMethod=StringMatchMethod::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 String &aLabel, const String &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, StringMatchMethod aStringMatchMethod) const noexcept
 
void Replace (size_t aStart, size_t aEnd, const uint16_t *aText, size_t aLength=npos)
 
void Replace (size_t aStart, size_t aEnd, const char16_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, StringMatchMethod aStringMatchMethod=StringMatchMethod::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
 
StringMatchType MatchType (const MString &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 (BidiParDir aParDir, BidiEngine *aBidiEngine, bool aParStart, bool aReorderFontSelectors)
 
void Abbreviate (const AbbreviationDictionary &aDictionary, bool aDeleteWords=false)
 
Result Transliterate (const StringTypeDictionary *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 String &aKey, const String &aValue)
 
Text Attribute (const MString &aKey) const noexcept
 
Text Attribute (const String &aKey) const noexcept
 
bool NextAttribute (size_t &aPos, Text &aKey, Text &aValue) const noexcept
 

Static Public Member Functions

static int32_t Compare (MIter< int32_t > &aIter1, MIter< int32_t > &aIter2, StringMatchMethod aStringMatchMethod) noexcept
 
static int32_t FuzzyCompare (MIter< int32_t > &aIter1, MIter< int32_t > &aIter2, int32_t aMaxDistance) 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 CartoTypeCore::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]

CartoTypeCore::MString::MString ( )
inlineprotected

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

◆ MString() [2/2]

CartoTypeCore::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 CartoTypeCore::MString::Abbreviate ( const AbbreviationDictionary aDictionary,
bool  aDeleteWords = false 
)

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 and not empty.

If aDeleteWords is true any words with abbreviations, including empty abbreviations, are removed entirely.

Leading and trailing whitespace is removed.

◆ Append() [1/5]

void CartoTypeCore::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 CartoTypeCore::MString::Append ( const MString aString)
inline

Appends aString.

◆ Append() [3/5]

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

Appends a standard string.

◆ Append() [4/5]

void CartoTypeCore::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 CartoTypeCore::MString::Append ( uint16_t  aChar)
inline

Appends aChar.

◆ AppendCommaSeparated()

void CartoTypeCore::MString::AppendCommaSeparated ( const String aLabel,
const String 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.

◆ Attribute() [1/2]

Text CartoTypeCore::MString::Attribute ( 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.

◆ Attribute() [2/2]

Text CartoTypeCore::MString::Attribute ( const String aKey) const
noexcept

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

◆ Clear()

void CartoTypeCore::MString::Clear ( )
inline

Deletes all the text.

◆ Compare() [1/9]

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

Compares two strings lexicographically.

◆ Compare() [2/9]

int32_t CartoTypeCore::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 CartoTypeCore::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 CartoTypeCore::MString::Compare ( const MString aString,
StringMatchMethod  aStringMatchMethod 
) const
noexcept

Compares two strings lexicographically using a specified string match method.

Returns 0 if the strings are equal, or StringMatchMethodFlag::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 CartoTypeCore::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 CartoTypeCore::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 CartoTypeCore::MString::Compare ( const uint16_t *  aText,
size_t  aLength,
StringMatchMethod  aStringMatchMethod 
) const
noexcept

Compares two strings lexicographically.

◆ Compare() [8/9]

int32_t CartoTypeCore::MString::Compare ( MIter< int32_t > &  aIter,
StringMatchMethod  aStringMatchMethod 
) const
noexcept

Compares two strings lexicographically.

◆ Compare() [9/9]

int32_t CartoTypeCore::MString::Compare ( MIter< int32_t > &  aIter1,
MIter< int32_t > &  aIter2,
StringMatchMethod  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 StringMatchMethodFlag::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 StringMatchMethodFlag::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

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

◆ CompareExact()

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

Compares two strings lexicographically.

◆ CompareFoldCase()

int32_t CartoTypeCore::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 > CartoTypeCore::MString::CreateUtf16String ( ) const

Create a UTF-16 copy of a string.

◆ CreateUtf8String()

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

Create a UTF8 copy of a string.

◆ Data()

virtual const uint16_t * CartoTypeCore::MString::Data ( ) const
pure virtual

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

Implemented in CartoTypeCore::WritableTextView, CartoTypeCore::TextBuffer< aMaxLength >, CartoTypeCore::Text, and CartoTypeCore::String.

◆ Delete()

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

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

◆ DeletePrefix()

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

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

◆ DeleteSuffix()

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

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

◆ Find()

size_t CartoTypeCore::MString::Find ( const MString aString,
StringMatchMethod  aStringMatchMethod = StringMatchMethod::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 StringMatchMethodFlag::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()

Text CartoTypeCore::MString::First ( size_t  aLength) const

Returns a Text object referring to the first aLength characters of a string, trimmed to the actual string.

◆ FuzzyCompare()

int32_t CartoTypeCore::MString::FuzzyCompare ( MIter< int32_t > &  aIter1,
MIter< int32_t > &  aIter2,
int32_t  aMaxDistance 
)
staticnoexcept

Compares two strings using fuzzy matching.

Returns 0 if the strings are equal, or StringMatchMethodFlag::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.

◆ FuzzyMatch() [1/2]

bool CartoTypeCore::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 CartoTypeCore::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.

◆ Insert() [1/4]

void CartoTypeCore::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 CartoTypeCore::MString::Insert ( size_t  aIndex,
const MString aString 
)
inline

Inserts aString at aIndex.

◆ Insert() [3/4]

void CartoTypeCore::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 CartoTypeCore::MString::Insert ( size_t  aIndex,
uint16_t  aChar 
)
inline

Inserts aChar at aIndex.

◆ IsEmpty()

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

Returns true if the text is empty.

◆ IsLineBreak()

bool CartoTypeCore::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()

Text CartoTypeCore::MString::Last ( size_t  aLength) const

Returns a Text object referring to the last aLength characters of a string, trimmed to the actual string.

◆ LayerMatch() [1/2]

bool CartoTypeCore::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. The wild text 'road/' matches 'road' and 'road/major' but not 'road2'.

◆ LayerMatch() [2/2]

bool CartoTypeCore::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. The wild text 'road/' matches 'road' and 'road/major' but not 'road2'.

◆ Length()

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

Returns the length of the text.

◆ LineBreakAfter()

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

◆ MatchType()

StringMatchType CartoTypeCore::MString::MatchType ( const MString aText) const

Finds a match for aText in this string and returns the match type. Substring matches indicate that aText is a substring of this string, not the other way round.

◆ NextAttribute()

bool CartoTypeCore::MString::NextAttribute ( size_t &  aPos,
Text aKey,
Text 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()

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

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

◆ operator!=() [1/4]

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

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

◆ operator!=() [2/4]

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

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

◆ operator!=() [3/4]

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

The inequality operator.

◆ operator!=() [4/4]

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

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

◆ operator%() [1/3]

bool CartoTypeCore::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 CartoTypeCore::MString::operator% ( const MString aString) const
inline

The equality operator, ignoring case.

◆ operator%() [3/3]

bool CartoTypeCore::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 & CartoTypeCore::MString::operator+= ( const T &  aText)
inline

Appends aText to this string.

◆ operator<()

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

The less-than operator.

◆ operator<=()

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

The less-than-or-equals operator.

◆ operator=()

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

The assignment operator.

◆ operator==() [1/4]

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

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

◆ operator==() [2/4]

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

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

◆ operator==() [3/4]

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

The equality operator.

◆ operator==() [4/4]

bool CartoTypeCore::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 CartoTypeCore::MString::operator> ( const T &  aOther) const
inline

The greater-than operator.

◆ operator>=()

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

The greater-than-or-equals operator.

◆ operator[]()

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

Gets the character at the position aIndex.

◆ Replace() [1/6]

void CartoTypeCore::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/6]

void CartoTypeCore::MString::Replace ( size_t  aStart,
size_t  aEnd,
const char16_t *  aText,
size_t  aLength = npos 
)
inline

Replaces 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() [3/6]

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

Replaces the text aStart...aEnd with aString.

◆ Replace() [4/6]

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

Replaces 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() [5/6]

Result CartoTypeCore::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() [6/6]

void CartoTypeCore::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 CartoTypeCore::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 CartoTypeCore::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 CartoTypeCore::MString::Set ( const MString aString)
inline

Sets the string to aString.

◆ Set() [4/6]

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

Sets the text to a standard string.

◆ Set() [5/6]

void CartoTypeCore::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 CartoTypeCore::MString::Set ( uint16_t  aChar)
inline

Sets the entire text to aChar.

◆ SetAttribute() [1/2]

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

◆ SetAttribute() [2/2]

void CartoTypeCore::MString::SetAttribute ( const String aKey,
const String aValue 
)

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

◆ SetCase()

void CartoTypeCore::MString::SetCase ( LetterCase  aCase,
const StringTypeDictionary aTitleCaseDictionary = 0 
)

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

◆ SetLengthToZero()

void CartoTypeCore::MString::SetLengthToZero ( )
inline

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

◆ SetSentenceCase()

void CartoTypeCore::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 CartoTypeCore::MString::Shape ( BidiParDir  aParDir,
BidiEngine 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.

◆ Substring()

Text CartoTypeCore::MString::Substring ( size_t  aStart,
size_t  aLength 
) const

Returns a Text object referring to substring starting at aStart, of aLength characters, trimmed to the actual string.

◆ ToDimension()

double CartoTypeCore::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 CartoTypeCore::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 CartoTypeCore::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 CartoTypeCore::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 CartoTypeCore::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.

◆ Token()

String CartoTypeCore::MString::Token ( size_t  aIndex,
const MString aSeparators = nullptr,
const MString aSingleCharacterTokens = nullptr 
) const

Returns a token identified by its index, or the empty string if the index is out of range. The token is trimmed of any whitespace. If aSeparators is empty the comma is used as a separator. Strings quoted using single or double quotes are handled.

◆ ToUint32()

uint32_t CartoTypeCore::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()

Result CartoTypeCore::MString::Transliterate ( const StringTypeDictionary 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.

◆ Trim()

void CartoTypeCore::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 CartoTypeCore::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 CartoTypeCore::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 CartoTypeCore::MString::iLength
protected

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

◆ KMaxFuzzyDistance

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

Maximum edit distance allowed by fuzzy matching: the maximum value for aMaxDistance in the fuzzy matching functions.


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