sincerely Singaporean

If you have not done so, read this full tutorial on how to use SGEXTN to build an application.

SGXString

see header file

see source file

class SGXString;

part of SGEXTN module SG_Core

Unicode compatible string with language aware features

detailed description

list of all including inherited members

implementation details

preprocessor file inclusion directive: #include ‹SGXString.h›

CMake target for BuildLah: SGEXTN::SG_Core

see this link for more information about BuildLah

parent class: (none)

children classes: (none)

instance member functions

SGXString(const char* cString);

SGXString();

SGXString(char c);

SGXString(SGXChar c);

[[nodiscard]] SGXChar at(int i) const;

void cleanWhitespace() const;

[[nodiscard]] bool contains(SGXChar c) const;

[[nodiscard]] bool contains(const SGXString& s) const;

[[nodiscard]] int count(SGXChar c) const;

[[nodiscard]] int count(const SGXString& s) const;

[[nodiscard]] SGXString fillLeftToLength(int length, SGXChar fillChar) const;

[[nodiscard]] SGXString fillRightToLength(int length, SGXChar fillChar) const;

[[nodiscard]] int findFirstFromLeft(const SGXString& s) const;

[[nodiscard]] int findFirstFromLeft(SGXChar c) const;

[[nodiscard]] int findFirstFromLeftCustomStart(const SGXString& s, int start) const;

[[nodiscard]] int findFirstFromLeftCustomStart(SGXChar c, int start) const;

[[nodiscard]] int findFirstFromRight(SGXChar c) const;

[[nodiscard]] int findFirstFromRight(const SGXString& s) const;

[[nodiscard]] int findFirstFromRightCustomStart(const SGXString& s, int start) const;

[[nodiscard]] int findFirstFromRightCustomStart(SGXChar c, int start) const;

[[nodiscard]] SGXString getLowerLanguageAware() const;

[[nodiscard]] SGXString getUpperLanguageAware() const;

[[nodiscard]] int hash() const;

SGXString& insert(int pos, SGXChar c);

SGXString& insert(int pos, const SGXString& s);

[[nodiscard]] bool isASCII() const;

[[nodiscard]] bool isDigit() const;

[[nodiscard]] bool isDigitBase16() const;

[[nodiscard]] bool isEnglishAlphanumeric() const;

[[nodiscard]] bool isEnglishLetter() const;

[[nodiscard]] bool isEnglishLowercase() const;

[[nodiscard]] bool isEnglishUppercase() const;

[[nodiscard]] bool isWhitespace() const;

[[nodiscard]] int length() const;

[[nodiscard]] bool operator!=(const SGXString& x) const;

SGXString& operator+=(SGXChar x);

[[nodiscard]] SGXString operator+(const SGXString& x) const;

SGXString& operator+=(const SGXString& x);

[[nodiscard]] SGXString operator+(SGXChar x) const;

[[nodiscard]] bool operator‹(const SGXString& x) const;

[[nodiscard]] bool operator‹=(const SGXString& x) const;

[[nodiscard]] bool operator==(const SGXString& x) const;

[[nodiscard]] bool operator›(const SGXString& x) const;

[[nodiscard]] bool operator›=(const SGXString& x) const;

[[nodiscard]] double parseToDouble(bool* isValid) const;

[[nodiscard]] float parseToFloat(bool* isValid) const;

[[nodiscard]] int parseToInt(bool* isValid) const;

[[nodiscard]] int parseToIntBase16(bool* isValid) const;

[[nodiscard]] int parseToIntCustomBase(bool* isValid, int base) const;

[[nodiscard]] long long parseToLongLong(bool* isValid) const;

[[nodiscard]] long long parseToLongLongBase16(bool* isValid) const;

[[nodiscard]] long long parseToLongLongCustomBase(bool* isValid, int base) const;

[[nodiscard]] unsigned int parseToUnsignedInt(bool* isValid) const;

[[nodiscard]] unsigned int parseToUnsignedIntBase16(bool* isValid) const;

[[nodiscard]] unsigned int parseToUnsignedIntCustomBase(bool* isValid, int base) const;

[[nodiscard]] unsigned long long parseToUnsignedLongLong(bool* isValid) const;

[[nodiscard]] unsigned long long parseToUnsignedLongLongBase16(bool* isValid) const;

[[nodiscard]] unsigned long long parseToUnsignedLongLongCustomBase(bool* isValid, int base) const;

void removeLeadingTrailingWhitespace() const;

SGXString& replace(SGXChar oldChar, SGXChar newChar);

SGXString& replace(const SGXString& oldText, const SGXString& newText);

[[nodiscard]] SGLArraySGXStringsplit() const;

[[nodiscard]] SGLArraySGXStringsplitCustomSeparator(SGXChar separator) const;

[[nodiscard]] SGLArraySGXStringsplitCustomSeparator(const SGXString& separator) const;

[[nodiscard]] SGXString substring(int start, int length) const;

[[nodiscard]] SGXString substringLeft(int length) const;

[[nodiscard]] SGXString substringRight(int length) const;

void toLowerLanguageAware() const;

void toUpperLanguageAware() const;

static member functions

static SGXString doubleToString(double x);

static SGXString doubleToStringDecimalPlaces(double x, int dp);

static SGXString doubleToStringScientificNotation(double x, int sf);

static SGXString doubleToStringSignificantFigures(double x, int sf);

static SGXString floatToString(float x);

static SGXString floatToStringDecimalPlaces(float x, int dp);

static SGXString floatToStringScientificNotation(float x, int sf);

static SGXString floatToStringSignificantFigures(float x, int sf);

static SGXString intToString(int x);

static SGXString intToStringBase16(int x);

static SGXString intToStringCustomBase(int x, int base);

static SGXString longLongToString(long long x);

static SGXString longLongToStringBase16(long long x);

static SGXString longLongToStringCustomBase(long long x, int base);

static SGXString repeatChar(SGXChar c, int count);

static SGXString unsignedIntToString(unsigned int x);

static SGXString unsignedIntToStringBase16(unsigned int x);

static SGXString unsignedIntToStringCustomBase(unsigned int x, int base);

static SGXString unsignedLongLongToString(unsigned long long x);

static SGXString unsignedLongLongToStringBase16(unsigned long long x);

static SGXString unsignedLongLongToStringCustomBase(unsigned long long x, int base);

Detailed Description

SGXString is a string that can store anything in the Unicode Basic Multilingual Plane (essentially all characters you will ever need except for emojis) in a single SGXChar. It provides both string operations such as substring, string addition, and find-replace, in addition to language aware features including case conversion.

Implementation Details

wrapper of QString, with usage of SGXChar

SGXString(const char* cString);

Creates a SGXString from C string cString.

SGXString();

Creates an empty SGXString, or a "".

SGXString(char c);

Creates a SGXString containing a single character, c.

SGXString(SGXChar c);

Creates a SGXString containing a single character, c.

[[nodiscard]] SGXChar at(int i) const;

Returns the SGXChar at index i of this SGXString.

If i is out of bounds, this will crash.

void cleanWhitespace() const;

Removes leading and trailing whitespace from this SGXString and replaces all consecutive groups of whitespace characters with a single space.

Whitespace is defined by SGXChar::isWhitespace.

[[nodiscard]] bool contains(SGXChar c) const;

Returns if this SGXString contains the character c.

[[nodiscard]] bool contains(const SGXString& s) const;

Returns if this SGXString contains the substring s.

[[nodiscard]] int count(SGXChar c) const;

Returns the number of characters c in this SGXString.

[[nodiscard]] int count(const SGXString& s) const;

Returns the number of substrings s in this SGXString.

[[nodiscard]] SGXString fillLeftToLength(int length, SGXChar fillChar) const;

Returns the string formed when this SGXString is prefixed with fillChar until its length is at least length.

This SGXString is returned if its length is already more than or equal to length.

[[nodiscard]] SGXString fillRightToLength(int length, SGXChar fillChar) const;

Returns the string formed when this SGXString is postfixed with fillChar until its length is at least length.

This SGXString is returned if its length is already more than or equal to length.

[[nodiscard]] int findFirstFromLeft(const SGXString& s) const;

Returns the index of the first index of substring s found in this SGXString when searching from the left.

This returns -1 if the substring s is not in this SGXString.

[[nodiscard]] int findFirstFromLeft(SGXChar c) const;

Returns the index of the first index of character c found in this SGXString when searching from the left.

This returns -1 if the character c is not in this SGXString.

[[nodiscard]] int findFirstFromLeftCustomStart(const SGXString& s, int start) const;

Returns the index of the first index of substring s found in this SGXString when searching from the left starting at start.

This returns -1 if the substring s is not in this SGXString.

This will crash if start is out of bounds.

[[nodiscard]] int findFirstFromLeftCustomStart(SGXChar c, int start) const;

Returns the index of the first index of character c found in this SGXString when searching from the left starting at start.

This returns -1 if the character c is not in this SGXString.

This will crash if start is out of bounds.

[[nodiscard]] int findFirstFromRight(SGXChar c) const;

Returns the index of the first index of character c found in this SGXString when searching from the right.

This returns -1 if the character c is not in this SGXString.

[[nodiscard]] int findFirstFromRight(const SGXString& s) const;

Returns the index of the first index of substring s found in this SGXString when searching from the right.

This returns -1 if the substring s is not in this SGXString.

[[nodiscard]] int findFirstFromRightCustomStart(const SGXString& s, int start) const;

Returns the index of the first index of substring s found in this SGXString when searching from the right starting at start.

This returns -1 if the substring s is not in this SGXString.

This will crash if start is out of bounds.

[[nodiscard]] int findFirstFromRightCustomStart(SGXChar c, int start) const;

Returns the index of the first index of character c found in this SGXString when searching from the right starting at start.

This returns -1 if the character c is not in this SGXString.

This will crash if start is out of bounds.

[[nodiscard]] SGXString getLowerLanguageAware() const;

Returns the language aware lowercase version of this SGXString.

For a single SGXChar, use SGXChar::getLowerLanguageAware instead.

[[nodiscard]] SGXString getUpperLanguageAware() const;

Returns the language aware uppercase version of this SGXString.

For a single SGXChar, use SGXChar::getUpperLanguageAware instead.

[[nodiscard]] int hash() const;

Hash function for SGLHash.

SGXString& insert(int pos, SGXChar c);

Inserts c into this SGXString such that c will start at index pos of this SGXString after insertion, then returns a reference to this SGXString to enable expression chaining.

Out of bounds pos will crash.

SGXString& insert(int pos, const SGXString& s);

Inserts s into this SGXString such that s will start at index pos of this SGXString after insertion, then returns a reference to this SGXString to enable expression chaining.

Out of bounds pos will crash.

[[nodiscard]] bool isASCII() const;

Returns if all characters in this SGXString are ASCII characters.

For a single SGXChar, use SGXChar::isASCII instead.

[[nodiscard]] bool isDigit() const;

Returns if all characters in this SGXString are digits from 0 to 9.

For a single SGXChar, use SGXChar::isDigit instead.

[[nodiscard]] bool isDigitBase16() const;

Returns if all characters in this SGXString are base 16 digits from 0 to F.

Both uppercase and lowercase representations of non numerical base16 digits are accepted.

For a single SGXChar, use SGXChar::isDigitBase16 instead.

[[nodiscard]] bool isEnglishAlphanumeric() const;

Returns if all characters in this SGXString are alphanumeric characters.

This can be used to validate usernames and file names.

For a single SGXChar, use SGXChar::isEnglishAlphanumeric instead.

[[nodiscard]] bool isEnglishLetter() const;

Returns if all characters in this SGXString are English letters ignoring case.

For a single SGXChar, use SGXChar::isEnglishLetter instead.

[[nodiscard]] bool isEnglishLowercase() const;

Returns if all characters in this SGXString are English lowercase letters from a to z.

For a single SGXChar, use SGXChar::isEnglishLowercase instead.

[[nodiscard]] bool isEnglishUppercase() const;

Returns if all characters in this SGXString are English uppercase letters from A to Z.

For a single SGXChar, use SGXChar::isEnglishUppercase instead.

[[nodiscard]] bool isWhitespace() const;

Returns if all characters in this SGXString are whitespace characters.

Whitespace is defined by SGXChar::isWhitespace.

For a single SGXChar, use SGXChar::isWhitespace instead.

[[nodiscard]] int length() const;

Returns the length of this SGXString, which is the number of SGXChar it contains.

[[nodiscard]] bool operator!=(const SGXString& x) const;

Returns if this SGXString is different from x.

SGXString& operator+=(SGXChar x);

Appends the SGXChar x behind this SGXString.

[[nodiscard]] SGXString operator+(const SGXString& x) const;

Appends the SGXString x behind this SGXString.

SGXString& operator+=(const SGXString& x);

Appends the SGXString x behind this SGXString.

[[nodiscard]] SGXString operator+(SGXChar x) const;

Appends the SGXChar x behind this SGXString.

[[nodiscard]] bool operator‹(const SGXString& x) const;

Returns if this SGXString is in front of x when ordered alphabetically.

[[nodiscard]] bool operator‹=(const SGXString& x) const;

Returns if this SGXString is in front of or equal to x when ordered alphabetically.

[[nodiscard]] bool operator==(const SGXString& x) const;

Returns if this SGXString is the same as x.

[[nodiscard]] bool operator›(const SGXString& x) const;

Returns if this SGXString is behind x when ordered alphabetically.

[[nodiscard]] bool operator›=(const SGXString& x) const;

Returns if this SGXString is behind or equal to x when ordered alphabetically.

[[nodiscard]] double parseToDouble(bool* isValid) const;

Returns the double precision floating point number that this SGXString represents. If this SGXString does not represent a double precision floating point number, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a double precision floating point number and false otherwise.

If you are not interested in if this SGXString represents a double precision floating point number, pass nullptr to isValid.

[[nodiscard]] float parseToFloat(bool* isValid) const;

Returns the floating point number that this SGXString represents. If this SGXString does not represent a floating point number, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a floating point number and false otherwise.

If you are not interested in if this SGXString represents a floating point number, pass nullptr to isValid.

[[nodiscard]] int parseToInt(bool* isValid) const;

Returns the int that this SGXString represents. If this SGXString does not represent a int, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a int and false otherwise.

If you are not interested in if this SGXString represents a int, pass nullptr to isValid.

[[nodiscard]] int parseToIntBase16(bool* isValid) const;

Returns the int in base16 that this SGXString represents. If this SGXString does not represent a base16 int, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a base16 int and false otherwise.

If you are not interested in if this SGXString represents a base16 int, pass nullptr to isValid.

Both uppercase and lowercase represents of non numerical base16 digits are accepted.

[[nodiscard]] int parseToIntCustomBase(bool* isValid, int base) const;

Returns the int in base base that this SGXString represents. If this SGXString does not represent a base base int, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a base base int and false otherwise.

If you are not interested in if this SGXString represents a base base int, pass nullptr to isValid.

Both uppercase and lowercase represents of non numerical base base digits are accepted.

base being below 2 or above 36 is undefined behaviour.

[[nodiscard]] long long parseToLongLong(bool* isValid) const;

Returns the long long that this SGXString represents. If this SGXString does not represent a long long, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a long long and false otherwise.

If you are not interested in if this SGXString represents a long long, pass nullptr to isValid.

[[nodiscard]] long long parseToLongLongBase16(bool* isValid) const;

Returns the long long in base16 that this SGXString represents. If this SGXString does not represent a base16 long long, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a base16 long long and false otherwise.

If you are not interested in if this SGXString represents a base16 long long, pass nullptr to isValid.

Both uppercase and lowercase represents of non numerical base16 digits are accepted.

[[nodiscard]] long long parseToLongLongCustomBase(bool* isValid, int base) const;

Returns the long long in base base that this SGXString represents. If this SGXString does not represent a base base long long, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a base base long long and false otherwise.

If you are not interested in if this SGXString represents a base base long long, pass nullptr to isValid.

Both uppercase and lowercase represents of non numerical base base digits are accepted.

base being below 2 or above 36 is undefined behaviour.

[[nodiscard]] unsigned int parseToUnsignedInt(bool* isValid) const;

Returns the unsigned int that this SGXString represents. If this SGXString does not represent a unsigned int, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a unsigned int and false otherwise.

If you are not interested in if this SGXString represents a unsigned int, pass nullptr to isValid.

[[nodiscard]] unsigned int parseToUnsignedIntBase16(bool* isValid) const;

Returns the unsigned int in base16 that this SGXString represents. If this SGXString does not represent a base16 unsigned int, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a base16 unsigned int and false otherwise.

If you are not interested in if this SGXString represents a base16 unsigned int, pass nullptr to isValid.

Both uppercase and lowercase represents of non numerical base16 digits are accepted.

[[nodiscard]] unsigned int parseToUnsignedIntCustomBase(bool* isValid, int base) const;

Returns the unsigned int in base base that this SGXString represents. If this SGXString does not represent a base base unsigned int, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a base base unsigned int and false otherwise.

If you are not interested in if this SGXString represents a base base unsigned int, pass nullptr to isValid.

Both uppercase and lowercase represents of non numerical base base digits are accepted.

base being below 2 or above 36 is undefined behaviour.

[[nodiscard]] unsigned long long parseToUnsignedLongLong(bool* isValid) const;

Returns the unsigned long long that this SGXString represents. If this SGXString does not represent a unsigned long long, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a unsigned long long and false otherwise.

If you are not interested in if this SGXString represents a unsigned long long, pass nullptr to isValid.

[[nodiscard]] unsigned long long parseToUnsignedLongLongBase16(bool* isValid) const;

Returns the unsigned long long in base16 that this SGXString represents. If this SGXString does not represent a base16 unsigned long long, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a base16 unsigned long long and false otherwise.

If you are not interested in if this SGXString represents a base16 unsigned long long, pass nullptr to isValid.

Both uppercase and lowercase represents of non numerical base16 digits are accepted.

[[nodiscard]] unsigned long long parseToUnsignedLongLongCustomBase(bool* isValid, int base) const;

Returns the unsigned long long in base base that this SGXString represents. If this SGXString does not represent a base base unsigned long long, 0 is returned as default. If isValid is not nullptr, the bool that it points to is set to true if this SGXString represents a base base unsigned long long and false otherwise.

If you are not interested in if this SGXString represents a base base unsigned long long, pass nullptr to isValid.

Both uppercase and lowercase represents of non numerical base base digits are accepted.

base being below 2 or above 36 is undefined behaviour.

void removeLeadingTrailingWhitespace() const;

Removes leading and trailing whitespace from this SGXString.

Whitespace is defined by SGXChar::isWhitespace.

SGXString& replace(SGXChar oldChar, SGXChar newChar);

Replaces every instance of oldChar in this SGXString with newChar, then returns a reference to this SGXString to enable expression chaining.

If this SGXString does not contain oldChar, nothing is done.

SGXString& replace(const SGXString& oldText, const SGXString& newText);

Replaces every instance of oldText in this SGXString with newText, then returns a reference to this SGXString to enable expression chaining.

If this SGXString does not contain oldText, nothing is done.

[[nodiscard]] SGLArraySGXStringsplit() const;

Returns a SGLArray of SGXString of space separated strings that make up this SGXString.

This can be used to parse text input.

The extracted strings will not contain any space.

[[nodiscard]] SGLArraySGXStringsplitCustomSeparator(SGXChar separator) const;

Returns a SGLArray of SGXString of strings separated by character separator that make up this SGXString.

This can be used to parse text input.

The extracted strings will not contain any separator character.

[[nodiscard]] SGLArraySGXStringsplitCustomSeparator(const SGXString& separator) const;

Returns a SGLArray of SGXString of strings separated by substring separator that make up this SGXString.

This can be used to parse text input.

The extracted strings will not contain any separator substring.

[[nodiscard]] SGXString substring(int start, int length) const;

Returns the substring of this SGXString starting at start with a length of length.

This will crash if start or start + length - 1 is out of bounds.

This will crash if length is negative.

[[nodiscard]] SGXString substringLeft(int length) const;

Returns the substring of this SGXString containing the first length letters from the left.

This will crash is length is negative or greater than the length of this SGXString.

[[nodiscard]] SGXString substringRight(int length) const;

Returns the substring of this SGXString containing the first length letters from the right.

This will crash is length is negative or greater than the length of this SGXString.

void toLowerLanguageAware() const;

Converts this SGXString to its language aware lowercase form.

For a single SGXChar, use SGXChar::toLowerLanguageAware instead.

void toUpperLanguageAware() const;

Converts this SGXString to its language aware uppercase form.

For a single SGXChar, use SGXChar::toUpperLanguageAware instead.

static SGXString doubleToString(double x);

Returns the SGXString that represents x.

static SGXString doubleToStringDecimalPlaces(double x, int dp);

Returns the SGXString that represents x rounded to dp decimal places. Negative dp rounds x to nearest 10 ^ ( - dp )

static SGXString doubleToStringScientificNotation(double x, int sf);

Returns the SGXString that represents x rounds to sf significant figures, expressed in scientific notation.

The exponent is prefixed with English lowercase letter e.

Negative or zero sf will crash.

static SGXString doubleToStringSignificantFigures(double x, int sf);

Returns the SGXString that represents x rounds to sf significant figures.

Negative or zero sf will crash.

static SGXString floatToString(float x);

Returns the SGXString that represents x.

static SGXString floatToStringDecimalPlaces(float x, int dp);

Returns the SGXString that represents x rounded to dp decimal places. Negative dp rounds x to nearest 10 ^ ( - dp )

static SGXString floatToStringScientificNotation(float x, int sf);

Returns the SGXString that represents x rounds to sf significant figures, expressed in scientific notation.

The exponent is prefixed with English lowercase letter e.

Negative or zero sf will crash.

static SGXString floatToStringSignificantFigures(float x, int sf);

Returns the SGXString that represents x rounds to sf significant figures.

Negative or zero sf will crash.

static SGXString intToString(int x);

Returns the SGXString that represents x.

static SGXString intToStringBase16(int x);

Returns the SGXString that represents x in base16.

static SGXString intToStringCustomBase(int x, int base);

Returns the SGXString that represents x in base base.

static SGXString longLongToString(long long x);

Returns the SGXString that represents x.

static SGXString longLongToStringBase16(long long x);

Returns the SGXString that represents x in base16.

static SGXString longLongToStringCustomBase(long long x, int base);

Returns the SGXString that represents x in base base.

static SGXString repeatChar(SGXChar c, int count);

Returns the SGXString formed by putting together count copies of c.

Negative count will crash.

static SGXString unsignedIntToString(unsigned int x);

Returns the SGXString that represents x.

static SGXString unsignedIntToStringBase16(unsigned int x);

Returns the SGXString that represents x in base16.

static SGXString unsignedIntToStringCustomBase(unsigned int x, int base);

Returns the SGXString that represents x in base base.

static SGXString unsignedLongLongToString(unsigned long long x);

Returns the SGXString that represents x.

static SGXString unsignedLongLongToStringBase16(unsigned long long x);

Returns the SGXString that represents x in base16.

static SGXString unsignedLongLongToStringCustomBase(unsigned long long x, int base);

Returns the SGXString that represents x in base base.

©2025 05524F.sg (Singapore)

contact 05524F / report a bug / make a suggestion

about 05524F SINGAPORE values

list of 05524F projects