ZFFramework
 
Loading...
Searching...
No Matches
ZFSerializable.h File Reference

serializable interface More...

#include "ZFObjectCore.h"
#include "ZFIOCallback.h"

Go to the source code of this file.

Classes

class  ZFSerializable
 base class of call serializable object More...
 

Macros

#define ZFSerializableKeyword_styleKey
 keyword for ZFSerializable to hold style, see ZFStyleSet
 
#define ZFSerializableKeyword_serializableNewInstanceId
 used for ZFSerializable to override default constructor
 
#define ZFSerializableKeyword_serializableNewInstance
 see ZFSerializableKeyword_serializableNewInstanceId
 
#define ZFTOKEN_ZFSerializablePropertyTypeUnspecified
 string tokens
 
#define ZFTOKEN_ZFSerializablePropertyTypeNotSerializable
 string tokens
 
#define ZFTOKEN_ZFSerializablePropertyTypeSerializable
 string tokens
 
#define ZFTOKEN_ZFSerializablePropertyTypeEmbeded
 string tokens
 

Enumerations

enum  ZFSerializablePropertyType { ZFSerializablePropertyTypeUnspecified , ZFSerializablePropertyTypeNotSerializable , ZFSerializablePropertyTypeSerializable , ZFSerializablePropertyTypeEmbeded }
 serializable property type, see ZFSerializable::serializableOnCheckPropertyType More...
 

Functions

zfbool ZFObjectIsSerializable (ZFObject *obj)
 true if object is serializable
 
zfbool ZFObjectFromDataT (zfauto &result, const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
 convenient method to ZFSerializable::serializeFromData
 
zfauto ZFObjectFromData (const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
 see ZFObjectFromDataT
 
zfbool ZFObjectToDataT (ZFSerializableData &serializableData, ZFObject *obj, zfstring *outErrorHint=zft_zfnull, ZFSerializable *refOwner=zft_zfnull)
 see ZFObjectFromDataT
 
ZFSerializableData ZFObjectToData (ZFObject *obj, zfbool *outSuccess=zft_zfnull, zfstring *outErrorHint=zft_zfnull, ZFSerializable *refOwner=zft_zfnull)
 see ZFObjectFromDataT
 
zfbool ZFObjectFromStringT (zfauto &result, const ZFClass *cls, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 convenient method to ZFSerializable::serializeFromString
 
zfauto ZFObjectFromString (const ZFClass *cls, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 see ZFObjectFromStringT
 
zfbool ZFObjectToStringT (zfstring &ret, ZFObject *obj, zfstring *errorHint=zft_zfnull)
 see ZFObjectFromStringT
 
zfstring ZFObjectToString (ZFObject *obj, zfstring *errorHint=zft_zfnull)
 see ZFObjectFromStringT
 
zfbool ZFObjectFromStringOrDataT (zfauto &result, const ZFClass *cls, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 convenient method to ZFObjectFromString or ZFObjectFromData
 
zfauto ZFObjectFromStringOrData (const ZFClass *cls, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 see ZFObjectFromStringOrDataT
 
zfbool ZFObjectToStringOrDataT (zfstring &ret, ZFObject *obj, zfstring *errorHint=zft_zfnull)
 see ZFObjectFromStringOrDataT
 
zfstring ZFObjectToStringOrData (ZFObject *obj, zfstring *errorHint=zft_zfnull)
 see ZFObjectFromStringOrDataT
 

Detailed Description

serializable interface

Macro Definition Documentation

◆ ZFSerializableKeyword_serializableNewInstanceId

#define ZFSerializableKeyword_serializableNewInstanceId

used for ZFSerializable to override default constructor

by default, serializable would be created by ZFClass::newInstance while serializing from data, you may supply this method to override:

  • static zfauto serializableNewInstance(void);

the method should be supplied as ZFMethod
the method should return a newly created object, or retain your existing singleton instance
typically this method is used to achieve some singleton logic

Enumeration Type Documentation

◆ ZFSerializablePropertyType

serializable property type, see ZFSerializable::serializableOnCheckPropertyType

Enumerator
ZFSerializablePropertyTypeUnspecified 

see ZFSerializable::serializableOnCheckPropertyType

ZFSerializablePropertyTypeNotSerializable 

see ZFSerializable::serializableOnCheckPropertyType

ZFSerializablePropertyTypeSerializable 

see ZFSerializable::serializableOnCheckPropertyType

ZFSerializablePropertyTypeEmbeded 

see ZFSerializable::serializableOnCheckPropertyType

Function Documentation

◆ ZFObjectIsSerializable()

zfbool ZFObjectIsSerializable ( ZFObject * obj)
extern

true if object is serializable

note that null is treated as serializable

◆ ZFObjectFromDataT()

zfbool ZFObjectFromDataT ( zfauto & result,
const ZFSerializableData & serializableData,
zfstring * outErrorHint = zft_zfnull,
ZFSerializableData * outErrorPos = zft_zfnull )
extern

convenient method to ZFSerializable::serializeFromData

Note
return null object doesn't necessarily mean fail, if the input is ZFSerializableKeyword_null, which describe a null object, the result would be null