Maps SDK for C++ 1.0.0
Loading...
Searching...
No Matches
gem::String Class Reference

String object. More...

Inheritance diagram for gem::String:
Collaboration diagram for gem::String:

Public Member Functions

 String ()
 Create an empty string object.
 String (const char *str, int len=-1)
 Create and initialize a string object from an utf8 char string.
 String (const char16_t *str, int len=-1)
 Create and initialize a string object from a char16_t string.
 String (const char32_t *str, int len=-1)
 Create and initialize a string object from a char32_t string.
 String (const std::string &str)
 Create and initialize a string object from a std::string.
 String (const std::u16string &str)
 Create and initialize a string object from a std::u16string.
 String (const std::u32string &str)
 Create and initialize a string object from a std::u32string.
 String (const StdString &str)
 Create and initialize a string object from a StdString.
 String (const String &string)=default
 Default copy constructor.
 String (String &&string)=default
 Default move constructor noexcept is deduced.
Stringoperator= (const String &string)=default
 Default copy assignment.
Stringoperator= (String &&string)=default
 Default move assignment noexcept is deduced.
Stringoperator= (const char *str)
 Assign to String from char*.
Stringoperator= (const char16_t *str)
 Assign to String from char16_t*.
Stringoperator= (const char32_t *str)
 Assign to String from char32_t*.
Stringoperator= (const std::string &str)
 Assign to String from std::string.
Stringoperator= (const std::u16string &str)
 Assign to String from std::u16string.
Stringoperator= (const std::u32string &str)
 Assign to String from std::u32string.
bool operator== (const String &str) const
 Equal operator.
bool operator!= (const String &str) const
 Not Equal operator.
bool operator< (const String &str) const
 Less Than operator.
bool operator<= (const String &str) const
 Less Than or Equal operator.
bool operator> (const String &str) const
 Greater Than operator.
bool operator>= (const String &str) const
 Greater Than or Equal operator.
char16_t operator[] (int pos) const
 Character access at the given index.
char16_t front () const
 First character access.
char16_t & front ()
 First character access.
char16_t back () const
 Last character access.
char16_t & back ()
 Last character access.
Stringoperator+= (const String &s)
 Append String operator.
Stringoperator+= (const char16_t *s)
 Append char16_t string operator.
Stringoperator+= (char16_t c)
 Append char16_t char operator.
Stringappend (const char *str, int len=-1)
 Append from a char string.
Stringappend (const char16_t *str, int len=-1)
 Append from a char16_t string.
Stringappend (const String &str)
 Append from a String.
Stringappend (char16_t ch)
 Append from a char16_t char.
Stringassign (const char *str, int len=-1)
 Assign from a char string.
Stringassign (const char16_t *str, int len=-1)
 Assign from a char16_t string.
Stringassign (const char32_t *str, int len=-1)
 Assign from a char32_t string.
Stringassign (const std::string &str)
 Assign from a std::string.
Stringassign (const std::u16string &str)
 Assign from a std::u16string.
Stringassign (const std::u32string &str)
 Assign from a std::u32string.
Stringclear ()
 Clear the string(sets string to empty).
int compareCaseInsensitive (String const &str) const
 Case-insensitive comparison between current string and string provided as parameter.
int compareCaseSensitive (String const &str) const
 Case-sensitive comparison between current string and string provided as parameter.
bool contains (const char16_t *str, int from=0) const
 Check if string contains specified char16_t sub-string.
bool contains (const String &str, int from=0) const
 Check if string contains specified String sub-string.
bool contains (char16_t ch, int from=0) const
 Check if string contains specified char16_t character.
template<typename TChar16Convertible = char16_t>
TChar16Convertible * data ()
 Data buffer access as char16_t pointer.
template<typename TChar16Convertible = char16_t>
const TChar16Convertible * constData () const
 Data buffer access as read-only char16_t pointer.
bool empty () const
 Check if string is empty.
int find (const char16_t *str, int from=0) const
 Find a char16_t sub-string.
int find (const String &str, int from=0) const
 Find a String sub-string.
int find (const char16_t ch, int from=0) const
 Find a char16_t character.
int findLast (const char16_t *str, int from=-1) const
 Find last occurrence of a substring.
int findLast (const String &str, int from=-1) const
 Find last occurrence of a substring.
int findLast (const char16_t ch, int from=-1) const
 Find last occurrence of a character.
int findSeparators (const char16_t *sep, int from=0) const
 Find first occurrence of any of separators in specified collection.
int findSeparators (const String &sep, int from=0) const
 Find first occurrence of any of separators in specified collection.
Stringinsert (int from, const String &str)
 Insert the given string at the given position.
Stringinsert (int from, char16_t ch)
 Insert the given character at the given position.
Stringinsert (int from, const char16_t *ch)
 Insert the given character array at the given position.
template<typename ... TArgs>
Stringformat (const char *format, TArgs &&... args)
 Format string in sprintf style.
template<typename ... TArgs>
Stringformat (const char16_t *format, TArgs &&... args)
 Format string in sprintf style.
template<typename ... TArgs>
Stringformat (const String &format, TArgs &&... args)
 Format string in sprintf style.
String left (int len) const
 Substring containing the n leftmost characters of the string.
String right (int len) const
 Substring containing the n rightmost characters of the string.
String mid (int start, int len=-1) const
 Substring containing the characters starting from position and given length.
Stringprepend (const char *str, int len=-1)
 Prepend from a char string.
Stringprepend (const char16_t *str, int len=-1)
 Prepend from a char16_t string.
Stringprepend (const String &str)
 Prepend from a String.
Stringremove (int from, int len)
 Remove characters from string.
Stringreplace (int from, int len, const char16_t *str)
 Replace part of string with given sub-string.
Stringreplace (int from, int len, const String &str)
 Replace part of string with given sub-string.
Stringreplace (const String &before, const String &after)
 Replace every occurrence of the string before with the string after.
StringreplaceInSet (const char16_t *cset, char16_t c)
 Replace all characters in set with new one.
void set (int pos, char16_t c)
 Set the character at the given position.
int size () const
 Get string length.
Stringresize (int len, char16_t c=0)
 Set string length.
template<typename Collector>
void split (const char16_t *seps, Collector collector, bool collectEmpty=false) const
 Split the string based on the given separators collection.
template<typename Collector>
void split (const String &seps, Collector collector, bool collectEmpty=false) const
 Split string at positions where any one of specified separators is found.
String toUpper (int from=0, int len=-1) const
 Convert to uppercase string.
String toLower (int from=0, int len=-1) const
 Convert to lowercase string.
int toInt (int from=0, int len=-1) const
 Convert to integer.
LargeInteger toLargeInt (int from=0, int len=-1) const
 Convert to LargeInteger.
double toFloat (int from=0, int len=-1) const
 Convert to float.
std::string toStdString (int from=0, int len=-1) const
 Convert to std::string.
std::u16string toStdString16 (int from=0, int len=-1) const
 Convert to std::u16string.
std::u32string toStdString32 (int from=0, int len=-1) const
 Convert to std::u32string.
Stringtrim ()
 Trim white spaces from string.
String trimmed () const
 Get a trimmed string from this.
void truncate (int len)
 Truncate the string to the given length.
bool isRightToLeft () const
 Check if string contains right-to-left substring sequences.
unsigned hashCode () const
 String hash code.
StringfallbackToLegacyUnicode ()
 Replace some later unicode version characters with older legacy ones.

Static Public Member Functions

template<typename ... TArgs>
static String formatString (const char16_t *format, TArgs &&... args)
 Format string in sprintf style.
template<typename ... TArgs>
static String formatString (const String &format, TArgs &&... args)
 Format string in sprintf style.

Detailed Description

String object.

Implements share-read / copy-on-write Api object over IString.

Constructor & Destructor Documentation

◆ String() [1/9]

gem::String::String ( const char * str,
int len = -1 )
inline

Create and initialize a string object from an utf8 char string.

Parameters
[in]str8-bit char initialization string, must NOT be nullptr.
[in]lenCharacters count copied from initialization string. Default -1 means whole string will be copied.

◆ String() [2/9]

gem::String::String ( const char16_t * str,
int len = -1 )
inline

Create and initialize a string object from a char16_t string.

Parameters
[in]strchar16_t initialization string, must NOT be nullptr.
[in]lenCharacters count copied from initialization string. Default -1 means whole string will be copied.

◆ String() [3/9]

gem::String::String ( const char32_t * str,
int len = -1 )
inline

Create and initialize a string object from a char32_t string.

Parameters
[in]strchar32_t initialization string, must NOT be nullptr.
[in]lenCharacters count copied from initialization string. Default -1 means whole string will be copied.

◆ String() [4/9]

gem::String::String ( const std::string & str)
inline

Create and initialize a string object from a std::string.

Parameters
[in]strstd::string initialization string, must NOT be nullptr.

◆ String() [5/9]

gem::String::String ( const std::u16string & str)
inline

Create and initialize a string object from a std::u16string.

Parameters
[in]strstd::u16string initialization string, must NOT be nullptr.

◆ String() [6/9]

gem::String::String ( const std::u32string & str)
inline

Create and initialize a string object from a std::u32string.

Parameters
[in]strstd::u32string initialization string, must NOT be nullptr.

◆ String() [7/9]

gem::String::String ( const StdString & str)
inline

Create and initialize a string object from a StdString.

Parameters
[in]strStdString initialization string, must NOT be nullptr.

◆ String() [8/9]

gem::String::String ( const String & string)
default

Default copy constructor.

Parameters
[in]stringSource string

◆ String() [9/9]

gem::String::String ( String && string)
default

Default move constructor noexcept is deduced.

Parameters
[in]stringSource string

Member Function Documentation

◆ append() [1/4]

String & gem::String::append ( char16_t ch)
inline

Append from a char16_t char.

Parameters
[in]chSource char16_t char.
Returns
Reference to this object

◆ append() [2/4]

String & gem::String::append ( const char * str,
int len = -1 )
inline

Append from a char string.

Parameters
[in]strSource char string, must NOT be nullptr.
[in]lenCharacters count copied from the source string. Default -1 means whole string will be copied.
Returns
Reference to this object

◆ append() [3/4]

String & gem::String::append ( const char16_t * str,
int len = -1 )
inline

Append from a char16_t string.

Parameters
[in]strSource char16_t string, must NOT be nullptr.
[in]lenCharacters count copied from the source string. Default -1 means whole string will be copied.
Returns
Reference to this object

◆ append() [4/4]

String & gem::String::append ( const String & str)
inline

Append from a String.

Parameters
[in]strSource string, must NOT be nullptr.
Returns
Reference to this object

◆ assign() [1/6]

String & gem::String::assign ( const char * str,
int len = -1 )
inline

Assign from a char string.

Parameters
[in]strInitialization string, must NOT be nullptr.
[in]lenCharacters count copied from initialization string. Default -1 means whole string will be copied.
Returns
Reference to this object

◆ assign() [2/6]

String & gem::String::assign ( const char16_t * str,
int len = -1 )
inline

Assign from a char16_t string.

Parameters
[in]strInitialization string, must NOT be nullptr.
[in]lenCharacters count copied from initialization string. Default -1 means whole string will be copied.
Returns
Reference to this object

◆ assign() [3/6]

String & gem::String::assign ( const char32_t * str,
int len = -1 )
inline

Assign from a char32_t string.

Parameters
[in]strInitialization string, must NOT be nullptr.
[in]lenCharacters count copied from initialization string. Default -1 means whole string will be copied.
Returns
Reference to this object

◆ assign() [4/6]

String & gem::String::assign ( const std::string & str)
inline

Assign from a std::string.

Parameters
[in]strInitialization string, must NOT be nullptr.
Returns
Reference to this object

◆ assign() [5/6]

String & gem::String::assign ( const std::u16string & str)
inline

Assign from a std::u16string.

Parameters
[in]strInitialization string, must NOT be nullptr.
Returns
Reference to this object

◆ assign() [6/6]

String & gem::String::assign ( const std::u32string & str)
inline

Assign from a std::u32string.

Parameters
[in]strInitialization string, must NOT be nullptr.
Returns
Reference to this object

◆ back() [1/2]

char16_t & gem::String::back ( )
inline

Last character access.

Returns
Last character of the string

◆ back() [2/2]

char16_t gem::String::back ( ) const
inline

Last character access.

Returns
Last character of the string

◆ clear()

String & gem::String::clear ( )
inline

Clear the string(sets string to empty).

Returns
Reference to this object

◆ compareCaseInsensitive()

int gem::String::compareCaseInsensitive ( String const & str) const
inline

Case-insensitive comparison between current string and string provided as parameter.

Returns
-1 if less, 0 if equal, 1 if greater
Parameters
[in]strString to compare with

◆ compareCaseSensitive()

int gem::String::compareCaseSensitive ( String const & str) const
inline

Case-sensitive comparison between current string and string provided as parameter.

Returns
-1 if less, 0 if equal, 1 if greater
Parameters
[in]strString to compare with

◆ constData()

template<typename TChar16Convertible = char16_t>
const TChar16Convertible * gem::String::constData ( ) const
inline

Data buffer access as read-only char16_t pointer.

Returns
Pointer to the data buffer
Template Parameters
TChar16ConvertibleChar16 convertible type

◆ contains() [1/3]

bool gem::String::contains ( char16_t ch,
int from = 0 ) const
inline

Check if string contains specified char16_t character.

Returns
True if string contains the character, false otherwise
Parameters
[in]chCharacter to search for
[in]fromZero-based position index where to start searching

◆ contains() [2/3]

bool gem::String::contains ( const char16_t * str,
int from = 0 ) const
inline

Check if string contains specified char16_t sub-string.

Returns
True if string contains the sub-string, false otherwise
Parameters
[in]strSub-string to search for
[in]fromZero-based position index where to start searching

◆ contains() [3/3]

bool gem::String::contains ( const String & str,
int from = 0 ) const
inline

Check if string contains specified String sub-string.

Returns
True if string contains the sub-string, false otherwise
Parameters
[in]strSub-string to search for
[in]fromZero-based position index where to start searching

◆ data()

template<typename TChar16Convertible = char16_t>
TChar16Convertible * gem::String::data ( )
inline

Data buffer access as char16_t pointer.

Returns
Pointer to the data buffer
Template Parameters
TChar16ConvertibleChar16 convertible type

◆ empty()

bool gem::String::empty ( ) const
inline

Check if string is empty.

Returns
True if string is empty, false otherwise

◆ fallbackToLegacyUnicode()

String & gem::String::fallbackToLegacyUnicode ( )
inline

Replace some later unicode version characters with older legacy ones.

Can be used to correct display on some fonts which are missing them

Returns
Reference to this object

◆ find() [1/3]

int gem::String::find ( const char16_t * str,
int from = 0 ) const
inline

Find a char16_t sub-string.

Returns
Zero-based index position of the substring, -1 if not found.
Parameters
[in]strSub-string to search for
[in]fromZero-based position index where to start searching

◆ find() [2/3]

int gem::String::find ( const char16_t ch,
int from = 0 ) const
inline

Find a char16_t character.

Returns
Zero-based index position of the character, -1 if not found.
Parameters
[in]chCharacter to search for
[in]fromZero-based position index where to start searching

◆ find() [3/3]

int gem::String::find ( const String & str,
int from = 0 ) const
inline

Find a String sub-string.

Returns
Zero-based index position of the substring, -1 if not found.
Parameters
[in]strSub-string to search for
[in]fromZero-based position index where to start searching

◆ findLast() [1/3]

int gem::String::findLast ( const char16_t * str,
int from = -1 ) const
inline

Find last occurrence of a substring.

Returns
Zero-based index position of the substring, -1 if not found.

Search position positive values are string start based and should be in [0, size()-1] interval

Search position negative values are string end based and should be in [-1, -size()] interval

Parameters
[in]strSub-string to search for
[in]fromZero-based position index where to start searching

◆ findLast() [2/3]

int gem::String::findLast ( const char16_t ch,
int from = -1 ) const
inline

Find last occurrence of a character.

Returns
Zero-based index position of the substring, -1 if not found.
Parameters
[in]chCharacter to search for
[in]fromZero-based position index where to start searching

◆ findLast() [3/3]

int gem::String::findLast ( const String & str,
int from = -1 ) const
inline

Find last occurrence of a substring.

Returns
Zero-based index position of the substring, -1 if not found.
Parameters
[in]strSub-string to search for
[in]fromZero-based position index where to start searching

◆ findSeparators() [1/2]

int gem::String::findSeparators ( const char16_t * sep,
int from = 0 ) const
inline

Find first occurrence of any of separators in specified collection.

Returns
Zero-based index position of the first separator found, -1 if not found.
Parameters
[in]sepCollection of separators
[in]fromZero-based position index where to start searching

◆ findSeparators() [2/2]

int gem::String::findSeparators ( const String & sep,
int from = 0 ) const
inline

Find first occurrence of any of separators in specified collection.

Returns
Zero-based index position of the first separator found, -1 if not found.
Parameters
[in]sepCollection of separators
[in]fromZero-based position index where to start searching

◆ format() [1/3]

template<typename ... TArgs>
String & gem::String::format ( const char * format,
TArgs &&... args )
inline

Format string in sprintf style.

See sprintf man page for format specifications

Parameters
[in]formatFormat char string
[in]argsFormat arguments. Allowed values are integers, floating point, pointers, char*, char16_t*, char32_t* and String and String convertible types.
Returns
Reference to this object
Template Parameters
TArgsArgument types

◆ format() [2/3]

template<typename ... TArgs>
String & gem::String::format ( const char16_t * format,
TArgs &&... args )
inline

Format string in sprintf style.

See sprintf man page for format specifications.

Parameters
[in]formatFormat char16_t string.
[in]argsFormat arguments. Allowed values are integers, floating point, pointers, char*, char16_t*, char32_t* and String and String convertible types.
Returns
Reference to this object
Template Parameters
TArgsArgument types

◆ format() [3/3]

template<typename ... TArgs>
String & gem::String::format ( const String & format,
TArgs &&... args )
inline

Format string in sprintf style.

See sprintf man page for format specifications.

Parameters
[in]formatFormat String string.
[in]argsFormat arguments. Allowed values are integers, floating point, pointers, char*, char16_t*, char32_t* and String and String convertible types.
Returns
Reference to this object
Template Parameters
TArgsArgument types

◆ formatString() [1/2]

template<typename ... TArgs>
String gem::String::formatString ( const char16_t * format,
TArgs &&... args )
inlinestatic

Format string in sprintf style.

See sprintf man page for format specifications.

static function, can be used without instantiating an instance of this class.

Parameters
[in]formatFormat char16_t string.
[in]argsFormat arguments. Allowed values are integers, floating point, pointers, char*, char16_t*, char32_t* and String and String convertible types.
Returns
Formatted string
Template Parameters
TArgsArgument types

◆ formatString() [2/2]

template<typename ... TArgs>
String gem::String::formatString ( const String & format,
TArgs &&... args )
inlinestatic

Format string in sprintf style.

See sprintf man page for format specifications.

static function, can be used without instantiating an instance of this class.

Parameters
[in]formatFormat String string.
[in]argsFormat arguments. Allowed values are integers, floating point, pointers, char*, char16_t*, char32_t* and String and String convertible types.
Returns
Formatted string
Template Parameters
TArgsArgument types

◆ front() [1/2]

char16_t & gem::String::front ( )
inline

First character access.

Returns
First character of the string

◆ front() [2/2]

char16_t gem::String::front ( ) const
inline

First character access.

Returns
First character of the string

◆ hashCode()

unsigned gem::String::hashCode ( ) const
inline

String hash code.

Returns
Hash code

◆ insert() [1/3]

String & gem::String::insert ( int from,
char16_t ch )
inline

Insert the given character at the given position.

Parameters
[in]fromPosition where to insert the character
[in]chCharacter to insert
Returns
Reference to this object

◆ insert() [2/3]

String & gem::String::insert ( int from,
const char16_t * ch )
inline

Insert the given character array at the given position.

Parameters
[in]fromPosition where to insert the character array
[in]chCharacter array to insert
Returns
Reference to this object

◆ insert() [3/3]

String & gem::String::insert ( int from,
const String & str )
inline

Insert the given string at the given position.

Parameters
[in]fromPosition where to insert the string
[in]strString to insert
Returns
Reference to this object

◆ isRightToLeft()

bool gem::String::isRightToLeft ( ) const
inline

Check if string contains right-to-left substring sequences.

Returns
True if string contains right-to-left substring sequences, false otherwise

◆ left()

String gem::String::left ( int len) const
inline

Substring containing the n leftmost characters of the string.

Parameters
[in]lenNumber of characters to copy.
Returns
Substring containing the n leftmost characters of the string.

◆ mid()

String gem::String::mid ( int start,
int len = -1 ) const
inline

Substring containing the characters starting from position and given length.

Parameters
[in]startZero-based position index where to start.
[in]lenNumber of characters to copy. Default -1 means whole string will be copied.
Returns
Substring containing the characters starting from position and given length

◆ operator!=()

bool gem::String::operator!= ( const String & str) const
inline

Not Equal operator.

Parameters
[in]strString to compare with
Returns
True if strings are not equal, false otherwise

◆ operator+=() [1/3]

String & gem::String::operator+= ( char16_t c)
inline

Append char16_t char operator.

Parameters
[in]cSource char16_t char
Returns
Reference to this object

◆ operator+=() [2/3]

String & gem::String::operator+= ( const char16_t * s)
inline

Append char16_t string operator.

Parameters
[in]sSource char16_t string, must NOT be nullptr.
Returns
Reference to this object

◆ operator+=() [3/3]

String & gem::String::operator+= ( const String & s)
inline

Append String operator.

Parameters
[in]sString to append
Returns
Reference to this object

◆ operator<()

bool gem::String::operator< ( const String & str) const
inline

Less Than operator.

Parameters
[in]strString to compare with
Returns
True if current string is less than the provided string, false otherwise

◆ operator<=()

bool gem::String::operator<= ( const String & str) const
inline

Less Than or Equal operator.

Parameters
[in]strString to compare with
Returns
True if current string is less than or equal to the provided string, false otherwise

◆ operator=() [1/8]

String & gem::String::operator= ( const char * str)
inline

Assign to String from char*.

Parameters
[in]strSource char string, must NOT be nullptr.
Returns
Reference to this object

◆ operator=() [2/8]

String & gem::String::operator= ( const char16_t * str)
inline

Assign to String from char16_t*.

Parameters
[in]strSource char16_t string, must NOT be nullptr.
Returns
Reference to this object

◆ operator=() [3/8]

String & gem::String::operator= ( const char32_t * str)
inline

Assign to String from char32_t*.

Parameters
[in]strSource char32_t string, must NOT be nullptr.
Returns
Reference to this object

◆ operator=() [4/8]

String & gem::String::operator= ( const std::string & str)
inline

Assign to String from std::string.

Parameters
[in]strSource std::string
Returns
Reference to this object

◆ operator=() [5/8]

String & gem::String::operator= ( const std::u16string & str)
inline

Assign to String from std::u16string.

Parameters
[in]strSource std::u16string
Returns
Reference to this object

◆ operator=() [6/8]

String & gem::String::operator= ( const std::u32string & str)
inline

Assign to String from std::u32string.

Parameters
[in]strSource std::u32string
Returns
Reference to this object

◆ operator=() [7/8]

String & gem::String::operator= ( const String & string)
default

Default copy assignment.

Parameters
[in]stringSource string
Returns
Reference to this object

◆ operator=() [8/8]

String & gem::String::operator= ( String && string)
default

Default move assignment noexcept is deduced.

Parameters
[in]stringSource string
Returns
Reference to this object

◆ operator==()

bool gem::String::operator== ( const String & str) const
inline

Equal operator.

Parameters
[in]strString to compare with
Returns
True if strings are equal, false otherwise

◆ operator>()

bool gem::String::operator> ( const String & str) const
inline

Greater Than operator.

Parameters
[in]strString to compare with
Returns
True if current string is greater than the provided string, false otherwise

◆ operator>=()

bool gem::String::operator>= ( const String & str) const
inline

Greater Than or Equal operator.

Parameters
[in]strString to compare with
Returns
True if current string is greater than or equal to the provided string, false otherwise

◆ operator[]()

char16_t gem::String::operator[] ( int pos) const
inline

Character access at the given index.

Parameters
[in]posIndex. Must be valid, i.e. 0 <= pos < length
Returns
Character at the given index

◆ prepend() [1/3]

String & gem::String::prepend ( const char * str,
int len = -1 )
inline

Prepend from a char string.

Parameters
[in]strSource string, must NOT be nullptr.
[in]lenCharacters count copied from the source string. Default -1 means whole string will be copied.
Returns
Reference to this object

◆ prepend() [2/3]

String & gem::String::prepend ( const char16_t * str,
int len = -1 )
inline

Prepend from a char16_t string.

Parameters
[in]strSource string, must NOT be nullptr.
[in]lenCharacters count copied from the source string. Default -1 means whole string will be copied.
Returns
Reference to this object

◆ prepend() [3/3]

String & gem::String::prepend ( const String & str)
inline

Prepend from a String.

Parameters
[in]strSource string, must NOT be nullptr.
Returns
Reference to this object

◆ remove()

String & gem::String::remove ( int from,
int len )
inline

Remove characters from string.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to remove.
Returns
Reference to this object

◆ replace() [1/3]

String & gem::String::replace ( const String & before,
const String & after )
inline

Replace every occurrence of the string before with the string after.

Parameters
[in]beforeSub-string to search for
[in]afterSub-string to replace with
Returns
Reference to this object

◆ replace() [2/3]

String & gem::String::replace ( int from,
int len,
const char16_t * str )
inline

Replace part of string with given sub-string.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to replace.
[in]strSource char16_t string where to copy characters from.
Returns
Reference to this object

◆ replace() [3/3]

String & gem::String::replace ( int from,
int len,
const String & str )
inline

Replace part of string with given sub-string.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to replace.
[in]strSource String where to copy characters from.
Returns
Reference to this object

◆ replaceInSet()

String & gem::String::replaceInSet ( const char16_t * cset,
char16_t c )
inline

Replace all characters in set with new one.

Parameters
[in]csetSet of characters to replace
[in]cNew character
Returns
Reference to this object

◆ resize()

String & gem::String::resize ( int len,
char16_t c = 0 )
inline

Set string length.

If the string length is bigger it will be truncated to the given length

If the string length is smaller the given char will be appended until the given length

Parameters
[in]lenNew string length
[in]cCharacter to append if the string is shorter than the given length. Default value is 0.
Returns
Reference to this object

◆ right()

String gem::String::right ( int len) const
inline

Substring containing the n rightmost characters of the string.

Parameters
[in]lenNumber of characters to copy.
Returns
Substring containing the n rightmost characters of the string.

◆ set()

void gem::String::set ( int pos,
char16_t c )
inline

Set the character at the given position.

Parameters
[in]posPosition where to set the character
[in]cCharacter to set

◆ size()

int gem::String::size ( ) const
inline

Get string length.

Returns
String length

◆ split() [1/2]

template<typename Collector>
void gem::String::split ( const char16_t * seps,
Collector collector,
bool collectEmpty = false ) const
inline

Split the string based on the given separators collection.

Parameters
[in]sepsSeparators list
[in]collectorSubstrings collector callback: bool (*)( const char16_t *substring, int size ). If return true, the splitting continues, if return false the splitting ends
[in]collectEmptyCollect empty strings ( between 2 consecutive separators )

Substrings are passed one by one to the caller via the callback method

Template Parameters
CollectorSubstrings collector callback type

◆ split() [2/2]

template<typename Collector>
void gem::String::split ( const String & seps,
Collector collector,
bool collectEmpty = false ) const
inline

Split string at positions where any one of specified separators is found.

Parameters
[in]sepsSeparators list
[in]collectEmptyCollect empty strings ( between 2 consecutive separators )
Template Parameters
CollectorSubstrings collector callback type
Parameters
[in]collectorSubstrings collector callback: bool (*)( const char16_t *substring, int size ). If return true, the splitting continues, if return false the splitting ends

◆ toFloat()

double gem::String::toFloat ( int from = 0,
int len = -1 ) const
inline

Convert to float.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to convert. Default -1 means whole string will be converted.
Returns
Float value

◆ toInt()

int gem::String::toInt ( int from = 0,
int len = -1 ) const
inline

Convert to integer.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to convert. Default -1 means whole string will be converted.
Returns
Integer value

◆ toLargeInt()

LargeInteger gem::String::toLargeInt ( int from = 0,
int len = -1 ) const
inline

Convert to LargeInteger.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to convert. Default -1 means whole string will be converted.
Returns
LargeInteger value

◆ toLower()

String gem::String::toLower ( int from = 0,
int len = -1 ) const
inline

Convert to lowercase string.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to convert. Default -1 means whole string will be converted.
Returns
Lowercase string

◆ toStdString()

std::string gem::String::toStdString ( int from = 0,
int len = -1 ) const
inline

Convert to std::string.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to convert. Default -1 means whole string will be converted.
Returns
std::string

◆ toStdString16()

std::u16string gem::String::toStdString16 ( int from = 0,
int len = -1 ) const
inline

Convert to std::u16string.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to convert. Default -1 means whole string will be converted.
Returns
std::u16string

◆ toStdString32()

std::u32string gem::String::toStdString32 ( int from = 0,
int len = -1 ) const
inline

Convert to std::u32string.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to convert. Default -1 means whole string will be converted.
Returns
std::u32string

◆ toUpper()

String gem::String::toUpper ( int from = 0,
int len = -1 ) const
inline

Convert to uppercase string.

Parameters
[in]fromZero-based position index where to start.
[in]lenNumber of characters to convert. Default -1 means whole string will be converted.
Returns
Uppercase string

◆ trim()

String & gem::String::trim ( )
inline

Trim white spaces from string.

Returns
Reference to this object

◆ trimmed()

String gem::String::trimmed ( ) const
inline

Get a trimmed string from this.

Returns
Trimmed string

◆ truncate()

void gem::String::truncate ( int len)
inline

Truncate the string to the given length.

Parameters
[in]lenThe new string length