From: stephan b. <sg...@us...> - 2004-12-30 22:53:04
|
Update of /cvsroot/pclasses/pclasses2/src/SIO/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2755/src/SIO/Proxy Added Files: AppDetails_s11n.h LexT_s11n.h Makefile.toc SimplePropertyStore_s11n.h String_s11n.h Time_s11n.h Log Message: egg - moving over proxies from s11n/proxy. --- NEW FILE: LexT_s11n.h --- //////////////////////////////////////////////////////////////////////// // Defines an s11n proxy for the LexT type. // Should be included from any code which wants to de/serialize // a LexT using the standard s11n interface. // // Conventions: // - Clients must include SIO support before including this. //////////////////////////////////////////////////////////////////////// #if !defined(PCLASSES_S11N_INCLUDED) # error "s11n.h or SIO.h must be included before plugging in s11n proxies!" #else #if !defined(p_UTIL_LEXT_REGISTERED_WITH_S11N) # define p_UTIL_LEXT_REGISTERED_WITH_S11N 1 # include <pclasses/Util/LexT.h> // better safe than sorry. # define PS11N_TYPE P::Util::LexT # define PS11N_TYPE_NAME "LexT" # define PS11N_SERIALIZE_FUNCTOR ::P::s11n::streamable_type_serialization_proxy # include <pclasses/s11n/reg_serializable_traits.h> #endif // p_UTIL_LEXT_REGISTERED_WITH_S11N #endif // PCLASSES_S11N_INCLUDED //////////////////////////////////////////////////////////////////////// --- NEW FILE: Makefile.toc --- #!/usr/bin/make -f include toc.make HEADERS = $(wildcard *.h) DIST_FILES += \ $(HEADERS) INSTALL_HEADERS = $(HEADERS) INSTALL_HEADERS_DEST = $(INSTALL_HEADERS_DEST_BASE)/SIO/Proxy SYMLINK_HEADERS = $(HEADERS) SYMLINK_HEADERS_DEST = $(top_srcdir)/include/pclasses/SIO/Proxy include $(TOC_MAKESDIR)/SYMLINK_HEADERS.make all: SYMLINK_HEADERS --- NEW FILE: Time_s11n.h --- //////////////////////////////////////////////////////////////////////// // Defines an s11n proxy for the Time, Date and DateTime types. // Should be included from any code which wants to de/serialize // these types using the standard s11n interface. // // Conventions: // - Clients must include SIO support before including this. //////////////////////////////////////////////////////////////////////// #if !defined(PCLASSES_S11N_INCLUDED) # error "s11n.h or SIO.h must be included before plugging in s11n proxies!" #else //////////////////////////////////////////////////////////////////////// // Time proxy //////////////////////////////////////////////////////////////////////// #if !defined(p_TIME_REGISTERED_WITH_S11N) # define p_TIME_REGISTERED_WITH_S11N 1 # include <pclasses/Time.h> namespace P { using ::P::Time; struct Time_s11n { // serialize template <typename NodeType> bool operator()( NodeType & dest, const Time & src ) const { typedef ::P::s11n::node_traits<NodeType> TR; TR::class_name( dest, "P::Time" ); // don't use ::classname<Time>() here: it causes an ODR violation :( # define SSET(K,F) TR::set( dest, std::string(K), src.F() ); SSET("sec", second ); SSET("min", minute ); SSET("hour", hour ); SSET("usec", usec ); # undef SSET return true; } // deserialize template <typename NodeType> bool operator()( const NodeType & src, Time & dest ) const { typedef ::P::s11n::node_traits<NodeType> TR; # define SGET(K,SF,GF) dest.SF( TR::get( src, std::string(K), dest.GF() ) ); SGET("sec", setSecond, second ); SGET("min", setMinute, minute ); SGET("hour", setHour, hour ); SGET("usec", setUsec, usec ); # undef SGET return true; } }; // Time_s11n }// namespace P # define PS11N_TYPE ::P::Time # define PS11N_TYPE_NAME "P::Time" # define PS11N_SERIALIZE_FUNCTOR P::Time_s11n # include <pclasses/s11n/reg_serializable_traits.h> #endif // p_TIME_REGISTERED_WITH_S11N //////////////////////////////////////////////////////////////////////// // Date proxy //////////////////////////////////////////////////////////////////////// #if !defined(p_DATE_REGISTERED_WITH_S11N) # define p_DATE_REGISTERED_WITH_S11N 1 # include <pclasses/Date.h> namespace P { using ::P::Date; struct Date_s11n { // serialize template <typename NodeType> bool operator()( NodeType & dest, const Date & src ) const { typedef ::P::s11n::node_traits<NodeType> TR; TR::class_name( dest, "P::Date" ); # define SSET(K,F) TR::set( dest, std::string(K), src.F() ); SSET("year", year ); SSET("month", month ); SSET("day", day ); # undef SSET return true; } // deserialize template <typename NodeType> bool operator()( const NodeType & src, Date & dest ) const { typedef ::P::s11n::node_traits<NodeType> TR; # define SGET(K,SF,GF) dest.SF( TR::get( src, std::string(K), dest.GF() ) ); SGET("year", setYear, year ); SGET("month", setMonth, month ); SGET("day", setDay, day ); # undef SGET return true; } }; // Date_s11n }// namespace P # define PS11N_TYPE ::P::Date # define PS11N_TYPE_NAME "P::Date" # define PS11N_SERIALIZE_FUNCTOR P::Date_s11n # include <pclasses/s11n/reg_serializable_traits.h> #endif // p_DATE_REGISTERED_WITH_S11N //////////////////////////////////////////////////////////////////////// // DateTime proxy //////////////////////////////////////////////////////////////////////// #if !defined(p_DATETIME_REGISTERED_WITH_S11N) # define p_DATETIME_REGISTERED_WITH_S11N 1 # include <pclasses/DateTime.h> namespace P { using ::P::DateTime; struct DateTime_s11n { // serialize template <typename NodeType> bool operator()( NodeType & dest, const DateTime & src ) const { typedef ::P::s11n::node_traits<NodeType> TR; TR::class_name( dest, "P::DateTime" ); using namespace ::P::s11n; bool worked = serialize_subnode<NodeType,Time>( dest, "time", src ); worked = worked && serialize_subnode<NodeType,Date>( dest, "date", src ); return worked; } // deserialize template <typename NodeType> bool operator()( const NodeType & src, DateTime & dest ) const { typedef ::P::s11n::node_traits<NodeType> TR; using namespace ::P::s11n; bool worked = deserialize_subnode<NodeType,Time>( src, "time", dest ); if( worked ) { worked = deserialize_subnode<NodeType,Date>( src, "date", dest ); } return worked; } }; // DateTime_s11n }// namespace P # define PS11N_TYPE ::P::DateTime # define PS11N_TYPE_NAME "P::DateTime" # define PS11N_SERIALIZE_FUNCTOR P::DateTime_s11n # include <pclasses/s11n/reg_serializable_traits.h> #endif // p_DATETIME_REGISTERED_WITH_S11N #endif // PCLASSES_S11N_INCLUDED //////////////////////////////////////////////////////////////////////// --- NEW FILE: SimplePropertyStore_s11n.h --- #if !defined(PCLASSES_S11N_INCLUDED) # error "s11n.h or SIO.h must be included before plugging in s11n proxies!" #else #include "LexT_s11n.h" #if !defined(p_UTIL_SIMPLEPRPOPERTYSTORE_REGISTERED_WITH_S11N) # define p_UTIL_SIMPLEPRPOPERTYSTORE_REGISTERED_WITH_S11N 1 # define PS11N_TYPE ::P::Util::SimplePropertyStore # define PS11N_TYPE_NAME "P::Util::SimplePropertyStore" # define PS11N_SERIALIZE_FUNCTOR ::P::s11n::map::streamable_map_serializable_proxy # include <pclasses/s11n/reg_serializable_traits.h> #endif // p_UTIL_SIMPLEPRPOPERTYSTORE_REGISTERED_WITH_S11N #endif // PCLASSES_S11N_INCLUDED //////////////////////////////////////////////////////////////////////// --- NEW FILE: String_s11n.h --- //////////////////////////////////////////////////////////////////////// // Defines an s11n proxy for the String type. // Should be included from any code which wants to de/serialize // a String using the standard s11n interface. // // Conventions: // - Clients must include SIO support before including this. //////////////////////////////////////////////////////////////////////// #if !defined(PCLASSES_S11N_INCLUDED) # error "s11n.h or SIO.h must be included before plugging in s11n proxies!" #else #if !defined(p_UNICODE_STRING_REGISTERED_WITH_S11N) #include <pclasses/Unicode/String.h> namespace P { namespace SIO { namespace Proxy { struct String_s11n { public: // serialize template <typename NodeType> bool operator()( NodeType & dest, const ::P::Unicode::String & src ) const { typedef ::P::s11n::node_traits<NodeType> TR; TR::class_name( dest, "P::Unicode::String" ); TR::set( dest, "str", src.utf8() ); return true; } // deserialize template <typename NodeType> bool operator()( const NodeType & src, ::P::Unicode::String & dest ) const { typedef ::P::s11n::node_traits<NodeType> TR; std::string s = TR::get( src, "str", std::string() ); try { dest = ::P::Unicode::String::fromLatin1( s, s.size() ); } catch( ... ) { return false; } return true; } }; }}} // namespace ::P::SIO::Proxy #define PS11N_TYPE ::P::Unicode::String #define PS11N_TYPE_NAME "P::Unicode::String" #define PS11N_SERIALIZE_FUNCTOR ::P::SIO::Proxy::String_s11n #include <pclasses/s11n/reg_serializable_traits.h> #endif // p_UNICODE_STRING_REGISTERED_WITH_S11N #endif // PCLASSES_S11N_INCLUDED //////////////////////////////////////////////////////////////////////// --- NEW FILE: AppDetails_s11n.h --- //////////////////////////////////////////////////////////////////////// // Defines an s11n proxy for the String type. // Should be included from any code which wants to de/serialize // a String using the standard s11n interface. // // Conventions: // - Clients must include SIO support before including this. //////////////////////////////////////////////////////////////////////// #if !defined(PCLASSES_S11N_INCLUDED) # error "s11n.h or SIO.h must be included before plugging in s11n proxies!" #else #if !defined(p_APP_APPINFO_REGISTERED_WITH_S11N) #include <pclasses/App/AppDetails.h> #include <pclasses/s11n/list.h> // needed to de/serialize DetailList #include <pclasses/SIO/Proxy/String_s11n.h> // needed to de/ser String namespace P { namespace SIO { namespace Proxy { struct AppDetails_s11n { // serialize template <typename NodeType> bool operator()( NodeType & dest, const ::P::App::AppDetails & src ) const { typedef ::P::s11n::node_traits<NodeType> TR; TR::class_name( dest, "P::App::AppDetails" ); TR::set( dest, "name", src.getName().utf8() ); TR::set( dest, "about", src.getAboutText().utf8() ); TR::set( dest, "license", src.getLicenseText().utf8() ); return ::P::s11n::serialize_subnode( dest, "authors", src.getAuthors() ); } // deserialize template <typename NodeType> bool operator()( const NodeType & src, ::P::App::AppDetails & dest ) const { CERR << "Deserialize AppDetails...\n"; typedef ::P::s11n::node_traits<NodeType> TR; dest.setName( TR::get( src, "name", ::P::Unicode::String() ) ); dest.setAboutText( TR::get( src, "about", ::P::Unicode::String() ) ); dest.setLicenseText( TR::get( src, "license", ::P::Unicode::String() ) ); return ::P::s11n::deserialize_subnode( src, "authors", dest.getAuthors() ); } }; // AppDetails_s11n }}} // namespace ::P::SIO::Proxy # define PS11N_TYPE P::App::AppDetails # define PS11N_TYPE_NAME "P::App::AppDetails" # define PS11N_SERIALIZE_FUNCTOR P::SIO::Proxy::AppDetails_s11n # include <pclasses/s11n/reg_serializable_traits.h> #endif // p_APP_APPINFO_REGISTERED_WITH_S11N #endif // PCLASSES_S11N_INCLUDED //////////////////////////////////////////////////////////////////////// |