ZFFramework
 
Loading...
Searching...
No Matches
UI serialization

most of UI elements in ZFFramework is also serializable, and it's easy to serialize from and to xml format
here's a quick example to see the xml output format:

parent->child(child)->c_sizeFill();
child->label()->text("button");
zfstring xmlString;
ZFLogTrim() << "serialized data:";
ZFLogTrim() << xmlString;
zfauto objNew = ZFObjectFromData(dataNew);
ZFLogTrim() << "re-serialized object:";
ZFLogTrim() << objNew;
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
ZFInput ZFInputForString(const zfstring &src, zfbool serializable=_ZFT_t_zffalse)
create a input callback from string
ZFOutput ZFOutputForString(zfstring &s)
create a output callback to output to a zfstring
#define ZFLogTrim(...)
see ZFLog
Definition ZFLog.h:80
ZFSerializableData ZFObjectToData(ZFObject *obj, zfbool *outSuccess=zft_zfnull, zfstring *outErrorHint=zft_zfnull, ZFSerializable *refOwner=zft_zfnull)
see ZFObjectFromDataT
zfauto ZFObjectFromData(const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
see ZFObjectFromDataT
ZFLIB_ZFAlgorithm zfbool ZFSerializableDataToXml(ZFXml &xmlElement, const ZFSerializableData &serializableData, zfstring *outErrorHint=(zft_zfnull), ZFSerializableData *outErrorPos=(zft_zfnull))
print serializable to xml formated data
ZFLIB_ZFAlgorithm zfbool ZFSerializableDataFromXml(ZFSerializableData &serializableData, const ZFXml &xmlElement, zfstring *outErrorHint=(zft_zfnull), ZFXml *outErrorPos=(zft_zfnull))
parse xml formated data to serializable
ZFSerializable's data container, see ZFSerializable.
Definition ZFSerializableData.h:74
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
util class to alloc and hold ZFObject type
Definition ZFObjectAutoPtr.h:157

which would output these:

serialized data:
<ZFUIButtonBasic category="child" >
<ZFUITextView prop="labelNormal" >
<zfstring prop="text" value="button" />
<ZFUILayoutParam category="layoutParam" >
<ZFUISizeParam prop="sizeParam" value="(Fill, Fill)" />
re-serialized object:
<ZFUIView(0x7fe61e1340b0) (0, 0, 0, 0)>
basic button, see ZFUIButton
Definition ZFUIButtonBasic.h:33
base class of all layout param in ZFUIView
Definition ZFUIViewType.h:123
2D size
Definition ZFUIViewType.h:41
view to display plain text
Definition ZFUITextView.h:21
base class of all UI views
Definition ZFUIView.h:93