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->childAdd(child)->c_sizeFill();
child->label()->text("button");
zfstring xmlString;
zfLogTrim() << "serialized data:";
zfLogTrim() << xmlString;
zfauto objNew = ZFObjectFromData(dataNew);
zfLogTrim() << "re-serialized object:";
zfLogTrim() << objNew;
ZFInput ZFInputForBufferUnsafe(const void *src, zfindex count=((zfindex) -1), zfbool serializable=_ZFT_t_zffalse)
create a intput callback input from a const void *, you must ensure the buffer is alive during the ca...
ZFOutput ZFOutputForString(zfstring &s)
create a output callback to output to a zfstring
#define zfLogTrim(...)
see zfLog
Definition ZFLog.h:67
ZFSerializableData ZFObjectToData(ZFObject *obj, zfbool *outSuccess=0, zfstring *outErrorHint=0, ZFSerializable *referencedOwnerOrNull=0)
see ZFObjectFromDataT
zfauto ZFObjectFromData(const ZFSerializableData &serializableData, zfstring *outErrorHint=0, ZFSerializableData *outErrorPos=0)
see ZFObjectFromDataT
zfbool ZFSerializableDataToXml(ZFXml &xmlElement, const ZFSerializableData &serializableData, zfstring *outErrorHint=(0), ZFSerializableData *outErrorPos=(0))
print serializable to xml formated data
zfbool ZFSerializableDataFromXml(ZFSerializableData &serializableData, const ZFXml &xmlElement, zfstring *outErrorHint=(0), ZFXml *outErrorPos=(0))
parse xml formated data to serializable
ZFSerializable's data container, see ZFSerializable.
Definition ZFSerializableData.h:72
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:164

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:124
2D size
Definition ZFUIViewType.h:40
view to display plain text
Definition ZFUITextView.h:21
base class of all UI views
Definition ZFUIView.h:93