Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXString Class Reference

FXString provides essential string manipulation capabilities in FOX. More...

#include <FXString.h>

List of all members.

Public Member Functions

 FXString ()
 Construct empty string.
 FXString (const FXString &s)
 Construct copy of another string.
 FXString (const FXchar *s)
 Construct and init from string.
 FXString (const FXnchar *s)
 Construct and init from narrow character string.
 FXString (const FXwchar *s)
 Construct and init from wide character string.
 FXString (const FXchar *s, FXint n)
 Construct and init with substring.
 FXString (const FXnchar *s, FXint n)
 Construct and init with narrow character substring.
 FXString (const FXwchar *s, FXint n)
 Construct and init with wide character substring.
 FXString (FXchar c, FXint n)
 Construct and fill with constant.
FXint length () const
 Length of text in bytes.
void length (FXint len)
 Change the length of the string to len.
FXwchar wc (FXint p) const
 Return wide character starting at offset p.
FXint inc (FXint p) const
 Increment byte offset by one utf8 character.
FXint inc (FXint p, FXint n) const
 Increment byte offset by n utf8 characters.
FXint dec (FXint p) const
 Decrement byte offset by one utf8 character.
FXint dec (FXint p, FXint n) const
 Decrement byte offset by n utf8 characters.
FXint extent (FXint p) const
 Return extent of utf8 character at position.
FXint count () const
 Count number of utf8 characters.
FXint count (FXint start, FXint end) const
 Count number of utf8 characters in subrange start...end.
FXint offset (FXint indx) const
 Return byte offset of utf8 character at index.
FXint index (FXint offs) const
 Return index of utf8 character at byte offset.
FXint validate (FXint p) const
 Validate position to point to begin of utf8 character.
FXchar * text ()
 Get text contents.
const FXchar * text () const
FXbool empty () const
 See if string is empty.
FXbool operator! () const
 See if string is empty.
FXchar & operator[] (FXint i)
 Return a non-const reference to the ith character.
const FXchar & operator[] (FXint i) const
 Return a const reference to the ith character.
FXchar & at (FXint i)
 Return a non-const reference to the ith character.
const FXchar & at (FXint i) const
 Return a const reference to the ith character.
FXchar & head ()
 Return a non-const reference to the first character.
const FXchar & head () const
 Return a const reference to the first character.
FXchar & tail ()
 Return a non-const reference to the last character.
const FXchar & tail () const
 Return a const reference to the last character.
FXStringoperator= (const FXchar *s)
 Assign a constant string to this string.
FXStringoperator= (const FXnchar *s)
 Assign a narrow character string to this string.
FXStringoperator= (const FXwchar *s)
 Assign a wide character string to this string.
FXStringoperator= (const FXString &s)
 Assign another string to this string.
FXStringoperator+= (FXchar c)
 Append single character to this string.
FXStringoperator+= (const FXchar *s)
 Append constant string after this string.
FXStringoperator+= (const FXnchar *s)
 Append narrow character string after this string.
FXStringoperator+= (const FXwchar *s)
 Append wide characeter string after this string.
FXStringoperator+= (const FXString &s)
 Append another string after this string.
FXStringadopt (FXString &s)
 Adopt string s, leaving s empty.
FXStringassign (FXchar c)
 Assign character c to this string.
FXStringassign (FXchar c, FXint n)
 Assign n characters c to this string.
FXStringassign (const FXchar *s, FXint n)
 Assign first n characters of string s to this string.
FXStringassign (const FXnchar *s, FXint n)
 Assign first n characters of narrow character string s to this string.
FXStringassign (const FXwchar *s, FXint n)
 Assign first n characters of wide character string s to this string.
FXStringassign (const FXchar *s)
 Assign string s to this string.
FXStringassign (const FXnchar *s)
 Assign narrow character string s to this string.
FXStringassign (const FXwchar *s)
 Assign wide character string s to this string.
FXStringassign (const FXString &s)
 Assign string s to this string.
FXStringinsert (FXint pos, FXchar c)
 Insert character at specified position.
FXStringinsert (FXint pos, FXchar c, FXint n)
 Insert n characters c at specified position.
FXStringinsert (FXint pos, const FXchar *s, FXint n)
 Insert first n characters of string at specified position.
FXStringinsert (FXint pos, const FXnchar *s, FXint n)
 Insert first n characters of narrow character string at specified position.
FXStringinsert (FXint pos, const FXwchar *s, FXint n)
 Insert first n characters of wide character string at specified position.
FXStringinsert (FXint pos, const FXchar *s)
 Insert string at specified position.
FXStringinsert (FXint pos, const FXnchar *s)
 Insert narrow character string at specified position.
FXStringinsert (FXint pos, const FXwchar *s)
 Insert wide character string at specified position.
FXStringinsert (FXint pos, const FXString &s)
 Insert string at specified position.
FXStringprepend (FXchar c)
 Prepend string with input character.
FXStringprepend (FXchar c, FXint n)
 Prepend string with n characters c.
FXStringprepend (const FXchar *s, FXint n)
 Prepend first n characters of string s.
FXStringprepend (const FXnchar *s, FXint n)
 Prepend first n characters of narrow character string s.
FXStringprepend (const FXwchar *s, FXint n)
 Prepend first n characters of wide character string s.
FXStringprepend (const FXchar *s)
 Prepend string with string s.
FXStringprepend (const FXnchar *s)
 Prepend string with narrow character string.
FXStringprepend (const FXwchar *s)
 Prepend string with wide character string.
FXStringprepend (const FXString &s)
 Prepend string with string s.
FXStringappend (FXchar c)
 Append character c to this string.
FXStringappend (FXchar c, FXint n)
 Append n characters c to this string.
FXStringappend (const FXchar *s, FXint n)
 Append first n characters of string s to this string.
FXStringappend (const FXnchar *s, FXint n)
 Append first n characters of narrow character string s to this string.
FXStringappend (const FXwchar *s, FXint n)
 Append first n characters of wide character string s to this string.
FXStringappend (const FXchar *s)
 Append string s to this string.
FXStringappend (const FXnchar *s)
 Append narrow character string s to this string.
FXStringappend (const FXwchar *s)
 Append wide character string s to this string.
FXStringappend (const FXString &s)
 Append string s to this string.
FXStringreplace (FXint pos, FXchar c)
 Replace a single character.
FXStringreplace (FXint pos, FXint r, FXchar c, FXint n)
 Replace the r characters at pos with n characters c.
FXStringreplace (FXint pos, FXint r, const FXchar *s, FXint n)
 Replaces the r characters at pos with first n characters of string s.
FXStringreplace (FXint pos, FXint r, const FXnchar *s, FXint n)
 Replaces the r characters at pos with first n characters of narrow character string s.
FXStringreplace (FXint pos, FXint r, const FXwchar *s, FXint n)
 Replaces the r characters at pos with first n characters of wide character string s.
FXStringreplace (FXint pos, FXint r, const FXchar *s)
 Replace the r characters at pos with string s.
FXStringreplace (FXint pos, FXint r, const FXnchar *s)
 Replace the r characters at pos with narrow character string s.
FXStringreplace (FXint pos, FXint r, const FXwchar *s)
 Replace the r characters at pos with wide character string s.
FXStringreplace (FXint pos, FXint r, const FXString &s)
 Replace the r characters at pos with string s.
FXStringmove (FXint dst, FXint src, FXint n)
 Move range of m characters from src position to dst position.
FXStringerase (FXint pos)
 Remove one character.
FXStringerase (FXint pos, FXint n)
 Remove substring.
FXStringtrunc (FXint pos)
 Truncate string at pos.
FXStringclear ()
 Clear.
FXint contains (FXchar ch) const
 Return number of occurrences of ch in string.
FXint contains (const FXchar *sub, FXint n) const
 Return number of occurrences of string sub in string.
FXint contains (const FXchar *sub) const
 Return number of occurrences of string sub in string.
FXint contains (const FXString &sub) const
 Return number of occurrences of string sub in string.
FXStringsubstitute (FXchar org, FXchar sub, FXbool all=true)
 Substitute one character by another.
FXStringsubstitute (const FXchar *org, FXint olen, const FXchar *rep, FXint rlen, FXbool all=true)
 Substitute one string by another.
FXStringsubstitute (const FXchar *org, const FXchar *rep, FXbool all=true)
 Substitute one string by another.
FXStringsubstitute (const FXString &org, const FXString &rep, FXbool all=true)
 Substitute one string by another.
FXStringlower ()
 Convert to lower case.
FXStringupper ()
 Convert to upper case.
FXStringsimplify ()
 Simplify whitespace in string.
FXStringtrim ()
 Remove leading and trailing whitespace.
FXStringtrimBegin ()
 Remove leading whitespace.
FXStringtrimEnd ()
 Remove trailing whitespace.
FXString left (FXint n) const
 Get left most part.
FXString right (FXint n) const
 Get right most part.
FXString mid (FXint pos, FXint n) const
 Get some part in the middle.
FXString section (FXchar delim, FXint start, FXint num=1) const
 Return num partition(s) from a given start partition in a string separated by delimiters delim.
FXString section (const FXchar *delim, FXint n, FXint start, FXint num) const
 Return num partition(s) from a given start partition in a string separated by set of delimiters from delim of size n.
FXString section (const FXchar *delim, FXint start, FXint num=1) const
 Return num partition(s) from a given start partition in a string separated by set of delimiters from delim.
FXString section (const FXString &delim, FXint start, FXint num=1) const
 Return num partition(s) from a given start partition in a string separated by set of delimiters from delim.
FXString before (FXchar ch, FXint n=1) const
 Return all characters before the n-th occurrence of ch, searching from the beginning of the string.
FXString rbefore (FXchar ch, FXint n=1) const
 Return all characters before the n-th occurrence of ch, searching from the end of the string.
FXString after (FXchar ch, FXint n=1) const
 Return all characters after the nth occurrence of ch, searching from the beginning of the string.
FXString rafter (FXchar ch, FXint n=1) const
 Return all characters after the nth occurrence of ch, searching from the end of the string.
FXint find (FXchar c, FXint pos=0) const
 Find a character, searching forward; return position or -1.
FXint rfind (FXchar c, FXint pos=2147483647) const
 Find a character, searching backward; return position or -1.
FXint find (FXchar c, FXint pos, FXint n) const
 Find n-th occurrence of character, searching forward; return position or -1.
FXint rfind (FXchar c, FXint pos, FXint n) const
 Find n-th occurrence of character, searching backward; return position or -1.
FXint find (const FXchar *substr, FXint n, FXint pos) const
 Find a substring of length n, searching forward; return position or -1.
FXint rfind (const FXchar *substr, FXint n, FXint pos) const
 Find a substring of length n, searching backward; return position or -1.
FXint find (const FXchar *substr, FXint pos=0) const
 Find a substring, searching forward; return position or -1.
FXint rfind (const FXchar *substr, FXint pos=2147483647) const
 Find a substring, searching backward; return position or -1.
FXint find (const FXString &substr, FXint pos=0) const
 Find a substring, searching forward; return position or -1.
FXint rfind (const FXString &substr, FXint pos=2147483647) const
 Find a substring, searching backward; return position or -1.
FXint find_first_of (const FXchar *set, FXint n, FXint pos) const
 Find first character in the set of size n, starting from pos; return position or -1.
FXint find_first_of (const FXchar *set, FXint pos=0) const
 Find first character in the set, starting from pos; return position or -1.
FXint find_first_of (const FXString &set, FXint pos=0) const
 Find first character in the set, starting from pos; return position or -1.
FXint find_first_of (FXchar c, FXint pos=0) const
 Find first character, starting from pos; return position or -1.
FXint find_last_of (const FXchar *set, FXint n, FXint pos) const
 Find last character in the set of size n, starting from pos; return position or -1.
FXint find_last_of (const FXchar *set, FXint pos=2147483647) const
 Find last character in the set, starting from pos; return position or -1.
FXint find_last_of (const FXString &set, FXint pos=2147483647) const
 Find last character in the set, starting from pos; return position or -1.
FXint find_last_of (FXchar c, FXint pos=0) const
 Find last character, starting from pos; return position or -1.
FXint find_first_not_of (const FXchar *set, FXint n, FXint pos) const
 Find first character NOT in the set of size n, starting from pos; return position or -1.
FXint find_first_not_of (const FXchar *set, FXint pos=0) const
 Find first character NOT in the set, starting from pos; return position or -1.
FXint find_first_not_of (const FXString &set, FXint pos=0) const
 Find first character NOT in the set, starting from pos; return position or -1.
FXint find_first_not_of (FXchar c, FXint pos=0) const
 Find first character NOT equal to c, starting from pos; return position or -1.
FXint find_last_not_of (const FXchar *set, FXint n, FXint pos) const
 Find last character NOT in the set of size n, starting from pos; return position or -1.
FXint find_last_not_of (const FXchar *set, FXint pos=2147483647) const
 Find last character NOT in the set, starting from pos; return position or -1.
FXint find_last_not_of (const FXString &set, FXint pos=2147483647) const
 Find last character NOT in the set, starting from pos; return position or -1.
FXint find_last_not_of (FXchar c, FXint pos=0) const
 Find last character NOT equal to c, starting from pos; return position or -1.
FXint scan (const FXchar *fmt,...) const FX_SCANF(2
 Scan a string a-la scanf.
FXint FXint vscan (const FXchar *fmt, va_list args) const
FXint format (const FXchar *fmt,...) FX_PRINTF(2
 Format a string a-la printf.
FXint FXint vformat (const FXchar *fmt, va_list args)
FXint toInt (FXint base=10, FXbool *ok=NULL) const
 Convert to integer.
FXuint toUInt (FXint base=10, FXbool *ok=NULL) const
 Convert to unsigned integer.
FXlong toLong (FXint base=10, FXbool *ok=NULL) const
 Convert to long integer.
FXulong toULong (FXint base=10, FXbool *ok=NULL) const
 Convert to unsigned long integer.
FXfloat toFloat (FXbool *ok=NULL) const
 Convert to float.
FXdouble toDouble (FXbool *ok=NULL) const
 Convert to double.
FXStringfromInt (FXint number, FXint base=10)
 Convert from integer.
FXStringfromUInt (FXuint number, FXint base=10)
 Convert from unsigned integer.
FXStringfromLong (FXlong number, FXint base=10)
 Convert from long integer.
FXStringfromULong (FXulong number, FXint base=10)
 Convert from unsigned long integer.
FXStringfromFloat (FXfloat number, FXint prec=6, FXint fmt=2)
 Convert from float; fmt is 0 (no exponent), 1 (force exponent), or 2 (exponent when needed)
FXStringfromDouble (FXdouble number, FXint prec=6, FXint fmt=2)
 Convert from double; fmt is 0 (no exponent), 1 (force exponent), or 2 (exponent when needed)
FXuint hash () const
 Compute hash value of string.
 ~FXString ()
 Delete.

Static Public Member Functions

static FXString value (FXint num, FXint base=10)
 Return a string value by converting an integer number to a string, using the given number base, which must be between 2 and 16.
static FXString value (FXuint num, FXint base=10)
static FXString value (FXlong num, FXint base=10)
 Return a string value by converting a long integer number to a string, using the given number base, which must be between 2 and 16.
static FXString value (FXulong num, FXint base=10)
static FXString value (FXfloat num, FXint prec=6, FXint fmt=2)
 Return a string value by converting real number to a string, using the given procision and exponential notation mode, which may be 0 (never), 1 (always), or 2 (when needed).
static FXString value (FXdouble num, FXint prec=6, FXint fmt=2)
static FXString value (const FXchar *fmt,...) FX_PRINTF(1
 Return a string value from printf-like format arguments.
static FXString static FXString vvalue (const FXchar *fmt, va_list args)
 Return a string value from vprintf-like format arguments.
static FXuint hash (const FXchar *s)
 Compute hash value of string.

Static Public Attributes

static const FXchar null []
static const FXchar value2Digit [36]
static const FXschar digit2Value [256]
static const FXschar utfBytes [256]

Friends

FXStringswap (FXString &dst, FXString &src)
 Swap two strings.
FXAPI FXStreamoperator<< (FXStream &store, const FXString &s)
 Saving to a stream.
FXAPI FXStreamoperator>> (FXStream &store, FXString &s)
 Load from a stream.

Detailed Description

FXString provides essential string manipulation capabilities in FOX.

Internally, all strings are stored as an array of bytes preceeded by the length of the string; an end-of-string character is appended at the end, but is not included in the length of the string. An empty string is represented by unique empty-string value which comprises a length of 0, followed by an end-of-string character. Thus, it is ALWAYS safe to dereference FXString as it will never be NULL. FXString can be initialized direcly from literal strings in UTF-8 encoding, but supports automatic conversion from UTF-16 encoded ("narrow") character strings and UTF-32 encoded ("wide") character strings.


Member Function Documentation

FXString FX::FXString::after ( FXchar  ch,
FXint  n = 1 
) const

Return all characters after the nth occurrence of ch, searching from the beginning of the string.

If the character is not found, return the empty string. If n<=0, return the entire string.

FXString FX::FXString::before ( FXchar  ch,
FXint  n = 1 
) const

Return all characters before the n-th occurrence of ch, searching from the beginning of the string.

If the character is not found, return the entire string. If n<=0, return the empty string.

FXString FX::FXString::rafter ( FXchar  ch,
FXint  n = 1 
) const

Return all characters after the nth occurrence of ch, searching from the end of the string.

If the character is not found, return the entire string. If n<=0, return the empty string.

FXString FX::FXString::rbefore ( FXchar  ch,
FXint  n = 1 
) const

Return all characters before the n-th occurrence of ch, searching from the end of the string.

If the character is not found, return the empty string. If n<=0, return the entire string.


The documentation for this class was generated from the following file:

Copyright © 1997-2016 Jeroen van der Zijp