|
Jameo Core Library
|
String implements our generic string because std::string is inadequate and inconvenient. The internal character encoding is Unicode (UTF-8).
More...
Public Member Functions | |
| String () | |
| Constructor for empty string. | |
| String (const char *cstring) | |
| This constructor generates a character string. The encoding is the standard encoding (UTF-8). | |
| String (const ByteArray &buffer) | |
| This constructor generates a character string. The encoding is the standard encoding (UTF-8). | |
| String (const char *cstring, Charset *charset) | |
| This constructor generates a character string. | |
| String (const ByteArray &buffer, Charset *charset) | |
| This constructor generates a character string. | |
| String (const char *buffer, size_t size) | |
| This constructor generates a character string. The encoding is the standard encoding (UTF-8). | |
| String (const uint16 *buffer, size_t size) | |
| This constructor generates a character string. The encoding is the standard encoding (UTF-8). | |
| String (const char *buffer, size_t size, Charset *charset) | |
| This constructor generates a character string. The encoding is the standard encoding (UTF-8). | |
| String (const String &another) noexcept | |
| Copy constructor. | |
| ~String () override | |
| Destructor. | |
| size_t | size () const |
| Returns the size of the string. | |
| ByteArray | toCString () const |
| This method generates a C-string from the string, taking into account the standard encoding (UTF-8). | |
| uint16 * | toWString () const |
| This method generates a C-string with 16-bit elements, taking into account the Unicode encoding. It is essentially a copy of the buffer. | |
| ByteArray | toCString (Charset *charset) const |
| This method generates a C-string from the string, taking into account the specified character encoding. | |
| size_t | count (Char character) const |
| Count the occurrences of the character in the string. | |
| void | clear () |
| This method clears the content of the string and releases any allocated memory. | |
| void | zero () |
| This method sets the length to 0 without freeing any memory. | |
| void | append (const String &another) |
| This method appends another string to this string. | |
| void | append (Char unicodechar) |
| This method appends a character to this string. | |
| void | deleteCharAt (size_t index) |
| This method deletes a character from this string. | |
| void | deleteCharRangeAt (size_t index, size_t length) |
| This method deletes a section from this string. | |
| bool | equals (const Object *other) const override |
| Comparison of objects. | |
| bool | equals (const String &another) const |
| This method checks if this string is identical to another string. It compares each character to determine if the characters are exactly the same. | |
| int32 | compareTo (const String &another) const override |
| This method compares the order of the strings. It compares character by character from left to right. | |
| int32 | compareFancyTo (const String &another) const |
| This method compares the order of the strings, taking into account numbers. Components that can be interpreted as numbers are compared separately. Due to limitations in the MS C++ compiler, currently only the first 256 characters are compared for efficiency reasons. | |
| bool | equalsIgnoreCase (const String &another) const |
| This method checks if this string is identical to another string, ignoring case. | |
| bool | startsWith (const String &another) const |
| This method checks if the beginning of this string matches another string. | |
| bool | endsWith (const String &another) const |
| This method checks if the end of this string matches another string. | |
| bool | atIs (size_t position, const String &another) const |
| This method checks, is the string at position is the same as the other string. | |
| bool | atIsIgnoreCase (size_t position, const String &another) const |
| Same as atIs, but ignoring case. | |
| int64 | hashCode () |
| This method calculates the hash code for this string and returns it. | |
| int64 | constHashCode () const |
| This method calculates the hash code for this string and returns it. | |
| String | toLowerCase () const |
| This method returns a string in which all uppercase letters have been replaced with lowercase letters. | |
| String | toUpperCase () const |
| This method returns a string in which all lowercase letters have been replaced with uppercase letters. | |
| String | substring (size_t beginIndex) const |
| This method creates a substring that consists of a portion of this string. | |
| String | substring (size_t beginIndex, size_t endIndex) const |
| This method creates a substring that consists of a portion of this string. | |
| String | trim () const |
| This method returns a new string with all non-visible text characters (whitespaces) removed from the beginning and end of the string. | |
| String | replace (Char oldChar, Char newChar) const |
| This method replaces characters in the string. The "old" character is replaced with the "new" character at all positions. | |
| String | replace (const String &oldStr, const String &newStr) const |
| This method replaces substrings in the string. The "oldStr" substring is replaced with the "newStr" substring at all positions. | |
| String | reverse () const |
| This method reverses the order of characters in the string. | |
| StringList | split (Char character) const |
| Splits the string into a list of strings, using the specified character as a separator. | |
| size_t | indexOf (Char character) const |
| This method returns the zero-based position of the first occurrence of the desired character in the string. | |
| size_t | indexOf (const String &str) const |
| This method returns the zero-based position of the first occurrence of the desired string in the string. | |
| size_t | indexOf (Char character, size_t fromIndex) const |
| This method returns the zero-based position of the first occurrence of the desired character in the string. | |
| size_t | indexOf (const String &str, size_t fromIndex) const |
| This method returns the zero-based position of the first occurrence of the desired string in the string. | |
| size_t | lastIndexOf (Char character) const |
| This method returns the zero-based position of the last occurrence of the desired character in the string. | |
| size_t | lastIndexOf (const String &str) const |
| This method returns the zero-based position of the last occurrence of the desired string in the string. | |
| size_t | lastIndexOf (Char character, size_t fromIndex) const |
| This method returns the zero-based position of the last occurrence of the desired character in the string. | |
| size_t | lastIndexOf (const String &str, size_t fromIndex) const |
| This method returns the zero-based position of the last occurrence of the desired string in the string. | |
| Char | charAt (size_t index) const |
| This method returns the character at a specific position in the string. | |
| void | setCharAt (size_t index, Char character) |
| This method replaces a character in the string with a new one. | |
| void | insert (size_t index, Char character) |
| This method inserts a character into the string at the specified index and shifts all subsequent characters to the right. | |
| void | insert (size_t index, const String &string) |
| This method inserts a string into the string at the specified index and shifts all subsequent characters to the right. | |
| String | arg (int64 value, int64 fieldwidth=0, Char fillchar=Char(' ')) const |
| Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number. | |
| String | arg (int32 value, int64 fieldwidth=0, Char fillchar=Char(' ')) const |
| Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number. | |
| String | arg (uint32 value, int64 fieldwidth=0, Char fillchar=Char(' ')) const |
| Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number. | |
| String | arg (uint64 value, int64 fieldwidth=0, Char fillchar=Char(' ')) const |
| Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number. | |
| String | arg (const String &value, int64 fieldwidth=0, Char fillchar=Char(' ')) const |
| Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number. | |
| String | arg (Char character, int64 fieldwidth=0, Char fillchar=Char(' ')) const |
| Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a character. | |
| String | arg (double value, int64 fieldwidth=0, int64 precision=-1, Char fillchar=Char(' ')) const |
| Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number. | |
| bool | toBool () const |
| Returns a boolean representation of the string. | |
| double | toDouble () const |
| Returns a double representation of the string. | |
| int64 | toInt () const |
| Returns a int representation of the string. | |
| size_t | toSize () const |
| Returns a size_t representation of the string. | |
| bool | isEmpty () const |
| Returns true if the string is empty. False otherwise. | |
| String & | operator= (const String &another) |
| String & | operator+= (const String &another) |
| void | checkCapacity (size_t more) |
| This method checks, if the string has the capacity to hold more bytes. If not, the array will be enlarged. | |
Public Member Functions inherited from jm::Object | |
| Object () noexcept | |
| Constructor. | |
| virtual | ~Object () noexcept |
| Destructor. | |
| void | release () noexcept |
| Decreases the reference counter and releases the object immediately when the reference counter becomes 0. | |
| Object * | retain () noexcept |
| Increases the reference counter of this object by 1. | |
| Object * | autorelease () noexcept |
| Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object. | |
| int32 | referenceCount () const noexcept |
| Returns the value of the reference counter. | |
| virtual String | displayName () const |
| Returns the display name of the object intended to present to a user. | |
| virtual void | printDiffInfo (DiffOperation operation, Object *other) const |
| Output method for outputting the diff results for the diff algorithm. | |
| void | setHighBit (bool status) noexcept |
| bool | highBit () const noexcept |
Public Member Functions inherited from jm::Comparable< String > | |
| Comparable () | |
| virtual | ~Comparable () |
Static Public Member Functions | |
| static void | setConsoleCharset (Charset *cs) |
| static String | valueOf (double number) |
| Converts a double into a string. | |
| static String | valueOf (double number, int64 precision, bool trunc) |
| Converts the double to decimal String. | |
| static String | valueOf (int64 number) |
| Converts a integer into a string. | |
| static String | valueOf (uint64 number) |
| static String | valueOf (int32 number) |
| static String | valueOf (uint32 number) |
| static String | valueOf (bool value) |
| Converts a bool value into a string. | |
| static String | lineSeparator () |
| Returns operation system dependent line separator. | |
Friends | |
| DllExport friend bool | operator== (String const &v1, String const &v2) |
| DllExport friend bool | operator!= (String const &v1, String const &v2) |
| DllExport friend std::ostream & | operator<< (std::ostream &out, const String &str) |
| DllExport friend String & | operator<< (String &out, const String &str) |
| DllExport friend String & | operator<< (String &out, const int64 &i) |
| DllExport friend String & | operator<< (String &out, const uint64 &i) |
| DllExport friend String & | operator<< (String &out, const int64 &i) |
| DllExport friend String & | operator<< (String &out, const int32 &i) |
| DllExport friend String & | operator<< (String &out, const uint32 &i) |
| DllExport friend String & | operator<< (String &out, const double &d) |
| DllExport friend String & | operator<< (String &out, const char &c) |
| DllExport friend String & | operator<< (String &out, const Char &c) |
| DllExport friend std::istream & | operator>> (std::istream &in, String &str) |
| DllExport friend String | operator+ (const String &left, const String &right) |
| DllExport friend String | operator+ (const char *&left, const String &right) |
| DllExport friend String | operator+ (const String &left, const char *&right) |
| DllExport friend String | operator+ (const jm::Char &left, const String &right) |
| DllExport friend String | operator+ (const String &left, const jm::Char &right) |
| DllExport friend String | operator+ (const int64 &left, const String &right) |
| DllExport friend String | operator+ (const String &left, const int64 &right) |
| DllExport friend String | operator+ (const double &left, const String &right) |
| DllExport friend String | operator+ (const String &left, const double &right) |
| DllExport friend String | operator+ (const int8 &left, const String &right) |
| DllExport friend String | operator+ (const String &left, const int8 &right) |
| DllExport friend bool | operator< (const String &left, const String &right) |
String implements our generic string because std::string is inadequate and inconvenient. The internal character encoding is Unicode (UTF-8).
For the conversion from std::string to jm::String the following call can be used:
| jm::String::String | ( | ) |
Constructor for empty string.
| jm::String::String | ( | const char * | cstring | ) |
This constructor generates a character string. The encoding is the standard encoding (UTF-8).
| cstring | A C-string that represents the character string. A C string is characterized by the fact that the end of the character string is symbolized by a 0 byte. |
|
explicit |
This constructor generates a character string. The encoding is the standard encoding (UTF-8).
| buffer | A C-string that represents the character string. A C string is characterized by the fact that the end of the character string is symbolized by a 0 byte. |
| jm::String::String | ( | const char * | cstring, |
| Charset * | charset | ||
| ) |
This constructor generates a character string.
| cstring | A C-string that represents the character string. A C string is characterized by the fact that the end of the character string is symbolized by a 0 byte. |
| charset | The coding with which the character string is encoded. |
This constructor generates a character string.
| buffer | A C-string that represents the character string. A C string is characterized by the fact that the end of the character string is symbolized by a 0 byte. |
| charset | The coding with which the character string is encoded. |
| jm::String::String | ( | const char * | buffer, |
| size_t | size | ||
| ) |
This constructor generates a character string. The encoding is the standard encoding (UTF-8).
| buffer | An array, which contains the string. |
| size | The length of the string. |
| jm::String::String | ( | const uint16 * | buffer, |
| size_t | size | ||
| ) |
This constructor generates a character string. The encoding is the standard encoding (UTF-8).
| buffer | An array, which contains the string. |
| size | The length of the string. |
| jm::String::String | ( | const char * | buffer, |
| size_t | size, | ||
| Charset * | charset | ||
| ) |
This constructor generates a character string. The encoding is the standard encoding (UTF-8).
| buffer | An array, which contains the string. |
| size | The length of the string. |
| charset | The coding with which the character string is encoded. |
|
noexcept |
Copy constructor.
|
override |
Destructor.
| void jm::String::append | ( | Char | unicodechar | ) |
This method appends a character to this string.
| unicodechar | The Unicode code point, character, to be appended to this string. |
The character is appended to the end of the string.
| void jm::String::append | ( | const String & | another | ) |
This method appends another string to this string.
| another | The string to be appended to the end of this string. |
Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a character.
| String jm::String::arg | ( | const String & | value, |
| int64 | fieldwidth = 0, |
||
| Char | fillchar = Char(' ') |
||
| ) | const |
Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number.
| String jm::String::arg | ( | double | value, |
| int64 | fieldwidth = 0, |
||
| int64 | precision = -1, |
||
| Char | fillchar = Char(' ') |
||
| ) | const |
Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number.
| value | The number value. |
| fieldwidth | The (minimum) number of characters for the value. If fieldwidth is >0 the leading space is filled (right align). If fieldwidth is < 0 the trailing space is filled (left align). |
| precision | The number of digits after the descimal separator. |
| fillchar | The character for filling the space, until fieldwidth chars are reached. |
Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number.
Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number.
Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number.
Searches in the string for a n (e.g. %1, %2 etc) with the lowest number and replace it by a string representation of the number.
| bool jm::String::atIs | ( | size_t | position, |
| const String & | another | ||
| ) | const |
This method checks, is the string at position is the same as the other string.
| position | The position where another string is expected |
| another | The comparing string |
true is the substring sequence at position is the same as another. Otherwise false | bool jm::String::atIsIgnoreCase | ( | size_t | position, |
| const String & | another | ||
| ) | const |
Same as atIs, but ignoring case.
| position | The position where another string is expected |
| another | The comparing string |
true is the substring sequence at position is the same as another. Otherwise false | Char jm::String::charAt | ( | size_t | index | ) | const |
This method returns the character at a specific position in the string.
| index | The zero-based index of the desired character. |
This method returns the character at the specified position in the string.
| void jm::String::checkCapacity | ( | size_t | more | ) |
This method checks, if the string has the capacity to hold more bytes. If not, the array will be enlarged.
| more | The number of additional bytes. |
| void jm::String::clear | ( | ) |
This method clears the content of the string and releases any allocated memory.
| int32 jm::String::compareFancyTo | ( | const String & | another | ) | const |
This method compares the order of the strings, taking into account numbers. Components that can be interpreted as numbers are compared separately. Due to limitations in the MS C++ compiler, currently only the first 256 characters are compared for efficiency reasons.
| another | The string to compare with. |
Returns a negative value if this string is less than another, zero if they are equal, and a positive value if this string is greater than another.
|
overridevirtual |
This method compares the order of the strings. It compares character by character from left to right.
| another | The string to compare with. |
Returns a negative value if this string is less than another, zero if they are equal, and a positive value if this string is greater than another.
Implements jm::Comparable< String >.
| int64 jm::String::constHashCode | ( | ) | const |
This method calculates the hash code for this string and returns it.
The hash code is calculated based on the content of the string.
| size_t jm::String::count | ( | Char | character | ) | const |
Count the occurrences of the character in the string.
| void jm::String::deleteCharAt | ( | size_t | index | ) |
This method deletes a character from this string.
| index | The zero-based index of the position of the character. |
| void jm::String::deleteCharRangeAt | ( | size_t | index, |
| size_t | length | ||
| ) |
This method deletes a section from this string.
| index | The zero-based index of the starting position. |
| length | The length of the section to delete. |
This method deletes a section of characters from this string, starting at the specified index and with the specified length.
| bool jm::String::endsWith | ( | const String & | another | ) | const |
This method checks if the end of this string matches another string.
| another | The string to be checked. |
|
overridevirtual |
| bool jm::String::equals | ( | const String & | another | ) | const |
This method checks if this string is identical to another string. It compares each character to determine if the characters are exactly the same.
| another | The string to compare with. |
| bool jm::String::equalsIgnoreCase | ( | const String & | another | ) | const |
This method checks if this string is identical to another string, ignoring case.
| another | The string to compare with. |
| int64 jm::String::hashCode | ( | ) |
This method calculates the hash code for this string and returns it.
The hash code is calculated based on the content of the string.
| size_t jm::String::indexOf | ( | Char | character | ) | const |
This method returns the zero-based position of the first occurrence of the desired character in the string.
| character | The character to search for. |
This method searches for the first occurrence of the desired character in the string and returns its zero-based position.
| size_t jm::String::indexOf | ( | Char | character, |
| size_t | fromIndex | ||
| ) | const |
This method returns the zero-based position of the first occurrence of the desired character in the string.
| character | The character to search for. |
| fromIndex | The zero-based position to start searching from. |
This method searches for the first occurrence of the desired character in the string starting from the specified position and returns its zero-based index.
| size_t jm::String::indexOf | ( | const String & | str | ) | const |
This method returns the zero-based position of the first occurrence of the desired string in the string.
| str | The string to search for. |
This method searches for the first occurrence of the desired string in the string and returns its zero-based position.
| size_t jm::String::indexOf | ( | const String & | str, |
| size_t | fromIndex | ||
| ) | const |
This method returns the zero-based position of the first occurrence of the desired string in the string.
| str | The string to search for. |
| fromIndex | The position to start searching from. |
This method searches for the first occurrence of the desired string in the string starting from the specified position and returns its zero-based index.
| void jm::String::insert | ( | size_t | index, |
| Char | character | ||
| ) |
This method inserts a character into the string at the specified index and shifts all subsequent characters to the right.
| index | The zero-based index of the character where the letter should be inserted. |
| character | The character to be inserted. |
This method inserts the character at the specified index in the string and shifts all subsequent characters to the right.
| void jm::String::insert | ( | size_t | index, |
| const String & | string | ||
| ) |
This method inserts a string into the string at the specified index and shifts all subsequent characters to the right.
| index | The zero-based index of the character where the string should be inserted. |
| string | The string to be inserted. |
This method inserts the string at the specified index in the string and shifts all subsequent characters to the right.
| bool jm::String::isEmpty | ( | ) | const |
Returns true if the string is empty. False otherwise.
| size_t jm::String::lastIndexOf | ( | Char | character | ) | const |
This method returns the zero-based position of the last occurrence of the desired character in the string.
This method can also be understood as searching from the end of the string for the first occurrence of the character.
| character | The character to search for. |
| size_t jm::String::lastIndexOf | ( | Char | character, |
| size_t | fromIndex | ||
| ) | const |
This method returns the zero-based position of the last occurrence of the desired character in the string.
This method can also be understood as searching from the end of the string for the first occurrence of the character.
| character | The character to search for. |
| fromIndex | The zero-based index to start searching from (from the end). |
| size_t jm::String::lastIndexOf | ( | const String & | str | ) | const |
This method returns the zero-based position of the last occurrence of the desired string in the string.
This method can also be understood as searching from the end of the string for the first occurrence of the string.
| str | The string to search for. |
| size_t jm::String::lastIndexOf | ( | const String & | str, |
| size_t | fromIndex | ||
| ) | const |
This method returns the zero-based position of the last occurrence of the desired string in the string.
This method can also be understood as searching from the end of the string for the first occurrence of the string.
| str | The string to search for. |
| fromIndex | The zero-based index to start searching from (from the end). |
|
static |
Returns operation system dependent line separator.
This method replaces characters in the string. The "old" character is replaced with the "new" character at all positions.
| oldChar | The old character to be replaced. |
| newChar | The new character to replace the old character. |
This method replaces occurrences of the "old" character with the "new" character in the string.
This method replaces substrings in the string. The "oldStr" substring is replaced with the "newStr" substring at all positions.
| oldStr | The substring to be replaced. |
| newStr | The substring to replace the old substring. |
This method replaces occurrences of the "oldStr" substring with the "newStr" substring in the string.
| String jm::String::reverse | ( | ) | const |
This method reverses the order of characters in the string.
This method reverses the order of characters in the string.
| void jm::String::setCharAt | ( | size_t | index, |
| Char | character | ||
| ) |
This method replaces a character in the string with a new one.
| index | The zero-based index of the character to be replaced. |
| character | The character to be inserted. |
This method replaces the character at the specified index in the string with the new character.
|
static |
| size_t jm::String::size | ( | ) | const |
Returns the size of the string.
| StringList jm::String::split | ( | Char | character | ) | const |
Splits the string into a list of strings, using the specified character as a separator.
| character | The character to use as a separator. |
This method splits the string into multiple substrings based on the specified character. Each substring is added to a list of strings, which is then returned.
| bool jm::String::startsWith | ( | const String & | another | ) | const |
This method checks if the beginning of this string matches another string.
| another | The string to be checked. |
| String jm::String::substring | ( | size_t | beginIndex | ) | const |
This method creates a substring that consists of a portion of this string.
| beginIndex | The zero-based index of the first character to be included in the new substring. |
| String jm::String::substring | ( | size_t | beginIndex, |
| size_t | endIndex | ||
| ) | const |
This method creates a substring that consists of a portion of this string.
| beginIndex | The zero-based index of the first character to be included in the new substring. |
| endIndex | The zero-based index of the first character that should not be included in the new substring. |
This method creates a new string that contains a portion of the original string, starting from the character at the beginIndex and ending one character before the endIndex.
| bool jm::String::toBool | ( | ) | const |
Returns a boolean representation of the string.
| ByteArray jm::String::toCString | ( | ) | const |
This method generates a C-string from the string, taking into account the standard encoding (UTF-8).
The generated C-string must be freed by the application later (delete).
This method generates a C-string from the string, taking into account the specified character encoding.
| charset | The character encoding to use for encoding the string into the C-string. |
The generated C-string must be freed by the application later (delete).
| double jm::String::toDouble | ( | ) | const |
Returns a double representation of the string.
| int64 jm::String::toInt | ( | ) | const |
Returns a int representation of the string.
| String jm::String::toLowerCase | ( | ) | const |
This method returns a string in which all uppercase letters have been replaced with lowercase letters.
The method creates a new string with all uppercase letters replaced by their lowercase counterparts.
| size_t jm::String::toSize | ( | ) | const |
Returns a size_t representation of the string.
| String jm::String::toUpperCase | ( | ) | const |
This method returns a string in which all lowercase letters have been replaced with uppercase letters.
The method creates a new string with all lowercase letters replaced by their uppercase counterparts.
| uint16 * jm::String::toWString | ( | ) | const |
This method generates a C-string with 16-bit elements, taking into account the Unicode encoding. It is essentially a copy of the buffer.
The generated C-string must be freed by the application later (delete).
| String jm::String::trim | ( | ) | const |
This method returns a new string with all non-visible text characters (whitespaces) removed from the beginning and end of the string.
The method creates a new string by removing all non-visible text characters (whitespaces) from the beginning and end of the original string.
|
static |
Converts a bool value into a string.
| value | The value. |
|
static |
Converts a double into a string.
| number | The double value. |
|
static |
Converts the double to decimal String.
| number | The double value. |
| precision | Number of digits after . |
| trunc | Truncate trailing 0 ? |
|
static |
|
static |
Converts a integer into a string.
| number | The value |
|
static |
|
static |
| void jm::String::zero | ( | ) |
This method sets the length to 0 without freeing any memory.
This method sets the length of the string to 0 without releasing any memory. It effectively clears the content of the string without deallocating the underlying buffer.
|
friend |
|
friend |