You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(622) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(303) |
Feb
(64) |
Mar
(5) |
Apr
(63) |
May
(82) |
Jun
(53) |
Jul
(50) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: stephan b. <sg...@us...> - 2004-12-26 11:10:12
|
Update of /cvsroot/pclasses/pclasses2/src/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3367/src/Util Modified Files: StringTool.cpp Log Message: Added expandVars() and expandVarsInline(), to expand a map<string,string> as a set of ${vars} in an input string. Index: StringTool.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Util/StringTool.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- StringTool.cpp 26 Dec 2004 10:42:05 -0000 1.1 +++ StringTool.cpp 26 Dec 2004 11:10:00 -0000 1.2 @@ -215,4 +215,105 @@ map["\""] = "\\\""; } -}} // P::StringTool + std::string + expandVars( const EntityMap & src, const std::string & text ) + { + std::string foo = text; + expandVarsInline( src, foo ); + return foo; + } + + size_t + expandVarsInline( const EntityMap & src, std::string & buffer ) + { + //CERR << "expandVars(["<<buffer<<"])"<<std::endl; + if( buffer.size() < 2 ) return 0; + + EntityMap::const_iterator entit, entet = src.end(); + + std::string::size_type posA = 0, posB = 0; + static const char vardelim = '$'; + posA = buffer.find( vardelim ); + if( std::string::npos == posA ) + { + return 0; + } + static const char opener = '{'; + static const char closer = '}'; + size_t count = 0; + static const std::string allowable_chars = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_?"; + // ^^^^^^ why is '?' in the list? So that eshell can support the shell-ish $? var :/. + char atc; + posA = buffer.size() - 1; + bool slashmode = false; + std::string varname; + for( ; posA >= 0 && posA != std::string::npos; posA-- ) + { + atc = buffer[posA]; + if( atc != vardelim ) + { + continue; + } + if( posA>0 && !slashmode && buffer[posA-1] == '\\' ) slashmode = true; + if( slashmode ) + { + slashmode = false; + continue; + } + posB = buffer.find_first_not_of( allowable_chars, posA+1 ); // find first non-variablename char + if( posB != posA +1 ) posB -= 1; + if( posB == std::string::npos ) + { + posB = buffer.size() -1; + } + + if( posB == posA + 1 ) // ${VAR} or $F, hopefully + { + atc = buffer[posB]; + if( atc != opener ) + { + // $NONBRACED_VAR + posB = buffer.find_first_not_of( allowable_chars, posB ); + varname = buffer.substr( posA + 1, posB ); + //CERR << "nonbraced var? ["<<varname<<"]\n"; + // varname += atc; + // if( varname.find_first_of( allowable_chars ) != 0 ) + // { + // varname = string(); + // } + + } + else // ${VAR} + { + //cout << "Activating Bat-parser! atc="<<atc<<" posA="<<posA<<" posB="<<posB << endl; + const size_t maxpos = buffer.size()-1; + while( atc != closer && posB <= maxpos ) + { // extract variable-name part: + atc = buffer[++posB]; + if ( atc != closer ) varname += atc; + } + } + } + else + { + // extract variable-name part: + varname = buffer.substr( posA+1 /*skip '$'*/, posB-posA ); + } + //CERR << "expandVars(): varname=["<<varname<<"]"<<endl; + if( varname.empty() ) continue; + + entit = src.find( varname ); + if( entet == entit ) continue;// don't expand unknown vars to empty strings. + varname = (*entit).second; + //CERR << "expandVars(): expanded varname=["<<varname<<"]"<<endl; + ++count; + buffer.erase( posA, posB - posA +1 ); + buffer.insert( posA, varname.c_str() ); + varname.clear(); + } + return count; + } + + +} } // P::StringTool |
From: stephan b. <sg...@us...> - 2004-12-26 10:42:36
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32146/include/pclasses/Util Modified Files: Makefile.toc Log Message: Added StringTool. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Util/Makefile.toc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.toc 25 Dec 2004 01:03:52 -0000 1.3 +++ Makefile.toc 26 Dec 2004 10:42:25 -0000 1.4 @@ -4,6 +4,7 @@ HEADERS = \ LexT.h \ ManagedThread.h \ + StringTool.h \ ThreadPool.h \ WorkQueue.h |
From: stephan b. <sg...@us...> - 2004-12-26 10:42:35
|
Update of /cvsroot/pclasses/pclasses2/src/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32146/src/Util Modified Files: Makefile.toc Log Message: Added StringTool. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Util/Makefile.toc,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Makefile.toc 24 Dec 2004 23:06:27 -0000 1.5 +++ Makefile.toc 26 Dec 2004 10:42:25 -0000 1.6 @@ -1,21 +1,16 @@ #!/usr/bin/make -f -################################################### -# AUTO-GENERATED guess at a toc-aware Makefile, -# based off of the contents of directory: -# ./src/Util -# Created by ./toc/bin/create_makefile_stubs.sh -# Thu Dec 23 01:31:56 CET 2004 -# It must be tweaked to suit your needs. -################################################### include toc.make -############## FLEXES: -SOURCES = ManagedThread.cpp \ +SOURCES = \ + ManagedThread.cpp \ + StringTool.cpp \ ThreadPool.cpp \ WorkQueue.cpp DIST_FILES += $(SOURCES) -OBJECTS = ManagedThread.o \ +OBJECTS = \ + ManagedThread.o \ + StringTool.o \ ThreadPool.o \ WorkQueue.o @@ -37,6 +32,3 @@ endif all: SHARED_LIBS -################################################### -# end auto-generated rules -################################################### |
From: stephan b. <sg...@us...> - 2004-12-26 10:42:14
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32078/include/pclasses/Util Added Files: StringTool.h Log Message: egg --- NEW FILE: StringTool.h --- #ifndef p_Util_STRINGTOOL_HPP_INCLUDED #define p_Util_STRINGTOOL_HPP_INCLUDED 1 #include <string> #include <map> #include <pclasses/Phoenix.h> #include <pclasses/Util/LexT.h> namespace P { /** The StringTool namespace encapsulates a set of utility functions for working with string objects. */ namespace StringTool { using ::P::Util::LexT; /** Convenience typedef for use with translateEntities(). */ typedef std::map<std::string,std::string> EntityMap; /** For each entry in the input string, the characters are mapped to string sequences using the given translation_map. Where no mappings exist, the input sequence is left as-is. It returns the number of translations made. If reverse_translation == true then a reverse mapping is done: map values are treated as keys. This is useful, for example, for doing XML-entity-to-char conversions. It is amazingly INefficient, but seems to work okay. */ size_t translateEntities( std::string &, const EntityMap & translation_map, bool reverse_translation = false ); /** A policy enum used by trimString(). */ enum TrimPolicy { /** Trim only leading spaces. */ TrimLeading = 0x01, /** Trim only trailing spaces. */ TrimTrailing = 0x02, /** Trim leading and trailing spaces. */ TrimAll = TrimLeading + TrimTrailing }; /** Trims leading and trailing whitespace from the input string and returns the number of whitespace characters removed. */ size_t trimString( std::string &, TrimPolicy = TrimAll ); /** Trims leading and trailing whitespace from the input string and returns the trimmed string. */ std::string trimString( const std::string &, TrimPolicy = TrimAll ); /** Attempts to remove all backslash-escaped chars from str. Removes backslash-escaped newlines from the input string, including any whitespace immediately following each backslash. The optional slash parameter defines the escape character. */ size_t stripSlashes( std::string &str, const char slash = '\\' ); /** Adds an escape sequence in front of any characters in instring which are also in the list of chars_to_escape. Returns the number of escapes added. e.g., to escape (with a single backslash) all $, % and \ in mystring with a backslash: <pre> escapeString( mystring, "$%\\", "\\" ); </pre> (WARNING: the doxygen-generated HTML version of these docs may incorrectly show single backslashes in the above example!) */ size_t escapeString( std::string & instring, const std::string & chars_to_escape, const std::string & escape_seq = "\\" ); /** normalizeString() is like trimString() and strip_slashes(), combined, plus it removes leading/trailing quotes: <pre> "this is a \ sample multi-line, backslash-escaped \ string." </pre> Will translate to: <pre> this is a sample multi-line, backslash-escaped string. </pre> */ void normalizeString( std::string & ); /** Returns the first whitespace-delimited token from the given string, or an empty string if there is no such token. */ std::string firstToken( const std::string & ); /** Returns the passed-in string, minus the first whitespace-delimited token. An empty string is returned if there is no second token. */ std::string afterFirstToken( const std::string & ); /** Returns int values for chars '0'-'9', 'a'-'f' and 'A'-'F', else -1. */ int int4hexchar( char c ); /** Returns decimal value of wd, which is assumed to be a hex-encoded number. wd may optionally be prefixed with '#', as in \#ff00ff. Case is insignificant. On error 0 is returned, but 0 is also a valid number, so there is really no way of knowing if it fails or not. :/ */ int hex2int( const std::string & wd ); /** Lexically casts v to a string. */ template <typename ValueT> std::string to( const ValueT & v ) { return LexT(v).str(); } /** Lexically casts v to a ValueT, or returns dflt if conversion fails. */ template <typename ValueT> ValueT from( const std::string & v, const ValueT & dflt = ValueT() ) { return LexT(v).template castTo<ValueT>( dflt ); } /** See translateEntities() for details. */ typedef std::map<std::string,std::string> EntityMap; /** YAGNI! A functor for translating entities in a set of strings. Designed for use with std::for_each(). */ struct EntityTranslator { /** Sets the map and reverse options to be used from calls to operator(). */ EntityTranslator( const EntityMap & map, bool reverse ) : m_map(map),m_rev(reverse) { } /** Calls translateEntities( str, MAP, REVERSE ), where MAP and REVERSE are the flags set via the ctor. */ inline void operator()( std::string & str ) const { translateEntities( str, this->m_map, this->m_rev ); } private: EntityMap m_map; bool m_rev; }; /** Internal-use initializer for setting up an entity translation map for default quote-escaping behaviour. */ struct defaultEscapesInitializer { /** Adds the following escape sequences to map: - single backslash (\) == double backslash. - single quote == backslash, quote - double quote == backslash, double quote */ void operator()( EntityMap & map ); }; /** Internal marker type. */ template <typename ContextT> struct StrSharingContext {}; /** Returns the default entity translation map, which can be used to [un]slash-escape the folling entities: '\\', '\'', '"'. */ inline const EntityMap & defaultEscapesTranslations() { typedef ::P::Phoenix<EntityMap, StrSharingContext<EntityMap>, defaultEscapesInitializer > TMap; return TMap::instance(); } /** Converts v to a string, applies translateEntities(...,trans,reverse ), and returns the resulting string. */ template <typename ValueT> std::string translate( const ValueT & v, const EntityMap & trans, bool reverse ) { std::string val = to( v ); translateEntities( val, trans, reverse ); return val; } /** Calls translate( v,trans, false); */ template <typename ValueT> std::string escape( const ValueT & v, const EntityMap & trans = defaultEscapesTranslations() ) { return translate( v, trans, false ); } /** Calls translate( v, trans, true ); */ template <typename ValueT> std::string unescape( const ValueT & v, const EntityMap & trans = defaultEscapesTranslations() ) { return translate( v, trans, true ); } /** Returns v as a quoted string, using the given quote character. */ template <typename ValueT> std::string quote( const ValueT & v, const std::string & quote = "\'" ) { return quote + to( v ) + quote; } }} // namespace P::StringTool #endif // p_Util_STRINGTOOL_HPP_INCLUDED |
From: stephan b. <sg...@us...> - 2004-12-26 10:42:14
|
Update of /cvsroot/pclasses/pclasses2/src/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32078/src/Util Added Files: StringTool.cpp Log Message: egg --- NEW FILE: StringTool.cpp --- #include <pclasses/Util/StringTool.h> namespace P { namespace StringTool { size_t translateEntities( std::string & str, const EntityMap & map, bool reverse ) { if( str.empty() || ( 0 == map.size() ) ) return 0; size_t count = 0; std::string::size_type pos = str.npos; EntityMap::const_iterator mit; EntityMap::const_iterator met = map.end(); std::string key; std::string val; if( reverse ) { mit = map.begin(); for( ; mit != met; ++mit ) { key = (*mit).second; val = (*mit).first; while( str.npos != (pos = str.rfind( key )) ) { ++count; str.replace( pos, key.size(), val ); } } } else { pos = str.size() - 1; for( ; pos != std::string::npos; --pos ) { mit = map.find( str.substr(pos,1) ); if( met == mit ) continue; ++count; str.replace( pos, 1, (*mit).second ); } } return count; } size_t escapeString( std::string & ins, const std::string & to_esc, const std::string & esc ) { std::string::size_type pos; pos = ins.find_first_of( to_esc ); size_t reps = 0; while( pos != std::string::npos ) { ins.insert( pos, esc ); ++reps; pos = ins.find_first_of( to_esc, pos + esc.size() + 1 ); } return reps; } size_t stripSlashes( std::string &str, const char slash ) { std::string::size_type osz; if( str.empty() || ((osz = str.size()) < 2 ) ) return 0; std::string::size_type pos = 0; size_t count = 0; pos = str.find( slash ); if( pos == str.npos ) return 0; if( osz < 2 ) return 0; // strip escaped newlines. this is in a separate loop // because it used to be in a different function. :/ pos = osz-2; std::string::size_type search; while( pos > 2 ) { char c = str[pos]; if( slash == c && (str[pos-1] != slash) ) { ++count; search = str.find_first_not_of( " \t\n", pos +1 ); if( search > pos + 1 ) { //COUT << "stripping until " << search << ":["<<str.substr(pos,search-pos)<<"]"<<endl; str.erase( pos, search -pos ); } --pos; // one extra. } --pos; } pos = str.find( slash ); while( !( (pos == std::string::npos) || (pos > str.size()-2) ) ) { // todo: search from the end, going // backwards. This "might" be faster in terms // of string's required workload. ++count; str.erase( pos, 1 ); if( slash != str[pos+1] ) { pos += 1; } else pos += 2; pos = str.find( slash, pos ); } return count; } void normalizeString( std::string &str ) { //COUT << "normalize_string("<<str<<")" << endl; trimString( str ); stripSlashes( str ); const char ch = str[0]; if( '"' == ch || '\'' == ch ) { str.erase( 0, 1 ); str.resize( str.size() - 1 ); } //COUT << "normalizeString("<<str<<")" << endl; return; } std::string trimString( const std::string &str, TrimPolicy policy ) { std::string foo = str; trimString( foo, policy ); return foo; } size_t trimString( std::string &str, TrimPolicy policy ) { if( str.empty() ) return 0; static const std::string space(" \t\n\r"); size_t sc = 0; if( policy & TrimTrailing ) { while( !str.empty() && str.find_last_of( space ) == (str.size()-1) ) { str.erase( str.size()-1 ); ++sc; } } if( policy & TrimLeading ) { while( !str.empty() && (str.find_first_of( space ) == 0 ) ) { str.erase( 0, 1 ); ++sc; } } //CERR << "trimString(...,"<<std::hex<<policy<<") = ["<<str<<"]"<<std::endl; return sc; } std::string firstToken( const std::string & input ) { if( input.empty() ) return input; return input.substr( 0, input.find_first_of( " \n\t" ) ); } std::string afterFirstToken( const std::string & input ) { if( input.empty() ) return input; std::string::size_type pos = input.find_first_of( " \n\t" ); if( pos == std::string::npos ) return std::string(); return trimString( input.substr( pos ) ); } int int4hexchar( char c ) { int i = -1; if( c >= 48 && c <=57 ) // 0-9 { i = ((int)c - 48); } else if( c >= 65 && c <=70 ) // A-F { i = ((int)c - 65) + 10; } else if( c >= 97 && c <=102 ) // a-f { i = ((int)c - 97) + 10; } return i; } int hex2int( const std::string & wd ) { unsigned int mult = 1; int ret = 0; char c; for( std::string::size_type i = wd.size(); i > 0; --i ) { //COUT << "i="<<i<<endl; c = wd[i-1]; if( '#' == c ) continue; ret += mult * int4hexchar( c ); mult = mult * 16; } return ret; } void defaultEscapesInitializer::operator()( EntityMap & map ) { map["\\"] = "\\\\"; map["\'"] = "\\\'"; map["\""] = "\\\""; } }} // P::StringTool |
From: stephan b. <sg...@us...> - 2004-12-26 09:44:37
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22441/src/s11n Modified Files: SIO.cpp SIO.h Log Message: Fixed a copy/paste error which left the decls for serializerClass() in the impl file, not the header. Index: SIO.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/SIO.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SIO.h 26 Dec 2004 09:36:19 -0000 1.3 +++ SIO.h 26 Dec 2004 09:44:27 -0000 1.4 @@ -210,6 +210,17 @@ return serialize( n, src ) && save( n, dest ); } + /** + Sets the current Serializer class used by createSerializer(). + Pass it a class name of a SerializerInterface type. + */ + void serializerClass( const std::string & ); + + /** + Gets the name of the current default Serializer type. + */ + std::string serializerClass(); + } // namespace SIO } // namespace P Index: SIO.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/SIO.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- SIO.cpp 26 Dec 2004 09:35:58 -0000 1.3 +++ SIO.cpp 26 Dec 2004 09:44:27 -0000 1.4 @@ -78,16 +78,6 @@ return ::P::s11n::io::load_node<S11nNode>( src ); } - /** - Sets the current Serializer class used by createSerializer(). - Pass it a class name of a SerializerInterface type. - */ - void serializerClass( const std::string & ); - - /** - Gets the name of the current default Serializer type. - */ - std::string serializerClass(); void serializerClass( const std::string & c ) { |
From: stephan b. <sg...@us...> - 2004-12-26 09:37:14
|
Update of /cvsroot/pclasses/pclasses2/doc/manual In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21304/doc/manual Modified Files: pclasses2.lyx Log Message: Added initial s11n module docs. Index: pclasses2.lyx =================================================================== RCS file: /cvsroot/pclasses/pclasses2/doc/manual/pclasses2.lyx,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pclasses2.lyx 25 Dec 2004 02:38:39 -0000 1.3 +++ pclasses2.lyx 26 Dec 2004 09:37:05 -0000 1.4 @@ -253,6 +253,9 @@ \layout Itemize Crypto: cryptography and hasing support. +\layout Itemize + +s11n: object serialization support. \layout Section Core Module @@ -643,6 +646,104 @@ WorkQueue \layout Section +s11n Module +\layout Standard + +The types in this section all live in the namespace P::s11n. +\layout Standard + +This module is a direct fork/port of s11n.net's libs11n framework. + Only the core, non-platform-dependents parts are ported here. +\layout Standard + +P::s11n will not be documented much here, as it is just a clone of libs11n, + which already has a +\emph on +huge +\emph default + amount of documentation. +\layout Standard + + +\series bold +\emph on +\color red +Caveat and appology +\series default +\emph default +\color default +: as this module is basically a copy/paste operation from the main s11n + tree, the classes and namespaces in this module do not conform to P's standard + naming conventions. + Also, i [stephan] am the maintainer of s11n.net, as well of of P::s11n, + and want to keep the cross-tree-porting effort to a minimum. + We hope you can appreciate the reasons for this API inconsistency. + A more P-friendly interface will be developed at some point, to hide this + difference from (most) client code. + +\layout Subsection + +SIO interface +\layout Standard + +Clients using P's s11n features are encourages to use the P::SIO API, provided + via +\family typewriter +<pclasses/s11n/SIO.h> +\family default +. +\layout Subsection + +Registering Serializables +\layout Standard + +See (srcdir)/test/s11nTest.cpp, registrations.cpp, FactoryTest.h and CType.cpp + for a complete example of plugging in types to P::s11n. +\layout Subsection + +Loading Serializers +\layout Standard + +For reading s11n data, clients do not need to know the input format or Serialize +r needed to read it - this is handled automatically by s11n. + For output, however, clients must choose a Serializer. + Something like this will do the trick: +\layout Quote + +#include <pclasses/s11n/SIO.h> // P client interface into s11n +\layout Quote + +... +\layout Quote + +::P::SIO::SerializerInterface; +\layout Quote + +// NODE_TYPE is an arbitrary s11n-support data node type, like P::s11n::s11n_nod +e or data_node. +\layout Quote + +// Load it via the plugin manager: +\layout Quote + +SerializerBase * ser = ::P::SIO::createSerializer( "expat" ); +\layout Standard + +Of course, +\begin_inset Quotes sld +\end_inset + +expat +\begin_inset Quotes srd +\end_inset + + may be the name of any linked-in or dynamically loadable SerializerBase + type. +\layout Standard + +See the file (srctree)/test/s11nTest.cpp for a full example. +\layout Section + Misc notes \layout Subsection |
From: stephan b. <sg...@us...> - 2004-12-26 09:36:30
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21162/src/s11n Modified Files: SIO.h Log Message: API corrections/additions. Index: SIO.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/SIO.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SIO.h 26 Dec 2004 09:15:27 -0000 1.2 +++ SIO.h 26 Dec 2004 09:36:19 -0000 1.3 @@ -29,14 +29,14 @@ /** The concrete "data node" type used by serialization operations. - Node that it is considered poor form to use an S11nNode's + Note that it is considered poor form to use an S11nNode's API directly, as it's type and interface may change. The - only guaranty the S11nNode's API guarantees is that + only guaranty the S11nNode's API gives is that NodeTraits::funcs(S11nNode &...) operations will work as - expected. More clearly: use NodeTraits to manipulate and - query nodes, not the node API directly. In fact s11n_node's - useful API is all private, so you CAN'T touch it without - going through NodeTraits. :) Gotcha! + expected/documented. More clearly: use NodeTraits to + manipulate and query nodes, not the node API directly. In + fact S11nNode's useful API is all private, so you CAN'T + touch it without going through NodeTraits. :) Gotcha! */ typedef ::P::s11n::s11n_node S11nNode; |
From: stephan b. <sg...@us...> - 2004-12-26 09:36:07
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21019/src/s11n Modified Files: SIO.cpp Log Message: Corrected use of PCLASSES_HAVE_LIBEXPAT define. Index: SIO.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/SIO.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SIO.cpp 26 Dec 2004 09:15:27 -0000 1.2 +++ SIO.cpp 26 Dec 2004 09:35:58 -0000 1.3 @@ -20,7 +20,7 @@ void SIO_init() { m_serializer_class = SIO_KEY_DEFAULT_SERIALIZER; -#if PCLASSES_HAVE_LIBEXPAT +#ifdef PCLASSES_HAVE_LIBEXPAT // @fixme: be more dynamic here, look poking around // libdir/pclasses/*_serializer.so. SerializerPluginManager::instance().alias( SIO_KEY_DEFAULT_SERIALIZER, "expat" ); |
From: stephan b. <sg...@us...> - 2004-12-26 09:30:46
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20123/test Modified Files: FactoryTest.cpp Log Message: Accommodated classname() rename in Factory. Index: FactoryTest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/FactoryTest.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- FactoryTest.cpp 26 Dec 2004 06:00:55 -0000 1.8 +++ FactoryTest.cpp 26 Dec 2004 09:30:37 -0000 1.9 @@ -27,8 +27,8 @@ std::string dllname = "SumDumDLL"; pm.alias( dllname, "CType" ); -#define CLOAD(CN) a = P::CL::classload<TheBase>( CN ); \ - CERR << CN << " classload("<<CN<<")ed? == " << a << "\n"; \ +#define CLOAD(CN) a = P::CL::create<TheBase>( CN ); \ + CERR << CN << " P::CL::create("<<CN<<")ed? == " << a << "\n"; \ if( a ) CERR << "classname="<<a->classname()<<"\n"; \ delete( a ); a = 0; |
From: stephan b. <sg...@us...> - 2004-12-26 09:28:35
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19633/include/pclasses Modified Files: Factory.h Log Message: Renamed P::CL::classload() ==> P::CL::create(), for consistency. Index: Factory.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Factory.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Factory.h 26 Dec 2004 07:55:32 -0000 1.13 +++ Factory.h 26 Dec 2004 09:28:17 -0000 1.14 @@ -479,7 +479,7 @@ Returns the same as NamedTypeFactory<InterfaceT>::instance().create( classname ). */ template <typename InterfaceT> - InterfaceT * classload( const std::string & classname ) + InterfaceT * create( const std::string & classname ) { return NamedTypeFactory<InterfaceT>::instance().create( classname ); } |
From: stephan b. <sg...@us...> - 2004-12-26 09:21:32
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18340/include/pclasses Modified Files: pclasses-config.h.at Log Message: Added PCLASSES_HAVE_LIBEXPAT. Index: pclasses-config.h.at =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/pclasses-config.h.at,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pclasses-config.h.at 26 Dec 2004 01:28:34 -0000 1.7 +++ pclasses-config.h.at 26 Dec 2004 09:21:22 -0000 1.8 @@ -22,6 +22,13 @@ # define PCLASSES_HAVE_LARGEFILE @PCLASSES_HAVE_LARGEFILE@ #endif +#if @PCLASSES_HAVE_LIBEXPAT@ == 0 +# undef PCLASSES_HAVE_LIBEXPAT +#else +# define PCLASSES_HAVE_LIBEXPAT @PCLASSES_HAVE_LIBEXPAT@ +#endif + + #if @PCLASSES_HAVE_DLFCN_H@ == 0 # undef PCLASSES_HAVE_DLFCN_H #else |
From: stephan b. <sg...@us...> - 2004-12-26 09:21:05
|
Update of /cvsroot/pclasses/pclasses2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18208 Modified Files: configure.pclasses2 Log Message: Corrected PCLASSES_HAVE_LIBEXPAT, such that the no-expat case is handled properly by the #defines. Index: configure.pclasses2 =================================================================== RCS file: /cvsroot/pclasses/pclasses2/configure.pclasses2,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- configure.pclasses2 26 Dec 2004 04:10:27 -0000 1.13 +++ configure.pclasses2 26 Dec 2004 09:20:57 -0000 1.14 @@ -43,8 +43,8 @@ fi toc_test libs11n; toc_export PCLASSES_HAVE_S11N=${HAVE_LIBS11N} toc_test libexpat +toc_export PCLASSES_HAVE_LIBEXPAT="${HAVE_LIBEXPAT-0}" if test x1 = "x${HAVE_LIBEXPAT}"; then - toc_export PCLASSES_HAVE_LIBEXPAT=1 toc_export LIBEXPAT_CLIENT_LDADD="-lexpat" expat_ldadd="-lexpat" fi |
From: stephan b. <sg...@us...> - 2004-12-26 09:16:36
|
Update of /cvsroot/pclasses/pclasses2/src/s11n/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17089/src/s11n/io Modified Files: serializers.h Log Message: Removed some debug code. Cleaned up a factory call. Index: serializers.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/io/serializers.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- serializers.h 26 Dec 2004 06:09:11 -0000 1.2 +++ serializers.h 26 Dec 2004 09:16:27 -0000 1.3 @@ -123,7 +123,7 @@ std::string ext = std::string("_serializer.") + ::P::System::SharedLib::extension(); PM.searchPath().addExtension( ext ); } - CERR << "register_serializer(" << classname << ","<<alias<<")\n"; + // CERR << "register_serializer(" << classname << ","<<alias<<")\n"; PM.registerFactory( classname, FACCREATE ); PM.alias( alias, classname ); @@ -144,9 +144,10 @@ { try { + typedef s11n::io::data_node_serializer<NodeT> SerializerInterface; CERR << "create_serializer("<<classname<<") trying plugin manager...\n"; // return SPM::instance().create( classname ); - return ::P::s11n::cl::classloader< SPM >().create( classname ); + return ::P::Plugin::pluginManager< SerializerInterface >().create( classname ); } catch(const ::P::Exception & e) { |
From: stephan b. <sg...@us...> - 2004-12-26 09:15:45
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16835/src/s11n Modified Files: SIO.cpp SIO.h Log Message: More tweaks and fixes. Almost essentially complete. Index: SIO.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/SIO.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SIO.h 26 Dec 2004 07:52:07 -0000 1.1 +++ SIO.h 26 Dec 2004 09:15:27 -0000 1.2 @@ -4,7 +4,7 @@ //////////////////////////////////////////////////////////////////////// // SIO.h: // Author: stephan beal <st...@s1...> -// License: Public Domain +// License: LGPL, copyright(c) 2004, 2005 stephan beal // // This header is intended to provide the standard P::s11n interface, // in particular the client-side interface. @@ -41,7 +41,8 @@ typedef ::P::s11n::s11n_node S11nNode; /** - NodeTraits are used to get information from S11nNode. + NodeTraits are used to view and manipulate data in S11nNode + objects. */ typedef ::P::s11n::node_traits<S11nNode> NodeTraits; @@ -74,7 +75,7 @@ } /** - See ::P::s11n::deserialize(). + See ::P::s11n::deserialize(). */ template <typename DeserializableT> bool deserialize( const S11nNode & src, DeserializableT & target ) @@ -136,6 +137,80 @@ return ::P::s11n::io::load_serializable<S11nNode,SerializableType>( src ); } + /** + See ::P::s11n::io::create_serializer(). + + In short: it looks at the given file to determine what + Serializer should be able to read it. + + Once IOManager support is completed this will also support + URL-based lookups. + */ + SerializerInterface * serializerFor( const std::string & url ); + + /** + Saves src to dest using the default + serializerClass(). Returns true on success, false on error. + */ + bool save( const S11nNode & src, const std::string & dest ); + + /** + Saves src to dest using the default + serializerClass(). Returns true on success, false on error. + */ + bool save( const S11nNode & src, std::ostream & dest ); + + /** + Uses SerializerPluginManager to load the Serializer + set via serializerClass() + + The caller owns the returned pointer, which may be 0. + */ + SerializerInterface * createSerializer(); + /** + Uses SerializerPluginManager to load a Serializer. + + The caller owns the returned pointer, which may be 0. + */ + SerializerInterface * createSerializer( const std::string & ); + + /** + Uses serialize(src,node) to serialize src then calls + save(n,dest). Returns true on success, false on error. + */ + template <typename SerializableT> + bool save( const SerializableT & src, std::ostream & dest ) + { + S11nNode n; + return (serialize( n, src ) && save( n, dest )); + } + + /** + Serializes src to a S11nNode && returns serialize(node,url). + + Returns true on success, false on error. + */ + template <typename SerializableT> + bool save( const SerializableT & src, const std::string & url ) + { + S11nNode n; + if( ! serialize( n, src ) ) return false; + return serialize( n, url ); + } + + /** + Serializes src to a S11nNode && returns serialize(node,dest). + + Returns true on success, false on error. + */ + template <typename SerializableT> + bool save( const SerializableT & src, const std::ostream & dest ) + { + S11nNode n; + return serialize( n, src ) && save( n, dest ); + } + + } // namespace SIO } // namespace P Index: SIO.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/SIO.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SIO.cpp 26 Dec 2004 07:52:07 -0000 1.1 +++ SIO.cpp 26 Dec 2004 09:15:27 -0000 1.2 @@ -1,5 +1,13 @@ +//////////////////////////////////////////////////////////////////////// +// SIO.cpp - implementation code for SIO.h +// author: st...@s1... +// License: LGPL, copyright(c) 2004, 2005 stephan beal +//////////////////////////////////////////////////////////////////////// #include "SIO.h" +#include <pclasses/s11n/s11n_debuggering_macros.h> +#include <pclasses/pclasses-config.h> // PCLASSES_HAVE_LIBEXPAT +#define SIO_KEY_DEFAULT_SERIALIZER "/P/SIO/DefaultSerializer" namespace P { /** @@ -7,6 +15,57 @@ namespace SIO { + std::string m_serializer_class; + + void SIO_init() + { + m_serializer_class = SIO_KEY_DEFAULT_SERIALIZER; +#if PCLASSES_HAVE_LIBEXPAT + // @fixme: be more dynamic here, look poking around + // libdir/pclasses/*_serializer.so. + SerializerPluginManager::instance().alias( SIO_KEY_DEFAULT_SERIALIZER, "expat" ); +#endif + } + int SIO_init_placeholder = (SIO_init(),0); + + + SerializerInterface * serializerFor( const std::string & url ) + { + // @fixme: be more dynamic here: + // todo: port in IManager support from "original" ps11n + // once IOM is re-implemented in P2. + return ::P::s11n::io::create_serializer<S11nNode>( m_serializer_class ); + } + + SerializerInterface * createSerializer( const std::string & c ) + { + return SerializerPluginManager::instance().create( c ); + } + + SerializerInterface * createSerializer() + { + return SerializerPluginManager::instance().create( m_serializer_class ); + } + + bool save( const S11nNode & src, std::ostream & dest ) + { + typedef std::auto_ptr<SerializerInterface> SAP; + SAP ser = SAP(createSerializer()); + if( ! ser.get() ) + { + CERR << "Could not load Serializer!\n"; + return false; + } + return ser->serialize( src, dest ); + } + + bool save( const S11nNode & src, const std::string & dest ) + { + std::ofstream os(dest.c_str()); + if( ! os ) return false; + return save( src, os ); + } + S11nNode * loadNode( std::istream & src ) { @@ -19,4 +78,27 @@ return ::P::s11n::io::load_node<S11nNode>( src ); } + /** + Sets the current Serializer class used by createSerializer(). + Pass it a class name of a SerializerInterface type. + */ + void serializerClass( const std::string & ); + + /** + Gets the name of the current default Serializer type. + */ + std::string serializerClass(); + + void serializerClass( const std::string & c ) + { + m_serializer_class = c; + } + + std::string serializerClass() + { + return m_serializer_class; + } + + + }} // P::SIO |
From: stephan b. <sg...@us...> - 2004-12-26 09:15:12
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16737/src/s11n Modified Files: s11n_node.h Log Message: Moved begin()/end() into the public interface, for use by generic algorithms. Index: s11n_node.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/s11n_node.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- s11n_node.h 26 Dec 2004 07:53:19 -0000 1.3 +++ s11n_node.h 26 Dec 2004 09:15:02 -0000 1.4 @@ -126,6 +126,32 @@ */ std::string name() const; + /** + Returns the first item in this object's property + map. + + Note that the iterator represents a value_type + (std::pair), so use (*it).first to get the key and + (*it).second to get the value. + */ + iterator begin(); + + /** + Returns a const_iterator pointing at this object's + first property. + */ + const_iterator begin() const; + + /** + * The after-the-end iterator for this object's properties. + */ + iterator end(); + + /** + * The after-the-end iterator for this object's properties. + */ + const_iterator end() const; + private: @@ -248,31 +274,6 @@ */ void unset( const std::string & key ); - /** - Returns the first item in this object's property - map. - - Note that the iterator represents a value_type - (std::pair), so use (*it).first to get the key and - (*it).second to get the value. - */ - iterator begin(); - - /** - Returns a const_iterator pointing at this object's - first property. - */ - const_iterator begin() const; - - /** - * The after-the-end iterator for this object's properties. - */ - iterator end(); - - /** - * The after-the-end iterator for this object's properties. - */ - const_iterator end() const; map_type & properties(); const map_type & properties() const; |
From: stephan b. <sg...@us...> - 2004-12-26 09:14:23
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16563/src/s11n Modified Files: map.h Log Message: traits-related fixes. Index: map.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/map.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- map.h 26 Dec 2004 07:53:19 -0000 1.4 +++ map.h 26 Dec 2004 09:14:12 -0000 1.5 @@ -60,6 +60,7 @@ template <typename NodeType, typename MapType> bool serialize_streamable_map( NodeType & dest, const MapType & src ) { + typedef ::P::s11n::node_traits<NodeType> TR; typedef typename MapType::value_type VT; typedef typename VT::first_type FT; typedef typename VT::second_type ST; @@ -68,7 +69,7 @@ using ::P::Util::LexT; for( ; src.end() != it; ++it ) { - dest.set( + TR::set( dest, LexT( (*it).first ).str(), LexT( (*it).second ).str() ); @@ -174,7 +175,7 @@ template <typename NodeType, typename PairType> bool serialize_streamable_pair( NodeType & dest, const PairType & src ) { - typedef s11n::node_traits<NodeType> TR; + typedef ::P::s11n::node_traits<NodeType> TR; TR::class_name( dest, ::classname<PairType>() ); typedef typename PairType::first_type FT; typedef typename PairType::second_type ST; @@ -225,7 +226,7 @@ template <typename NodeType, typename MapType> bool serialize_streamable_map_pairs( NodeType & dest, const MapType & src ) { - typedef s11n::node_traits<NodeType> TR; + typedef ::P::s11n::node_traits<NodeType> TR; TR::class_name( dest, ::classname<MapType>() ); typedef typename MapType::value_type VT; typedef typename VT::first_type FT; @@ -290,7 +291,7 @@ template <typename NodeType, typename PairType> bool serialize_pair( NodeType & dest, const PairType & src ) { - typedef s11n::node_traits<NodeType> NT; + typedef ::P::s11n::node_traits<NodeType> NT; NT::class_name( dest, ::classname<PairType>() ); NodeType * ch = & create_child( dest, "first" ); if( ! serialize( *ch, src.first ) ) |
From: stephan b. <sg...@us...> - 2004-12-26 08:09:36
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5502/test Modified Files: FactoryTest.h Log Message: Now uses P::SIO interface. Index: FactoryTest.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/FactoryTest.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FactoryTest.h 26 Dec 2004 06:00:55 -0000 1.4 +++ FactoryTest.h 26 Dec 2004 08:09:26 -0000 1.5 @@ -11,14 +11,10 @@ #include <pclasses/Factory.h> -#ifndef USE_S11N -# define USE_S11N 0 -#endif - -#include <pclasses/s11n/s11n.h> +#include <pclasses/s11n/SIO.h> -#define NODE_TYPE ::P::s11n::s11n_node -#define NODETR ::P::s11n::node_traits< NODE_TYPE > +#define NODE_TYPE ::P::SIO::S11nNode +#define NODETR ::P::SIO::NodeTraits struct TheBase { @@ -55,12 +51,16 @@ } }; +//////////////////////////////////////////////////////////////////////// +// register TheBase with s11n's classloaders and register +// proxy: #define PS11N_TYPE TheBase #define PS11N_TYPE_IS_ABSTRACT #define PS11N_TYPE_NAME "TheBase" #define PS11N_SERIALIZE_FUNCTOR TheBase_s11n #include <pclasses/s11n/reg_serializable_traits.h> + struct AType : public TheBase { AType() @@ -90,20 +90,7 @@ virtual std::string classname() const { return "BType"; } }; - -// #ifndef PCLASSES_S11N_INCLUDED -// // avoid duplicate registrations... -// # define PFACREG_TYPE AType -// # define PFACREG_TYPE_INTERFACE TheBase -// // #define PFACREG_TYPE_IS_ABSTRACT // define to install a null factory for AType -// # define PFACREG_TYPE_NAME "AType" -// # include <pclasses/FactoryReg.h> - -// # define PFACREG_TYPE BType -// # define PFACREG_TYPE_INTERFACE TheBase -// # define PFACREG_TYPE_NAME "BType" -// # include <pclasses/FactoryReg.h> -// #endif // PCLASSES_S11N_INCLUDED - +// s11n registrations for AType and BType are in registrations.cpp, to +// demonstrate how scheiss-egal linkage is. #endif // ptest_FACTORYTEST_HPP_INCLUDED |
From: stephan b. <sg...@us...> - 2004-12-26 08:09:20
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5467/test Modified Files: in.s11n s11nTest.cpp Log Message: Now uses P::SIO interface. Plugged in streamable proxy for the demo map, to lower the noise. Index: s11nTest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/s11nTest.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- s11nTest.cpp 26 Dec 2004 06:00:55 -0000 1.3 +++ s11nTest.cpp 26 Dec 2004 08:09:07 -0000 1.4 @@ -1,34 +1,46 @@ #include <pclasses/s11n/s11n_debuggering_macros.h> -#include <pclasses/s11n/s11n.h> -#include <pclasses/s11n/s11n_node.h> -#include <pclasses/s11n/io/s11n_io.h> +#include <pclasses/s11n/SIO.h> +#include <pclasses/s11n/pods_streamable.h> #include <pclasses/s11n/list.h> #include <pclasses/s11n/map.h> -#include <pclasses/s11n/pods_streamable.h> #include <pclasses/Util/LexT.h> #include <memory> // auto_ptr #include <cassert> #include <list> #include <map> -#include "FactoryTest.h" // must come after s11n.h - the FactoryTest.h for why +#include "FactoryTest.h" -#define SERIALIZE(Node,SType,SObj) ::P::s11n::serialize< NODE_TYPE >( Node, SObj ) -#define DESERIALIZE(Node,SType) ::P::s11n::deserialize< NODE_TYPE, SType >( Node ) -typedef ::P::s11n::io::data_node_serializer<NODE_TYPE> SerializerBase; +using namespace ::P::SIO; + +typedef std::map<std::string,::P::Util::LexT> TestMapType; + +// install a custom proxy, which doesn't produce as fat +// output as the default one for maps: +#define PS11N_TYPE TestMapType +#define PS11N_TYPE_NAME "TestMapType" +#define PS11N_SERIALIZE_FUNCTOR ::P::s11n::map::streamable_map_serializable_proxy +#include <pclasses/s11n/reg_serializable_traits.h> + + +#define SERIALIZE(Node,SType,SObj) serialize< SType >( Node, SObj ) +#define DESERIALIZE(Node,SType) deserialize< SType >( Node ) +#define SERIALIZER_CLASS_NAME "<!DOCTYPE P::s11n::io::expat_serializer>" +// #define SERIALIZER_CLASS_NAME "expat" bool test_load( const std::string & fn ) { + using namespace ::P::SIO; typedef std::auto_ptr<NODE_TYPE> NAP; - NAP n = NAP( P::s11n::io::load_node<NODE_TYPE>( fn ) ); + NAP n = NAP( loadNode( fn ) ); assert( n.get() && "Failed loading node from file :(" ); if( n.get() ) { - typedef std::auto_ptr<SerializerBase> SAP; - std::string serclass = "expat"; - SAP ser = SAP( ::P::Plugin::pluginManager<SerializerBase>().create( serclass ) ); + typedef std::auto_ptr<SerializerInterface> SAP; + std::string serclass = SERIALIZER_CLASS_NAME; + SAP ser = SAP( ::P::Plugin::pluginManager<SerializerInterface>().create( serclass ) ); assert( ser.get() && "Could not load serializer :(" ); return ser->serialize( *(n.get()), std::cout ); } @@ -38,6 +50,8 @@ /// i wish i could make this a P::App... int main( int argc, char ** argv ) { + using namespace ::P::SIO; + CERR << "P::s11n tests...\n"; if( 2 == argc ) @@ -48,7 +62,7 @@ typedef std::auto_ptr<TheBase> TAP; TAP b1 = TAP( new BType ); NODE_TYPE node; - assert( SERIALIZE(node,TheBase,b1.get() ) ); + assert( SERIALIZE(node,TheBase, *b1.get() ) ); // weird: i shouldn't have to deref that AP. CERR << "Serialize Workie!\n"; NODETR::class_name( node, "CType" ); // should force load of CType.so on next line... @@ -56,9 +70,9 @@ assert( b2.get() && "Deserialize failed :(" ); CERR << "Deser workie: " << b2->classname()<<"\n"; - typedef std::auto_ptr<SerializerBase> SAP; - std::string serclass = "expat"; - SAP ser = SAP( ::P::Plugin::pluginManager<SerializerBase>().create( serclass ) ); + typedef std::auto_ptr<SerializerInterface> SAP; + std::string serclass = SERIALIZER_CLASS_NAME; + SAP ser = SAP( ::P::Plugin::pluginManager<SerializerInterface>().create( serclass ) ); assert( ser.get() && "Could not load serializer :(" ); CERR << "Loaded serializer '"<<serclass<<"'. :)\n"; @@ -67,35 +81,35 @@ using ::P::Util::LexT; typedef std::list<LexT> ListT; - typedef std::map<int,LexT> MapT; ListT list; - MapT map; - LexT tmpval; + TestMapType map; + LexT tmpv; + LexT tmpk; for( int i = 0; i < 10; i++ ) { - tmpval = std::string("this is item #") + LexT(i).str(); - CERR << "Adding ["<<tmpval<<"]\n"; - list.push_back( tmpval ); - map[i] = tmpval; + tmpk = "item" + LexT(i).str(); + // ^^^ reminder: we do this to avoid numeric keys + // in map, because that don't work with XML-compliant Serializers. + tmpv = std::string("this is item #") + LexT(i).str(); + CERR << "Adding ["<<tmpv<<"]\n"; + list.push_back( tmpv ); + map[tmpk] = tmpv; } CERR << "list/map sizes == " << list.size() << " , " << map.size()<<"\n"; - bool worked; CERR << "Containers...\n"; - assert( ::P::s11n::serialize(node,list) ); + assert( serialize(node,list) ); assert( ser->serialize( node, std::cout ) ); list.clear(); - worked = ::P::s11n::deserialize( node, list ); - assert( worked && "deser list failed :(" ); + assert( deserialize( node, list ) && "deser list failed :(" ); - node.clear(); - assert( ::P::s11n::serialize(node,map) ); + NodeTraits::clear(node); + assert( serialize(node,map) ); assert( ser->serialize( node, std::cout ) ); map.clear(); - worked = ::P::s11n::deserialize( node, map ); - assert( worked && "deser map failed :(" ); - + assert( deserialize( node, map ) && "deser map failed :(" ); + NodeTraits::set( node, "i_deserialized_this", "yes" ); CERR << "Deserialized:\n"; CERR << "deser list.size() == " << list.size()<<"\n"; @@ -109,7 +123,7 @@ { CERR << "list["<<at++<<"] = " << (*(lit++))<<"\n"; } - MapT::const_iterator mit = map.begin(); + TestMapType::const_iterator mit = map.begin(); while( mit != map.end() ) { CERR << "map["<<(*mit).first<<"] = "<<(*mit).second<<"\n"; Index: in.s11n =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/in.s11n,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- in.s11n 26 Dec 2004 07:54:10 -0000 1.1 +++ in.s11n 26 Dec 2004 08:09:07 -0000 1.2 @@ -1,83 +1,13 @@ <!DOCTYPE P::s11n::io::expat_serializer> -<s11n_node class="map"> - <pair class="pair"> - <first class="int"> - <v>0</v> - </first> - <second class="LexT"> - <v>this is item #0</v> - </second> - </pair> - <pair class="pair"> - <first class="int"> - <v>1</v> - </first> - <second class="LexT"> - <v>this is item #1</v> - </second> - </pair> - <pair class="pair"> - <first class="int"> - <v>2</v> - </first> - <second class="LexT"> - <v>this is item #2</v> - </second> - </pair> - <pair class="pair"> - <first class="int"> - <v>3</v> - </first> - <second class="LexT"> - <v>this is item #3</v> - </second> - </pair> - <pair class="pair"> - <first class="int"> - <v>4</v> - </first> - <second class="LexT"> - <v>this is item #4</v> - </second> - </pair> - <pair class="pair"> - <first class="int"> - <v>5</v> - </first> - <second class="LexT"> - <v>this is item #5</v> - </second> - </pair> - <pair class="pair"> - <first class="int"> - <v>6</v> - </first> - <second class="LexT"> - <v>this is item #6</v> - </second> - </pair> - <pair class="pair"> - <first class="int"> - <v>7</v> - </first> - <second class="LexT"> - <v>this is item #7</v> - </second> - </pair> - <pair class="pair"> - <first class="int"> - <v>8</v> - </first> - <second class="LexT"> - <v>this is item #8</v> - </second> - </pair> - <pair class="pair"> - <first class="int"> - <v>9</v> - </first> - <second class="LexT"> - <v>this is item #9</v> - </second> - </pair> +<s11n_node class="TestMapType"> + <item0>this is item #0</item0> + <item1>this is item #1</item1> + <item2>this is item #2</item2> + <item3>this is item #3</item3> + <item4>this is item #4</item4> + <item5>this is item #5</item5> + <item6>this is item #6</item6> + <item7>this is item #7</item7> + <item8>this is item #8</item8> + <item9>this is item #9</item9> </s11n_node> |
From: stephan b. <sg...@us...> - 2004-12-26 07:55:43
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3282/include/pclasses Modified Files: Factory.h Log Message: added an API comment. Index: Factory.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Factory.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Factory.h 26 Dec 2004 06:01:52 -0000 1.12 +++ Factory.h 26 Dec 2004 07:55:32 -0000 1.13 @@ -300,6 +300,11 @@ could be loaded for the given key. Subtypes are free to implement, e.g., DLL lookups. + + This implementation calls expandAliases(_key) to + unexpand any aliased class names. Subclasses + "should" do the same, but are not strictly required + to. */ virtual ResultType create( const key_type & _key ) { |
From: stephan b. <sg...@us...> - 2004-12-26 07:54:18
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3063/test Modified Files: Makefile.toc Added Files: in.s11n Log Message: added in.s11n. Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/Makefile.toc,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Makefile.toc 26 Dec 2004 06:00:55 -0000 1.8 +++ Makefile.toc 26 Dec 2004 07:54:10 -0000 1.9 @@ -16,7 +16,8 @@ StackTest.cpp \ ThreadTest.cpp -DIST_FILES += $(SOURCES) $(HEADERS) +DIST_FILES += $(SOURCES) $(HEADERS) \ + in.s11n OBJECTS = \ IntTypeTest.o \ --- NEW FILE: in.s11n --- <!DOCTYPE P::s11n::io::expat_serializer> <s11n_node class="map"> <pair class="pair"> <first class="int"> <v>0</v> </first> <second class="LexT"> <v>this is item #0</v> </second> </pair> <pair class="pair"> <first class="int"> <v>1</v> </first> <second class="LexT"> <v>this is item #1</v> </second> </pair> <pair class="pair"> <first class="int"> <v>2</v> </first> <second class="LexT"> <v>this is item #2</v> </second> </pair> <pair class="pair"> <first class="int"> <v>3</v> </first> <second class="LexT"> <v>this is item #3</v> </second> </pair> <pair class="pair"> <first class="int"> <v>4</v> </first> <second class="LexT"> <v>this is item #4</v> </second> </pair> <pair class="pair"> <first class="int"> <v>5</v> </first> <second class="LexT"> <v>this is item #5</v> </second> </pair> <pair class="pair"> <first class="int"> <v>6</v> </first> <second class="LexT"> <v>this is item #6</v> </second> </pair> <pair class="pair"> <first class="int"> <v>7</v> </first> <second class="LexT"> <v>this is item #7</v> </second> </pair> <pair class="pair"> <first class="int"> <v>8</v> </first> <second class="LexT"> <v>this is item #8</v> </second> </pair> <pair class="pair"> <first class="int"> <v>9</v> </first> <second class="LexT"> <v>this is item #9</v> </second> </pair> </s11n_node> |
From: stephan b. <sg...@us...> - 2004-12-26 07:53:29
|
Update of /cvsroot/pclasses/pclasses2/src/s11n/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2805/src/s11n/io Modified Files: data_node_io.h Log Message: Mass commit: fixes vis-a-vis node traits. Made s11n_node's API mostly private, which turned up lots of long-standing code which was not using traits. Index: data_node_io.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/io/data_node_io.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- data_node_io.h 26 Dec 2004 04:04:32 -0000 1.1 +++ data_node_io.h 26 Dec 2004 07:53:19 -0000 1.2 @@ -94,7 +94,9 @@ { this->magic_cookie( "WARNING: magic_cookie() not set!" ); // ^^^ subclasses must do this. - this->metadata().name( "serializer_metadata" ); + typedef ::P::s11n::node_traits<node_type> NTR; + NTR::name( this->metadata(), "serializer_metadata" ); + // this->metadata().name( "serializer_metadata" ); }; virtual ~data_node_serializer(){}; |
From: stephan b. <sg...@us...> - 2004-12-26 07:53:29
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2805/src/s11n Modified Files: Makefile.toc data_node_algo.h data_node_functor.h list.h map.h s11n_node.h Log Message: Mass commit: fixes vis-a-vis node traits. Made s11n_node's API mostly private, which turned up lots of long-standing code which was not using traits. Index: s11n_node.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/s11n_node.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- s11n_node.h 26 Dec 2004 00:55:20 -0000 1.2 +++ s11n_node.h 26 Dec 2004 07:53:19 -0000 1.3 @@ -12,7 +12,7 @@ #include <vector> #include "str.h" // to/from() string - +#include "traits.h" // node_traits namespace P { namespace s11n { /** @@ -22,7 +22,7 @@ class s11n_node { public: - + friend class node_traits<s11n_node>; /** The map type this object uses to store properties. */ @@ -117,6 +117,18 @@ */ s11n_node( const s11n_node & rhs ); + + /** + Returns this node's name, as set via name(string). + + Only in the public API because name() is used by + some algos which don't know about node_traits. + */ + std::string name() const; + + + private: + /** Returns a list of the s11n_node children of this object. The caller should not delete any pointers @@ -190,10 +202,6 @@ */ void name( const std::string & n ); - /** - Returns this node's name, as set via name(string). - */ - std::string name() const; /** Index: map.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/map.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- map.h 26 Dec 2004 01:26:15 -0000 1.3 +++ map.h 26 Dec 2004 07:53:19 -0000 1.4 @@ -435,15 +435,14 @@ NodeType * ch = 0; for( ; e != b; ++b ) { - ch = new NodeType; - ch->name( "pair" ); + ch = TR::create( "pair" ); if( ! serialize_pair( *ch, *b ) ) { delete( ch ); CERR << "serialize_map: child failed serialize.\n"; return false; } - dest.children().push_back( ch ); + TR::children(dest).push_back( ch ); } return true; } @@ -457,14 +456,14 @@ const std::string & subnodename, const MapType & src ) { - NodeType * ch = new NodeType; - ch->name( subnodename ); + typedef node_traits<NodeType> TR; + NodeType * ch = TR::create( subnodename ); if( ! serialize_map<NodeType,MapType>( *ch, src ) ) { delete( ch ); return false; } - dest.children().push_back( ch ); + TR::children(dest).push_back( ch ); return true; } @@ -492,6 +491,7 @@ template <typename NodeType, typename MapType> bool deserialize_map( const NodeType & src, MapType & dest ) { + typedef node_traits<NodeType> TR; typedef typename NodeType::child_list_type::const_iterator CIT; //typedef typename SerializableType::value_type VT; // ^^^ no, because VT::first_type is const! @@ -500,7 +500,7 @@ typedef typename MapType::mapped_type VType; typedef std::pair< KType, VType > PairType; PairType pair; - CIT b = src.children().begin(), e = src.children().end(); + CIT b = TR::children(src).begin(), e = TR::children(src).end(); const NodeType *ch = 0; for( ; e != b ; ++b ) { Index: data_node_algo.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/data_node_algo.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- data_node_algo.h 26 Dec 2004 00:55:20 -0000 1.2 +++ data_node_algo.h 26 Dec 2004 07:53:19 -0000 1.3 @@ -108,12 +108,13 @@ const NodeT * find_child_by_name( const NodeT & parent, const std::string & name ) { + typedef node_traits<NodeT> TR; typedef typename NodeT::child_list_type::const_iterator CIT; - CIT it = std::find_if( parent.children().begin(), - parent.children().end(), - s11n::same_name<NodeT>( name ) + CIT it = std::find_if( TR::children(parent).begin(), + TR::children(parent).end(), + same_name<NodeT>( name ) ); - return (parent.children().end() == it) ? 0 : *it; + return (TR::children(parent).end() == it) ? 0 : *it; } /** @@ -131,12 +132,13 @@ NodeT * find_child_by_name( NodeT & parent, const std::string & name ) { + typedef node_traits<NodeT> TR; typedef typename NodeT::child_list_type::iterator IT; - IT it = std::find_if( parent.children().begin(), - parent.children().end(), - s11n::same_name<NodeT>( name ) + IT it = std::find_if( TR::children(parent).begin(), + TR::children(parent).end(), + same_name<NodeT>( name ) ); - return (parent.children().end() == it) ? 0 : *it; + return (TR::children(parent).end() == it) ? 0 : *it; } Index: Makefile.toc =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/Makefile.toc,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Makefile.toc 26 Dec 2004 04:09:28 -0000 1.5 +++ Makefile.toc 26 Dec 2004 07:53:19 -0000 1.6 @@ -4,10 +4,12 @@ SUBDIRS = io + SOURCES = \ data_node.cpp \ s11n.cpp \ s11n_node.cpp \ + SIO.cpp \ string_util.cpp HEADERS = $(wildcard *.h) @@ -17,6 +19,7 @@ data_node \ s11n \ s11n_node \ + SIO \ string_util \ ) Index: list.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/list.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- list.h 26 Dec 2004 01:26:15 -0000 1.3 +++ list.h 26 Dec 2004 07:53:19 -0000 1.4 @@ -82,7 +82,7 @@ NodeType * ch = new NodeType; if( ! serialize( *ch, *it ) ) { - CERR << "serialize_list: a child failed to serialize: " << ch->name() << " @ " << std::hex << ch << "\n"; + CERR << "serialize_list: a child failed to serialize: " << TR::name(*ch) << " @ " << std::hex << ch << "\n"; s11n::dump_node_debug( *ch, std::cerr ); delete( ch ); return false; @@ -102,6 +102,7 @@ const std::string & subnodename, const SerType & src ) { + typedef node_traits<NodeType> TR; NodeType * ch = new NodeType; ch->name( subnodename ); if( ! serialize_list<NodeType,SerType>( *ch, src ) ) @@ -109,7 +110,7 @@ delete( ch ); return false; } - dest.children().push_back( ch ); + TRchildren(dest).push_back( ch ); return true; } @@ -153,7 +154,7 @@ std::string implclass; static const char * errprefix = "deserialize_list(node,list) "; #define ERRPRE if(0) CERR << errprefix << "srcnode="<<std::dec<<&src << ": " - ERRPRE <<"starting... dest list size="<<dest.size()<<". src child count="<<src.children().size()<<"\n"; + ERRPRE <<"starting... dest list size="<<dest.size()<<". src child count="<<TR::children(src).size()<<"\n"; int bogocount = 0; for( ; et != it; ++it ) { @@ -179,7 +180,7 @@ if( ! deserialize( *nch, ser ) ) { CERR << "deserialize_list(): deser of a child failed!\n"; - CERR << "name="<< nch->name()<< ". implclass="<< implclass<<" @ " << std::hex<<nch <<"\n"; + CERR << "name="<< TR::name(*nch)<< ". implclass="<< implclass<<" @ " << std::hex<<nch <<"\n"; s11n::dump_node_debug( *nch, std::cerr ); ACVT::release( ser ); return false; Index: data_node_functor.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/data_node_functor.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- data_node_functor.h 26 Dec 2004 00:55:20 -0000 1.2 +++ data_node_functor.h 26 Dec 2004 07:53:19 -0000 1.3 @@ -44,7 +44,7 @@ void dump_node_debug( const NodeType & n, std::ostream & os ) { typedef node_traits<NodeType> NTR; - os << "node dump: ["<<n.name()<<"]["<<NTR::class_name(n)<<"]@"<<std::hex<<&n<<"\n"; + os << "node dump: ["<<NTR::name(n)<<"]["<<NTR::class_name(n)<<"]@"<<std::hex<<&n<<"\n"; typedef typename NTR::const_iterator PT; PT b = NTR::begin(n), e = NTR::end(n); os << "==================== properties:\n"; |
From: stephan b. <sg...@us...> - 2004-12-26 07:52:16
|
Update of /cvsroot/pclasses/pclasses2/src/s11n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2695/src/s11n Added Files: SIO.cpp SIO.h Log Message: egg --- NEW FILE: SIO.h --- #ifndef p_SIO_H_INCLUDED #define p_SIO_H_INCLUDED 1 //////////////////////////////////////////////////////////////////////// // SIO.h: // Author: stephan beal <st...@s1...> // License: Public Domain // // This header is intended to provide the standard P::s11n interface, // in particular the client-side interface. // //////////////////////////////////////////////////////////////////////// #include <string> #include <pclasses/Plugin/Plugin.h> #include <pclasses/s11n/s11n.h> #include <pclasses/s11n/io/serializers.h> namespace P { /** The SIO namespace encapsulates the entire client-side s11n-related API. Clients using s11n proxies and implementing serialization code may need to use the classes in the P::s11n as well. */ namespace SIO { /** The concrete "data node" type used by serialization operations. Node that it is considered poor form to use an S11nNode's API directly, as it's type and interface may change. The only guaranty the S11nNode's API guarantees is that NodeTraits::funcs(S11nNode &...) operations will work as expected. More clearly: use NodeTraits to manipulate and query nodes, not the node API directly. In fact s11n_node's useful API is all private, so you CAN'T touch it without going through NodeTraits. :) Gotcha! */ typedef ::P::s11n::s11n_node S11nNode; /** NodeTraits are used to get information from S11nNode. */ typedef ::P::s11n::node_traits<S11nNode> NodeTraits; /** The parent type of Serializers supported by this interface. */ typedef ::P::s11n::io::data_node_serializer<S11nNode> SerializerInterface; /** A plugin manager type for loading SerializerInterface objects. */ typedef ::P::Plugin::PluginManager<SerializerInterface> SerializerPluginManager; /** See ::P::s11n::serialize(). */ template <typename SerializableT> bool serialize( S11nNode & dest, const SerializableT & src ) { return ::P::s11n::serialize<S11nNode,SerializableT>( dest, src ); } /** See ::P::s11n::derialize(). */ template <typename SerializableType> SerializableType * deserialize( const S11nNode & src ) { return ::P::s11n::deserialize<S11nNode,SerializableType>( src ); } /** See ::P::s11n::deserialize(). */ template <typename DeserializableT> bool deserialize( const S11nNode & src, DeserializableT & target ) { return ::P::s11n::deserialize<S11nNode,DeserializableT>( src, target ); } /** See ::P::s11n::serialize_subnode(). */ template <typename SerializableType> bool serializeSubnode( S11nNode & dest, const std::string & subnodename, const SerializableType & src ) { return ::P::s11n::serialize_subnode<S11nNode,SerializableType>( dest, subnodename, src ); } /** See ::P::s11n::deserialize_subnode(). */ template <typename DeserializableT> DeserializableT * deserializeSubnode( const S11nNode & src, const std::string & subnodename ) { return ::P::s11n::deserialize_subnode<S11nNode,DeserializableT>( src, subnodename ); } /** See ::P::s11n::deserialize_subnode(). */ template <typename DeserializableT> bool deserializeSubnode( const S11nNode & src, const std::string & subnodename, DeserializableT & target ) { return ::P::s11n::deserialize_subnode<S11nNode,DeserializableT>( src, subnodename, target ); } /** See ::P::s11n::io::load_node(). */ S11nNode * loadNode( std::istream & src ); /** See ::P::s11n::io::load_node(src). */ S11nNode * loadNode( const std::string & src ); /** See ::P::s11n::io::load_serializable(). */ template <typename SerializableType> SerializableType * loadSerializable( std::istream & src ) { return ::P::s11n::io::load_serializable<S11nNode,SerializableType>( src ); } } // namespace SIO } // namespace P #endif // p_SIO_H_INCLUDED --- NEW FILE: SIO.cpp --- #include "SIO.h" namespace P { /** */ namespace SIO { S11nNode * loadNode( std::istream & src ) { return ::P::s11n::io::load_node<S11nNode>( src ); } S11nNode * loadNode( const std::string & src ) { return ::P::s11n::io::load_node<S11nNode>( src ); } }} // P::SIO |
From: stephan b. <sg...@us...> - 2004-12-26 06:09:20
|
Update of /cvsroot/pclasses/pclasses2/src/s11n/io In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18900/src/s11n/io Modified Files: serializers.h Log Message: Removed unnecessary serializer_plugin_manager. Now uses Factory's aliasing support to map the cookie and short-form alias. Index: serializers.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/s11n/io/serializers.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- serializers.h 26 Dec 2004 04:04:32 -0000 1.1 +++ serializers.h 26 Dec 2004 06:09:11 -0000 1.2 @@ -19,55 +19,6 @@ namespace s11n { namespace io { - template <typename NodeType> - class serializer_plugin_manager : - public ::P::Plugin::PluginManager< data_node_serializer< NodeType > > - { - public: - serializer_plugin_manager(){} - virtual ~serializer_plugin_manager(){} - - }; - } // P::s11n::io - } // P::s11n - - namespace Hook - { - /** - This hook will cause calls to Factory::instance() to return - a serializer_plugin_manager instance in disguise. - */ - template < typename NodeT > - struct FactoryInstanceHook< ::P::Factory< ::P::s11n::io::data_node_serializer<NodeT>, ::P::Sharing::FactoryContext, std::string > > - { - typedef ::P::Factory< ::P::s11n::io::data_node_serializer<NodeT>, ::P::Sharing::FactoryContext, std::string > FactoryType; - typedef ::P::s11n::io::serializer_plugin_manager< NodeT > RealFactoryType; - typedef FactoryInstanceHook<FactoryType> ThisType; - - /** - Initializes the passed-in factory. i.e., it does - nothing. It's here for demonstration purposes. - */ - void operator()( FactoryType & ) throw() - { - CERR << "Initializing a PluginManager instance() we hacked in via FactoryInstanceHook!\n"; - } - - /** - The default implementation returns a shared Factory object. - THIS type's operator() will be called on the factory immediately - after creating the factory. - */ - static FactoryType & instance() - { - typedef ::P::Phoenix<RealFactoryType, ::P::Sharing::FactoryContext, ThisType > PHX; - return PHX::instance(); - } - }; - - } // P::Hook - - namespace s11n { namespace io { /** Populates target list with the names of registered @@ -164,27 +115,21 @@ // CERR << "FIXME: register_serializer() not yet fixed to work with P::Factory.\n"; // return; -#define PM pluginManager< BaseST >() +#define PM ::P::Plugin::pluginManager< BaseST >() #define FACCREATE ::P::Hook::FactoryCreateHook<BaseST,ST>::create - using namespace ::P::Plugin; static bool inited = false; if( ! inited && (inited=true) ) { - PM.searchPath().addExtension( "_serializer.so" ); - PM.searchPath().addExtension( "_serializer.dll" ); - // cllite::class_path().add_extension( "_serializer.so" ); - // cllite::class_path().add_extension( "_serializer.dll" ); + std::string ext = std::string("_serializer.") + ::P::System::SharedLib::extension(); + PM.searchPath().addExtension( ext ); } CERR << "register_serializer(" << classname << ","<<alias<<")\n"; PM.registerFactory( classname, FACCREATE ); - PM.registerFactory( alias, FACCREATE ); - PM.registerFactory( ST().magic_cookie(), FACCREATE ); + PM.alias( alias, classname ); + PM.alias( ST().magic_cookie(), classname ); #undef PM #undef FACCREATE -// ::P::s11n::cl::classloader_register< BaseST, ST >( classname ); -// ::P::s11n::cl::classloader< BaseST >().alias( alias, classname ); -// ::P::s11n::cl::classloader< BaseST >().alias( ST().magic_cookie(), classname ); } /** @@ -197,7 +142,6 @@ s11n::io::data_node_serializer<NodeT> * create_serializer( const std::string & classname ) { - // typedef serializer_plugin_manager<NodeT> SPM; try { CERR << "create_serializer("<<classname<<") trying plugin manager...\n"; |