1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of global functions
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
11 // Global functions/macros
12 // ============================================================================
14 /** @addtogroup group_funcmacro_misc */
18 This function encodes the given data using base64.
20 To allocate the buffer of the correct size, use wxBase64EncodedSize() or
21 call this function with @a dst set to @NULL -- it will then return the
22 necessary buffer size.
24 This raw encoding function overload writes the output string into the
25 provided buffer; the other overloads return it as a wxString.
28 The output buffer, may be @NULL to retrieve the needed buffer size.
30 The output buffer size, ignored if dst is @NULL.
32 The input buffer, must not be @NULL.
34 The length of the input data.
36 @return @c wxCONV_FAILED if the output buffer is too small.
40 size_t wxBase64Encode(char* dst
, size_t dstLen
,
45 This function encodes the given data using base64 and returns the output as
48 There is no error return.
50 To allocate the buffer of the correct size, use wxBase64EncodedSize() or
51 call this function with @a dst set to @NULL -- it will then return the
52 necessary buffer size.
55 The input buffer, must not be @NULL.
57 The length of the input data.
61 wxString
wxBase64Encode(const void* src
, size_t srcLen
);
64 This function encodes the given data using base64 and returns the output as
67 There is no error return.
71 wxString
wxBase64Encode(const wxMemoryBuffer
& buf
);
75 Returns the size of the buffer necessary to contain the data encoded in a
76 base64 string of length @e srcLen. This can be useful for allocating a
77 buffer to be passed to wxBase64Decode().
81 size_t wxBase64DecodedSize(size_t srcLen
);
84 Returns the length of the string with base64 representation of a buffer of
85 specified size @e len. This can be useful for allocating the buffer passed
90 size_t wxBase64EncodedSize(size_t len
);
93 This function decodes a Base64-encoded string.
95 This overload is a raw decoding function and decodes the data into the
96 provided buffer @a dst of the given size @e dstLen. An error is returned if
97 the buffer is not large enough -- that is not at least
98 wxBase64DecodedSize(srcLen) bytes.
100 This overload returns the number of bytes written to the buffer or the
101 necessary buffer size if @a dst was @NULL or @c wxCONV_FAILED on error,
102 e.g. if the output buffer is too small or invalid characters were
103 encountered in the input string.
106 Pointer to output buffer, may be @NULL to just compute the necessary
109 The size of the output buffer, ignored if dst is @NULL.
111 The input string, must not be @NULL. For the version using wxString,
112 the input string should contain only ASCII characters.
114 The length of the input string or special value wxNO_LEN if the string
115 is @NULL-terminated and the length should be computed by this function
118 This parameter specifies the function behaviour when invalid characters
119 are encountered in input. By default, any such character stops the
120 decoding with error. If the mode is wxBase64DecodeMode_SkipWS, then the
121 white space characters are silently skipped instead. And if it is
122 wxBase64DecodeMode_Relaxed, then all invalid characters are skipped.
124 If this pointer is non-@NULL and an error occurs during decoding, it is
125 filled with the index of the invalid character.
129 size_t wxBase64Decode(void* dst
, size_t dstLen
,
131 size_t srcLen
= wxNO_LEN
,
132 wxBase64DecodeMode mode
= wxBase64DecodeMode_Strict
,
133 size_t posErr
= NULL
);
136 See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t)
137 overload for more info about the parameters of this function.
139 This overload allocates memory internally and returns it as wxMemoryBuffer
140 and is recommended for normal use.
142 This overload returns a buffer with the base64 decoded binary equivalent
143 of the input string. In neither case is the buffer @NULL-terminated.
147 wxMemoryBuffer
wxBase64Decode(const char* src
,
148 size_t srcLen
= wxNO_LEN
,
149 wxBase64DecodeMode mode
= wxBase64DecodeMode_Strict
,
150 size_t posErr
= NULL
);
153 See the wxBase64Decode(void*,size_t,const char*,size_t,wxBase64DecodeMode,size_t)
154 overload for more info about the parameters of this function.
156 This overload takes as input a wxString and returns the internally-allocated
157 memory as a wxMemoryBuffer, containing the base64 decoded data.
161 wxMemoryBuffer
wxBase64Decode(const wxString
& src
,
162 wxBase64DecodeMode mode
= wxBase64DecodeMode_Strict
,
163 size_t posErr
= NULL
);