X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae3c17b4013e80b99976c750c19fca47729517f6..92c0fc34c104c8d7c12d6a3b78ea232690fc23f4:/interface/wx/base64.h diff --git a/interface/wx/base64.h b/interface/wx/base64.h index 3967d697b9..40ab606776 100644 --- a/interface/wx/base64.h +++ b/interface/wx/base64.h @@ -2,8 +2,7 @@ // Name: base64.h // Purpose: interface of global functions // Author: wxWidgets team -// RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -11,9 +10,20 @@ // Global functions/macros // ============================================================================ -/** @ingroup group_funcmacro_misc */ +/** @addtogroup group_funcmacro_misc */ //@{ +/** + Elements of this enum specify the possible behaviours of wxBase64Decode + when an invalid character is encountered. +*/ +enum wxBase64DecodeMode +{ + wxBase64DecodeMode_Strict, ///< Normal behaviour: stop at any invalid characters. + wxBase64DecodeMode_SkipWS, ///< Skip whitespace characters. + wxBase64DecodeMode_Relaxed ///< The most lenient behaviour: simply ignore all invalid characters. +}; + /** This function encodes the given data using base64. @@ -95,7 +105,8 @@ size_t wxBase64EncodedSize(size_t len); This overload is a raw decoding function and decodes the data into the provided buffer @a dst of the given size @e dstLen. An error is returned if the buffer is not large enough -- that is not at least - wxBase64DecodedSize(srcLen) bytes. + wxBase64DecodedSize(srcLen) bytes. Notice that the buffer will @e not be + @NULL-terminated. This overload returns the number of bytes written to the buffer or the necessary buffer size if @a dst was @NULL or @c wxCONV_FAILED on error, @@ -130,37 +141,55 @@ size_t wxBase64Decode(void* dst, size_t dstLen, const char* src, size_t srcLen = wxNO_LEN, wxBase64DecodeMode mode = wxBase64DecodeMode_Strict, - size_t posErr = NULL); + size_t *posErr = NULL); /** - See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t) - overload for more info about the parameters of this function. + Decode a Base64-encoded wxString. + + See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t*) + overload for more information about the parameters of this function, the + only difference between it and this one is that a wxString is used instead + of a @c char* pointer and its length. + + @since 2.9.1 + + @header{wx/base64.h} + */ +size_t wxBase64Decode(void* dst, size_t dstLen, + const wxString& str, + wxBase64DecodeMode mode = wxBase64DecodeMode_Strict, + size_t *posErr = NULL); - This overload allocates memory internally and returns it as wxMemoryBuffer - and is recommended for normal use. +/** + Decode a Base64-encoded string and return decoded contents in a buffer. - This overload returns a buffer with the base64 decoded binary equivalent - of the input string. In neither case is the buffer @NULL-terminated. + See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t*) + overload for more information about the parameters of this function. The + difference of this overload is that it allocates a buffer of necessary size + on its own and returns it, freeing you from the need to do it manually. + Because of this, it is simpler to use and is recommended for normal use. @header{wx/base64.h} */ wxMemoryBuffer wxBase64Decode(const char* src, size_t srcLen = wxNO_LEN, wxBase64DecodeMode mode = wxBase64DecodeMode_Strict, - size_t posErr = NULL); + size_t *posErr = NULL); /** - See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t) - overload for more info about the parameters of this function. + Decode a Base64-encoded wxString and return decoded contents in a buffer. + + See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t*) + overload for more information about the parameters of this function. This overload takes as input a wxString and returns the internally-allocated - memory as a wxMemoryBuffer, containing the base64 decoded data. + memory as a wxMemoryBuffer, containing the Base64-decoded data. @header{wx/base64.h} */ wxMemoryBuffer wxBase64Decode(const wxString& src, wxBase64DecodeMode mode = wxBase64DecodeMode_Strict, - size_t posErr = NULL); + size_t *posErr = NULL); //@}