]> git.saurik.com Git - wxWidgets.git/blame - interface/base64.h
Added the function and macro group pages for Doxygen.
[wxWidgets.git] / interface / base64.h
CommitLineData
23324ae1 1/////////////////////////////////////////////////////////////////////////////
7c913512 2// Name: base64.h
e54c96f1 3// Purpose: interface of global functions
7c913512
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9//@{
23324ae1
FM
10/**
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
7c913512 15 output buffer is too small. To allocate the buffer of the correct size, use
e54c96f1 16 wxBase64EncodedSize() or call this function with
4cc4bfaf 17 @a dst set to @NULL -- it will then return the necessary buffer size.
7c913512
FM
18
19 @param dst
4cc4bfaf
FM
20 The output buffer, may be @NULL to retrieve the needed buffer
21 size.
7c913512 22 @param dstLen
4cc4bfaf 23 The output buffer size, ignored if dst is @NULL.
7c913512 24 @param src
4cc4bfaf 25 The input buffer, must not be @NULL.
7c913512 26 @param srcLen
4cc4bfaf 27 The length of the input data.
23324ae1 28*/
4cc4bfaf
FM
29size_t wxBase64Encode(char* dst, size_t dstLen,
30 const void* src,
23324ae1 31 size_t srcLen);
4cc4bfaf 32wxString wxBase64Encode(const void* src, size_t srcLen);
7c913512 33wxString wxBase64Encode(const wxMemoryBuffer& buf);
23324ae1
FM
34//@}
35
36
7c913512
FM
37/**
38Returns the size of the buffer necessary to contain the data encoded in a
39base64 string of length @e srcLen. This can be useful for allocating a
e54c96f1 40buffer to be passed to wxBase64Decode().
23324ae1
FM
41*/
42size_t wxBase64DecodedSize(size_t srcLen);
43
44/**
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
e54c96f1 47 to wxBase64Encode().
23324ae1
FM
48*/
49size_t wxBase64EncodedSize(size_t len);
50
51//@{
52/**
53 These function decode a Base64-encoded string. The first version is a raw
4cc4bfaf 54 decoding function and decodes the data into the provided buffer @a dst of
23324ae1 55 the given size @e dstLen. An error is returned if the buffer is not large
e54c96f1 56 enough -- that is not at least wxBase64DecodedSize(srcLen)()
23324ae1
FM
57 bytes. The second version allocates memory internally and returns it as
58 wxMemoryBuffer and is recommended for normal use.
23324ae1 59 The first version returns the number of bytes written to the buffer or the
4cc4bfaf 60 necessary buffer size if @a dst was @NULL or @c wxCONV_FAILED on
23324ae1
FM
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.
7c913512
FM
65
66 @param dst
4cc4bfaf
FM
67 Pointer to output buffer, may be @NULL to just compute the
68 necessary buffer size.
7c913512 69 @param dstLen
4cc4bfaf
FM
70 The size of the output buffer, ignored if dst is
71 @NULL.
7c913512 72 @param src
4cc4bfaf
FM
73 The input string, must not be @NULL. For the version using
74 wxString, the input string should contain only ASCII characters.
7c913512 75 @param srcLen
4cc4bfaf
FM
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.
7c913512 79 @param mode
4cc4bfaf
FM
80 This parameter specifies the function behaviour when invalid
81 characters are encountered in input. By default, any such character stops
82 the
83 decoding with error. If the mode is wxBase64DecodeMode_SkipWS, then the
84 white
85 space characters are silently skipped instead. And if it is
86 wxBase64DecodeMode_Relaxed, then all invalid characters are skipped.
7c913512 87 @param posErr
4cc4bfaf
FM
88 If this pointer is non-@NULL and an error occurs during
89 decoding, it is filled with the index of the invalid character.
23324ae1 90*/
4cc4bfaf
FM
91size_t wxBase64Decode(void* dst, size_t dstLen,
92 const char* src,
23324ae1
FM
93 size_t srcLen = wxNO_LEN,
94 wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
4cc4bfaf
FM
95 size_t posErr = NULL);
96wxMemoryBuffer wxBase64Decode(const char* src,
7c913512
FM
97 size_t srcLen = wxNO_LEN,
98 wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
4cc4bfaf 99 size_t posErr = NULL);
7c913512
FM
100wxMemoryBuffer wxBase64Decode(const wxString& src,
101 wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
4cc4bfaf 102 size_t posErr = NULL);
23324ae1
FM
103//@}
104