KDWinUtils
Helper library for MFC to Qt migration
|
The KString class provides a Unicode character string. More...
#include <kstring.h>
Public Member Functions | |
int | Collate (const KString &other) const |
Compares two strings according to a localized collation algorithm. | |
int | CollateNoCase (const KString &other) const |
Compares two strings according to a localized collation algorithm. | |
int | Compare (const KString &other) const |
Compares two strings (case-sensitive). | |
int | CompareNoCase (const KString &other) const |
Compares two strings (case-insensitive). | |
int | Delete (int iIndex, int nCount=1) |
Deletes a character or characters from a string starting with the character at the given index. | |
void | Empty () |
Forces a string to have 0 length. | |
int | Find (const KString &other, int iStart=0) const |
Finds a character or substring inside a larger string. | |
int | FindOneOf (const KString &charSet) const |
Searches this string for the first character that matches any character contained in charSet. | |
template<typename... Ts> | |
KString & | Format (const wchar_t *format, Ts &&...args) |
Formats the string as sprintf does. | |
bool | GetEnvironmentVariable (const KString &envVar) |
Sets the string to the value of the specified environment variable. | |
int | GetLength () const |
Returns the number of characters in a KString object. | |
int | Insert (int iIndex, const KString &string) |
Inserts a substring at the given index within the string. | |
int | Insert (int iIndex, QChar character) |
Inserts a single character at the given index within the string. | |
bool | IsEmpty () const |
Tests whether a CString object contains no characters. | |
KString () | |
KString (const CString &str) | |
KString (const QString &str) | |
KString (const std::wstring_view str) | |
KString (const wchar_t *text) | |
KString (QString &&str) noexcept | |
KString | Left (int nCount) const |
Extracts the leftmost nCount characters from this string object. | |
KString & | MakeLower () |
Converts all the characters in this string to lowercase characters. | |
KString & | MakeReverse () |
Reverses the order of the characters in the KString object. | |
KString & | MakeUpper () |
Converts all the characters in this string to uppercase characters. | |
KString | Mid (int iFirst, int nCount=-1) const |
Extracts a substring of length nCount characters from this KString object, starting at position iFirst (zero-based). | |
operator const char * () const | |
Converts to a const char * implicitly. | |
operator CString () const | |
KString & | operator+= (const char *str) |
KString & | operator+= (const CString &str) |
KString & | operator+= (const QString &str) |
KString & | operator+= (const wchar_t *str) |
KString & | operator+= (QStringView str) |
KString & | operator= (const char *str) |
KString & | operator= (const CString &str) |
KString & | operator= (const QString &str) |
KString & | operator= (const std::wstring_view str) |
KString & | operator= (const wchar_t *str) |
KString & | operator= (QString &&str) noexcept |
int | Remove (QChar chRemove) |
Removes all instances of the specified character from the string. | |
int | Replace (const KString &before, const KString &after) |
Replaces a substring by another substring. Both substrings are null-terminated. | |
int | Replace (QChar before, QChar after) |
Replaces a character by another character. | |
int | ReverseFind (QChar ch) |
Searches this KString object for the last match of a character. | |
KString | Right (int nCount) const |
Extracts the rightmost nCount characters from this string object. | |
KString | SpanExcluding (const KString &excludeChars) const |
Extracts characters from the string, starting with the first character, that aren't in the set of characters identified by excludeChars. | |
KString | SpanIncluding (const KString &includeChars) const |
Extracts characters from the string, starting with the first character, that are in the set of characters identified by includeChars. | |
CString | toCString () const |
KString | Tokenize (const KString &tokens, int &iStart) const |
Finds the next token in a target string. | |
KString & | Trim () |
Trims leading and trailing whitespace from the string. | |
KString & | Trim (const KString &charsTarget) |
Trims leading and trailing characters from the string. | |
KString & | Trim (QChar chTarget) |
Trims leading and trailing character from the string. | |
KString & | TrimLeft () |
Trims leading whitespace from the string. | |
KString & | TrimLeft (const KString &charsTarget) |
Trims leading characters from the string. | |
KString & | TrimLeft (QChar charTarget) |
Trims leading character from the string. | |
KString & | TrimRight () |
Trims trailing whitespace from the string. | |
KString & | TrimRight (const KString &charsTarget) |
Trims trailing characters from the string. | |
KString & | TrimRight (QChar charTarget) |
Trims trailing character from the string. | |
~KString () | |
Static Public Member Functions | |
template<typename T , typename... Ts> | |
static QString | FormatString (T &&format, Ts... args) |
Creates a QString by passing a format string and arguments, like CString::Format. | |
Related Symbols | |
(Note that these are not member symbols.) | |
KString | operator+ (const KString &s1, const KString &s2) |
Concatenate two strings. | |
The KString class provides a Unicode character string.
This class can replace CString (unicode or non-unicode) with the same API, and is compatible with both CString and QString.
KString::KString | ( | ) |
KString::~KString | ( | ) |
KString::KString | ( | const wchar_t * | text | ) |
KString::KString | ( | const QString & | str | ) |
|
noexcept |
KString::KString | ( | const std::wstring_view | str | ) |
|
explicit |
int KString::Collate | ( | const KString & | other | ) | const |
Compares two strings according to a localized collation algorithm.
Does a case-sensitive comparison of the strings.
int KString::CollateNoCase | ( | const KString & | other | ) | const |
Compares two strings according to a localized collation algorithm.
Does a case-insensitive comparison of the strings.
int KString::Compare | ( | const KString & | other | ) | const |
Compares two strings (case-sensitive).
int KString::CompareNoCase | ( | const KString & | other | ) | const |
Compares two strings (case-insensitive).
int KString::Delete | ( | int | iIndex, |
int | nCount = 1 ) |
Deletes a character or characters from a string starting with the character at the given index.
iIndex. | The zero-based index of the first character in the KString object to delete. |
nCount. | The number of characters to be removed. |
void KString::Empty | ( | ) |
Forces a string to have 0 length.
int KString::Find | ( | const KString & | other, |
int | iStart = 0 ) const |
Finds a character or substring inside a larger string.
int KString::FindOneOf | ( | const KString & | charSet | ) | const |
Searches this string for the first character that matches any character contained in charSet.
charSet. | String containing characters for matching. |
|
inline |
Formats the string as sprintf does.
|
static |
Creates a QString by passing a format string and arguments, like CString::Format.
bool KString::GetEnvironmentVariable | ( | const KString & | envVar | ) |
Sets the string to the value of the specified environment variable.
envVar. | Pointer to a null-terminated string that specifies the environment variable. |
Retrieves the value of the specified variable from the environment block of the calling process. The value is in the form of a null-terminated string of characters.
int KString::GetLength | ( | ) | const |
Returns the number of characters in a KString object.
For multibyte characters, counts each 16-bit character; that is, a lead and trail byte in one multibyte character are counted as two characters. This also known as a "surrogate pair".
int KString::Insert | ( | int | iIndex, |
const KString & | string ) |
Inserts a substring at the given index within the string.
iIndex. | The index of the character before which the insertion will take place. |
string. | The substring to be inserted. |
int KString::Insert | ( | int | iIndex, |
QChar | character ) |
Inserts a single character at the given index within the string.
iIndex. | The index of the character before which the insertion will take place. |
character. | The character to be inserted. |
bool KString::IsEmpty | ( | ) | const |
Tests whether a CString object contains no characters.
KString KString::Left | ( | int | nCount | ) | const |
Extracts the leftmost nCount characters from this string object.
KString & KString::MakeLower | ( | ) |
Converts all the characters in this string to lowercase characters.
KString & KString::MakeReverse | ( | ) |
Reverses the order of the characters in the KString object.
KString & KString::MakeUpper | ( | ) |
Converts all the characters in this string to uppercase characters.
KString KString::Mid | ( | int | iFirst, |
int | nCount = -1 ) const |
Extracts a substring of length nCount characters from this KString object, starting at position iFirst (zero-based).
If nCount isn't supplied, then the rest of the string is extracted.
|
explicit |
Converts to a const char * implicitly.
This method is used mainly for compatibility for old API or code. This method requires a QByteArray internally, to be avoided if possible.
KString::operator CString | ( | ) | const |
KString & KString::operator+= | ( | const char * | str | ) |
KString & KString::operator+= | ( | const CString & | str | ) |
KString & KString::operator+= | ( | const QString & | str | ) |
KString & KString::operator+= | ( | const wchar_t * | str | ) |
KString & KString::operator+= | ( | QStringView | str | ) |
KString & KString::operator= | ( | const char * | str | ) |
KString & KString::operator= | ( | const CString & | str | ) |
KString & KString::operator= | ( | const QString & | str | ) |
KString & KString::operator= | ( | const std::wstring_view | str | ) |
KString & KString::operator= | ( | const wchar_t * | str | ) |
|
noexcept |
int KString::Remove | ( | QChar | chRemove | ) |
Removes all instances of the specified character from the string.
Comparisons for the character are case-sensitive.
Replaces a substring by another substring. Both substrings are null-terminated.
int KString::Replace | ( | QChar | before, |
QChar | after ) |
Replaces a character by another character.
int KString::ReverseFind | ( | QChar | ch | ) |
Searches this KString object for the last match of a character.
KString KString::Right | ( | int | nCount | ) | const |
Extracts the rightmost nCount characters from this string object.
Extracts characters from the string, starting with the first character, that aren't in the set of characters identified by excludeChars.
If no character from excludeChars is found in the string, then returns the entire string.
Extracts characters from the string, starting with the first character, that are in the set of characters identified by includeChars.
If the first character of the string isn't in the character set, then SpanIncluding returns an empty string. Otherwise, it returns a sequence of consecutive characters that are in the set.
CString KString::toCString | ( | ) | const |
Finds the next token in a target string.
tokens. | A string containing token delimiters. The order of these delimiters isn't important. |
iStart. | The zero-based index to begin the search. |
KString & KString::Trim | ( | ) |
Trims leading and trailing whitespace from the string.
Trims leading and trailing characters from the string.
KString & KString::Trim | ( | QChar | chTarget | ) |
Trims leading and trailing character from the string.
KString & KString::TrimLeft | ( | ) |
Trims leading whitespace from the string.
Trims leading characters from the string.
KString & KString::TrimLeft | ( | QChar | charTarget | ) |
Trims leading character from the string.
KString & KString::TrimRight | ( | ) |
Trims trailing whitespace from the string.
Trims trailing characters from the string.
KString & KString::TrimRight | ( | QChar | charTarget | ) |
Trims trailing character from the string.