Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
jm::String Class Reference

String implements our generic string because std::string is inadequate and inconvenient. The internal character encoding is Unicode (UTF-8). More...

Inheritance diagram for jm::String:
jm::Object jm::Comparable< String >

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.
 
Stringoperator= (const String &another)
 
Stringoperator+= (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.
 
Objectretain () noexcept
 Increases the reference counter of this object by 1.
 
Objectautorelease () 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 Stringoperator<< (String &out, const String &str)
 
DllExport friend Stringoperator<< (String &out, const int64 &i)
 
DllExport friend Stringoperator<< (String &out, const uint64 &i)
 
DllExport friend Stringoperator<< (String &out, const int64 &i)
 
DllExport friend Stringoperator<< (String &out, const int32 &i)
 
DllExport friend Stringoperator<< (String &out, const uint32 &i)
 
DllExport friend Stringoperator<< (String &out, const double &d)
 
DllExport friend Stringoperator<< (String &out, const char &c)
 
DllExport friend Stringoperator<< (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)
 

Detailed Description

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:

std::string msg = "Hello World!";
jm::String str = jm::String(msg.c_str());
String implements our generic string because std::string is inadequate and inconvenient....
Definition String.h:70

Constructor & Destructor Documentation

◆ String() [1/9]

jm::String::String ( )

Constructor for empty string.

◆ String() [2/9]

jm::String::String ( const char *  cstring)

This constructor generates a character string. The encoding is the standard encoding (UTF-8).

Parameters
cstringA 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.

◆ String() [3/9]

jm::String::String ( const ByteArray buffer)
explicit

This constructor generates a character string. The encoding is the standard encoding (UTF-8).

Parameters
bufferA 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.

◆ String() [4/9]

jm::String::String ( const char *  cstring,
Charset charset 
)

This constructor generates a character string.

Parameters
cstringA 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.
charsetThe coding with which the character string is encoded.

◆ String() [5/9]

jm::String::String ( const ByteArray buffer,
Charset charset 
)

This constructor generates a character string.

Parameters
bufferA 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.
charsetThe coding with which the character string is encoded.

◆ String() [6/9]

jm::String::String ( const char *  buffer,
size_t  size 
)

This constructor generates a character string. The encoding is the standard encoding (UTF-8).

Parameters
bufferAn array, which contains the string.
sizeThe length of the string.

◆ String() [7/9]

jm::String::String ( const uint16 *  buffer,
size_t  size 
)

This constructor generates a character string. The encoding is the standard encoding (UTF-8).

Parameters
bufferAn array, which contains the string.
sizeThe length of the string.

◆ String() [8/9]

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

Parameters
bufferAn array, which contains the string.
sizeThe length of the string.
charsetThe coding with which the character string is encoded.

◆ String() [9/9]

jm::String::String ( const String another)
noexcept

Copy constructor.

◆ ~String()

jm::String::~String ( )
override

Destructor.

Member Function Documentation

◆ append() [1/2]

void jm::String::append ( Char  unicodechar)

This method appends a character to this string.

Parameters
unicodecharThe Unicode code point, character, to be appended to this string.

The character is appended to the end of the string.

◆ append() [2/2]

void jm::String::append ( const String another)

This method appends another string to this string.

Parameters
anotherThe string to be appended to the end of this string.

◆ arg() [1/7]

String jm::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.

◆ arg() [2/7]

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.

◆ arg() [3/7]

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.

Parameters
valueThe number value.
fieldwidthThe (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).
precisionThe number of digits after the descimal separator.
fillcharThe character for filling the space, until fieldwidth chars are reached.

◆ arg() [4/7]

String jm::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.

◆ arg() [5/7]

String jm::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.

◆ arg() [6/7]

String jm::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.

◆ arg() [7/7]

String jm::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.

◆ atIs()

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.

Parameters
positionThe position where another string is expected
anotherThe comparing string
Returns
Returns true is the substring sequence at position is the same as another. Otherwise false

◆ atIsIgnoreCase()

bool jm::String::atIsIgnoreCase ( size_t  position,
const String another 
) const

Same as atIs, but ignoring case.

Parameters
positionThe position where another string is expected
anotherThe comparing string
Returns
Returns true is the substring sequence at position is the same as another. Otherwise false

◆ charAt()

Char jm::String::charAt ( size_t  index) const

This method returns the character at a specific position in the string.

Parameters
indexThe zero-based index of the desired character.
Returns
The character at the specified position.

This method returns the character at the specified position in the string.

◆ checkCapacity()

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.

Parameters
moreThe number of additional bytes.

◆ clear()

void jm::String::clear ( )

This method clears the content of the string and releases any allocated memory.

◆ compareFancyTo()

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.

Parameters
anotherThe 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.

◆ compareTo()

int32 jm::String::compareTo ( const String another) const
overridevirtual

This method compares the order of the strings. It compares character by character from left to right.

Parameters
anotherThe 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 >.

◆ constHashCode()

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.

Returns
The hash code for this string.

◆ count()

size_t jm::String::count ( Char  character) const

Count the occurrences of the character in the string.

◆ deleteCharAt()

void jm::String::deleteCharAt ( size_t  index)

This method deletes a character from this string.

Parameters
indexThe zero-based index of the position of the character.

◆ deleteCharRangeAt()

void jm::String::deleteCharRangeAt ( size_t  index,
size_t  length 
)

This method deletes a section from this string.

Parameters
indexThe zero-based index of the starting position.
lengthThe 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.

◆ endsWith()

bool jm::String::endsWith ( const String another) const

This method checks if the end of this string matches another string.

Parameters
anotherThe string to be checked.
Returns
Returns true if this string ends with the specified string, otherwise false. If the specified string is longer than this string, false is always returned.

◆ equals() [1/2]

bool jm::String::equals ( const Object other) const
overridevirtual

Comparison of objects.

Parameters
otherThe object to compare with.

Reimplemented from jm::Object.

◆ equals() [2/2]

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.

Parameters
anotherThe string to compare with.
Returns
Returns true if both strings are identical, otherwise false. For example, "abc" == "abc" is true, but "aBc" == "abc" is false.

◆ equalsIgnoreCase()

bool jm::String::equalsIgnoreCase ( const String another) const

This method checks if this string is identical to another string, ignoring case.

Parameters
anotherThe string to compare with.
Returns
Returns true if both strings are identical, ignoring case, otherwise false. For example, "abc" == "abc" is true, but "aBc" == "abc" is also true.

◆ hashCode()

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.

Returns
The hash code for this string.

◆ indexOf() [1/4]

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.

Parameters
characterThe character to search for.
Returns
Returns the zero-based index, or -1 if the character is not found in the string.

This method searches for the first occurrence of the desired character in the string and returns its zero-based position.

◆ indexOf() [2/4]

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.

Parameters
characterThe character to search for.
fromIndexThe zero-based position to start searching from.
Returns
Returns the zero-based index, or -1 if the character is not found in the string.

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.

◆ indexOf() [3/4]

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.

Parameters
strThe string to search for.
Returns
Returns the zero-based index, or -1 if the string is not found in the string.

This method searches for the first occurrence of the desired string in the string and returns its zero-based position.

◆ indexOf() [4/4]

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.

Parameters
strThe string to search for.
fromIndexThe position to start searching from.
Returns
Returns the zero-based index, or -1 if the string is not found in the string.

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.

◆ insert() [1/2]

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.

Parameters
indexThe zero-based index of the character where the letter should be inserted.
characterThe character to be inserted.

This method inserts the character at the specified index in the string and shifts all subsequent characters to the right.

◆ insert() [2/2]

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.

Parameters
indexThe zero-based index of the character where the string should be inserted.
stringThe string to be inserted.

This method inserts the string at the specified index in the string and shifts all subsequent characters to the right.

◆ isEmpty()

bool jm::String::isEmpty ( ) const

Returns true if the string is empty. False otherwise.

◆ lastIndexOf() [1/4]

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.

Parameters
characterThe character to search for.
Returns
Returns the zero-based index, or -1 if the character is not found in the string.

◆ lastIndexOf() [2/4]

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.

Parameters
characterThe character to search for.
fromIndexThe zero-based index to start searching from (from the end).
Returns
Returns the zero-based index, or -1 if the character is not found in the string.

◆ lastIndexOf() [3/4]

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.

Parameters
strThe string to search for.
Returns
Returns the zero-based index, or -1 if the string is not found in the string.

◆ lastIndexOf() [4/4]

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.

Parameters
strThe string to search for.
fromIndexThe zero-based index to start searching from (from the end).
Returns
Returns the zero-based index, or -1 if the string is not found in the string.

◆ lineSeparator()

static String jm::String::lineSeparator ( )
static

Returns operation system dependent line separator.

◆ operator+=()

String & jm::String::operator+= ( const String another)

◆ operator=()

String & jm::String::operator= ( const String another)

◆ replace() [1/2]

String jm::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.

Parameters
oldCharThe old character to be replaced.
newCharThe new character to replace the old character.
Returns
The string with the replacements.

This method replaces occurrences of the "old" character with the "new" character in the string.

◆ replace() [2/2]

String jm::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.

Parameters
oldStrThe substring to be replaced.
newStrThe substring to replace the old substring.
Returns
The string with the replacements.

This method replaces occurrences of the "oldStr" substring with the "newStr" substring in the string.

◆ reverse()

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.

◆ setCharAt()

void jm::String::setCharAt ( size_t  index,
Char  character 
)

This method replaces a character in the string with a new one.

Parameters
indexThe zero-based index of the character to be replaced.
characterThe character to be inserted.

This method replaces the character at the specified index in the string with the new character.

◆ setConsoleCharset()

static void jm::String::setConsoleCharset ( Charset cs)
static

◆ size()

size_t jm::String::size ( ) const

Returns the size of the string.

◆ split()

StringList jm::String::split ( Char  character) const

Splits the string into a list of strings, using the specified character as a separator.

Parameters
characterThe character to use as a separator.
Returns
A list of strings resulting from the split operation.

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.

◆ startsWith()

bool jm::String::startsWith ( const String another) const

This method checks if the beginning of this string matches another string.

Parameters
anotherThe string to be checked.
Returns
Returns true if this string starts with the specified string, otherwise false. If the specified string is longer than this string, false is always returned.

◆ substring() [1/2]

String jm::String::substring ( size_t  beginIndex) const

This method creates a substring that consists of a portion of this string.

Parameters
beginIndexThe zero-based index of the first character to be included in the new substring.
Returns
A new string that starts from the beginIndex and goes until the end of the string.

◆ substring() [2/2]

String jm::String::substring ( size_t  beginIndex,
size_t  endIndex 
) const

This method creates a substring that consists of a portion of this string.

Parameters
beginIndexThe zero-based index of the first character to be included in the new substring.
endIndexThe zero-based index of the first character that should not be included in the new substring.
Returns
A new string that starts from the beginIndex and ends one character before the endIndex.

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.

◆ toBool()

bool jm::String::toBool ( ) const

Returns a boolean representation of the string.

◆ toCString() [1/2]

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

◆ toCString() [2/2]

ByteArray jm::String::toCString ( Charset charset) const

This method generates a C-string from the string, taking into account the specified character encoding.

Parameters
charsetThe character encoding to use for encoding the string into the C-string.

The generated C-string must be freed by the application later (delete).

◆ toDouble()

double jm::String::toDouble ( ) const

Returns a double representation of the string.

◆ toInt()

int64 jm::String::toInt ( ) const

Returns a int representation of the string.

◆ toLowerCase()

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.

Returns
A new string with all uppercase letters replaced by lowercase letters.

◆ toSize()

size_t jm::String::toSize ( ) const

Returns a size_t representation of the string.

◆ toUpperCase()

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.

Returns
A new string with all lowercase letters replaced by uppercase letters.

◆ toWString()

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

◆ trim()

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.

Returns
A new string with all non-visible text characters (whitespaces) removed from the beginning and end.

◆ valueOf() [1/7]

static String jm::String::valueOf ( bool  value)
static

Converts a bool value into a string.

Parameters
valueThe value.
Returns
"true" if true and "false" if false.

◆ valueOf() [2/7]

static String jm::String::valueOf ( double  number)
static

Converts a double into a string.

Parameters
numberThe double value.
Returns
A string representing the double value. eg. "12.23" or "24.0".

◆ valueOf() [3/7]

static String jm::String::valueOf ( double  number,
int64  precision,
bool  trunc 
)
static

Converts the double to decimal String.

Parameters
numberThe double value.
precisionNumber of digits after .
truncTruncate trailing 0 ?

◆ valueOf() [4/7]

static String jm::String::valueOf ( int32  number)
static

◆ valueOf() [5/7]

static String jm::String::valueOf ( int64  number)
static

Converts a integer into a string.

Parameters
numberThe value
Returns
A String representing the int value. eg. "12" or "24".

◆ valueOf() [6/7]

static String jm::String::valueOf ( uint32  number)
static

◆ valueOf() [7/7]

static String jm::String::valueOf ( uint64  number)
static

◆ zero()

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.

Friends And Related Symbol Documentation

◆ operator!=

DllExport friend bool operator!= ( String const &  v1,
String const &  v2 
)
friend

◆ operator+ [1/11]

DllExport friend String operator+ ( const char *&  left,
const String right 
)
friend

◆ operator+ [2/11]

DllExport friend String operator+ ( const double &  left,
const String right 
)
friend

◆ operator+ [3/11]

DllExport friend String operator+ ( const int64 &  left,
const String right 
)
friend

◆ operator+ [4/11]

DllExport friend String operator+ ( const int8 &  left,
const String right 
)
friend

◆ operator+ [5/11]

DllExport friend String operator+ ( const jm::Char left,
const String right 
)
friend

◆ operator+ [6/11]

DllExport friend String operator+ ( const String left,
const char *&  right 
)
friend

◆ operator+ [7/11]

DllExport friend String operator+ ( const String left,
const double &  right 
)
friend

◆ operator+ [8/11]

DllExport friend String operator+ ( const String left,
const int64 &  right 
)
friend

◆ operator+ [9/11]

DllExport friend String operator+ ( const String left,
const int8 &  right 
)
friend

◆ operator+ [10/11]

DllExport friend String operator+ ( const String left,
const jm::Char right 
)
friend

◆ operator+ [11/11]

DllExport friend String operator+ ( const String left,
const String right 
)
friend

◆ operator<

DllExport friend bool operator< ( const String left,
const String right 
)
friend

◆ operator<< [1/10]

DllExport friend std::ostream & operator<< ( std::ostream &  out,
const String str 
)
friend

◆ operator<< [2/10]

DllExport friend String & operator<< ( String out,
const char &  c 
)
friend

◆ operator<< [3/10]

DllExport friend String & operator<< ( String out,
const Char c 
)
friend

◆ operator<< [4/10]

DllExport friend String & operator<< ( String out,
const double &  d 
)
friend

◆ operator<< [5/10]

DllExport friend String & operator<< ( String out,
const int32 &  i 
)
friend

◆ operator<< [6/10]

DllExport friend String & operator<< ( String out,
const int64 &  i 
)
friend

◆ operator<< [7/10]

DllExport friend String & operator<< ( String out,
const int64 &  i 
)
friend

◆ operator<< [8/10]

DllExport friend String & operator<< ( String out,
const String str 
)
friend

◆ operator<< [9/10]

DllExport friend String & operator<< ( String out,
const uint32 &  i 
)
friend

◆ operator<< [10/10]

DllExport friend String & operator<< ( String out,
const uint64 &  i 
)
friend

◆ operator==

DllExport friend bool operator== ( String const &  v1,
String const &  v2 
)
friend

◆ operator>>

DllExport friend std::istream & operator>> ( std::istream &  in,
String str 
)
friend