\section{\class{wxString}}\label{wxstring} \wxheading{Derived from} None \wxheading{See also} \overview{Overview}{wxstringoverview} \latexignore{\rtfignore{\wxheading{Members}}} \membersection{wxString::wxString}\label{wxstringconstruct} \func{}{wxString}{\void} Default constructor. \func{}{wxString}{\param{const wxString\&}{ x}} Copy constructor. \func{}{wxString}{\param{char}{ ch}, \param{size\_t}{ n = 1}} Constructs a string of {\it n} copies of character {\it ch}. \func{}{wxString}{\param{const char*}{ psz}, \param{size\_t}{ nLength = STRING\_MAXLEN}} Takes first {\it nLength} characters from the C string {\it psz}. The default value of STRING\_MAXLEN means take all the string. \func{}{wxString}{\param{const unsigned char*}{ psz}, \param{size\_t}{ nLength = STRING\_MAXLEN}} For compilers using unsigned char: takes first {\it nLength} characters from the C string {\it psz}. The default value of STRING\_MAXLEN means take all the string. \func{}{wxString}{\param{const wchar\_t*}{ psz}} Constructs a string from the wide (UNICODE) string. \membersection{wxString::\destruct{wxString}}\label{wxstringdestruct} \func{}{\destruct{wxString}}{\void} String destructor. Note that this is not virtual, so wxString must not be inherited from. \membersection{wxString::Alloc}\label{wxstringAlloc} \func{void}{Alloc}{\param{uint}{ newsize}} Preallocate some space for wxString. Only works if the data of this string is not shared. \membersection{wxString::Append}\label{wxstringAppend} \func{wxString\&}{Append}{\param{const char*}{ psz}} Concatenates {\it psz} to this string, returning a reference to it. \func{wxString\&}{Append}{\param{char}{ ch}, \param{int}{ count = 1}} Concatenates character {\it ch} to this string, {\it count} times, returning a reference to it. \membersection{wxString::After}\label{wxstringAfter} \constfunc{wxString}{After}{\param{char}{ ch}} Gets all the characters after the first occurence of {\it ch}. Returns the empty string if {\it ch} is not found. \membersection{wxString::Before}\label{wxstringBefore} \constfunc{wxString}{Before}{\param{char}{ ch}} Gets all characters before the last occurence of {\it ch}. Returns empty string if {\it ch} is not found. \membersection{wxString::CompareTo}\label{wxstringCompareTo} \begin{verbatim} #define NO_POS ((int)(-1)) // undefined position enum caseCompare {exact, ignoreCase}; \end{verbatim} \constfunc{int}{CompareTo}{\param{const char*}{ psz}, \param{caseCompare}{ cmp = exact}} Case-sensitive comparison. Returns 0 if equal, 1 if greater or -1 if less. \membersection{wxString::Contains}\label{wxstringContains} \func{bool}{Contains}{\param{const wxString\&}{ str}} Returns 1 if target appears anyhere in wxString; else 0. \membersection{wxString::IsEmpty}\label{wxstringisempty} \constfunc{bool}{IsEmpty}{\void} \membersection{wxString::First}\label{wxstringfirst} \func{size\_t}{First}{\param{char}{ c}} \constfunc{size\_t}{First}{\param{const char*}{ psz}} \constfunc{size\_t}{First}{\param{const wxString\&}{ str}} \constfunc{size\_t}{First}{\param{const char}{ ch}} Returns first occurrence of item. \membersection{wxString::Firstchar}\label{wxstringFirstchar} \func{char}{Firstchar}{\param{void}{}} \param{ const}{} Element extraction. \membersection{wxString::Freq}\label{wxstringFreq} \func{int}{Freq}{\param{char}{ c}} \param{ const}{}\\ \func{int}{Freq}{\param{const wxString\&}{ y}} \param{ const}{}\\ \func{int}{Freq}{\param{const wxSubString\&}{ y}} \param{ const}{}\\ \func{int}{Freq}{\param{const char*}{ t}} \param{ const}{} Return number of occurrences of target in wxString. \membersection{wxString::From}\label{wxstringFrom} \func{wxSubString}{From}{\param{int}{ pos}}\\ \func{wxSubString}{From}{\param{const wxString\&}{ x}, \param{int}{ startpos = 0}}\\ \func{wxSubString}{From}{\param{const wxSubString\&}{ x}, \param{int}{ startpos = 0}}\\ \func{wxSubString}{From}{\param{const char*}{ t}, \param{int}{ startpos = 0}}\\ \func{wxSubString}{From}{\param{char}{ c}, \param{int}{ startpos = 0}}\\ \func{wxSubString}{From}{\param{const wxRegex\&}{ r}, \param{int}{ startpos = 0}} \membersection{wxString::GetData}\label{wxstringGetData} \func{char*}{GetData}{\param{void}{}} wxWindows compatibility conversion. \membersection{wxString::GSub}\label{wxstringGSub} \func{int}{GSub}{\param{const wxString\&}{ pat}, \param{const wxString\&}{ repl}}\\ \func{int}{GSub}{\param{const wxSubString\&}{ pat}, \param{const wxString\&}{ repl}}\\ \func{int}{GSub}{\param{const char*}{ pat}, \param{const wxString\&}{ repl}}\\ \func{int}{GSub}{\param{const char*}{ pat}, \param{const char*}{ repl}}\\ \func{int}{GSub}{\param{const wxRegex\&}{ pat}, \param{const wxString\&}{ repl}} Global substitution: substitute all occurrences of {\it pat} with {\it repl}, returning the number of matches. \membersection{wxString::Index}\label{wxstringIndex} \func{int}{Index}{\param{char}{ c}, \param{int}{ startpos = 0}} \param{ const}{}\\ \func{int}{Index}{\param{const wxString\&}{ y}, \param{int}{ startpos = 0}} \param{ const}{}\\ \func{int}{Index}{\param{const wxString\&}{ y}, \param{int}{ startpos}, \param{CaseCompare}{ cmp}} \param{ const}{}\\ \func{int}{Index}{\param{const wxSubString\&}{ y}, \param{int}{ startpos = 0}} \param{ const}{}\\ \func{int}{Index}{\param{const char*}{ t}, \param{int}{ startpos = 0}} \param{ const}{}\\ \func{int}{Index}{\param{const char*}{ t}, \param{int}{ startpos}, \param{CaseCompare}{ cmp}} \param{ const}{}\\ \func{int}{Index}{\param{const wxRegex\&}{ r}, \param{int}{ startpos = 0}} \param{ const}{} Return the position of target in string, or -1 for failure. \membersection{wxString::Insert}\label{wxstringInsert} \func{wxString\&}{Insert}{\param{int}{ pos}, \param{const char*}{ s}}\\ \func{wxString\&}{Insert}{\param{int}{ pos}, \param{const wxString\&}{ s}} Insertion. \membersection{wxString::IsAscii}\label{wxstringIsAscii} \func{int}{IsAscii}{\param{void}{}} \param{ const}{} Classification (should be capital, because of ctype.h macros). \membersection{wxString::IsDefined}\label{wxstringIsDefined} \func{int}{IsDefined}{\param{void}{}} \param{ const}{} Classification (should be capital, because of ctype.h macros). \membersection{wxString::IsNull}\label{wxstringIsNull} \func{int}{IsNull}{\param{void}{}} \param{ const}{} Classification (should be capital, because of ctype.h macros). \membersection{wxString::IsNumber}\label{wxstringIsNumber} \func{int}{IsNumber}{\param{void}{}} \param{ const}{} Classification (should be capital, because of ctype.h macros). \membersection{wxString::IsWord}\label{wxstringIsWord} \func{int}{IsWord}{\param{void}{}} \param{ const}{} Classification (should be capital, because of ctype.h macros). \membersection{wxString::Last}\label{wxstringLast} \func{int}{Last}{\param{char}{ c}} \param{ const}{}\\ \func{int}{Last}{\param{const char*}{ cs}} \param{ const}{}\\ \func{int}{Last}{\param{const wxString\&}{ cs}} \param{ const}{} First or last occurrence of item. \membersection{wxString::Lastchar}\label{wxstringLastchar} \func{char}{Lastchar}{\param{void}{}} \param{ const}{} Element extraction. \membersection{wxString::Length}\label{wxstringLength} \func{unsigned int}{Length}{\param{void}{}} \param{ const}{} \membersection{wxString::LowerCase}\label{wxstringLowerCase} \func{void}{LowerCase}{\param{void}{}} \membersection{wxString::Matches}\label{wxstringMatches} \func{bool}{Matches}{\param{char}{ c}, \param{int}{ pos = 0}} \param{ const}{}\\ \func{bool}{Matches}{\param{const wxString\&}{ y}, \param{int}{ pos = 0}} \param{ const}{}\\ \func{bool}{Matches}{\param{const wxSubString\&}{ y}, \param{int}{ pos = 0}} \param{ const}{}\\ \func{bool}{Matches}{\param{const char*}{ t}, \param{int}{ pos = 0}} \param{ const}{}\\ \func{bool}{Matches}{\param{const wxRegex\&}{ r}, \param{int}{ pos = 0}} \param{ const}{} Return 1 if target appears at position {\it pos} in wxString; else 0. \membersection{wxString::OK}\label{wxstringOK} \func{int}{OK}{\param{void}{}} \param{ const}{} \membersection{wxString::Prepend}\label{wxstringPrepend} \func{wxString\&}{Prepend}{\param{const wxString\&}{ y}}\\ \func{wxString\&}{Prepend}{\param{const wxSubString\&}{ y}}\\ \func{wxString\&}{Prepend}{\param{const char*}{ t}}\\ \func{wxString\&}{Prepend}{\param{char}{ c}} Prepend. \func{wxString\&}{Prepend}{\param{char}{ c}, \param{int}{ rep=1}} Prepend {\it c}, {\it rep} times. \membersection{wxString::Readline}\label{wxstringReadline} \func{friend int}{Readline}{\param{istream\&}{ s}, \param{wxString\&}{ x}, \param{char}{ terminator = '$\backslash$n'}, \param{int}{ discard\_terminator = 1}}\\ \func{friend int}{Readline}{\param{FILE *}{ f}, \param{wxString\&}{ x}, \param{char}{ terminator = '$\backslash$n'}, \param{int}{ discard\_terminator = 1}} \membersection{wxString::Remove}\label{wxstringRemove} \func{wxString\&}{RemoveLast}{\param{void}{}}\\ \func{wxString\&}{Remove}{\param{int}{ pos}}\\ \func{wxString\&}{Remove}{\param{int}{ pos}, \param{int}{ len}} Remove {\it pos} to end of string. \membersection{wxString::Replace}\label{wxstringReplace} \func{wxString\&}{Replace}{\param{int}{ pos}, \param{int}{ n}, \param{const char*}{ s}}\\ \func{wxString\&}{Replace}{\param{int}{ pos}, \param{int}{ n}, \param{const wxString\&}{ s}} \membersection{wxString::Replicate}\label{wxstringReplicate} \func{friend wxString}{Replicate}{\param{char}{ c}, \param{int}{ n}}\\ \func{friend wxString}{Replicate}{\param{const wxString\&}{ y}, \param{int}{ n}} Replication. \membersection{wxString::Reverse}\label{wxstringReverse} \func{void}{Reverse}{\param{void}{}}\\ \func{friend wxString}{Reverse}{\param{wxString\&}{ x}} \membersection{wxString::sprintf}\label{wxstringsprintf} \func{void}{sprintf}{\param{const wxString\& }{ fmt}} Formatted assignment. We do not use the 'sprintf' constructor anymore, because with that constructor, every initialisation with a string would go through sprintf and this is not desirable, because sprintf interprets some characters. With the above function we can write: \begin{verbatim} wxString msg; msg.sprintf("Processing item %d\n", count); \end{verbatim} \membersection{wxString::Strip}\label{wxstringStrip} \begin{verbatim} enumStripType {leading = 0x1, trailing = 0x2, both = 0x3}; \end{verbatim} \func{wxSubString}{Strip}{\param{StripType}{ s = trailing}, \param{char}{ c = ' '}} Strip characterss at the front and/or end. StripType is defined for bitwise ORing. \membersection{wxString::SubString}\label{wxstringSubString} \func{wxString}{SubString}{\param{int}{ from}, \param{int}{ to}} Edward Zimmermann's additions. \membersection{wxString::Through}\label{wxstringThrough} \func{wxSubString}{Through}{\param{int}{ pos}}\\ \func{wxSubString}{Through}{\param{const wxString\&}{ x}, \param{int}{ startpos = 0}}\\ \func{wxSubString}{Through}{\param{const wxSubString\&}{ x}, \param{int}{ startpos = 0}}\\ \func{wxSubString}{Through}{\param{const char*}{ t}, \param{int}{ startpos = 0}}\\ \func{wxSubString}{Through}{\param{char}{ c}, \param{int}{ startpos = 0}}\\ \func{wxSubString}{Through}{\param{const wxRegex\&}{ r}, \param{int}{ startpos = 0}} \membersection{wxString::Upcase}\label{wxstringUpcase} \func{void}{Upcase}{\param{void}{}}\\ \func{friend wxString}{Upcase}{\param{wxString\&}{ x}} \membersection{wxString::UpperCase}\label{wxstringUpperCase} \func{void}{UpperCase}{\param{void}{}}\\ \membersection{wxString::operator $=$}\label{wxstringoperatorassign} \func{wxString\&}{operator $=$}{\param{const wxString\&}{ y}}\\ \func{wxString\&}{operator $=$}{\param{const char*}{ y}}\\ \func{wxString\&}{operator $=$}{\param{char}{ c}}\\ \func{wxString\&}{operator $=$}{\param{const wxSubString\&}{ y}} Assignment. \membersection{wxString::operator $+=$}\label{wxstringPlusEqual} \func{wxString\&}{operator $+=$}{\param{const wxString\&}{ y}}\\ \func{wxString\&}{operator $+=$}{\param{const wxSubString\&}{ y}}\\ \func{wxString\&}{operator $+=$}{\param{const char*}{ t}}\\ \func{wxString\&}{operator $+=$}{\param{char}{ c}} Concatenation. \membersection{wxString::operator []}\label{wxstringoperatorbracket} \func{char\&}{operator []}{\param{int}{ i}} Element extraction. \membersection{wxString::operator ()}\label{wxstringoperatorparenth} \func{char\&}{operator ()}{\param{int}{ i}} \membersection{wxString::operator \cinsert}\label{wxstringoperatorout} \func{friend ostream\&}{operator \cinsert}{\param{ostream\&}{ s}, \param{const wxString\&}{ x}}\\ \func{friend ostream\&}{operator \cinsert}{\param{ostream\&}{ s}, \param{const wxSubString\&}{ x}} \membersection{wxString::operator \cextract}\label{wxstringoperatorin} \func{friend istream\&}{operator \cextract}{\param{istream\&}{ s}, \param{wxString\&}{ x}} \membersection{wxString::operator const char*}\label{wxstringoperatorconstcharpt} \constfunc{}{operator const char*}{\param{void}{}} Conversion. \membersection{wxCHARARG}\label{wxstringwxCHARARG} \begin{verbatim} #define wxCHARARG(s) ((const wxString\& )(s).Chars()) \end{verbatim} Here is a very, very, very ugly macro, but it makes things more transparent in cases, where a library function requires a (const wxString\& ) argument. This is especially the case in wxWindows, where all char-arguments are (const wxString\& ) and not (const char* ). This macro should only be used in such cases and NOT to modify the internal data. The conventional way would be 'function((char*)string.Chars())'. With the wxCHARARG macro, this can be achieved by 'function(wxCHARARG(string))'. This makes it clearer that the usage should be confined to arguments. \membersection{CommonPrefix}\label{wxstringCommonPrefix} \func{friend wxString}{CommonPrefix}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y},\\ \param{int}{ startpos = 0}}\\ \membersection{CommonSuffix}\label{wxstringCommonSuffix} \func{friend wxString}{CommonSuffix}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y},\\ \param{int}{ startpos = -1}} \membersection{Compare}\label{wxstringCompare} \func{int}{Compare}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{Compare}{\param{const wxString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{Compare}{\param{const wxString\&}{ x}, \param{const char*}{ y}}\\ \func{int}{Compare}{\param{const wxSubString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{Compare}{\param{const wxSubString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{Compare}{\param{const wxSubString\&}{ x}, \param{const char*}{ y}} Case dependent comparison. Returns 0 if the match succeeded. \membersection{FCompare}\label{wxstringFCompare} \func{int}{FCompare}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}} Case independent comparison. Returns 0 if the match succeeded. \membersection{Comparison operators}\label{wxstringComparison} \func{int}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $==$}{\param{const wxString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $!=$}{\param{const wxString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $>$}{\param{const wxString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $>=$}{\param{const wxString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $<$}{\param{const wxString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $<=$}{\param{const wxString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $==$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $!=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $>$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $>=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $<$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $<=$}{\param{const wxString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $==$}{\param{const wxSubString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $!=$}{\param{const wxSubString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $>$}{\param{const wxSubString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $>=$}{\param{const wxSubString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $<$}{\param{const wxSubString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $<=$}{\param{const wxSubString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{int}{operator $==$}{\param{const wxSubString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $!=$}{\param{const wxSubString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $>$}{\param{const wxSubString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $>=$}{\param{const wxSubString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $<$}{\param{const wxSubString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $<=$}{\param{const wxSubString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{int}{operator $==$}{\param{const wxSubString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $!=$}{\param{const wxSubString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $>$}{\param{const wxSubString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $>=$}{\param{const wxSubString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $<$}{\param{const wxSubString\&}{ x}, \param{const char*}{ t}}\\ \func{int}{operator $<=$}{\param{const wxSubString\&}{ x}, \param{const char*}{ t}} \membersection{operator $+$}\label{wxstringoperatorplus} \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{const char*}{ y}}\\ \func{wxString}{operator $+$}{\param{const wxString\&}{ x}, \param{char}{ y}}\\ \func{wxString}{operator $+$}{\param{const wxSubString\&}{ x}, \param{const wxString\&}{ y}}\\ \func{wxString}{operator $+$}{\param{const wxSubString\&}{ x}, \param{const wxSubString\&}{ y}}\\ \func{wxString}{operator $+$}{\param{const wxSubString\&}{ x}, \param{const char*}{ y}}\\ \func{wxString}{operator $+$}{\param{const wxSubString\&}{ x}, \param{char}{ y}}\\ \func{wxString}{operator $+$}{\param{const char*}{ x}, \param{const wxString\&}{ y}}\\ \func{wxString}{operator $+$}{\param{const char*}{ x}, \param{const wxSubString\&}{ y}} \membersection{Join}\label{wxstringJoin} \func{friend wxString}{Join}{\param{wxString}{ src[]}, \param{int}{ n}, \param{const wxString\&}{ sep}} \membersection{Split}\label{wxstringSplit} \func{friend int}{Split}{\param{const wxString\&}{ x}, \param{wxString}{ res[]}, \param{int}{ maxn},\\ \param{const wxString\&}{ sep}}\\ \func{friend int}{Split}{\param{const wxString\&}{ x}, \param{wxString}{ res[]}, \param{int}{ maxn},\\ \param{const wxRegex\&}{ sep}}\\ Split string into array res at separators; return number of elements