1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of global functions
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 These functions encode the given data using base64. The first of them is the
12 raw encoding function writing the output string into provided buffer while the
13 other ones return the output as wxString. There is no error return for these
14 functions except for the first one which returns @c wxCONV_FAILED if the
15 output buffer is too small. To allocate the buffer of the correct size, use
16 wxBase64EncodedSize() or call this function with
17 @a dst set to @NULL -- it will then return the necessary buffer size.
20 The output buffer, may be @NULL to retrieve the needed buffer
23 The output buffer size, ignored if dst is @NULL.
25 The input buffer, must not be @NULL.
27 The length of the input data.
29 size_t wxBase64Encode(char* dst
, size_t dstLen
,
32 wxString
wxBase64Encode(const void* src
, size_t srcLen
);
33 wxString
wxBase64Encode(const wxMemoryBuffer
& buf
);
38 Returns the size of the buffer necessary to contain the data encoded in a
39 base64 string of length @e srcLen. This can be useful for allocating a
40 buffer to be passed to wxBase64Decode().
42 size_t wxBase64DecodedSize(size_t srcLen
);
45 Returns the length of the string with base64 representation of a buffer of
46 specified size @e len. This can be useful for allocating the buffer passed
49 size_t wxBase64EncodedSize(size_t len
);
53 These function decode a Base64-encoded string. The first version is a raw
54 decoding function and decodes the data into the provided buffer @a dst of
55 the given size @e dstLen. An error is returned if the buffer is not large
56 enough -- that is not at least wxBase64DecodedSize(srcLen)()
57 bytes. The second version allocates memory internally and returns it as
58 wxMemoryBuffer and is recommended for normal use.
59 The first version returns the number of bytes written to the buffer or the
60 necessary buffer size if @a dst was @NULL or @c wxCONV_FAILED on
61 error, e.g. if the output buffer is too small or invalid characters were
62 encountered in the input string. The second version returns a buffer with the
63 base64 decoded binary equivalent of the input string. In neither case is the
64 buffer NUL-terminated.
67 Pointer to output buffer, may be @NULL to just compute the
68 necessary buffer size.
70 The size of the output buffer, ignored if dst is
73 The input string, must not be @NULL. For the version using
74 wxString, the input string should contain only ASCII characters.
76 The length of the input string or special value
77 wxNO_LEN if the string is NUL-terminated and the length should be
78 computed by this function itself.
80 This parameter specifies the function behaviour when invalid
81 characters are encountered in input. By default, any such character stops
83 decoding with error. If the mode is wxBase64DecodeMode_SkipWS, then the
85 space characters are silently skipped instead. And if it is
86 wxBase64DecodeMode_Relaxed, then all invalid characters are skipped.
88 If this pointer is non-@NULL and an error occurs during
89 decoding, it is filled with the index of the invalid character.
91 size_t wxBase64Decode(void* dst
, size_t dstLen
,
93 size_t srcLen
= wxNO_LEN
,
94 wxBase64DecodeMode mode
= wxBase64DecodeMode_Strict
,
95 size_t posErr
= NULL
);
96 wxMemoryBuffer
wxBase64Decode(const char* src
,
97 size_t srcLen
= wxNO_LEN
,
98 wxBase64DecodeMode mode
= wxBase64DecodeMode_Strict
,
99 size_t posErr
= NULL
);
100 wxMemoryBuffer
wxBase64Decode(const wxString
& src
,
101 wxBase64DecodeMode mode
= wxBase64DecodeMode_Strict
,
102 size_t posErr
= NULL
);