From: <sg...@us...> - 2003-11-17 20:41:38
|
Update of /cvsroot/libfunutil/libfunutil/client/s11nconvert In directory sc8-pr-cvs1:/tmp/cvs-serv767 Modified Files: AltSerializable.cpp AltSerializable.h BarClass.cpp BarClass.h FooClass.cpp FooClass.h LoadableClass.h Makefile in.paren in.s11n main.cpp maser.cpp test_s11n.sh Log Message: about to reorg Index: AltSerializable.cpp =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/AltSerializable.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AltSerializable.cpp 17 Oct 2003 09:07:35 -0000 1.2 +++ AltSerializable.cpp 17 Nov 2003 20:41:13 -0000 1.3 @@ -1,15 +1,14 @@ #include "AltSerializable.h" -#include <toolbox/debuggering_macros.h> // COUT/CERR -#include <toolbox/ClassLoader.h> // COUT/CERR -#include <toolbox/SimpleCLParser.h> // COUT/CERR -#include <s11n/serializable_adapter.h> +#include <S11N_NAMESPACEdebuggering_macros.h> // COUT/CERR +#include <S11N_NAMESPACEclass_loader.h> // COUT/CERR +#include <S11N_NAMESPACEargv_parser.h> // COUT/CERR -#define VERBOSE if (toolbox::SimpleCLParser::args().get_bool( "v", false ) ) CERR +#define VERBOSE if (S11N_NAMESPACEargv_parser::args().get_bool( "v", false ) ) CERR /** A test class for demonstrating the ability to use - non-s11n::Serializable types with the framework. + non-S11N_NAMESPACESerializable types with the s11n framework. */ namespace alts11n { AltSerializable::AltSerializable(){}; @@ -71,7 +70,7 @@ return b; } - AltSubSub::AltSubSub() {};// this->set_class("alts11n::AltSubSub"); } + AltSubSub::AltSubSub() {};// this->set_class("altS11N_NAMESPACEAltSubSub"); } AltSubSub::~AltSubSub() { VERBOSE << "~AltSubSub()"<<std::endl; @@ -91,4 +90,4 @@ return b; } }; - // namespace alts11n:: + // namespace altS11N_NAMESPACE Index: AltSerializable.h =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/AltSerializable.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AltSerializable.h 17 Oct 2003 09:07:36 -0000 1.2 +++ AltSerializable.h 17 Nov 2003 20:41:14 -0000 1.3 @@ -1,8 +1,11 @@ +#ifndef ALTS11N_ALTSERIALIZABLE_H_INCLUDED +#define ALTS11N_ALTSERIALIZABLE_H_INCLUDED 1 + #include <string> -#include <s11n/s11n_node.h> +#include <S11N_NAMESPACEs11n_node.h> /** A test class for demonstrating the ability to use - non-s11n::Serializable types with the framework. + non-S11N_NAMESPACESerializable types with the s11n framework. */ namespace alts11n { class AltSerializable @@ -12,7 +15,7 @@ public: AltSerializable(); virtual ~AltSerializable(); - typedef s11n::s11n_node state; + typedef S11N_NAMESPACEs11n_node state; virtual bool save_state( state & node ) const; virtual bool load_state( const state & node ); void bogo_method(std::string str= ""); @@ -31,9 +34,10 @@ virtual ~AltSubSub(); virtual bool load_state( const AltSerializable::state & node ); }; -} // namespace alts11n:: +} // namespace altS11N_NAMESPACE +#include <S11N_NAMESPACEserializable_adapter.h> /** This creates the required serializable_adapter<AltSerializable> specializations to map the AltSerializable API to @@ -42,9 +46,45 @@ instead of using this macro, and you must do so if your de/serialize() function signatures differ from the defaults. - It also registers the types with the appropriate ClassLoader and - sets up class_name<> specializations. + It also registers the types with the appropriate + S11N_NAMESPACEclass_loader and sets up S11N_NAMESPACEclass_name<> + specializations. */ -SERIALIZABLE_ADAPTER(alts11n::AltSerializable,save_state,load_state); -SERIALIZABLE_REGISTER(alts11n::AltSerializable,alts11n::AltSub); -SERIALIZABLE_REGISTER(alts11n::AltSerializable,alts11n::AltSubSub); +#define EASY_WAY 0 +#if EASY_WAY +SERIALIZABLE_ADAPTER(altS11N_NAMESPACEAltSerializable,save_state,load_state); +#else +CLASSLOADER_REGISTER(altS11N_NAMESPACEAltSerializable,altS11N_NAMESPACEAltSerializable); +CLASS_NAME(altS11N_NAMESPACEAltSerializable); +namespace { + typedef S11N_NAMESPACEs11n_node node_type; + template <> struct serializable_adapter<altS11N_NAMESPACEAltSerializable,node_type> + { + typedef altS11N_NAMESPACEAltSerializable serializable_type; + typedef altS11N_NAMESPACEAltSerializable impl_type; + explicit serializable_adapter(){}; + ~serializable_adapter(){}; + static std::string class_name() + { + return "altS11N_NAMESPACEAltSerializable"; + } + static bool serialize( const serializable_type & ser, node_type &node ) + { + static unsigned long count = 0; // you don't need this! + ++count; + node.impl_class( class_name() ); + return ser.save_state( node ); + } + static bool deserialize( serializable_type & ser, const node_type & node ) + { + static unsigned long count = 0; // you don't need this! + ++count; + return ser.load_state( node ); + } + }; +} +#endif // EASY_WAY +SERIALIZABLE_REGISTER(altS11N_NAMESPACEAltSerializable,altS11N_NAMESPACEAltSub); +SERIALIZABLE_REGISTER(altS11N_NAMESPACEAltSerializable,altS11N_NAMESPACEAltSubSub); + +#endif // ALTS11N_ALTSERIALIZABLE_H_INCLUDED Index: BarClass.cpp =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/BarClass.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- BarClass.cpp 17 Oct 2003 09:07:36 -0000 1.2 +++ BarClass.cpp 17 Nov 2003 20:41:14 -0000 1.3 @@ -1,4 +1,4 @@ -#include <s11n/s11n-macros.h> // COUT/CERR +#include <S11N_NAMESPACEs11n-macros.h> // COUT/CERR #include "BarClass.h" Index: BarClass.h =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/BarClass.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- BarClass.h 17 Oct 2003 09:07:36 -0000 1.2 +++ BarClass.h 17 Nov 2003 20:41:14 -0000 1.3 @@ -1,19 +1,19 @@ -#include <s11n/s11n-macros.h> // COUT/CERR -#include <s11n/s11n_node.h> +#include <S11N_NAMESPACEs11n-macros.h> // COUT/CERR +#include <S11N_NAMESPACEs11n_node.h> using namespace s11n; using namespace std; -// #include <s11n/serializable_adapter.h> -#include <s11n/Serializable.h> +// #include <S11N_NAMESPACEserializable_adapter.h> +#include <S11N_NAMESPACESerializable.h> -struct BarClass: public s11n::Serializable +struct BarClass: public S11N_NAMESPACESerializable { std::string name; int magic_number; BarClass( ); virtual ~ BarClass( ); - virtual bool s7e( s11n::s11n_node & ser ) const; - virtual bool d9e( const s11n::s11n_node & node ); + virtual bool s7e( S11N_NAMESPACEs11n_node & ser ) const; + virtual bool d9e( const S11N_NAMESPACEs11n_node & node ); }; -SERIALIZABLE_REGISTER(s11n::Serializable,BarClass); +SERIALIZABLE_REGISTER(S11N_NAMESPACESerializable,BarClass); Index: FooClass.cpp =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/FooClass.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- FooClass.cpp 17 Oct 2003 09:07:36 -0000 1.2 +++ FooClass.cpp 17 Nov 2003 20:41:14 -0000 1.3 @@ -1,8 +1,8 @@ -#include <s11n/s11n-macros.h> // COUT/CERR -#include <s11n/s11n_globals.h> // registration-related macros -// #include <toolbox/ClassLoader.h> -// #include <toolbox/Instantiator.h> +#include <S11N_NAMESPACEs11n-macros.h> // COUT/CERR +#include <S11N_NAMESPACEs11n_globals.h> // registration-related macros +// #include <S11N_NAMESPACEclass_loader.h> +// #include <S11N_NAMESPACEinstantiator.h> #include "FooClass.h" @@ -24,50 +24,60 @@ } // namespace foo -SERIALIZABLE_REGISTER(s11n::Serializable,foo::BarClass); -SERIALIZABLE_REGISTER(s11n::Serializable,foo::Baz); +SERIALIZABLE_REGISTER(S11N_NAMESPACESerializable,foo::BarClass); +SERIALIZABLE_REGISTER(S11N_NAMESPACESerializable,foo::Baz); namespace { - int DLLLoader_bootstrap() + /** + We use dll_loader_bootstrap() to run code, activated when + static objects are initialized. i.e., before main() or when + a DLL is dlopen()ed. + */ + int dll_loader_bootstrap() { - CERR << "DLLLoader_bootstrap()" << endl; - typedef toolbox::ClassLoader<s11n::Serializable> CL; + CERR << "dll_loader_bootstrap()" << endl; + typedef S11N_NAMESPACEclass_loader<S11N_NAMESPACESerializable> CL; CL::register_subtype<foo::FooClass>("foo::WonderBra"); return 0; } - static const int nomeaning = DLLLoader_bootstrap(); + static const int nomeaning = dll_loader_bootstrap(); } namespace foo { using namespace s11n; using namespace std; - std::string name; FooClass::FooClass() { - this->name = "unnamed FooClass"; - //LOUT << "FooClass()" << endl; - }; + this->name = "unnamed FooClass object"; + for( int i = 0; i < 5; i++ ) + { + this->m_vec.push_back( i ); + } + } FooClass::~FooClass() { - //LIBE_VERBOSE_DTORS(FooClass); - }; + } bool FooClass::s7e( s11n_node & node ) const { if ( !this->Serializable::s7e( node ) ) return false; node.set( "name", this->name ); + node.serialize_list( "vector", this->m_vec ); return true; } bool FooClass::d9e( const s11n_node & node ) { - CERR << node.impl_class()<<"::deserialize()" << std::endl; + this->m_vec.clear(); + CERR <<"deserialize() impl_class="<<node.impl_class() << std::endl; if ( !this->Serializable::d9e( node ) ) return false; this->name = node.get( "name", "<unnamed>" ); + node.deserialize_list( "vector", this->m_vec ); + CERR << "m_vec size = " << m_vec.size() << std::endl; return true; } }; // namespace foo Index: FooClass.h =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/FooClass.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- FooClass.h 17 Oct 2003 09:07:36 -0000 1.2 +++ FooClass.h 17 Nov 2003 20:41:14 -0000 1.3 @@ -1,17 +1,19 @@ #ifndef FOO_H_INCLUDED #define FOO_H_INCLUDED 1 -#include <s11n/s11n_io.h> +#include <S11N_NAMESPACEs11n_node.h> +#include <S11N_NAMESPACESerializable.h> +#include <vector> -#include <s11n/Serializable.h> namespace foo { - struct FooClass : public s11n::Serializable + struct FooClass : public S11N_NAMESPACESerializable { + std::vector<int> m_vec; std::string name; FooClass( ); virtual ~ FooClass( ); - virtual bool s7e( s11n::s11n_node & ser ) const; - virtual bool d9e( const s11n::s11n_node & ser ); + virtual bool s7e( S11N_NAMESPACEs11n_node & ser ) const; + virtual bool d9e( const S11N_NAMESPACEs11n_node & ser ); // private: // void bogosity(){} @@ -19,6 +21,6 @@ }; }; // namespace foo -SERIALIZABLE_REGISTER(s11n::Serializable,foo::FooClass); +SERIALIZABLE_REGISTER(S11N_NAMESPACESerializable,foo::FooClass); #endif // FOO_H_INCLUDED Index: LoadableClass.h =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/LoadableClass.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- LoadableClass.h 14 Oct 2003 03:26:54 -0000 1.1 +++ LoadableClass.h 17 Nov 2003 20:41:14 -0000 1.2 @@ -2,7 +2,7 @@ #define LOADABLECLASS_H_INCLUDED 1 #include <iostream> -#include <s11n/s11n-macros.h> // COUT +#include <S11N_NAMESPACEs11n-macros.h> // COUT struct LoadableClass { Index: Makefile =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile 17 Oct 2003 09:07:36 -0000 1.2 +++ Makefile 17 Nov 2003 20:41:14 -0000 1.3 @@ -1,14 +1,22 @@ include toc.make +############################## expected from toc.make: +S11N_NAMESPACE ?= s11n +############################## # CPPFLAGS += -DCLASSLOADER_DEBUG=1 + DIST_FILES += $(wildcard in.* *.cpp *.h) + + BIN_PROGRAMS = s11nconvert +# maser # alts11nconvert s11nconvert_bin_OBJECTS = main.o AltSerializable.o +maser_bin_OBJECTS = maser.o alts11nconvert_bin_OBJECTS = main2.o AltSerializable.o main2.cpp: main.cpp @@ -30,10 +38,12 @@ endif main_cpp_CPPFLAGS = -DSERIALIZABLE_TYPE=$(SERIALIZABLE_TYPE) -DSERIALIZABLE_TYPE_STRING=\"$(SERIALIZABLE_TYPE)\" main2_cpp_CPPFLAGS = -DSERIALIZABLE_TYPE=alts11n::AltSerializable -DSERIALIZABLE_TYPE_STRING=\"alts11n::AltSerializable\" +maser_cpp_CPPFLAGS = $(main_cpp_CPPFLAGS) BIN_PROGRAMS_LDADD += $(S11N_CLIENT_LDADD) + include $(toc_makesdir)/BIN_PROGRAMS.make -INSTALL_BINS = $(BIN_PROGRAMS) +INSTALL_BINS = s11nconvert %.o: Makefile @@ -61,7 +71,15 @@ install-BINS: strip-bins -all: BIN_PROGRAMS SHARED_LIBS tip link-bigso +NAMESPACE = $(S11N_NAMESPACE) +NAMESPACE_TOKEN = S11N_NAMESPACE +NAMESPACE_PREFIX = ns. +NAMESPACE_FILTERED_FILES = $(SOURCES) $(HEADERS) +namespace: $(NAMESPACE_FILTERED_FILES) +include $(toc_makesdir)/NAMESPACE.make + + +all: namespace BIN_PROGRAMS SHARED_LIBS tip link-bigso alt: clean ALTS11N=1 ${MAKE} Index: in.paren =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/in.paren,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- in.paren 14 Oct 2003 03:26:54 -0000 1.1 +++ in.paren 17 Nov 2003 20:41:14 -0000 1.2 @@ -6,7 +6,7 @@ ; one-line comment # one-line comment somenode=(NoClass - (a \)\\b) (* <--- testing the backslashing *) (foo bar) (long this is a long property) + (a \(\)\\b) (* <--- testing the backslashing *) (foo bar) (long this is a long property) this_is_empty=() # comment comment fred=(FredClass (key value)) # comment wilma=(WilmaClass (the lovely wife)) Index: in.s11n =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/in.s11n,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- in.s11n 14 Oct 2003 03:26:54 -0000 1.1 +++ in.s11n 17 Nov 2003 20:41:14 -0000 1.2 @@ -1,125 +1,124 @@ #SerialTree 1 +; comment test +# comment test theroot class=fake::FakeRoot { - foo = one - bar = two + foo one + bar two - xml_test this & that is < than the other thing, or maybe > then it? -othertype class=alts11n::AltSerializable -{ - got_milk 1 - sub class=alts11n::AltSub + xmlish this & \\that is < than the other thing, or \\maybe >? + othertype class=alts11n::AltSerializable { - prop val - subsub class=alts11n::AltSubSub - { - prop val - sub class=alts11n::AltSub - { - } - } - } -} - - - int_to_str_map class=s11n::s11n_node { - 0 eeeek! - 1 awwwwk! - 2 gggaaaaaawwwwk! - 3 when you're this stoned, it's hard to be serious. - } - - dbl_to_str_map class=s11n::s11n_node { - 0.0 this is zero - 1.0 this is one - 2.0 this is two - 3.0 this is three - 4.5 this is four-point-five. - } - - foo_child class=foo::FooClass { - fee = fii - fo = fum + got_milk 1 + sub class=alts11n::AltSub + { + prop val + subsub class=alts11n::AltSubSub + { + prop val + sub class=alts11n::AltSub + { + } + } + } } - foo_child class=foo::Baz - { - fee = fii - fo = fum - } - foo_child class=foo::BarClass - { - fee = fii - fo = fum - } - foo_child class=BarClass - { - fee = fii - fo = fum - } + int_to_str_map class=s11n::s11n_node { + 0 eeeek! + 1 awwwwk! + 2 gggaaaaaawwwwk! + 3 whhheeeee! + } - foo_child class=foo::FooClass - { - fee = fii - fo = fum - } + dbl_to_str_map class=s11n::s11n_node { + 0.0 this is zero + 1.0 this is one + 2.0 this is two + 3.0 this is three + 4.5 this is four-point-five. + } - foo_child class=foo::WonderBra - { - fii = fee - fum = fo - } + foo_child class=foo::FooClass { + name Bob + fee fii + fo fum + vector class=s11n::s11n_node { + 1 4 + 2 7 + 3 849 + } + } - foo_child class=BarClass { - meeza_child = true - minibar class=woo::hoo::BarClass - { - myprop 17 - myotherprop "this string here, seen?" - } - not_loadable class=ThisClassIsNotRegistered - { - } + foo_child class=foo::Baz + { + fee fii + fo fum + } + foo_child class=foo::BarClass + { + fee fii + fo fum + } - } + foo_child class=BarClass + { + fee fii + fo fum + } - root class=FooClass - { - foo = one - bar = two - endvar true - } + foo_child class=foo::FooClass + { + fee fii + fo fum + } + foo_child class=foo::WonderBra + { + fii fee + fum fo + } - root_too class=BarClass - { - the_real_node 42.424242424242427848 - quoted_string="this is a quoted string" - unquoted_string this is an unquoted string - unquoted_string2 this is an "unquoted" string; - squoted_string 'this is a \ - single-quoted \ - string' + foo_child class=BarClass { + meeza_child true + minibar class=woo::hoo::BarClass + { + myprop 17 + myotherprop "this string here, seen?" + } + not_loadable class=ThisClassIsNotRegistered + { + } - mstring this is a \ - "multi-line" \ - string + } - key = semi-colon val; - another semi-colon val; + root class=FooClass + { + foo one + bar two + endvar true + } - yet = another \ - test eek \ - multi-line, ohne quote! - SOURCES = foo \ - elib_globals.cpp \ - CommandLiner.cpp + root_too class=BarClass + { + the_real_node 42.424242424242427848 + quoted_string "this is a quoted string" + unquoted_string this is an unquoted string + unquoted_string2 this is an "unquoted" string + squoted_string 'this is a \ + single-quoted \ + string' - HEADERS = Readline.h \ - ShellProcess.h \ - StringList.h + mstring this is a \ + "multi-line" \ + string + SOURCES foo \ +elib_globals.cpp \ + CommandLiner.cpp - } + HEADERS Readline.h \ + ShellProcess.h \ + StringList.h + } } Index: main.cpp =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/main.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- main.cpp 17 Oct 2003 09:07:36 -0000 1.2 +++ main.cpp 17 Nov 2003 20:41:14 -0000 1.3 @@ -11,31 +11,31 @@ #include <time.h> // time() #include <unistd.h> // isatty() -#include <toolbox/SimpleCLParser.h> +#include <S11N_NAMESPACEargv_parser.h> // #include <iterator> // for use with std::copy() -#include <s11n/s11n-macros.h> // COUT/CERR -#include <s11n/s11n_globals.h> // library_version() -#include <s11n/s11n_node.h> +#include <S11N_NAMESPACEs11n-macros.h> // COUT/CERR +#include <S11N_NAMESPACEs11n_globals.h> // library_version() +#include <S11N_NAMESPACEs11n_node.h> -#include <toolbox/eprintf.h> // efstring() -#include <toolbox/PointerList.h> -#include <toolbox/PropertyStore.h> -#include <toolbox/ClassLoader.h> -#include <toolbox/class_name.h> -#include <toolbox/Instantiator.h> +#include <S11N_NAMESPACEeprintf.h> // efstring() +#include <S11N_NAMESPACEpointer_list.h> +#include <S11N_NAMESPACEproperty_store.h> +#include <S11N_NAMESPACEclass_loader.h> +#include <S11N_NAMESPACEclass_name.h> +#include <S11N_NAMESPACEinstantiator.h> -#include <s11n/s11n_io.h> -#include <s11n/serializer_loader.h> -#include <s11n/node_loader.h> +#include <S11N_NAMESPACEs11n_io.h> +#include <S11N_NAMESPACEserializer_loader.h> +#include <S11N_NAMESPACEnode_loader.h> -#include <s11n/Serializable.h> -// #include <s11n/serializable_adapter.h> -// SERIALIZABLE_ADAPTER(s11n::Serializable,s7e,d9e); +#include <S11N_NAMESPACESerializable.h> +// #include <S11N_NAMESPACEserializable_adapter.h> +// SERIALIZABLE_ADAPTER(S11N_NAMESPACESerializable,s7e,d9e); -// #include <s11n/include_from_main.h> +// #include <S11N_NAMESPACEinclude_from_main.h> #if HAVE_CONFIG_H # include "config.h" // S11N_LIBRARY_VERSION, PACKAGE_{VERSION,NAME} @@ -45,24 +45,24 @@ #endif #if HAVE_ZLIB -# include <toolbox/gzstream.h> +# include <S11N_NAMESPACEgzstream.h> #endif #if HAVE_BZLIB -# include <toolbox/bzstream.h> +# include <S11N_NAMESPACEbzstream.h> #endif #ifndef SERIALIZABLE_TYPE -# define SERIALIZABLE_TYPE s11n::Serializable +# define SERIALIZABLE_TYPE S11N_NAMESPACESerializable #endif #ifndef SERIALIZABLE_TYPE_STRING -# define SERIALIZABLE_TYPE_STRING "s11n::Serializable" +# define SERIALIZABLE_TYPE_STRING "S11N_NAMESPACESerializable" #endif #include "AltSerializable.h" -using namespace toolbox; +using namespace s11n; using namespace s11n; using namespace std; @@ -70,9 +70,12 @@ #define APP_VERSION std::string("$Revision$") #define APP_NAME "s11nconvert" -int m_verbose = 0; +#define VERBOSE if( ARGV::args().get_bool( "v", ARGV::args().get_bool( "verbose", false ) ) ) CERR +#define GIGOVERBOSE VERBOSE << "id["<<this->m_id<<"@"<<depth<<"] " -#define VERBOSE if( 0 < m_verbose ) CERR +typedef S11N_NAMESPACEargv_parser ARGV; +#define QUIETLY if( ! ARGV::args().get_bool( "q", ARGV::args().get_bool( "quiet", false ) ) ) CERR +// ^^^^ output unless -q is set std::string random_ascii( unsigned int len ) { @@ -80,7 +83,8 @@ std::string out; for( unsigned int i = 0; i < len; i++ ) { - out += (unsigned char) ( random() % 94 ) + 32; + //out += (unsigned char) ( random() % 78 ) + 46; + out += (unsigned char) ( random() % 25 ) + 65; } return out; } @@ -93,84 +97,93 @@ Garbage In, Garbage Out. For generating lots of junk serialized data quickly. */ -class GIGO : public s11n::Serializable +class GIGO : public S11N_NAMESPACESerializable { public: typedef std::map<int,std::string> IntStrMap; typedef std::map<double,std::string> DblStrMap; - static long inst_count; + static unsigned long inst_count; + static unsigned long total_inst_count; + IntStrMap istrmap; + DblStrMap dstrmap; + typedef S11N_NAMESPACEpointer_list<GIGO> list_type; + typedef std::list<std::string> SL; + SL slist; + list_type childs; + S11N_NAMESPACEproperty_store props; + unsigned long m_id; GIGO() { - static bool donethat = false; - if( (!donethat) && (donethat=true) ) - { - inst_count = 0; - srandom( ::time(NULL) ); - } - VERBOSE << "GIG0() #"<< ++inst_count << std::endl; + m_id = ++total_inst_count; + ++inst_count; + childs.auto_delete( true ); +// GIGOVERBOSE << "GIG0() #"<< inst_count << std::endl; } virtual ~GIGO() { - VERBOSE << "~GIG0() remaining: "<< --inst_count << std::endl; + --inst_count; +// GIGOVERBOSE << "~GIG0() remaining: "<< inst_count << std::endl; } - virtual bool s7e( s11n_node & node ) const + // populates this object with garbage data + void garbage() { - VERBOSE << "GIG0::serialize()" << std::endl; - if( ! this->Serializable::s7e( node ) ) return false; - static int depth = 0; + childs.delete_all(); + istrmap.erase( istrmap.begin(), istrmap.end() ); + dstrmap.erase( dstrmap.begin(), dstrmap.end() ); + slist.erase( slist.begin(), slist.end() ); + this->props.clear_properties(); + static long depth = 0; + ++depth; static const int max_childs = 5; - typedef std::list<std::string> SL; - SL slist; for( int i = 0; i < random() % 5; i++ ) { - slist.push_back( toolbox::efstring( "string list item #", i ) ); + slist.push_back( random_ascii(random()%30 ) ); } - unsigned long count = node.serialize_list( "string_list", slist ); - //VERBOSE << "Serialized string_list: " << count << std::endl; - - IntStrMap istrmap; - DblStrMap dstrmap; int i = 0; + #define INSTR(S) istrmap[i++] = S; dstrmap[i++] = S; for( ; i < random() % 10; ) { INSTR(random_ascii(random()%30)); } - count = node.serialize_map( "int_to_str_map", istrmap ); - //VERBOSE << "Serialized int_to_str_map: " << count; - count = node.serialize_map( "dbl_to_str_map", dstrmap ); - //cerr << " dbl_to_str_map: " << count << std::endl; - int rnd = random() % 10; std::string pname; std::string pval; for( int i = 0; i < rnd; i++ ) { - pname = toolbox::efstring( "property",i ); + pname = S11N_NAMESPACEefstring( "property",i ); pval = random_ascii( random() % 50 ); - //toolbox::efstring( random() % 1000 * 1.17 ); - node.set( pname, pval ); + props.set( pname, pval ); } - GIGO * ch = 0; - toolbox::PointerList<GIGO> childs; // s11n::Serializable - childs.auto_delete( true ); rnd = random() % max_childs - depth; - ++depth; - node.set( "depth", depth ); + GIGO * ch = 0; for( int i = 0; i < rnd; i++ ) { ch = new GIGO(); + ch->garbage(); childs.push_back( ch ); -// ch = new GIGO(); -// node.serialize( "gigo_child", *ch ); -// delete( ch ); } + --depth; + } + + virtual bool s7e( s11n_node & node ) const + { + if( ! this->Serializable::s7e( node ) ) return false; + static long depth = 0; + ++depth; + GIGOVERBOSE << "GIG0::serialize()" << std::endl; + + node.set( "id", m_id ); + node.serialize_list( "string_list", slist ); + node.serialize_map( "int_to_str_map", istrmap ); + node.serialize_map( "dbl_to_str_map", dstrmap ); + node.serialize_properties( this->props ); node.serialize_children( "gigo_child", childs ); --depth; return true; @@ -178,37 +191,46 @@ virtual bool d9e( const s11n_node & node ) { if( ! this->Serializable::d9e( node ) ) return false; + static long depth = 0; + ++depth; - VERBOSE <<"d9e() depth="<<node.get_string("depth")<<std::endl; - typedef std::list<std::string> SL; - SL slist; - unsigned long count = node.deserialize_list( "string_list", slist ); - VERBOSE << "string_list entries: " << count << std::endl; + istrmap.erase( istrmap.begin(), istrmap.end() ); + dstrmap.erase( dstrmap.begin(), dstrmap.end() ); + childs.delete_all(); + this->props.clear_properties(); + slist.erase( slist.begin(), slist.end() ); - IntStrMap istrmap; - DblStrMap dstrmap; -// typedef alts11n::AltSerializable CHSType; // should fail to deserialize. - typedef GIGO CHSType; -// typedef s11n::Serializable CHSType; + this->m_id = node.get<int>( "id", m_id ); - toolbox::PointerList<CHSType> childs; - childs.auto_delete( true ); + unsigned long count = 0; + count = node.deserialize_list( "string_list", slist ); + GIGOVERBOSE << "string_list entries: " << count << std::endl; +// GIGO * g = node.deserialize<GIGO>( "gigo_child" ); +// GIGOVERBOSE << "node.deserialize<GIGO>(...) = " <<std::hex<<g<<std::endl; +// delete( g ); + count = node.deserialize_properties( this->props ); + GIGOVERBOSE << "property count: " << this->props.size() << std::endl; - VERBOSE << "int_to_str_map entries: " << node.deserialize_map( "int_to_str_map", istrmap ) - << " dbl_to_str_map entries: " << node.deserialize_map( "dbl_to_str_map", dstrmap ) - << " gigo_child count: " - << node.deserialize_children( "gigo_child", childs ) -// << node.deserialize_children<CHSType>( "gigo_child", childs ) - << std::endl; + count = node.deserialize_map( "int_to_str_map", istrmap ); + GIGOVERBOSE << "int_to_str_map entries: " << count << std::endl; + + count = node.deserialize_map( "dbl_to_str_map", dstrmap ); + GIGOVERBOSE << " dbl_to_str_map entries: " << count << std::endl; + + count = node.deserialize_children( "gigo_child", childs ); + GIGOVERBOSE << "gigo_child count: " << count + << ", and childs.size() says: " << childs.size() << std::endl; + --depth; return true; } }; -long GIGO::inst_count = 0; +unsigned long GIGO::inst_count = 0; +unsigned long GIGO::total_inst_count = 0; /** Register with the framework: */ -SERIALIZABLE_REGISTER(s11n::Serializable,GIGO); +SERIALIZABLE_REGISTER(S11N_NAMESPACESerializable,GIGO); /** A test namespace. @@ -218,14 +240,14 @@ /** A test class. */ - struct FakeRoot:public Serializable + struct FakeRoot : public S11N_NAMESPACESerializable { std::string m_foo; std::string m_bar; typedef std::map<double,std::string> IntStrMap; typedef std::map<double,std::string> DblStrMap; - typedef PointerList < s11n::Serializable > FakeVec; + typedef pointer_list < S11N_NAMESPACESerializable > FakeVec; //typedef std::vector<BarClass *> FakeVec; FakeVec m_vec; FakeRoot() @@ -246,36 +268,25 @@ return true; } - virtual bool d9e( const s11n_node & ser ) + virtual bool d9e( const s11n_node & node ) { VERBOSE << "FakeRoot::deserialize()" << std::endl; -#define TEST_ALT_IN_FAKE 1 -#if TEST_ALT_IN_FAKE - typedef alts11n::AltSerializable ALT; - ALT * theother = 0; // ser.classloader<ALT>().load( "alts11n::AltSerializable" ); - - theother = ser.deserialize<ALT>("othertype"); + typedef altS11N_NAMESPACEAltSerializable ALT; + ALT * theother = 0; // node.classloader<ALT>().load( "altS11N_NAMESPACEAltSerializable" ); + theother = node.deserialize<ALT>("othertype"); VERBOSE << "theother=="<<std::hex<<theother<<std::endl; - if( theother ) - { - theother->bogo_method(); - delete( theother ); - } -#endif - - //m_vec.deleteAll(); - m_foo = ser.get( "foo", "<not set>" ); - m_bar = ser.get( "bar", "<not set>" ); - m_vec.deleteAll(); - // ser.deserialize_children<s11n::Serializable>( "foo_child", m_vec ); - ser.deserialize_children( "foo_child", m_vec ); - VERBOSE << "deser: foo_child count: " << m_vec.size() << std::endl; + delete( theother ); + m_vec.delete_all(); + // node.deserialize_children<S11N_NAMESPACESerializable>( "foo_child", m_vec ); + unsigned long count = 0; + count = node.deserialize_children( "foo_child", m_vec ); + VERBOSE << "deser: foo_child count: "<<count<<", and m_vec.size() says: " << m_vec.size() << std::endl; // VERBOSE << "deser: m_foo=["<<m_foo<<"]"<<std::endl; // VERBOSE << "deser: m_bar=["<<m_bar<<"]"<<std::endl; IntStrMap istrmap; - unsigned long mcount = ser.deserialize_map( "int_to_str_map", istrmap ); + unsigned long mcount = node.deserialize_map( "int_to_str_map", istrmap ); if( mcount ) { VERBOSE << "int-to-string map entry count: " << mcount << std::endl; @@ -283,7 +294,7 @@ for( ; it != et; ++it ) VERBOSE << (*it).first << "=["<<(*it).second<<"]"<<std::endl; } DblStrMap dstrmap; - mcount = ser.deserialize_map( "dbl_to_str_map", dstrmap ); + mcount = node.deserialize_map( "dbl_to_str_map", dstrmap ); if( mcount ) { VERBOSE << "double-to-string map entry count: " << mcount << std::endl; @@ -298,20 +309,27 @@ }; }; // namespace fake -SERIALIZABLE_REGISTER(s11n::Serializable,fake::FakeRoot); +SERIALIZABLE_REGISTER(S11N_NAMESPACESerializable,fake::FakeRoot); s11n_node *gigo( unsigned int gcount ) { - GIGO g; + S11N_NAMESPACEpointer_list<GIGO> gc; + gc.auto_delete( true ); + GIGO * g = new GIGO(); + gc.push_back( g ); + g->garbage(); // CERR << "gigo class name="<< serializable_adapter<GIGO>::class_name(g)<<std::endl; s11n_node * node = new s11n_node( "garbage_nodes" ); // , g.impl_class() ); - node->serialize( g ); + node->serialize( *g ); for( unsigned int i = 0; i < gcount; i++ ) { - node->serialize( "gigo_child", g ); + g = new GIGO(); + gc.push_back( g ); + g->garbage(); + node->serialize( "gigo_child", *g ); } return node; } @@ -321,29 +339,62 @@ out << APP_NAME << " " << APP_VERSION << std::endl; out << "s11n library version: " << std::endl; out << "\tCompiled for: " << S11N_LIBRARY_VERSION << std::endl; - out << "\tRunning with: " << s11n::library_version() << std::endl; + out << "\tRunning with: " << S11N_NAMESPACElibrary_version() << std::endl; out << "Serializer interface: " << SERIALIZABLE_TYPE_STRING << std::endl; + out << "License: " << PACKAGE_LICENSE << std::endl; - -#define VERSION_SHORTCUT 1 +#define VERSION_SHORTCUT 0 #if VERSION_SHORTCUT - fake::FakeRoot root; - s11n_node node; - node.serialize( "fake", root ); - node.serialize( "gigo", GIGO() ); - ParenSerializer serializer; - serializer.serialize( node, std::cerr ); - fake::FakeRoot * clone = s11n_clone( root ); - serializer.basic_serializer::serialize( "boo", *clone, std::cerr ); // WTF must i qualify that??? - delete( clone ); +#define LOAD_SERIALIZABLE(ST,FN) root = load_serializable<ST>(FN); \ +CERR << "load_serializable<"<<# ST<<">("<<FN<<") = " << std::hex<<root << std::endl; \ +delete( root ); + + S11N_NAMESPACESerializable * root = 0; +// fake::FakeRoot * root = 0; + std::string infile = "in.s11n"; + LOAD_SERIALIZABLE(fake::FakeRoot,infile); + LOAD_SERIALIZABLE(S11N_NAMESPACESerializable,"in.s11n"); + +// fake::FakeRoot root; +// s11n_node node; +// node.serialize( "fake", root ); +// node.serialize( "gigo", GIGO() ); +// ParenSerializer serializer; +// serializer.serialize( node, std::cerr ); +// fake::FakeRoot * clone = s11n_clone( root ); +// serializer.basic_serializer::serialize( "boo", *clone, std::cerr ); // WTF must i qualify that??? +// delete( clone ); #endif } + + +#define TEST_ANY 0 +#if TEST_ANY +#include <S11N_NAMESPACEany.h> +void any_test() +{ + using S11N_NAMESPACEany; + any a = "12.12"; +#define TESTANY(vaL,typE,defaulT) a = vaL; CERR << "any("<<a<<").get<"<<#typE<<">(err=["<<defaulT<<"]) = " << a.get<typE>(defaulT) << std::endl; + TESTANY(17.17,double,-1.0); + TESTANY(123.90,string,"error"); + TESTANY(123.90,double,-1.0); + TESTANY(123.90,int,-42); + TESTANY("",int,-1); + TESTANY("hi!",int,-1); + TESTANY("17.12732",double,-1.0); + TESTANY("this is a string",std::string,"error"); + TESTANY("this is a string",int,-1); + +} +#endif // TEST_ANY + typedef std::map<int,std::string> TestType; // CLASS_NAME(fake::FakeRoot); CLASS_NAME(TestType); -// CLASS_NAME(alts11n::AltSub); +// CLASS_NAME(altS11N_NAMESPACEAltSub); #define SHOW_CLASS_NAME(A) \ CERR << "class_name<"<<# A<<">() == "<<class_name<A>()<<std::endl; \ CERR << "class_name<"<<# A<<">::name() == "<<class_name<A>::name()<<std::endl; @@ -351,12 +402,17 @@ int main( int argc, char **argv ) { +#if TEST_ANY + any_test(); +#endif + + srandom( ::time(NULL) ); // SHOW_CLASS_NAME(fake::FakeRoot); -// SHOW_CLASS_NAME(alts11n::AltSub); -// SHOW_CLASS_NAME(alts11n::AltSubSub); -// SHOW_CLASS_NAME(alts11n::AltSerializable); +// SHOW_CLASS_NAME(altS11N_NAMESPACEAltSub); +// SHOW_CLASS_NAME(altS11N_NAMESPACEAltSubSub); +// SHOW_CLASS_NAME(altS11N_NAMESPACEAltSerializable); - if( S11N_LIBRARY_VERSION != s11n::library_version() ) + if( S11N_LIBRARY_VERSION != S11N_NAMESPACElibrary_version() ) { CERR << "Warning: your libs11n does not match the one this was compiled against. " << "This might not work at all!" << std::endl; @@ -375,54 +431,56 @@ ErrorCloningFailed = 6 }; - toolbox::SimpleCLParser::args( argc, argv ); - toolbox::SimpleCLParser & args = toolbox::SimpleCLParser::args(); + S11N_NAMESPACEargv_parser & args = S11N_NAMESPACEargv_parser::args( argc, argv ); - args.setHelp( "f filename", "input filename. Same as --file." ); - args.setHelp( "o filename", "output filename. Filename of - means stdout." ); + args.set_help( "f filename", "input filename. Same as --file." ); + args.set_help( "o filename", "output filename. Filename of - means stdout. Remember to also use -oFORMAT" ); - args.setHelp( "d", "try to deserialize the input file (useful for testing class loading)." ); - args.setHelp( "dc", "Requires -d. If -d succeeds, try to s11n_clone() the object." ); - args.setHelp( "dd", "Requires -d. If -d succeeds, dump the object using the selected -oX format. If -dc is used, the clone is dumped." ); + args.set_help( "d", "try to deserialize the input file (useful for testing class loading)." ); + args.set_help( "dc", "Requires -d. If -d succeeds, try to s11n_clone() the object." ); + args.set_help( "dd", "Requires -d. If -d succeeds, dump the object using the selected -oX format. If -dc is used, the clone is dumped instead." ); - args.setHelp( "version", "print app and libs11n version info and quit." ); + args.set_help( "version", "print app and libs11n version info and quit." ); - args.setHelp( "ot", "output in fun::txt format" ); - args.setHelp( "ox", "output in fun::xml format" ); - args.setHelp( "osx", "output in s11n::simplexml format" ); - args.setHelp( "op", "output in s11n::parens format" ); - args.setHelp( "oh", "output in s11n::hex format" ); - args.setHelp( "oc", "output in s11n::compact format" ); + args.set_help( "ot", "output in fun::txt format" ); + args.set_help( "ox", "output in fun::xml format" ); + args.set_help( "osx", "output in S11N_NAMESPACEsimplexml format" ); + args.set_help( "op", "output in S11N_NAMESPACEparens format" ); + args.set_help( "oh", "output in S11N_NAMESPACEhex format" ); + args.set_help( "oc", "output in S11N_NAMESPACEcompact format" ); - args.setHelp( "v, verbose", "enable some extra output." ); + args.set_help( "q, quiet", "disable some warnings." ); - args.setHelp( "cldebug", "enable classloader debug output" ); - args.setHelp( "nodedebug", "enable s11n_node debug output" ); + args.set_help( "v, verbose", "enable some extra output." ); + + args.set_help( "cldebug", "enable classloader debug output" ); + args.set_help( "nodedebug", "enable s11n_node debug output" ); - if( "s11n::Serializable" == SERIALIZABLE_TYPE_STRING ) + if( "S11N_NAMESPACESerializable" == SERIALIZABLE_TYPE_STRING ) { - args.setHelp( "sopath path", "Sets the classloader path. Use a :-delimited list." ); + args.set_help( "sopath path", "Sets the classloader path. Use a :-delimited list." ); } - args.setHelp( "gigo N", "Number of garbage-in-garbage-out loops to run (for testing/debugging)." ); + args.set_help( "gigo N", "Number of garbage-in-garbage-out loops to run (for testing/debugging)." ); #if HAVE_ZLIB - args.setHelp( "z", "enable zlib compression on output." ); + args.set_help( "z", "enable zlib compression on output." ); #endif #if HAVE_BZLIB - args.setHelp( "bz", "enable bz2 compression on output." ); + args.set_help( "bz", "enable bz2 compression on output." ); #endif - if( args.isSet( "version" ) ) + if( args.is_set( "version" ) ) { show_version( std::cout ); return ErrorVersion; } - if ( args.isHelpSet() ) + if ( args.is_help_set() ) { - std::cout << "Only one -oX option may be used."<< std::endl; + std::cout << args.dump_help() << std::endl; + std::cout << "Only one -oFORMAT option may be used."<< std::endl; #if HAVE_ZLIB && HAVE_BZLIB std::cout << "Only one of -z or -bz can be used." <<std::endl; #endif @@ -455,22 +513,17 @@ } #endif - if( args.get_bool( "v", args.get_bool("verbose", false ) ) ) - { - m_verbose = 1; - } - // set library-wide compression policy: - if( args.get_bool( "z", false ) ) toolbox::compression_policy( toolbox::GZipCompression ); - else if( args.get_bool( "bz", false ) ) toolbox::compression_policy( toolbox::BZipCompression ); + if( args.get_bool( "z", false ) ) S11N_NAMESPACEcompression_policy( S11N_NAMESPACEGZipCompression ); + else if( args.get_bool( "bz", false ) ) S11N_NAMESPACEcompression_policy( S11N_NAMESPACEBZipCompression ); s11n_node::debug_level( args.get_bool( "nodedebug", false ) ? 1 : 0 ); - toolbox::classloader_debug_level( args.get_bool( "cldebug", false ) ? 1 : 0 ); + S11N_NAMESPACEclass_loader_debug_level( args.get_bool( "cldebug", false ) ? 1 : 0 ); // CERR << "debug level: " << s11n_node::debug_level() << std::endl; string infilename = args.get_string( "file", args.get_string( "f", "" ) ); - if ( infilename.empty() && ! args.isSet( "gigo" ) ) + if ( infilename.empty() && ! args.is_set( "gigo" ) ) { // todo: add support for reading stdin. The problem is that // we can't normally load from streams unless we know the input @@ -483,38 +536,33 @@ string ofilename = args.get_string( "o", "" ); /** - Output formats enum. The values are set up for bitmasking. + Output formats enum. */ - enum OutModes { NoFormat = 0x0000, - TextFormat = 0x0001, - XMLFormat = 0x0002, - SimpleXMLFormat = 0x0004, - ParenFormat = 0x0010, - HexFormat = 0x0020, - CompactFormat = 0x0040 + enum OutModes { NoFormat = 1, + TextFormat, + XMLFormat, + SimpleXMLFormat, + ParenFormat, + HexFormat, + CompactFormat }; - int outmode = NoFormat; // default mode + int outmode = NoFormat; // get selected output mode: - if( args.get_bool( "ox", false ) ) outmode += XMLFormat; - else if( args.get_bool( "op", false ) ) outmode += ParenFormat; - else if( args.get_bool( "osx", false ) ) outmode += SimpleXMLFormat; - else if( args.get_bool( "ot", false ) ) outmode += TextFormat; - else if( args.get_bool( "oh", false ) ) outmode += HexFormat; - else if( args.get_bool( "oc", false ) ) outmode += CompactFormat; - - if( outmode == NoFormat ) - { -// CERR << "No output format specified! Use one of the -oX options." << std::endl; -// return ErrorNoOutputFormat; - } + if( args.get_bool( "ox", false ) ) outmode = XMLFormat; + else if( args.get_bool( "op", false ) ) outmode = ParenFormat; + else if( args.get_bool( "osx", false ) ) outmode = SimpleXMLFormat; + else if( args.get_bool( "ot", false ) ) outmode = TextFormat; + else if( args.get_bool( "oh", false ) ) outmode = HexFormat; + else if( args.get_bool( "oc", false ) ) outmode = CompactFormat; + if( NoFormat == outmode ) QUIETLY << "Warning: no output format selected." << std::endl; - if( args.isSet( "sopath" ) ) + if( args.is_set( "sopath" ) ) { VERBOSE << "setting DLL path=["<<args.get_string( "sopath" )<<"]"<<std::endl; - s11n_node::classloader<s11n::Serializable>().path().path( args.get_string( "sopath" ) ); + class_loader<SERIALIZABLE_TYPE>().path(true).path( args.get_string( "sopath" ) ); } s11n_node * root = 0; @@ -522,7 +570,7 @@ int gigos = args.get( "gigo", -1 ); if( 0 < gigos ) { - CERR << "Running "<<gigos<<" Garbage In, Garbage Out loop"<<(gigos!=1?"s":"") << "..." << std::endl; + QUIETLY << "Running "<<gigos<<" Garbage In, Garbage Out loop"<<(gigos!=1?"s":"") << "..." << std::endl; root = gigo( gigos ); } else @@ -558,19 +606,19 @@ } else { - os = toolbox::get_ostream( ofilename ); // possibly returns a compressor stream. + os = S11N_NAMESPACEget_ostream( ofilename ); // possibly returns a compressor stream. warnonsavefail = true; } basic_serializer * serializer = 0; - typedef ClassLoader<basic_serializer,int> S8rLoader; + typedef class_loader<basic_serializer,int> S8rLoader; S8rLoader::register_subtype<FunXMLSerializer>( XMLFormat ); S8rLoader::register_subtype<SimpleXMLSerializer>( SimpleXMLFormat ); S8rLoader::register_subtype<FunTxtSerializer>( TextFormat ); S8rLoader::register_subtype<ParenSerializer>( ParenFormat ); - S8rLoader::register_subtype<HexSerializer>( HexFormat ); +// S8rLoader::register_subtype<HexSerializer>( HexFormat ); S8rLoader::register_subtype<CompactSerializer>( CompactFormat ); serializer = S8rLoader::load_class( outmode ); @@ -578,8 +626,8 @@ if( args.get_bool( "d", false ) || args.get_bool( "dd", false ) ) { // deserialize the data? -// typedef ClassLoader<base_serializable_adapter> AdCL; -// AdCL::value_type * whoa = AdCL::load_class( //"serializable_adapter<s11n::Serializable>" +// typedef class_loader<base_serializable_adapter> AdCL; +// AdCL::value_type * whoa = AdCL::load_class( //"serializable_adapter<S11N_NAMESPACESerializable>" // std::string( "serializable_adapter<" ) + // std::string( SERIALIZABLE_TYPE_STRING ) + // std::string( ">" ) @@ -590,9 +638,9 @@ // now what? we still can't get the exact TYPE we need at runtime, because // various Serializables necessarily decend from different bases :( - //typedef alts11n::AltSerializable serializable_type; + //typedef altS11N_NAMESPACEAltSerializable serializable_type; typedef SERIALIZABLE_TYPE serializable_type; -// typedef ClassLoader<base_serializable_adapter> CLA; +// typedef class_loader<base_serializable_adapter> CLA; serializable_type * ser = 0; ser = root->deserialize<serializable_type>(); @@ -608,7 +656,7 @@ serializable_type * clone = 0; if( args.get_bool( "dc", false ) ) { - clone = s11n::s11n_clone( *ser ); + clone = S11N_NAMESPACEs11n_clone( *ser ); CERR << "s11n_clone()"<< (clone ? "worked" : "failed" ) << std::endl; if( ! clone ) return ErrorCloningFailed; } @@ -616,8 +664,8 @@ if( todump && serializer && args.get_bool( "dd", false ) ) { // dump deserialized object back out. Useful for debuggering. CERR << (clone ? "cloned" : "deser'd")<< " object:" << std::endl; - serializer->serialize( "root", *todump, std::cerr ); - if( ! args.isSet( "o" ) ) outmode = NoFormat; // avoid duplicating the output to stdout + serializer->serialize( "root", *todump, std::cout ); + if( ! args.is_set( "o" ) ) outmode = NoFormat; // avoid duplicating the output to stdout } delete( clone ); delete( ser ); @@ -667,7 +715,7 @@ grep class= INFILE | cut -d'=' -f2 | sort -u | \ perl -ne \ - 'chomp; print "CLASSLOADER\::register_factory( \"".$_."\", FACTORY_CLASS::newInstance );\n";' + 'chomp; print "CLASSLOADER\::register_factory( \"".$_."\", FACTORY_CLASS::new_instance );\n";' */ Index: maser.cpp =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/maser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- maser.cpp 17 Nov 2003 20:37:45 -0000 1.1 +++ maser.cpp 17 Nov 2003 20:41:14 -0000 1.2 @@ -17,30 +17,30 @@ #include <time.h> // time() #include <unistd.h> // isatty() -#include <s11n/argv_parser.h> -#include <s11n/string_util.h> // translate_entities() +#include <S11N_NAMESPACEargv_parser.h> +#include <S11N_NAMESPACEstring_util.h> // translate_entities() // #include <iterator> // for use with std::copy() -// #include <s11n/s11n_io.h> -#include <s11n/s11n-macros.h> // COUT/CERR -#include <s11n/s11n_globals.h> // library_version() -#include <s11n/s11n_node.h> +// #include <S11N_NAMESPACEs11n_io.h> +#include <S11N_NAMESPACEs11n-macros.h> // COUT/CERR +#include <S11N_NAMESPACEs11n_globals.h> // library_version() +#include <S11N_NAMESPACEs11n_node.h> -#include <s11n/node_loader.h> +#include <S11N_NAMESPACEnode_loader.h> -#include <s11n/Serializable.h> -#include <s11n/Serializer.h> +#include <S11N_NAMESPACESerializable.h> +#include <S11N_NAMESPACESerializer.h> #if HAVE_CONFIG_H # include "config.h" // S11N_LIBRARY_VERSION, PACKAGE_{VERSION,NAME} #endif #ifndef SERIALIZABLE_TYPE -# define SERIALIZABLE_TYPE s11n::Serializable +# define SERIALIZABLE_TYPE S11N_NAMESPACESerializable #endif #ifndef SERIALIZABLE_TYPE_STRING -# define SERIALIZABLE_TYPE_STRING "s11n::Serializable" +# define SERIALIZABLE_TYPE_STRING "S11N_NAMESPACESerializable" #endif @@ -54,7 +54,7 @@ #define VERBOSE if( ARGV::args().get_bool( "v", ARGV::args().get_bool( "verbose", false ) ) ) CERR -typedef s11n::argv_parser ARGV; +typedef S11N_NAMESPACEargv_parser ARGV; #define QUIETLY if( ! ARGV::args().get_bool( "q", ARGV::args().get_bool( "quiet", false ) ) ) CERR // ^^^^ output unless -q is set @@ -134,7 +134,7 @@ xmap["\n"] = std::string("\n") + prefix; } - s11n::translate_entities( cmt, xmap ); + S11N_NAMESPACEtranslate_entities( cmt, xmap ); os << cmt << std::endl; } @@ -232,7 +232,7 @@ out << APP_NAME << " " << APP_VERSION << std::endl; out << "s11n library version: " << std::endl; out << "\tCompiled for: " << S11N_LIBRARY_VERSION << std::endl; - out << "\tRunning with: " << s11n::library_version() << std::endl; + out << "\tRunning with: " << S11N_NAMESPACElibrary_version() << std::endl; out << "Serializer interface: " << SERIALIZABLE_TYPE_STRING << std::endl; out << "License: " << PACKAGE_LICENSE << std::endl; } @@ -244,7 +244,7 @@ srandom( ::time(NULL) ); - if( S11N_LIBRARY_VERSION != s11n::library_version() ) + if( S11N_LIBRARY_VERSION != S11N_NAMESPACElibrary_version() ) { CERR << "Warning: your libs11n does not match the one this was compiled against. " << "This might not work at all!" << std::endl; @@ -261,7 +261,7 @@ ErrorNoFileSpecified = 4 }; - s11n::argv_parser & args = s11n::argv_parser::args( argc, argv ); + S11N_NAMESPACEargv_parser & args = S11N_NAMESPACEargv_parser::args( argc, argv ); args.set_help( "f filename", "input filename. Same as --file." ); args.set_help( "o filename", "output filename. Filename of - means stdout. Remember to also use -oFORMAT" ); @@ -269,7 +269,7 @@ args.set_help( "q, quiet", "disable some warnings." ); args.set_help( "v, verbose", "enable some extra output." ); - if( "s11n::Serializable" == SERIALIZABLE_TYPE_STRING ) + if( "S11N_NAMESPACESerializable" == SERIALIZABLE_TYPE_STRING ) { args.set_help( "sopath path", "Sets the classloader path. Use a :-delimited list." ); } @@ -315,7 +315,7 @@ } typedef auto_ptr<s11n_node> NODE; - NODE node = NODE( s11n::node_loader::load_node( infilename ) ); + NODE node = NODE( S11N_NAMESPACEnode_loader::load_node( infilename ) ); if( ! node.get() ) { CERR << "Error loading file '"<<infilename<<"'!"<<std::endl; Index: test_s11n.sh =================================================================== RCS file: /cvsroot/libfunutil/libfunutil/client/s11nconvert/test_s11n.sh,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test_s11n.sh 14 Oct 2003 03:26:54 -0000 1.1 +++ test_s11n.sh 17 Nov 2003 20:41:14 -0000 1.2 @@ -1,7 +1,7 @@ #!/bin/bash infile=${1} converter=./s11nconvert -formats="x t p sx h c" +formats="x t p sx c" test x$infile = x && { echo "Usage: $0 input file" exit 1 |