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
27
32
33// ============================================================
34// encode
42 , ZFMP_IN(zfindex, srcLen)
44 )
45
50 ZF_OUT zfchar *buf
51 , ZF_IN const void *src
52 , ZF_IN_OPT zfindex srcLen = zfindexMax()
53 , ZF_OUT_OPT zfindex *outResultSize = zfnull
54 , ZF_IN_OPT const zfchar *table = ZFBase64TableDefault()
57 );
62 , ZFMP_IN_OUT(const ZFOutput &, outputCallback)
63 , ZFMP_IN(const ZFInput &, inputCallback)
64 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
65 , ZFMP_IN_OPT(const zfchar *, table, ZFBase64TableDefault())
68 )
69
74 , ZFMP_IN_OUT(zfstring &, buf)
75 , ZFMP_IN(const zfchar *, src)
76 , ZFMP_IN_OPT(zfindex, srcLen, zfindexMax())
77 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
78 , ZFMP_IN_OPT(const zfchar *, table, ZFBase64TableDefault())
81 )
82
83// ============================================================
84// decode
92 , ZFMP_IN(zfindex, srcLen)
94 )
102 ZF_OUT void *buf
103 , ZF_IN const zfchar *src
104 , ZF_IN_OPT zfindex srcLen = zfindexMax()
105 , ZF_OUT_OPT zfindex *outResultSize = zfnull
106 , ZF_IN_OPT const zfchar *table = ZFBase64TableDefault()
108 );
113 , ZFMP_IN_OUT(const ZFOutput &, outputCallback)
114 , ZFMP_IN(const ZFInput &, inputCallback)
115 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
116 , ZFMP_IN_OPT(const zfchar *, table, ZFBase64TableDefault())
119
124 , ZFMP_IN_OUT(zfstring &, buf)
125 , ZFMP_IN(const zfchar *, src)
126 , ZFMP_IN_OPT(zfindex, srcLen, zfindexMax())
127 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
128 , ZFMP_IN_OPT(const zfchar *, table, ZFBase64TableDefault())
131
132// ============================================================
136zfclass ZFLIB_ZFAlgorithm ZFBase64 : zfextend ZFObject, zfimplement ZFSerializable {
137 ZFOBJECT_DECLARE(ZFBase64, ZFObject)
138 ZFIMPLEMENT_DECLARE(ZFSerializable)
139
140public:
147
148public:
151 , ZFMP_IN(zfindex, srcLen)
154 virtual inline zfbool encode(
155 ZF_OUT zfchar *buf
156 , ZF_IN const void *src
157 , ZF_IN_OPT zfindex srcLen = zfindexMax()
158 , ZF_OUT_OPT zfindex *outResultSize = zfnull
159 ) {
160 return ZFBase64Encode(buf, src, srcLen, outResultSize, this->table(), this->pad(), this->lineBreakPos());
161 }
162
164 , ZFMP_IN_OUT(const ZFOutput &, output)
165 , ZFMP_IN(const ZFInput &, input)
166 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
168public:
171 , ZFMP_IN(zfindex, srcLen)
174 virtual inline zfbool decode(
175 ZF_OUT void *buf
176 , ZF_IN const zfchar *src
177 , ZF_IN_OPT zfindex srcLen = zfindexMax()
178 , ZF_OUT_OPT zfindex *outResultSize = zfnull
179 ) {
180 return ZFBase64Decode(buf, src, srcLen, outResultSize, this->table(), this->pad());
181 }
182
184 , ZFMP_IN_OUT(const ZFOutput &, output)
185 , ZFMP_IN(const ZFInput &, input)
186 , ZFMP_OUT_OPT(zfindex *, outResultSize, zfnull)
188};
189
191#endif // #ifndef _ZFI_ZFBase64_h_
192
global header for ZFAlgorithm module
#define ZFLIB_ZFAlgorithm
used to export symbols
Definition ZFAlgorithmDef.h:14
ZFLIB_ZFAlgorithm zfbool ZFBase64Decode(void *buf, const zfchar *src, zfindex srcLen=((zfindex) -1), zfindex *outResultSize=zft_zfnull, const zfchar *table=ZFBase64TableDefault(), zfchar pad=ZFBase64PadDefault())
encode base64, return byte size written even if error occurred
zfindex const & ZFBase64LineBreakPosStandard(void)
standard line break position for ZFBase64, 76 by default
Definition ZFBase64.h:26
ZFLIB_ZFAlgorithm zfindex ZFBase64DecodeCalcSize(zfindex srcLen, zfindex lineBreakPos=(ZFBase64LineBreakPosNone()))
calculate required size to store result, ensured big enough but not ensure exactly the same
ZFLIB_ZFAlgorithm zfbool ZFBase64Encode(zfchar *buf, const void *src, zfindex srcLen=((zfindex) -1), zfindex *outResultSize=zft_zfnull, const zfchar *table=ZFBase64TableDefault(), zfchar pad=ZFBase64PadDefault(), zfindex lineBreakPos=ZFBase64LineBreakPosNone())
encode base64
ZFLIB_ZFAlgorithm zfindex ZFBase64EncodeCalcSize(zfindex srcLen, zfindex lineBreakPos=(ZFBase64LineBreakPosNone()))
calculate required size to store result, ensured big enough but not ensure exactly the same
const zfchar *const & ZFBase64TableDefault(void)
char table for ZFBase64, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" by defaul...
Definition ZFBase64.h:16
zfindex const & ZFBase64LineBreakPosNone(void)
no line break for ZFBase64
Definition ZFBase64.h:31
zfchar const & ZFBase64PadDefault(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 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 ZFBase64LineBreakPosNone
Definition ZFBase64.h:146
virtual zfstring & table()
see ZFBase64TableDefault
Definition ZFBase64.h:142
virtual zfindex encodeCalcSize(zfindex srcLen)
see ZFBase64EncodeCalcSize
virtual zfchar & pad()
see ZFBase64PadDefault
Definition ZFBase64.h:144
virtual zfbool encode(zfchar *buf, const void *src, zfindex srcLen=((zfindex) -1), zfindex *outResultSize=zft_zfnull)
see ZFBase64Encode
Definition ZFBase64.h:154
virtual zfbool decode(void *buf, const zfchar *src, zfindex srcLen=((zfindex) -1), zfindex *outResultSize=zft_zfnull)
see ZFBase64Decode
Definition ZFBase64.h:174
general input callback
Definition ZFIOCallback_input.h:37
general output callback
Definition ZFIOCallback_output.h:37