ZFFramework
 
Loading...
Searching...
No Matches
ZFSerializableData.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFSerializableData_h_
7#define _ZFI_ZFSerializableData_h_
8
9#include "zfany.h"
10#include "zfautoFwd.h"
11#include "ZFPathInfo.h"
13
29
38#define ZFSerializableKeyword_node "node"
43#define ZFSerializableKeyword_prop "prop"
48#define ZFSerializableKeyword_value "value"
53#define ZFSerializableKeyword_category "category"
63#define ZFSerializableKeyword_null "null"
64
65// ============================================================
67zfclassFwd _ZFP_ZFSerializableDataPrivate;
75public:
77 explicit ZFSerializableData(ZF_IN _ZFP_ZFSerializableDataPrivate *d);
80 ZFSerializableData(ZF_IN const zfnullT &dummy);
81 ZFSerializableData &operator = (ZF_IN const zfnullT &dummy);
82 ZFSerializableData &operator = (ZF_IN const ZFSerializableData &ref);
83 zfbool operator == (ZF_IN const ZFSerializableData &ref) const;
84 inline zfbool operator != (ZF_IN const ZFSerializableData &ref) const {return !this->operator == (ref);}
85 inline zfbool operator == (ZF_IN const zfnullT &dummy) const {return !this->valid();}
86 inline zfbool operator != (ZF_IN const zfnullT &dummy) const {return this->valid();}
87 inline operator bool (void) const {return this->valid();}
90
91public:
99 inline ZFSerializableData copy(void) const {
101 ret.copyFrom(*this);
102 return ret;
103 }
104
109
110 // ============================================================
111 // local path logic
112public:
123
124 // ============================================================
125 // parent
126public:
131
132 // ============================================================
133 // class
134public:
136 zffinal void itemClass(ZF_IN const zfstring &classNameFull);
138 zffinal const zfstring &itemClass(void) const;
139
140 // ============================================================
141 // other types
142public:
144 inline void propertyName(ZF_IN const zfstring &name) {
145 this->attr(ZFSerializableKeyword_prop, name);
146 }
147
148 inline zfstring propertyName(void) const {
149 return this->attr(ZFSerializableKeyword_prop);
150 }
151
152 inline void propertyValue(ZF_IN const zfstring &value) {
153 this->attr(ZFSerializableKeyword_value, value);
154 }
155
156 inline zfstring propertyValue(void) const {
157 return this->attr(ZFSerializableKeyword_value);
158 }
159
163
164 inline zfstring category(void) const {
166 }
167
168 // ============================================================
169public:
173 zffinal void removeAll(void);
174
175 // ============================================================
176public:
183 ZF_IN const zfstring &key
184 , ZF_IN ZFObject *tag
185 );
194 ) const;
212
213 // ============================================================
214 // attribute
215public:
223 ZF_IN const zfstring &name
224 , ZF_IN const zfstring &value
225 );
227 zffinal zfstring attr(ZF_IN const zfstring &name) const;
228
231
235 zffinal void attrRemove(ZF_IN const zfstring &name);
236
241
250
253 ZF_IN_OUT zfiter &it
254 , ZF_IN const zfstring &value
255 );
258
265
266 // ============================================================
267 // element
268public:
274 zffinal void child(ZF_IN const ZFSerializableData &element);
281 ZF_IN const ZFSerializableData &element
282 , ZF_IN zfindex atIndex
283 );
284
289 ZF_IN zfindex index
290 , ZF_IN const ZFSerializableData &element
291 );
292
301
308
317
318 // ============================================================
319 // resolved state
320public:
331 zffinal void resolveMark(void) const;
333 zffinal void resolveUnmark(void) const;
334
338 zffinal void resolveAttrMark(ZF_IN const zfstring &name) const;
340 zffinal void resolveAttrUnmark(ZF_IN const zfstring &name) const;
341
346
350
354
359
363
367
372
376
380
385 ZF_OUT_OPT ZFSerializableData *firstNotResolvedElement = zfnull
386 , ZF_OUT_OPT zfstring *firstNotResolvedAttr = zfnull
387 ) const;
391 zffinal void resolveMarkAll(void) const;
395 zffinal void resolveUnmarkAll(void) const;
399 zffinal void resolveAttrMarkAll(void) const;
404
405 // ============================================================
406 // other functions
407public:
414 zfstring ret;
415 this->objectInfoT(ret);
416 return ret;
417 }
418
422 return d == another.d ? ZFCompareEqual : ZFCompareUncomparable;
423 }
424
432
433public:
437 inline zfbool valid(void) const {return d;}
438
439private:
440 _ZFP_ZFSerializableDataPrivate *d;
441 friend zfclassFwd _ZFP_ZFSerializableDataPrivate;
442};
443
445#endif // #ifndef _ZFI_ZFSerializableData_h_
446
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define ZF_OUT_OPT
dummy macro that shows the param used as optional output
Definition ZFCoreTypeDef_ClassType.h:192
#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 ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_OUT
dummy macro that shows the param used as required output
Definition ZFCoreTypeDef_ClassType.h:188
#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
#define zfnullT
type for zfnull, can be used for function overload
Definition ZFCoreTypeDef_CoreType.h:85
_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 zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
ZFCompareResult
compare result of two ZFObjects
Definition ZFCoreTypeDef_OtherType.h:28
@ ZFCompareUncomparable
Definition ZFCoreTypeDef_OtherType.h:29
@ ZFCompareEqual
Definition ZFCoreTypeDef_OtherType.h:31
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
path related info storage for impl
zfbool ZFSerializableDataResolveCheckEnable
whether enable resolve check during serialization, true by default if not built as debug
#define ZFSerializableKeyword_value
keyword for ZFSerializable to hold attribute or property's value, see ZFSerializableData::propertyVal...
Definition ZFSerializableData.h:48
#define ZFSerializableKeyword_prop
keyword for ZFSerializable to hold attribute or property's name, see ZFSerializableData::propertyName
Definition ZFSerializableData.h:43
#define ZFSerializableKeyword_category
keyword for ZFSerializable's to hold category, see ZFSerializableData::category
Definition ZFSerializableData.h:53
light weight array
Definition ZFCoreArray.h:331
base class of all objects
Definition ZFObjectCore.h:209
path related info storage for impl, actual meaning of the info depends on impl
Definition ZFPathInfo.h:35
ZFSerializable's data container, see ZFSerializable.
Definition ZFSerializableData.h:74
void copyFrom(const ZFSerializableData &ref)
copy all the contents
void attrRemove(const zfstring &name)
remove value with name, see attr
void propertyName(const zfstring &name)
see ZFSerializable, same as set value of attribute "prop"
Definition ZFSerializableData.h:144
zfauto serializableDataTagRemoveAndGet(const zfstring &key)
remove tag, return removed tag or null if not exist
zfindex childForCategory(const zfstring &name) const
see childForName
zfindex objectRetainCount(void) const
get current retain count
void resolveAttrMark(const zfstring &name) const
see resolved
void child(const ZFSerializableData &element)
add child element
zfiter attrIter(void) const
see zfiter
zfbool resolvedAttr(const zfstring &name) const
see resolved
void attrIterRemove(zfiter &it)
see zfiter
zfstring propertyName(void) const
see propertyName
Definition ZFSerializableData.h:148
ZFPathInfo pathInfoCheck(void) const
recursively check path info from child to parent
void serializableDataTagRemove(const zfstring &key)
remove tag, same as set tag to null
void objectInfoT(zfstring &ret) const
see objectInfo
zfbool valid(void) const
whether the data is valid
Definition ZFSerializableData.h:437
zfiter attrIterFind(const zfstring &name) const
see zfiter
zfindex childForName(const zfstring &name) const
find element with name or zfindexMax() if not found
zfbool resolvedAll(ZFSerializableData *firstNotResolvedElement=zft_zfnull, zfstring *firstNotResolvedAttr=zft_zfnull) const
see resolved, check whether self and all attribute and child element resolved
void childRemoveAll(void)
remove all element
ZFSerializableData copy(void) const
return a copy of this data
Definition ZFSerializableData.h:99
void attrIterResolveUnmark(const zfiter &it) const
see zfiter
void resolveUnmarkAll(void) const
see resolved, unmark self and all attribute and child element
ZFCompareResult objectCompareValue(const ZFSerializableData &another) const
compare another serializable data by contents
void attrIterValue(zfiter &it, const zfstring &value)
see zfiter
void serializableDataTagRemoveAll(void)
see serializableDataTag
zfstring attr(const zfstring &name) const
see attr
void resolveCategoryUnmark(void) const
see resolved
Definition ZFSerializableData.h:377
void resolveCategoryMark(void) const
see resolved
Definition ZFSerializableData.h:373
void category(const zfstring &category)
see ZFSerializable, same as set value of attribute "category"
Definition ZFSerializableData.h:160
ZFSerializableData & childAt(zfindex index)
see ZFSerializable
zfbool resolved(void) const
used to mark whether the data is resolved
zfindex attrCount(void) const
see attr
void resolveAttrUnmark(const zfstring &name) const
see resolved
const ZFSerializableData & childAt(zfindex index) const
see ZFSerializable
void attrRemoveAll(void)
remove all attribute
void resolveUnmark(void) const
see resolved
zfstring propertyValue(void) const
see propertyValue
Definition ZFSerializableData.h:156
void resolveMarkAll(void) const
see resolved, mark self and all attribute and child element
void serializableDataTagGetAllKeyValue(ZFCoreArray< zfstring > &allKey, ZFCoreArray< zfauto > &allValue) const
see serializableDataTag
zfindex childCount(void) const
see ZFSerializable
void resolvePropertyValueUnmark(void) const
see resolved
Definition ZFSerializableData.h:364
zfbool resolvedPropertyValue(void) const
see resolved
Definition ZFSerializableData.h:356
void removeAll(void)
clear all the contents
void resolvePropertyNameUnmark(void) const
see resolved
Definition ZFSerializableData.h:351
void resolveAttrMarkAll(void) const
see resolved, mark all attribute
zfbool serializableDataParent(ZFSerializableData &ret) const
access parent of this node, return true if parent exists
void pathInfo(const ZFPathInfo &pathInfo)
see pathInfo
zfbool resolvedPropertyName(void) const
see resolved
Definition ZFSerializableData.h:343
const zfstring & itemClass(void) const
see ZFSerializable
void child(const ZFSerializableData &element, zfindex atIndex)
add child element
void resolveMark(void) const
see resolved
zfbool resolvedCategory(void) const
see resolved
Definition ZFSerializableData.h:369
void itemClass(const zfstring &classNameFull)
see ZFSerializable
void attrIterResolveMark(const zfiter &it) const
see zfiter
void propertyValue(const zfstring &value)
see ZFSerializable, same as set value of attribute "value"
Definition ZFSerializableData.h:152
ZFCompareResult objectCompare(const ZFSerializableData &another) const
compare by instance
Definition ZFSerializableData.h:421
void childRemoveAt(zfindex index)
remove element at index
zfstring attrIterKey(const zfiter &it) const
see zfiter
zfstring category(void) const
see category
Definition ZFSerializableData.h:164
zfbool attrIterResolved(const zfiter &it) const
see zfiter
void serializableDataTag(const zfstring &key, ZFObject *tag)
used to store extra state for this serializable data
void attr(const zfstring &name, const zfstring &value)
see ZFSerializable, remove if value is null (same as attrRemove)
void resolvePropertyNameMark(void) const
see resolved
Definition ZFSerializableData.h:347
ZFPathInfo pathInfo(void) const
used for impl to store path related info, see ZFPathInfo
zfany serializableDataTag(const zfstring &key) const
see serializableDataTag
zfstring objectInfo(void) const
get a short info
Definition ZFSerializableData.h:413
void resolvePropertyValueMark(void) const
see resolved
Definition ZFSerializableData.h:360
zfstring attrIterValue(const zfiter &it) const
see zfiter
void childReplace(zfindex index, const ZFSerializableData &element)
replace existing element at index or assert fail if index out of range
void resolveAttrUnmarkAll(void) const
see resolved, unmark all attribute
base class of call serializable object
Definition ZFSerializable.h:163
util method to cast ZFObject types freely
Definition zfany.h:35
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
iterator for ZFFramework
Definition zfiter.h:40
util class to cast ZFObject types freely
smart pointer for ZFObject