ZFFramework
 
Loading...
Searching...
No Matches
ZFIOCallback_output.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFIOCallback_output_h_
7#define _ZFI_ZFIOCallback_output_h_
8
9#include "ZFIOCallback_fwd.h"
11
12// ============================================================
13// ZFOutput
38public:
41 ZF_IN const void *src
42 , ZF_IN_OPT zfindex count = zfindexMax()
43 ) const {
44 if(this->valid()) {
46 }
47 else {
48 return 0;
49 }
50 }
51
52 inline zfindex operator () (
53 ZF_IN const void *src
54 , ZF_IN_OPT zfindex count = zfindexMax()
55 ) const {
56 if(this->valid()) {
58 }
59 else {
60 return 0;
61 }
62 }
63
64 inline const ZFOutput &output(
65 ZF_IN const void *src
66 , ZF_IN_OPT zfindex count = zfindexMax()
67 , ZF_OUT_OPT zfindex *result = zfnull
68 ) const {
69 if(result != zfnull) {
70 *result = this->execute(src, count);
71 }
72 else {
73 this->execute(src, count);
74 }
75 return *this;
76 }
77_ZFP_ZFCALLBACK_DECLARE_END_NO_ALIAS(ZFLIB_ZFCore, ZFOutput, ZFIOCallback)
78
79
80template<typename T>
81inline const ZFOutput &operator << (ZF_IN_OUT const ZFOutput &o, ZF_IN T const &v) {
82 zfstring s;
83 zftToStringT(s, v);
84 o.output(s.cString(), s.length());
85 return o;
86}
87inline const ZFOutput &operator << (ZF_IN_OUT const ZFOutput &o, ZF_IN zfstring const &s) {
88 o.output(s.cString(), s.length());
89 return o;
90}
91inline const ZFOutput &operator << (ZF_IN_OUT const ZFOutput &o, ZF_IN const zfchar * const &s) {
92 if(s == zfnull) {
93 o.output(ZFTOKEN_zfnull);
94 }
95 else {
96 o.output(s);
97 }
98 return o;
99}
100inline const ZFOutput &operator << (ZF_IN_OUT const ZFOutput &o, ZF_IN zfchar * const &s) {
101 if(s == zfnull) {
102 o.output(ZFTOKEN_zfnull);
103 }
104 else {
105 o.output(s);
106 }
107 return o;
108}
110
111// ============================================================
112// common output callbacks
123#define ZFCallbackSerializeType_ZFOutputDummy "ZFOutputDummy"
128
145 ZF_IN void *buf
146 , ZF_IN_OPT zfindex maxCount = zfindexMax()
147 , ZF_IN_OPT zfbool autoAppendNullToken = zftrue
148 );
149
151#endif // #ifndef _ZFI_ZFIOCallback_output_h_
152
#define ZFCALLBACK_DECLARE_BEGIN(ZFLIB_, CallbackTypeName, ParentType)
util macro to declare a child type of ZFCallback
Definition ZFCallback.h:458
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
_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 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_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
_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 zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
#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
#define ZFTOKEN_zfnull
string tokens
Definition ZFCoreTypeDef_OtherType.h:16
void zftToStringT(zfstring &s, T_Type const &v)
util function to obtain object info
Definition ZFCoreTypeDef_OtherType.h:182
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
common callback defines
ZFOutput ZFOutputForBufferUnsafe(void *buf, zfindex maxCount=((zfindex) -1), zfbool autoAppendNullToken=_ZFT_t_zftrue)
create a output callback to output to a buffer
ZFOutput ZFOutputForString(zfstring &s)
create a output callback to output to a zfstring
ZFOutput ZFOutputDummy(void)
a dummy output that always output nothing with success state
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
T_ReturnType executeExact() const
see ZFCallback, you must assign the exact return type and param types for safe
Definition ZFCallback.h:123
zfbool valid(void) const
return true if callback is valid
Definition ZFCallback.h:238
abstract base class, use ZFOutput or ZFInput
Definition ZFIOCallback_fwd.h:62
general output callback
Definition ZFIOCallback_output.h:37
const ZFOutput & output(const void *src, zfindex count=((zfindex) -1), zfindex *result=zft_zfnull) const
see ZFOutput
Definition ZFIOCallback_output.h:64
zfindex execute(const void *src, zfindex count=((zfindex) -1)) const
see ZFOutput
Definition ZFIOCallback_output.h:40
const T_Char * cString(void) const
access string value
Definition zfstring.h:464
zfindex length(void) const
length of the string
Definition zfstring.h:468