]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/base64.h
fix for HP aCC
[wxWidgets.git] / interface / wx / 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
698d17c3
FM
9
10// ============================================================================
11// Global functions/macros
12// ============================================================================
13
b21126db 14/** @addtogroup group_funcmacro_misc */
7c913512 15//@{
698d17c3 16
23324ae1 17/**
698d17c3
FM
18 This function encodes the given data using base64.
19
7fa7088e
BP
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.
698d17c3
FM
23
24 This raw encoding function overload writes the output string into the
25 provided buffer; the other overloads return it as a wxString.
7c913512
FM
26
27 @param dst
698d17c3 28 The output buffer, may be @NULL to retrieve the needed buffer size.
7c913512 29 @param dstLen
4cc4bfaf 30 The output buffer size, ignored if dst is @NULL.
7c913512 31 @param src
4cc4bfaf 32 The input buffer, must not be @NULL.
7c913512 33 @param srcLen
4cc4bfaf 34 The length of the input data.
698d17c3 35
d29a9a8a 36 @return @c wxCONV_FAILED if the output buffer is too small.
7fa7088e
BP
37
38 @header{wx/base64.h}
23324ae1 39*/
4cc4bfaf
FM
40size_t wxBase64Encode(char* dst, size_t dstLen,
41 const void* src,
23324ae1 42 size_t srcLen);
698d17c3
FM
43
44/**
7fa7088e
BP
45 This function encodes the given data using base64 and returns the output as
46 a wxString.
698d17c3
FM
47
48 There is no error return.
49
7fa7088e
BP
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.
698d17c3
FM
53
54 @param src
55 The input buffer, must not be @NULL.
56 @param srcLen
57 The length of the input data.
7fa7088e
BP
58
59 @header{wx/base64.h}
698d17c3 60*/
4cc4bfaf 61wxString wxBase64Encode(const void* src, size_t srcLen);
698d17c3
FM
62
63/**
7fa7088e
BP
64 This function encodes the given data using base64 and returns the output as
65 a wxString.
698d17c3
FM
66
67 There is no error return.
7fa7088e
BP
68
69 @header{wx/base64.h}
698d17c3 70*/
7c913512 71wxString wxBase64Encode(const wxMemoryBuffer& buf);
23324ae1
FM
72
73
7c913512 74/**
698d17c3
FM
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().
7fa7088e
BP
78
79 @header{wx/base64.h}
23324ae1
FM
80*/
81size_t wxBase64DecodedSize(size_t srcLen);
82
83/**
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
e54c96f1 86 to wxBase64Encode().
7fa7088e
BP
87
88 @header{wx/base64.h}
23324ae1
FM
89*/
90size_t wxBase64EncodedSize(size_t len);
91
23324ae1 92/**
698d17c3
FM
93 This function decodes a Base64-encoded string.
94
7fa7088e
BP
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.
698d17c3
FM
99
100 This overload returns the number of bytes written to the buffer or the
7fa7088e
BP
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
698d17c3 103 encountered in the input string.
7c913512
FM
104
105 @param dst
7fa7088e
BP
106 Pointer to output buffer, may be @NULL to just compute the necessary
107 buffer size.
7c913512 108 @param dstLen
698d17c3 109 The size of the output buffer, ignored if dst is @NULL.
7c913512 110 @param src
7fa7088e
BP
111 The input string, must not be @NULL. For the version using wxString,
112 the input string should contain only ASCII characters.
7c913512 113 @param srcLen
7fa7088e
BP
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
116 itself.
7c913512 117 @param mode
3c4f71cc 118 This parameter specifies the function behaviour when invalid characters
698d17c3 119 are encountered in input. By default, any such character stops the
4cc4bfaf 120 decoding with error. If the mode is wxBase64DecodeMode_SkipWS, then the
698d17c3 121 white space characters are silently skipped instead. And if it is
4cc4bfaf 122 wxBase64DecodeMode_Relaxed, then all invalid characters are skipped.
7c913512 123 @param posErr
7fa7088e
BP
124 If this pointer is non-@NULL and an error occurs during decoding, it is
125 filled with the index of the invalid character.
126
127 @header{wx/base64.h}
23324ae1 128*/
4cc4bfaf
FM
129size_t wxBase64Decode(void* dst, size_t dstLen,
130 const char* src,
23324ae1
FM
131 size_t srcLen = wxNO_LEN,
132 wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
4cc4bfaf 133 size_t posErr = NULL);
698d17c3
FM
134
135/**
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.
138
139 This overload allocates memory internally and returns it as wxMemoryBuffer
140 and is recommended for normal use.
141
3c4f71cc 142 This overload returns a buffer with the base64 decoded binary equivalent
698d17c3 143 of the input string. In neither case is the buffer @NULL-terminated.
7fa7088e
BP
144
145 @header{wx/base64.h}
698d17c3 146*/
4cc4bfaf 147wxMemoryBuffer wxBase64Decode(const char* src,
7c913512
FM
148 size_t srcLen = wxNO_LEN,
149 wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
4cc4bfaf 150 size_t posErr = NULL);
698d17c3
FM
151
152/**
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.
155
156 This overload takes as input a wxString and returns the internally-allocated
157 memory as a wxMemoryBuffer, containing the base64 decoded data.
7fa7088e
BP
158
159 @header{wx/base64.h}
698d17c3 160*/
7c913512
FM
161wxMemoryBuffer wxBase64Decode(const wxString& src,
162 wxBase64DecodeMode mode = wxBase64DecodeMode_Strict,
4cc4bfaf 163 size_t posErr = NULL);
698d17c3 164
23324ae1
FM
165//@}
166