ZFFramework
 
Loading...
Searching...
No Matches
ZFBase64.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFBase64_h_
7#define _ZFI_ZFBase64_h_
8
9#include "ZFAlgorithmDef.h"
11
12// ============================================================
17
18
22
31
32// ============================================================
33// encode
41 , ZFMP_IN(zfindex, srcLen)
42 , ZFMP_IN_OPT(zfindex, lineBreakPos, ZFBase64LineBreakPos())
43 )
44
49 ZF_OUT zfchar *buf
50 , ZF_IN const void *src
51 , ZF_IN_OPT zfindex srcLen = zfindexMax()
52 , ZF_OUT_OPT zfindex *outResultSize = zfnull
53 , ZF_IN_OPT const zfchar *table = ZFBase64Table()
55 , ZF_IN_OPT zfindex lineBreakPos = ZFBase64LineBreakPos()
56 );
61 , ZFMP_IN_OUT(const ZFOutput &, outputCallback)
62 , ZFMP_IN(const ZFInput &, inputCallback)
63 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
64 , ZFMP_IN_OPT(const zfchar *, table, ZFBase64Table())
66 , ZFMP_IN_OPT(zfindex, lineBreakPos, ZFBase64LineBreakPos())
67 )
68
73 , ZFMP_IN_OUT(zfstring &, buf)
74 , ZFMP_IN(const zfchar *, src)
75 , ZFMP_IN_OPT(zfindex, srcLen, zfindexMax())
76 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
77 , ZFMP_IN_OPT(const zfchar *, table, ZFBase64Table())
79 , ZFMP_IN_OPT(zfindex, lineBreakPos, ZFBase64LineBreakPos())
80 )
81
82// ============================================================
83// decode
91 , ZFMP_IN(zfindex, srcLen)
92 , ZFMP_IN_OPT(zfindex, lineBreakPos, ZFBase64LineBreakPos())
93 )
101 ZF_OUT void *buf
102 , ZF_IN const zfchar *src
103 , ZF_IN_OPT zfindex srcLen = zfindexMax()
104 , ZF_OUT_OPT zfindex *outResultSize = zfnull
105 , ZF_IN_OPT const zfchar *table = ZFBase64Table()
107 );
112 , ZFMP_IN_OUT(const ZFOutput &, outputCallback)
113 , ZFMP_IN(const ZFInput &, inputCallback)
114 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
115 , ZFMP_IN_OPT(const zfchar *, table, ZFBase64Table())
118
123 , ZFMP_IN_OUT(zfstring &, buf)
124 , ZFMP_IN(const zfchar *, src)
125 , ZFMP_IN_OPT(zfindex, srcLen, zfindexMax())
126 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
127 , ZFMP_IN_OPT(const zfchar *, table, ZFBase64Table())
130
131// ============================================================
135zfclass ZFLIB_ZFAlgorithm ZFBase64 : zfextend ZFObject, zfimplement ZFSerializable {
136 ZFOBJECT_DECLARE(ZFBase64, ZFObject)
137 ZFIMPLEMENT_DECLARE(ZFSerializable)
138
139public:
146
147public:
150 , ZFMP_IN(zfindex, srcLen)
153 virtual inline zfbool encode(
154 ZF_OUT zfchar *buf
155 , ZF_IN const void *src
156 , ZF_IN_OPT zfindex srcLen = zfindexMax()
157 , ZF_OUT_OPT zfindex *outResultSize = zfnull
158 ) {
159 return ZFBase64Encode(buf, src, srcLen, outResultSize, this->table(), this->pad(), this->lineBreakPos());
160 }
161
163 , ZFMP_IN_OUT(const ZFOutput &, output)
164 , ZFMP_IN(const ZFInput &, input)
165 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
167public:
170 , ZFMP_IN(zfindex, srcLen)
173 virtual inline zfbool decode(
174 ZF_OUT void *buf
175 , ZF_IN const zfchar *src
176 , ZF_IN_OPT zfindex srcLen = zfindexMax()
177 , ZF_OUT_OPT zfindex *outResultSize = zfnull
178 ) {
179 return ZFBase64Decode(buf, src, srcLen, outResultSize, this->table(), this->pad());
180 }
181
183 , ZFMP_IN_OUT(const ZFOutput &, output)
184 , ZFMP_IN(const ZFInput &, input)
185 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
187};
188
190#endif // #ifndef _ZFI_ZFBase64_h_
191
global header for ZFAlgorithm module
#define ZFLIB_ZFAlgorithm
used to export symbols
Definition ZFAlgorithmDef.h:14
zfindex const & ZFBase64LineBreakPosStandard(void)
standard line break position for ZFBase64, 76 by default
Definition ZFBase64.h:30
zfindex ZFBase64DecodeCalcSize(zfindex srcLen, zfindex lineBreakPos=(ZFBase64LineBreakPos()))
calculate required size to store result, ensured big enough but not ensure exactly the same
zfbool ZFBase64Decode(void *buf, const zfchar *src, zfindex srcLen=((zfindex) -1), zfindex *outResultSize=zft_zfnull, const zfchar *table=ZFBase64Table(), zfchar pad=ZFBase64Pad())
encode base64, return byte size written even if error occurred
zfindex & ZFBase64LineBreakPos(void)
line break position for ZFBase64, zfindexMax by default
Definition ZFBase64.h:26
zfstring const & ZFBase64Table(void)
char table for ZFBase64, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" by defaul...
Definition ZFBase64.h:16
zfbool ZFBase64Encode(zfchar *buf, const void *src, zfindex srcLen=((zfindex) -1), zfindex *outResultSize=zft_zfnull, const zfchar *table=ZFBase64Table(), zfchar pad=ZFBase64Pad(), zfindex lineBreakPos=ZFBase64LineBreakPos())
encode base64
zfindex ZFBase64EncodeCalcSize(zfindex srcLen, zfindex lineBreakPos=(ZFBase64LineBreakPos()))
calculate required size to store result, ensured big enough but not ensure exactly the same
zfchar const & ZFBase64Pad(void)
pad token for ZFBase64, '=' by default
Definition ZFBase64.h:21
_ZFT_t_zfchar zfchar
char wrapper
Definition ZFCoreTypeDef_CharType.h:17
#define ZF_OUT_OPT
dummy macro that shows the param used as optional output
Definition ZFCoreTypeDef_ClassType.h:192
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:184
#define ZF_OUT
dummy macro that shows the param used as required output
Definition ZFCoreTypeDef_ClassType.h:188
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
#define zfindexMax()
(zfindex)-1, indicate a max index value, see zfindex
Definition ZFCoreTypeDef_CoreType.h:159
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFEXPORT_VAR_READONLY_DECLARE(ZFLIB_, Type, Name)
see ZFEXPORT_VAR_DECLARE
Definition ZFExport.h:115
#define ZFEXPORT_VAR_DECLARE(ZFLIB_, Type, Name)
util to export global variable
Definition ZFExport.h:68
#define ZFMP_IN_OUT(ParamType, paramName)
see ZFMP_IN
Definition ZFMethod.h:117
#define ZFMP_OUT_OPT(ParamType, paramName, DefaultValue)
see ZFMP_IN
Definition ZFMethod.h:114
#define ZFMP_IN_OPT(ParamType, paramName, DefaultValue)
see ZFMP_IN
Definition ZFMethod.h:108
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_DECLARE_3(ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2)
see ZFMethod
Definition ZFMethodDeclare.h:1206
#define ZFMETHOD_DECLARE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:854
#define ZFMETHOD_FUNC_DECLARE_5(ZFLIB_, ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:1228
#define ZFMETHOD_FUNC_DECLARE_2(ZFLIB_, ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:763
#define ZFMETHOD_FUNC_DECLARE_7(ZFLIB_, ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:1578
#define ZFMETHOD_FUNC_DECLARE_6(ZFLIB_, ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:1399
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
#define ZFIMPLEMENT_DECLARE(ImplementedInterfaces,...)
see ZFINTERFACE_DECLARE
Definition ZFObjectInterface.h:169
#define zfimplement
shows class implement from interface, see ZFInterface
Definition ZFObjectInterface.h:24
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:128
virtual zfindex decodeCalcSize(zfindex srcLen)
see ZFBase64DecodeCalcSize
virtual zfindex & lineBreakPos()
see ZFBase64LineBreakPos
Definition ZFBase64.h:145
virtual zfstring & table()
see ZFBase64Table
Definition ZFBase64.h:141
virtual zfindex encodeCalcSize(zfindex srcLen)
see ZFBase64EncodeCalcSize
virtual zfchar & pad()
see ZFBase64Pad
Definition ZFBase64.h:143
virtual zfbool encode(zfchar *buf, const void *src, zfindex srcLen=((zfindex) -1), zfindex *outResultSize=zft_zfnull)
see ZFBase64Encode
Definition ZFBase64.h:153
virtual zfbool decode(void *buf, const zfchar *src, zfindex srcLen=((zfindex) -1), zfindex *outResultSize=zft_zfnull)
see ZFBase64Decode
Definition ZFBase64.h:173
general input callback
Definition ZFIOCallback_input.h:35
general output callback
Definition ZFIOCallback_output.h:37