X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/99f09bc1b9cbc93a6cc952ec2c777d999d5483d0..cd9da200285e3c625be91768c9ca61dc218c94d0:/docs/latex/wx/wxstring.tex?ds=sidebyside diff --git a/docs/latex/wx/wxstring.tex b/docs/latex/wx/wxstring.tex index a70122b4ea..0f28c18abd 100644 --- a/docs/latex/wx/wxstring.tex +++ b/docs/latex/wx/wxstring.tex @@ -1,10 +1,10 @@ \section{\class{wxString}}\label{wxstring} -wxString is a class representing a character string. Please see wxString -\helpref{overview}{wxstringoverview} for more information about it. As explained -there, wxStrign implements about 90\% of methods of std::string class (iterators -are not supported and so all methods which use them are not supported neither), -but they are not documented here - please see any source of STL documentation. +wxString is a class representing a character string. Please see the +\helpref{wxString overview}{wxstringoverview} for more information about it. As explained +there, wxString implements about 90\% of methods of the std::string class (iterators +are not supported, nor all methods which use them). +These standard functions are not documented in this manual so please see the STL documentation. The behaviour of all these functions is identical to the behaviour described there. @@ -16,6 +16,12 @@ None +\wxheading{Predefined objects} + +Objects: + +{\bf wxEmptyString} + \wxheading{See also} \overview{Overview}{wxstringoverview} @@ -56,7 +62,7 @@ release builds. This section also contains both implicit and explicit conversions to C style strings. Although implicit conversion is quite convenient, it is advised to use explicit \helpref{c\_str()}{wxstringcstr} method for the sake of clarity. Also -see \helpref{overiview}{wxstringadvices} for the cases where it is necessary to +see \helpref{overview}{wxstringadvices} for the cases where it is necessary to use it. \helpref{GetChar}{wxstringgetchar}\\ @@ -126,20 +132,45 @@ lower case and leave the original string unchanged. \membersection{Searching and replacing} -These functions replace the standard {\it strchr()} and {\it strstr()} +These functions replace the standard {\it strchr()} and {\it strstr()} functions. \helpref{Find}{wxstringfind}\\ \helpref{Replace}{wxstringreplace} +\membersection{Conversion to numbers} + +The string provides functions for conversion to signed and unsigned integer and +floating point numbers. All three functions take a pointer to the variable to +put the numeric value in and return TRUE if the {\bf entire} string could be +converted to a number. + +\helpref{ToLong}{wxstringtolong}\\ +\helpref{ToULong}{wxstringtoulong}\\ +\helpref{ToDouble}{wxstringtodouble} + \membersection{Writing values into the string} Both formatted versions (\helpref{Printf}{wxstringprintf}) and stream-like -insertion operators exist (for basic types only). +insertion operators exist (for basic types only). Additionally, the +\helpref{Format}{wxstringformat} function allows to use simply append +formatted value to a string: +\begin{verbatim} + // the following 2 snippets are equivalent + + wxString s = "..."; + s += wxString::Format("%d", n); + + wxString s; + s.Printf("...%d", n); +\end{verbatim} + +\helpref{Format}{wxstringformat}\\ +\helpref{FormatV}{wxstringformatv}\\ \helpref{Printf}{wxstringprintf}\\ \helpref{PrintfV}{wxstringprintfv}\\ -\helpref{operator \cinsert}{wxstringoperatorout) +\helpref{operator \cinsert}{wxstringoperatorout} \membersection{Memory management} @@ -188,7 +219,7 @@ functions instead of them (or, even better, std::string compatible variants). \helpref{IsNumber}{wxstringisnumber}\\ \helpref{IsWord}{wxstringisword} -\membersection{std::string compatibility functions} +\membersection{std::string compatibility functions}\label{wxstringat} The supported functions are only listed here, please see any STL reference for their documentation. @@ -457,6 +488,20 @@ Returns the whole string if {\it ch} is not found. Gets all characters before the last occurence of {\it ch}. Returns the empty string if {\it ch} is not found. +\membersection{wxString::c\_str}\label{wxstringcstr} + +\constfunc{const char *}{c\_str}{\void} + +Returns a pointer to the string data. + +\membersection{wxString::Clear}\label{wxstringclear} + +\func{void}{Clear}{\void} + +Empties the string and frees memory occupied by it. + +See also: \helpref{Empty}{wxstringempty} + \membersection{wxString::Cmp}\label{wxstringcmp} \constfunc{int}{Cmp}{\param{const char*}{ psz}} @@ -487,7 +532,7 @@ See also \helpref{Cmp}{wxstringcmp}, \helpref{IsSameAs}{wxstringissameas}. #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. @@ -502,7 +547,9 @@ Returns 1 if target appears anyhere in wxString; else 0. \func{void}{Empty}{\void} -Reinitializes the string and frees the data. +Makes the string empty, but doesn't free memory occupied by the string. + +See also: \helpref{Clear()}{wxstringclear}. \membersection{wxString::Find}\label{wxstringfind} @@ -526,6 +573,28 @@ Searches for the given string. Returns the starting index, or -1 if not found. Returns the first occurrence of the item. +\membersection{wxString::Format}\label{wxstringformat} + +\func{static wxString}{Format}{\param{const wxChar }{*format}, \param{}{...}} + +This static function returns the string containing the result of calling +\helpref{Printf}{wxstringprintf} with the passed parameters on it. + +\wxheading{See also} + +\helpref{FormatV}{wxstringformatv}, \helpref{Printf}{wxstringprintf} + +\membersection{wxString::FormatV}\label{wxstringformatv} + +\func{static wxString}{Format}{\param{const wxChar }{*format}, \param{va\_list }{argptr}} + +This static function returns the string containing the result of calling +\helpref{PrintfV}{wxstringprintfv} with the passed parameters on it. + +\wxheading{See also} + +\helpref{Format}{wxstringformat}, \helpref{PrintfV}{wxstringprintfv} + \membersection{wxString::Freq}\label{wxstringfreq} \constfunc{int}{Frec}{\param{char }{ch}} @@ -620,7 +689,18 @@ caseSensitive is TRUE by default (case matters). Returns TRUE if strings are equal, FALSE otherwise. -See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}. +See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas2} + +\membersection{wxString::IsSameAs}\label{wxstringissameas2} + +\constfunc{bool}{IsSameAs}{\param{char}{ c}, \param{bool}{ caseSensitive = TRUE}} + +Test whether the string is equal to the single character {\it c}. The test is +case-sensitive if {\it caseSensitive} is TRUE (default) or not if it is FALSE. + +Returns TRUE if the string is equal to the character, FALSE otherwise. + +See also \helpref{Cmp}{wxstringcmp}, \helpref{CmpNoCase}{wxstringcmpnocase}, \helpref{IsSameAs}{wxstringissameas} \membersection{wxString::IsWord}\label{wxstringisword} @@ -763,11 +843,6 @@ Returns the number of replacements made. Returns the last {\it count} characters. -\constfunc{wxString}{Right}{\param{char}{ ch}} - -Returns all characters after the last occurence of {\it ch}. -Returns the whole string if {\it ch} is not found. - \membersection{wxString::SetChar}\label{wxstringsetchar} \func{void}{SetChar}{\param{size\_t}{ n}, \param{char}{ch}} @@ -804,6 +879,30 @@ doesn't change this string. Same as \helpref{Mid}{wxstringmid}. +\membersection{wxString::ToDouble}\label{wxstringtodouble} + +\constfunc{bool}{To}{\param{double}{ *val}} + +Attempts to convert the string to a floating point number. Returns TRUE on +suceess (the number is stored in the location pointed to by {\it val}) or FALSE +if the string does not represent such number. + +\membersection{wxString::ToLong}\label{wxstringtolong} + +\constfunc{bool}{To}{\param{long}{ *val}} + +Attempts to convert the string to a signed integer. Returns TRUE on suceess +(the number is stored in the location pointed to by {\it val}) or FALSE if the +string does not represent such number. + +\membersection{wxString::ToULong}\label{wxstringtoulong} + +\constfunc{bool}{To}{\param{unsigned long}{ *val}} + +Attempts to convert the string to an unsigned integer. Returns TRUE on suceess +(the number is stored in the location pointed to by {\it val}) or FALSE if the +string does not represent such number. + \membersection{wxString::Trim}\label{wxstringtrim} \func{wxString\&}{Trim}{\param{bool}{ fromRight = TRUE}} @@ -962,4 +1061,3 @@ Implicit conversion to a C string. These comparisons are case-sensitive. -