1 #ifndef __SSARCHIVER__
4 #include "./tinyxml2/tinyxml2.h"
5 #include "./babel/babel.h"
10 using namespace tinyxml2;
35 virtual EnumSsArchiver::Type getType(){
return EnumSsArchiver::unkown;}
58 virtual bool dc(
const char* name ,
int& member ) = 0;
59 virtual bool dc(
const char* name ,
float& member ) = 0;
60 virtual bool dc(
const char* name ,
bool& member ) = 0;
61 virtual bool dc(
const char* name , std::vector<SsString>& list ) = 0;
63 virtual bool dc(
const char* name , SsString& member ) = 0;
64 virtual bool dc(
const char* name ,
SsPoint2& member ) = 0;
65 virtual bool dc(
const char* name ,
SsCurve& member ) = 0;
68 virtual bool dc_attr(
const char* name , SsString& member ) = 0;
69 virtual bool dc_attr(
const char* name ,
int& member ) = 0;
74 inline static int GetTextToInt(
XMLElement* e ,
int default_value )
76 int ret =default_value;
90 virtual EnumSsArchiver::Type getType(){
return EnumSsArchiver::in;}
95 firstChild( ar , element_name );
99 setDocumet( doc , element_name );
111 virtual bool dc(
const char* name ,
int& member );
112 virtual bool dc(
const char* name ,
float& member );
113 virtual bool dc(
const char* name , SsString& member );
114 virtual bool dc(
const char* name ,
bool& member );
115 virtual bool dc(
const char* name , std::vector<SsString>& list );
116 virtual bool dc(
const char* name ,
SsPoint2& member );
117 virtual bool dc(
const char* name ,
SsCurve& member );
119 virtual bool dc_attr(
const char* name , SsString& member );
120 virtual bool dc_attr(
const char* name ,
int& member );
123 template<
class my
class>
bool dc(
const char* name , std::vector<myclass*>& list ,
const std::string key =
"value" )
133 myclass* _temp =
new myclass();
135 _temp->__Serialize( &_ar );
136 list.push_back( _temp );
143 template<
class my
class>
bool dc(
const char* name , myclass& type )
147 __StringToEnum_( str , type);
152 template<
class my
class>
bool dc_attr(
const char* name , myclass& type )
155 dc_attr( name , str );
156 __StringToEnum_( str , type);
164 #define SSSERIALIZE_BLOCK void __Serialize(ISsXmlArchiver* ar)
166 #define SSAR_DECLARE(t) ar->dc(#t,t)
167 #define SSAR_DECLARE_ATTRIBUTE(t) ar->dc_attr(#t,t)
169 #define SSAR_STRUCT_DECLARE(t) {SsXmlIArchiver _ar( ar , #t );\
170 t.__Serialize( &_ar );}\
172 template<
class my
class>
173 inline bool __SSAR_DECLARE_LIST__(
ISsXmlArchiver* ar , std::vector<myclass*>& list,
const char* name ,
const std::string key =
"value" )
175 if ( ar->getType() == EnumSsArchiver::in )
177 return (static_cast<SsXmlIArchiver*>(ar))->dc( name , list , key );
180 if ( ar->getType() == EnumSsArchiver::out )
187 #define SSAR_DECLARE_LIST(t) __SSAR_DECLARE_LIST__( ar , t , #t)
188 #define SSAR_DECLARE_LISTEX(t,key) __SSAR_DECLARE_LIST__( ar , t , #t , key )
190 template<
class my
class>
191 inline bool __SSAR_DECLARE_ENUM__(
ISsXmlArchiver* ar ,myclass& type,
const char* name )
193 if ( ar->getType() == EnumSsArchiver::in )
195 return (static_cast<SsXmlIArchiver*>(ar))->dc( name , type );
198 if ( ar->getType() == EnumSsArchiver::out )
204 template<
class my
class>
205 inline bool __SSAR_DECLARE_ATTRIBUTE_ENUM__(
ISsXmlArchiver* ar ,myclass& type,
const char* name )
207 if ( ar->getType() == EnumSsArchiver::in )
209 return (static_cast<SsXmlIArchiver*>(ar))->dc_attr( name , type );
212 if ( ar->getType() == EnumSsArchiver::out )
220 #define SSAR_DECLARE_ENUM(t) __SSAR_DECLARE_ENUM__( ar , t , #t)
221 #define SSAR_DECLARE_ATTRIBUTE_ENUM(t) __SSAR_DECLARE_ATTRIBUTE_ENUM__( ar , t , #t)
224 bool StringToPoint2(
const std::string& str ,
SsPoint2& point );
225 bool StringToIRect(
const std::string& str ,
SsIRect& rect );
229 void SsArchiverInit();
232 #define AR_SELF_CHECK() if ( this->getxml() == 0 ) return false;