ZFFramework
 
Loading...
Searching...
No Matches
ZFIODef_fwd.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFIODef_fwd_h_
7#define _ZFI_ZFIODef_fwd_h_
8
9#include "ZFObject.h"
11
13#define ZFSerializableKeyword_ZFIO_pathInfo "pathInfo"
15#define ZFSerializableKeyword_ZFIO_flags "flags"
17#define ZFSerializableKeyword_ZFIO_localPath "localPath"
18
19// ============================================================
20// ZFIOOpenOption
43 ZFENUM_VALUE_WITH_INIT(Write, 1 << 1)
44 ZFENUM_VALUE_WITH_INIT(Modify, 1 << 2)
51
52// ============================================================
53zfclassFwd _ZFP_ZFIOFindDataPrivate;
72public:
74 ZFIOFindData(void);
76 ZFIOFindData &operator = (ZF_IN ZFIOFindData const &ref);
77 zfbool operator == (ZF_IN ZFIOFindData const &ref) const;
78 zfbool operator != (ZF_IN ZFIOFindData const &ref) const {
79 return !this->operator == (ref);
80 }
82 ~ZFIOFindData(void);
83
84public:
88 const zfstring &name(void) const {
89 return this->impl().name;
90 }
91
94 zfbool isDir(void) const {
95 return this->impl().isDir;
96 }
97
98public:
102 inline zfstring objectInfo(void) const {
103 zfstring ret;
104 this->objectInfoT(ret);
105 return ret;
106 }
107
108public:
111 public:
114 void *nativeFd;
115 public:
117 Impl(void)
118 : name()
119 , isDir(zffalse)
121 {
122 }
124 private:
125 Impl(ZF_IN const Impl &);
126 Impl &operator = (ZF_IN const Impl &);
127 };
128public:
130 Impl &impl(void) const;
132 void implCopy(ZF_IN const ZFIOFindData &ref) const;
134 const zfstring &implName(void) const;
136 void *implUserData(void) const;
139 ZF_IN const zfstring &implName
141 );
143 void implDetach(void);
145 void *implCheck(ZF_IN const zfstring &implName) const;
146
149 ZF_IN const zfstring &key
150 , ZF_IN ZFObject *value
151 ) const;
153 zfany implTag(ZF_IN const zfstring &key) const;
154private:
155 _ZFP_ZFIOFindDataPrivate *d;
156};
159ZFOUTPUT_TYPE(ZFIOFindData, {v.objectInfoT(s);})
160
161// ============================================================
164zfabstract ZFLIB_ZFCore ZFIOToken : zfextend ZFObject {
165 ZFOBJECT_DECLARE_ABSTRACT(ZFIOToken, ZFObject)
166
167public:
173 ZFEVENT(IOCloseOnPrepare)
179 ZFEVENT(IOCloseOnFinish)
180
181protected:
183 virtual void objectOnDeallocPrepare(void) {
184 this->ioClose();
186 }
187protected:
189 virtual inline void objectInfoImpl(ZF_IN_OUT zfstring &ret) {
190 ret += this->pathType();
191 ret += ":";
192 ret += this->pathData();
193 }
194public:
196 virtual ZFPathInfo pathInfo(void) {
197 return ZFPathInfo(this->pathType(), this->pathData());
198 }
199
205
206public:
237 ZF_OUT void *buf
238 , ZF_IN zfindex maxByteSize
256 ZF_IN const void *src
257 , ZF_IN_OPT zfindex maxByteSize = zfindexMax()
264 virtual zfbool ioSeek(
265 ZF_IN zfindex byteSize
266 , ZF_IN_OPT ZFSeekPos seekPos = ZFSeekPosBegin
280};
281
282// ============================================================
284zfabstract ZFLIB_ZFCore ZFIOImpl : zfextend ZFObject {
285 ZFOBJECT_DECLARE_ABSTRACT(ZFIOImpl, ZFObject)
286protected:
288 virtual inline void objectInfoImpl(ZF_IN_OUT zfstring &ret) {
290 ret += "ZFIOImpl:";
291 ret += this->pathType();
293 }
294public:
301
307 virtual zfbool ioIsExist(ZF_IN const zfstring &pathData) zfpurevirtual;
313 virtual zfbool ioIsDir(ZF_IN const zfstring &pathData) zfpurevirtual;
321 , ZF_IN const zfstring &pathData
330 , ZF_IN const zfstring &pathData
331 , ZF_IN const zfstring &childName
340 , ZF_IN const zfstring &pathData
348 ZF_IN const zfstring &pathData
349 , ZF_IN_OPT zfbool autoCreateParent = zftrue
357 ZF_IN const zfstring &pathData
358 , ZF_IN_OPT zfbool isRecursive = zftrue
359 , ZF_IN_OPT zfbool isForce = zftrue
366 virtual zfbool ioMove(
367 ZF_IN const zfstring &pathDataFrom
368 , ZF_IN const zfstring &pathDataTo
369 , ZF_IN_OPT zfbool isForce = zftrue
378 , ZF_IN const zfstring &pathData
398 ZF_IN const zfstring &pathData
400 , ZF_IN_OPT zfbool autoCreateParent = zftrue
402
403 // ============================================================
404 // default/dummy impl
405public:
407 static zfbool ioIsExistDefault(ZF_IN const zfstring &pathData);
409 static zfbool ioIsDirDefault(ZF_IN const zfstring &pathData);
413 , ZF_IN const zfstring &pathData
414 );
418 , ZF_IN const zfstring &pathData
419 , ZF_IN const zfstring &childName
420 );
424 , ZF_IN const zfstring &pathData
425 );
428 ZF_IN const zfstring &pathData
429 , ZF_IN_OPT zfbool autoCreateParent = zftrue
430 );
433 ZF_IN const zfstring &pathData
434 , ZF_IN_OPT zfbool isRecursive = zftrue
435 , ZF_IN_OPT zfbool isForce = zftrue
436 );
439 ZF_IN const zfstring &pathDataFrom
440 , ZF_IN const zfstring &pathDataTo
441 , ZF_IN_OPT zfbool isForce = zftrue
442 );
446 , ZF_IN const zfstring &pathData
447 );
454 ZF_IN const zfstring &pathData
456 , ZF_IN_OPT zfbool autoCreateParent = zftrue
457 );
459 static zfbool ioCloseDefault(ZF_IN void *token);
462 ZF_IN void *token
463 , ZF_IN void *buf
464 , ZF_IN zfindex maxByteSize
465 );
468 ZF_IN void *token
469 , ZF_IN const void *src
470 , ZF_IN_OPT zfindex maxByteSize = zfindexMax()
471 );
474 ZF_IN void *token
475 , ZF_IN zfindex byteSize
476 , ZF_IN_OPT ZFSeekPos seekPos = ZFSeekPosBegin
477 );
479 static zfindex ioTellDefault(ZF_IN void *token);
481 static zfindex ioSizeDefault(ZF_IN void *token);
482};
483
484// ============================================================
499 , ZFMP_IN(const zfstring &, pathType)
503
506 , ZFMP_IN(const zfstring &, pathType)
507 , ZFMP_IN(ZFIOImpl *, ioImpl)
511 , ZFMP_IN(const zfstring &, pathType)
513
515#define ZFIO_DECLARE(ZFLIB_, pathType) \
516 ZFMETHOD_FUNC_DECLARE_0(ZFLIB_, const zfstring &, ZFPathType_##pathType)
517
519#define ZFIO_DEFINE(pathType, ZFIOImpl_) \
520 ZFMETHOD_FUNC_DEFINE_0(const zfstring &, ZFPathType_##pathType) { \
521 static zfstring ret = zftext(ZFM_TOSTRING(pathType)); \
522 return ret; \
523 } \
524 ZF_STATIC_REGISTER_INIT(ZFIOReg_##pathType) { \
525 ZFIOImplRegister(ZFPathType_##pathType(), zfobj<ZFIOImpl_>()); \
526 } \
527 ZF_STATIC_REGISTER_DESTROY(ZFIOReg_##pathType) { \
528 ZFIOImplUnregister(ZFPathType_##pathType()); \
529 } \
530 ZF_STATIC_REGISTER_END(ZFIOReg_##pathType)
531
533#endif // #ifndef _ZFI_ZFIODef_fwd_h_
534
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfpurevirtual
dummy macro shows that a method is pure virtual method
Definition ZFCoreTypeDef_ClassType.h:68
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#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
#define zfclassNotPOD
shows the class is not a POD type, you should not memset it or declare it in stack or copy value by c...
Definition ZFCoreTypeDef_ClassType.h:48
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_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 zffalse
bool false type
Definition ZFCoreTypeDef_CoreType.h:111
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
ZFSeekPos
seek position similar to SEEK_SET of FILE operation
Definition ZFCoreTypeDef_OtherType.h:47
#define ZFOUTPUT_TYPE(T_Type, outputAction)
declare your custom type conversion to string, convenient for debug
Definition ZFCoreTypeDef_OtherType.h:221
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFENUM_REG_FLAGS(ZFLIB_, EnumName, EnumFlagsName,...)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:189
#define ZFENUM_SEPARATOR()
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:158
#define ZFENUM_VALUE_REGISTER(Value)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:168
#define ZFENUM_VALUE_WITH_INIT(Value, initValue)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:154
#define ZFENUM_BEGIN(ZFLIB_, EnumName)
macros to define reflectable enum type
Definition ZFEnumDeclare.h:147
#define ZFENUM_END_FLAGS(ZFLIB_, EnumName, EnumFlagsName)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:179
v_ZFIOOpenOption::ZFEnumType ZFIOOpenOption
see v_ZFIOOpenOption
Definition ZFIODef_fwd.h:49
ZFCoreArray< zfautoT< ZFIOImpl > > ZFIOImplList()
return a list of ZFIOImplRegister, for debug use only
void ZFIOImplRegister(const zfstring &pathType, ZFIOImpl *ioImpl)
see ZFIOImplForPathType
void ZFIOImplUnregister(const zfstring &pathType)
see ZFIOImplForPathType
zfautoT< ZFIOImpl > ZFIOImplForPathType(const zfstring &pathType)
main entry for abstract IO for ZFFramework
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#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_0(ZFLIB_, ReturnType, MethodName)
declare function type of ZFMethod
Definition ZFMethodFuncDeclare.h:493
#define ZFMETHOD_FUNC_DECLARE_1(ZFLIB_, ReturnType, MethodName, ZFMP_0)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:624
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
ZFObject related include.
#define zfabstract
typename for class showing that its abstract
Definition ZFObjectClassTypeFwd.h:42
#define ZFTOKEN_ZFObjectInfoLeft
left bracket when output ZFObject's info
Definition ZFObjectCore.h:24
#define ZFTOKEN_ZFObjectInfoRight
right bracket when output ZFObject's info
Definition ZFObjectCore.h:29
#define ZFOBJECT_DECLARE_ABSTRACT(ChildClass, SuperClass,...)
necessary for every abstract class inherit from ZFObject
Definition ZFObjectDeclare.h:152
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:328
#define ZFTYPEID_ACCESS_ONLY_REG(ZFLIB_, TypeName, Type,...)
see ZFTYPEID_DECLARE
Definition ZFTypeIdDeclare.h:205
#define ZFTYPEID_ACCESS_ONLY_DECLARE(ZFLIB_, TypeName, Type)
see ZFTYPEID_DECLARE
Definition ZFTypeIdDeclare.h:195
light weight array
Definition ZFCoreArray.h:331
for impl to achieve custom find logic
Definition ZFIODef_fwd.h:110
zfbool isDir
whether directory
Definition ZFIODef_fwd.h:113
void * nativeFd
for impl to store native find data
Definition ZFIODef_fwd.h:114
zfstring name
file path
Definition ZFIODef_fwd.h:112
data used by ZFIO when finding files
Definition ZFIODef_fwd.h:71
void objectInfoT(zfstring &ret) const
see objectInfo
void implTag(const zfstring &key, ZFObject *value) const
util for impl to store extra data
zfany implTag(const zfstring &key) const
util for impl to store extra data
void * implUserData(void) const
user data passed from implAttach
const zfstring & name(void) const
return file name of file
Definition ZFIODef_fwd.h:88
zfbool isDir(void) const
return true if is a directory
Definition ZFIODef_fwd.h:94
void * implCheck(const zfstring &implName) const
check whether impl matches, assert fail if not match, return the implUserData
void implCopy(const ZFIOFindData &ref) const
copy the impl data
const zfstring & implName(void) const
name for the impl
void implDetach(void)
close find
void implAttach(const zfstring &implName, void *implUserData=zft_zfnull)
begin first find
Impl & impl(void) const
the impl
zfstring objectInfo(void) const
return object info
Definition ZFIODef_fwd.h:102
see ZFIOImplForPathType
Definition ZFIODef_fwd.h:284
static zfindex ioReadDefault(void *token, void *buf, zfindex maxByteSize)
see ZFIOImplForPathType
static zfindex ioTellDefault(void *token)
see ZFIOImplForPathType
virtual zfbool ioPathCreate(const zfstring &pathData, zfbool autoCreateParent=_ZFT_t_zftrue)=0
see ZFIOImplForPathType
virtual zfbool ioToFileName(zfstring &ret, const zfstring &pathData)=0
see ZFIOImplForPathType
static zfbool ioPathCreateDefault(const zfstring &pathData, zfbool autoCreateParent=_ZFT_t_zftrue)
see ZFIOImplForPathType
virtual zfstring pathType(void)=0
see ZFIOImplForPathType
static zfbool ioRemoveDefault(const zfstring &pathData, zfbool isRecursive=_ZFT_t_zftrue, zfbool isForce=_ZFT_t_zftrue)
see ZFIOImplForPathType
virtual zfbool ioFindNext(ZFIOFindData &fd)=0
see ZFIOImplForPathType
static zfindex ioWriteDefault(void *token, const void *src, zfindex maxByteSize=((zfindex) -1))
see ZFIOImplForPathType
static zfbool ioIsExistDefault(const zfstring &pathData)
see ZFIOImplForPathType
virtual zfbool ioFindFirst(ZFIOFindData &fd, const zfstring &pathData)=0
see ZFIOImplForPathType
static zfbool ioToParentDefault(zfstring &ret, const zfstring &pathData)
see ZFIOImplForPathType
virtual zfbool ioRemove(const zfstring &pathData, zfbool isRecursive=_ZFT_t_zftrue, zfbool isForce=_ZFT_t_zftrue)=0
see ZFIOImplForPathType
virtual zfbool ioToChild(zfstring &ret, const zfstring &pathData, const zfstring &childName)=0
see ZFIOImplForPathType
virtual zfautoT< ZFIOToken > ioOpen(const zfstring &pathData, ZFIOOpenOptionFlags flags, zfbool autoCreateParent=_ZFT_t_zftrue)=0
see ZFIOImplForPathType
static void ioFindCloseDefault(ZFIOFindData &fd)
see ZFIOImplForPathType
virtual zfbool ioToParent(zfstring &ret, const zfstring &pathData)=0
see ZFIOImplForPathType
static zfbool ioToChildDefault(zfstring &ret, const zfstring &pathData, const zfstring &childName)
see ZFIOImplForPathType
static zfbool ioSeekDefault(void *token, zfindex byteSize, ZFSeekPos seekPos=ZFSeekPosBegin)
see ZFIOImplForPathType
static zfbool ioFindNextDefault(ZFIOFindData &fd)
see ZFIOImplForPathType
static zfautoT< ZFIOToken > ioOpenDefault(const zfstring &pathData, ZFIOOpenOptionFlags flags, zfbool autoCreateParent=_ZFT_t_zftrue)
see ZFIOImplForPathType
static zfbool ioMoveDefault(const zfstring &pathDataFrom, const zfstring &pathDataTo, zfbool isForce=_ZFT_t_zftrue)
see ZFIOImplForPathType
static zfbool ioIsDirDefault(const zfstring &pathData)
see ZFIOImplForPathType
virtual void objectInfoImpl(zfstring &ret)
see objectInfo
Definition ZFIODef_fwd.h:288
virtual zfbool ioIsExist(const zfstring &pathData)=0
see ZFIOImplForPathType
static zfindex ioSizeDefault(void *token)
see ZFIOImplForPathType
static zfbool ioFindFirstDefault(ZFIOFindData &fd, const zfstring &pathData)
see ZFIOImplForPathType
virtual void ioFindClose(ZFIOFindData &fd)=0
see ZFIOImplForPathType
virtual zfbool ioMove(const zfstring &pathDataFrom, const zfstring &pathDataTo, zfbool isForce=_ZFT_t_zftrue)=0
see ZFIOImplForPathType
static zfbool ioToFileNameDefault(zfstring &ret, const zfstring &pathData)
see ZFIOImplForPathType
static zfbool ioCloseDefault(void *token)
see ZFIOImplForPathType
virtual zfbool ioIsDir(const zfstring &pathData)=0
see ZFIOImplForPathType
see v_ZFIOOpenOption, ZFIOOpenOptionFlagsToString, ZFIOOpenOptionFlagsFromString
Definition ZFIODef_fwd.h:49
virtual zfindex ioSize(void)=0
see ZFIOImplForPathType
virtual zfstring pathData(void)=0
path info for this token
virtual zfbool ioSeek(zfindex byteSize, ZFSeekPos seekPos=ZFSeekPosBegin)=0
see ZFIOImplForPathType
virtual ZFIOOpenOptionFlags ioFlags(void)=0
open flags for this token
virtual void objectInfoImpl(zfstring &ret)
see objectInfo
Definition ZFIODef_fwd.h:189
virtual zfstring pathType(void)=0
path info for this token
virtual zfbool ioClose(void)=0
see ZFIOImplForPathType
virtual ZFPathInfo pathInfo(void)
path info for this token
Definition ZFIODef_fwd.h:196
virtual zfindex ioWrite(const void *src, zfindex maxByteSize=((zfindex) -1))=0
see ZFIOImplForPathType
virtual zfindex ioRead(void *buf, zfindex maxByteSize)=0
see ZFIOImplForPathType
virtual zfindex ioTell(void)=0
see ZFIOImplForPathType
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
Definition ZFIODef_fwd.h:183
base class of all objects
Definition ZFObjectCore.h:205
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
Definition ZFObjectCore.h:754
path related info storage for impl, actual meaning of the info depends on impl
Definition ZFPathInfo.h:34
util method to cast ZFObject types freely
Definition zfany.h:35
type restrict version of zfauto
Definition zfautoFwd.h:113