added functions for base64 en/decoding (replaces patch 1739431)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47282 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-07-10 01:51:43 +00:00
parent 0514c6a202
commit 4db03d266b
16 changed files with 14342 additions and 14120 deletions

View File

@@ -37,6 +37,8 @@ the corresponding topic.
\helpref{wxASSERT\_MSG}{wxassertmsg}\\
\helpref{wxAtomicDec}{wxatomicdec}\\
\helpref{wxAtomicInc}{wxatomicinc}\\
\helpref{wxBase64Decode}{wxbase64decode}\\
\helpref{wxBase64Encode}{wxbase64encode}\\
\helpref{wxBeginBusyCursor}{wxbeginbusycursor}\\
\helpref{wxBell}{wxbell}\\
\helpref{wxBITMAP}{wxbitmapmacro}\\
@@ -2839,6 +2841,111 @@ The clipboard must have previously been opened for this call to succeed.
\section{Miscellaneous functions}\label{miscellany}
\membersection{wxBase64Decode}\label{wxbase64decode}
\func{size\_t}{wxBase64Decode}{\param{void *}{dst}, \param{size\_t}{dstLen},\\
\param{const char * }{src}, \param{size\_t }{srcLen = wxNO\_LEN},\\
\param{wxBase64DecodeMode }{mode = wxBase64DecodeMode\_Strict},\\
\param{size\_t }{*posErr = \NULL}}
\func{wxMemoryBuffer}{wxBase64Decode}{\\
\param{const char * }{src}, \param{size\_t }{srcLen = wxNO\_LEN},\\
\param{wxBase64DecodeMode }{mode = wxBase64DecodeMode\_Strict},\\
\param{size\_t }{*posErr = \NULL}}
These function decode a Base64-encoded string. The first version is a raw
decoding function and decodes the data into the provided buffer \arg{dst} of
the given size \arg{dstLen}. An error is returned if the buffer is not large
enough -- that is not at least \helpref{wxBase64DecodedSize(srcLen)}{wxbase64decodedsize}
bytes. The second version allocates memory internally and returns it as
\helpref{wxMemoryBuffer}{wxmemorybuffer} and is recommended for normal use.
The first version returns the number of bytes written to the buffer or the
necessary buffer size if \arg{dst} was \NULL or \texttt{wxCONV\_FAILED} on
error, e.g. if the output buffer is too small or invalid characters were
encountered in the input string. The second version returns a buffer with the
base64 decoded binary equivalent of the input string. In neither case is the
buffer NUL-terminated.
\wxheading{Parameters}
\docparam{dst}{Pointer to output buffer, may be \NULL to just compute the
necessary buffer size.}
\docparam{dstLen}{The size of the output buffer, ignored if \arg{dst} is
\NULL.}
\docparam{src}{The input string, must not be \NULL.}
\docparam{srcLen}{The length of the input string or special value
\texttt{wxNO\_LEN} if the string is \NUL-terminated and the length should be
computed by this function itself.}
\docparam{mode}{This parameter specifies the function behaviour when invalid
characters are encountered in input. By default, any such character stops the
decoding with error. If the mode is wxBase64DecodeMode\_SkipWS, then the white
space characters are silently skipped instead. And if it is
wxBase64DecodeMode\_Relaxed, then all invalid characters are skipped.}
\docparam{posErr}{If this pointer is non-\NULL and an error occurs during
decoding, it is filled with the index of the invalid character.}
\wxheading{Include files}
<wx/base64.h>
\membersection{wxBase64DecodedSize}\label{wxbase64decodedsize}
\func{size\_t}{wxBase64DecodedSize}{\param{size\_t }{srcLen}}
Returns the size of the buffer necessary to contain the data encoded in a
base64 string of length \arg{srcLen}. This can be useful for allocating a
buffer to be passed to \helpref{wxBase64Decode}{wxbase64decode}.
\membersection{wxBase64Encode}\label{wxbase64encode}
\func{size\_t}{wxBase64Encode}{\param{char *}{dst}, \param{size\_t}{dstLen},\\
\param{const void *}{src}, \param{size\_t }{srcLen}}
\func{wxString}{wxBase64Encode}{\param{const void *}{src}, \param{size\_t}{srcLen}}
\func{wxString}{wxBase64Encode}{\param{const wxMemoryBuffer\& }{buf}}
These functions encode the given data using base64. The first of them is the
raw encoding function writing the output string into provided buffer while the
other ones return the output as wxString. There is no error return for these
functions except for the first one which returns \texttt{wxCONV\_FAILED} if the
output buffer is too small. To allocate the buffer of the correct size, use
\helpref{wxBase64EncodedSize}{wxbase64encodedsize} or call this function with
\arg{dst} set to \NULL -- it will then return the necessary buffer size.
\wxheading{Parameters}
\docparam{dst}{The output buffer, may be \NULL to retrieve the needed buffer
size.}
\docparam{dstLen}{The output buffer size, ignored if \arg{dst} is \NULL.}
\docparam{src}{The input buffer, must not be \NULL.}
\docparam{srcLen}{The length of the input data.}
\wxheading{Include files}
<wx/base64.h>
\membersection{wxBase64EncodedSize}\label{wxbase64encodedsize}
\func{size\_t}{wxBase64EncodedSize}{\param{size\_t}{len}}
Returns the length of the string with base64 representation of a buffer of
specified size \arg{len}. This can be useful for allocating the buffer passed
to \helpref{wxBase64Encode}{wxbase64encode}.
\membersection{wxCONCAT}\label{wxconcat}
\func{}{wxCONCAT}{\param{}{x}, \param{}{y}}