SString — A wrapper for QString (QT Unicode string implementation).
class SString { public: // types typedef Char value_type; typedef unsigned int size_type; typedef value_type & reference; typedef const value_type & const_reference; typedef value_type * iterator; typedef const value_type * const_iterator; // construct/copy/destruct SString(); SString(const SString &); SString(const value_type *, size_type); SString(const unsigned char *, size_type); SString(const char *); SString(Char); SString(const QString &); SString& operator=(const SString &); SString& operator=(const char *); ~SString(); // public member functions void resize(size_type, value_type = 0) ; void reserve(size_type = 0) ; const value_type * c_str() const; const value_type * unicode() const; const value_type * data() const; size_type length() const; reference at(size_type) ; const_reference at(size_type) const; reference operator[](size_type) ; const_reference operator[](size_type) const; bool isEmpty() const; bool empty() const; bool isNull() const; iterator begin() ; const_iterator begin() const; iterator end() ; const_iterator end() const; SString & append(const SString &) ; SString & append(const SString &, size_type, size_type) ; SString & append(const value_type *, size_type) ; SString & append(const value_type *) ; SString & append(size_type, value_type) ; void push_back(value_type) ; SString & append(const_iterator, const_iterator) ; SString & insert(size_type, const SString &) ; SString & insert(size_type, const SString &, size_type, size_type) ; SString & insert(size_type, const value_type *, size_type) ; SString & insert(size_type, const value_type *) ; SString & insert(size_type, size_type, value_type) ; iterator insert(iterator, value_type = value_type()) ; void insert(iterator, size_type, value_type) ; void insert(iterator, const_iterator, const_iterator) ; SString & erase(size_type = 0, size_type = npos) ; iterator erase(iterator) ; iterator erase(iterator, iterator) ; SString & replace(size_type, size_type, const SString &) ; SString & replace(size_type, size_type, const SString &, size_type, size_type) ; SString & replace(size_type, size_type, const value_type *, size_type) ; SString & replace(size_type, size_type, const value_type *) ; SString & replace(size_type, size_type, size_type, value_type) ; SString & replace(iterator, iterator, const SString &) ; SString & replace(iterator, iterator, const value_type *, size_type) ; SString & replace(iterator, iterator, const value_type *) ; SString & replace(iterator, iterator, size_type, value_type) ; SString & replace(iterator, iterator, const_iterator, const_iterator) ; size_type copy(value_type *, size_type, size_type = 0) const; void swap(SString &) ; size_type find(const SString &, size_type = 0) const; size_type find(const value_type *, size_type, size_type) const; size_type find(const value_type *, size_type = 0) const; size_type find(value_type, size_type = 0) const; size_type rfind(const SString &, size_type = npos) const; size_type rfind(const value_type *, size_type, size_type) const; size_type rfind(const value_type *, size_type = npos) const; size_type rfind(value_type, size_type = npos) const; size_type find_first_of(const SString &, size_type = 0) const; size_type find_first_of(const value_type *, size_type, size_type) const; size_type find_first_of(const value_type *, size_type = 0) const; size_type find_first_of(value_type, size_type = 0) const; size_type find_last_of(const SString &, size_type = npos) const; size_type find_last_of(const value_type *, size_type, size_type) const; size_type find_last_of(const value_type *, size_type = npos) const; size_type find_last_of(value_type, size_type = npos) const; size_type find_first_not_of(const SString &, size_type = 0) const; size_type find_first_not_of(const value_type *, size_type, size_type) const; size_type find_first_not_of(const value_type *, size_type = 0) const; size_type find_last_not_of(const SString &, size_type = npos) const; size_type find_last_not_of(const value_type *, size_type, size_type) const; size_type find_last_not_of(const value_type *, size_type = npos) const; size_type find_last_not_of(value_type, size_type = npos) const; SString substr(size_type = 0, size_type = npos) const; int compare(const SString &) const; int compare(size_type, size_type, const SString &) const; int compare(size_type, size_type, const value_type *, size_type) const; int compare(size_type, size_type, const SString &, size_type, size_type) const; int compare(const value_type *) const; SString operator+(const SString &) const; SString & operator+=(const SString &) ; SString & operator+=(const char *) ; SString & operator+=(const value_type &) ; char * toLatin1(char * = 0, size_type = 0) const; char * toUtf8(char * = 0, size_type = 0) const; char * toLocal8Bit(char * = 0, size_type = 0) const; short toShort(bool * = 0, int = 10) const; unsigned short toUShort(bool * = 0, int = 10) const; int toInt(bool * = 0, int = 10) const; unsigned int toUInt(bool * = 0, int = 10) const; long toLong(bool * = 0, int = 10) const; unsigned long toULong(bool * = 0, int = 10) const; float toFloat(bool * = 0) const; double toDouble(bool * = 0) const; SString lower() const; SString upper() const; SString stripWhiteSpace() const; SString simplifyWhiteSpace() const; SString left(size_type) const; SString right(size_type) const; SString mid(size_type, size_type = npos) const; operator QString() const; // public static functions SString number(long, int = 10) ; SString number(unsigned, int = 10) ; SString number(int, int = 10) ; SString number(size_type, int = 10) ; SString number(double, char = 'g', int = 6) ; static const size_type npos; };
SString
construct/copy/destructConstructs null string.
Constructs string from another string.
Construct String from Unicode buffer data with length len.
Create SString from ASCII string.
Construct SString from single Unicode character.
Construct SString from QString.
SString
public member functionsResize string to the given length; pad end with c.
ensures capacity of the string
Returns pointer to the start of Unicode data of the string (null terminated).
Returns pointer to the start of Unicode data of the string.
Returns pointer to the start of Unicode data of the string.
Returns length of the string.
Returns reference to the character at given position.
Returns reference to the character at given position.
Returns TRUE if the string is empty (has zero length).
Returns TRUE if the string is empty (has zero length).
Returns TRUE if the string is null. Note that null string is not the same as empty string (when S = "", S is empty, not null)
iterator that points to the beginning of string
const iterator that points to the beginning of string
iterator that points just beyond the end of string
const iterator that points just beyond the end of string
SString & append(const SString & str) ;
equivalent to the
operator+=(\a str)
SString & append(const SString & str, size_type pos, size_type n) ;
appends n chars from str starting at pos
SString & append(const value_type * s, size_type n) ;
appends n chars from a sequence pointed to by s
SString & append(const value_type * s) ;
appends T::length(s) chars from a sequence pointed to by s
SString & append(size_type n, value_type c) ;
appends n c characters
SString<char> s("ab"); s.append(3, 'x'); \n s.c_str() == "abxxx";
appends c character, allows std::back_inserter<E> to be used
std::istreambuf_iterator start(cin), end; \n SString<char> s; std::copy(start, end, back_inserter<char>(s));
inserts characters from cin into s until EOF is reached
SString & append(const_iterator first, const_iterator last) ;
appends sequence of elements designated by [first, last)
SString & insert(size_type pos, const SString & str) ;
inserts contents of the string str at position pos
SString & insert(size_type pos1, const SString & str, size_type pos2, size_type n) ;
n characters of str starting at pos2 will be inserted at pos //!
SString<char> s("abcd"), str("1234"); s.insert(1, str, 2, 2); s.c_str() == "a34bcd";
SString & insert(size_type pos, const value_type * s, size_type n) ;
inserts n characters pointed to by s at position pos
SString & insert(size_type pos, const value_type * s) ;
inserts T::length(s) characters pointed to by null-terminated sequence pointed to by s at position pos
SString & insert(size_type pos, size_type n, value_type c) ;
inserts n characters c at position pos
equivalent to
insert(p - begin(), 1, c)
equivalent to
insert(p - begin(), n, c)
inserts copy of sequence designated by [first, last) at position corresponding to iterator p
SString & erase(size_type pos = 0, size_type n = npos) ;
removes n characters starting at position pos
equivalent to
erase(pos - begin(), 1);
pos
erases characters in range [first, last)
first
SString & replace(size_type pos, size_type n, const SString & str) ;
replaces n chars starting at position pos by contents of str
SString & replace(size_type pos1, size_type n1, const SString & str, size_type pos2, size_type n2) ;
replaces n1 chars starting at position pos1 by sequence of chars from range str[pos2, pos2 + n2)
SString & replace(size_type pos, size_type n1, const value_type * s, size_type n2) ;
replaces n1 chars starting at position pos by sequence of chars from range [s, s + n2)
SString & replace(size_type pos, size_type n, const value_type * s) ;
replaces n chars starting at position pos by T::length(s) chars //! from null-terminated sequence pointed to by s
SString & replace(size_type pos, size_type n1, size_type n2, value_type c) ;
replaces n1 chars starting at position pos by n2 chars c
SString & replace(iterator i1, iterator i2, const SString & str) ;
replaces sequence of chars designated by [i1, i2) by contents of the string str
SString & replace(iterator i1, iterator i2, const value_type * s, size_type n) ;
replaces sequence of chars designated by [i1, i2) by sequence of chars from range [s, s + n)
SString & replace(iterator i1, iterator i2, const value_type * s) ;
replaces sequence of chars designated by [i1, i2) by T::length(s) chars from null-terminated sequence pointed by s
SString & replace(iterator i1, iterator i2, size_type n, value_type c) ;
replaces sequence of chars designated by [i1, i2) by n characters c
SString & replace(iterator i1, iterator i2, const_iterator j1, const_iterator j2) ;
replaces sequence of chars designated by [i1, i2) by sequence designated by [j1, j2)
copies n characters starting at position pos into the buffer pointed to by s
swaps contents of the string with contents of rhs
finds the occurrence of str. search starts from position pos
position where str occurs or npos if search fails
finds the occurrence of sequence [s, s + n). search starts from position pos.
position where str occurs or npos if search fails
finds the occurrence of sequence [s, s + T::length(s)). search starts from position pos.
position where str occurs or npos if search fails
finds occurrence of char c, starting from position pos
finds backward for the occurrence of str. search starts from position pos
position where str occurs or npos if search fails
finds backward the occurrence of sequence [s, s + n). search starts from position pos.
position where str occurs or npos if search fails
finds backward the occurrence of sequence [s, s + T::length(s)). search starts from position pos.
position where str occurs or npos if search fails
finds backward occurrence of char c, starting from position pos
finds the first occurrence of any character from str. search starts from position pos returns position where char occurs or npos if search fails
finds the first occurrence of any character from [s, s + n). search starts from position pos.
position where char occurs or npos if search fails
finds the first occurrence of any character from sequence [s, s + T::length(s)). search starts from position pos.
position where char occurs or npos if search fails
finds the first occurrence of char c, starting from pos
finds the last occurrence of any character from str. search starts from position pos returns position where char occurs or npos if search fails
finds the last occurrence of any char from sequence [s, s + n). /// search starts from position pos.
position where char occurs or npos if search fails
finds the last occurrence of any char from sequence [s, s + T::length(s)) search starts from position pos.
position where char occurs or npos if search fails
finds the last occurrence of char c, starting from pos
finds the first occurrence of char not from str. search starts from position pos
position where char occurs or npos otherwise
finds the first occurrence of any char not from sequence [s, s + n). search starts from position pos.
position where char occurs or npos if search fails
finds the first occurrence of any character not from sequence [s, s + T::length(s)). search starts from position pos.
position where char occurs or npos if search fails
finds the first occurrence of char that's not c, starting from pos size_type find_first_not_of(value_type c, size_type pos = 0) const; finds the last occurrence of char not from str. search starts from position pos
position where char occurs or npos otherwise
finds the last occurrence of any char not from sequence [s, s + n). search starts from position pos
position where char occurs or npos if search fails
finds the last occurrence of any character not from sequence [s, s + T::length(s)). search starts from position pos.
position where char occurs or npos if search fails
finds the last occurrence of char that's not c, starting from pos
SString substr(size_type pos = 0, size_type n = npos) const;
returns copy of n characters starting from position pos
x such that x < 0 if str is greater than *this, x == 0 if str is equal to *this, and x > 0 if str is less than this
equivalent to
SString(*this, pos, n).compare(str);
equivalent to
SString(*this, pos1, n1).compare(SString(s, n2));
equivalent to
SString(*this, pos1, n1).compare(SString(str, pos2, n2));
equivalent to
compare(SString(s));
SString operator+(const SString & rhs) const;
returns string that's concatenation of *this and rhs
SString & operator+=(const SString & s) ;
returns string that's concatenation of *this and s
SString & operator+=(const char * s) ;
returns string that's concatenation of *this and s
SString & operator+=(const value_type & c) ;
returns string that's concatenation of *this and c
Translate string to latin_1, with max size maxlen. This function always returns buf. If buf = 0, then internal static buffer is used (use with caution!)
Translate string to utf8.
Translate string to local8bit.
converts string to numbers
converts string to numbers
converts string to numbers
converts string to numbers
converts string to numbers
converts string to numbers
converts string to numbers
converts string to numbers
SString lower() const;
Returns a lowercase copy of the string.
SString upper() const;
Returns an uppercase copy of the string.
SString stripWhiteSpace() const;
Returns a string that has whitespace removed from the start and the end.
Whitespace means any character for which Char::isSpace() returns TRUE. This includes Unicode characters with decimal values 9 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR) and 32 (Space), and may also include other Unicode characters.
See also: simplifyWhiteSpace()
SString simplifyWhiteSpace() const;
Returns a string that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space.
Whitespace means any character for which Char::isSpace() returns TRUE. This includes Unicode characters with decimal values 9 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR), and 32 (Space).
See also: stripWhiteSpace()
SString left(size_type len) const;
Returns a substring that contains the len leftmost characters of the string.
The whole string is returned if len exceeds the length of the string. See also: right(), mid(), isEmpty()
SString right(size_type len) const;
Returns a string that contains the len rightmost characters of the string.
If len is greater than the length of the string then the whole string is returned.
left(), mid(), isEmpty()
SString mid(size_type index, size_type len = npos) const;
Returns a string that contains the len characters of this string, starting at position index.
Returns a null string if the string is empty or index is out of range. Returns the whole string from index if index + len exceeds the length of the string.
left(), right()