|
From: stephan b. <st...@s1...> - 2004-12-26 04:43:20
|
Saving over XML works now:
stephan@owl:~/cvs/pclasses2/test> m && ./s11nTest
<snip>
s11nTest.cpp:117 : Loaded serializer 'expat'. :)
s11nTest.cpp:131 : Adding [this is item #0]
<snip>
s11nTest.cpp:131 : Adding [this is item #9]
s11nTest.cpp:138 : Containers...
<!DOCTYPE P::s11n::io::expat_serializer>
<s11n_node class="list">
<s11n_node class="LexT">
<v>this is item #0</v>
</s11n_node>
<snip>
<s11n_node class="LexT">
<v>this is item #9</v>
</s11n_node>
</s11n_node>
<!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>
<snip>
<pair class="pair">
<first class="int">
<v>9</v>
</first>
<second class="LexT">
<v>this is item #9</v>
</second>
</pair>
</s11n_node>
#define SERIALIZE(Node,SType,SObj) ::P::s11n::serialize< NODE_TYPE
>( Node, SObj )
#define DESERIALIZE(Node,SType) ::P::s11n::deserialize< NODE_TYPE, SType
>( Node )
#define TRAITS ::P::s11n::node_traits< NODE_TYPE >
The code to get at the Serializer is something like:
// get the base Serializer interface type:
typedef ::P::s11n::io::data_node_serializer<::P::s11n::s11n_node>
SerializerBase; // ugly, eh? i'll simplify that later.
// load it via the plugin manager:
SerializerBase * ser =
::P::Plugin::pluginManager<SerializerBase>().create( "expat" );
Things to note:
- P module deps: Core, System, Plugin, Util
- The serializers are loaded by name, just like other classes. DLL
support "should" work for them just like it does for all PluginManaged
types.
- The expat serializer is linked in if configure finds expat, otherwise
not. Since this is the only Serializer we will have until someone
implements more non-lex-based ones, you essentially NEED expat at the
moment to use ps11n stream/file i/o. See
src/s11n/io/expat/expat_serializer.* for ideas on how to implement a
Serializer for your own format.
- The interface will be refactored to make it more P-friendly, but this
will take time. The huge number of typedefs and template args will also
be reduced by introducing another interface layer (a-la s11nlite).
- Dynamic selection of Serializers when loading from streams "might"
work, and might not - it is untested so far (if it's broken, it's a
factory-related issue and will be easy to fix).
- We should decide on what serializable interface Serializable types
will have. We don't NEED to decide this, because s11n can adapt to
near-arbitrary interfaces, but we should, for consistency. There is
also a decision to be made about which "node type" to support by
default, but i need to explain that in detail before we can decide that
(and i'm too tired to do that right now). i'll go into these details
more later, because they are rather more complex than they should be
("Quall der Wahl" is the real problem).
- Now that s11n is in the P tree, and free of the "platform-sensitive"
code, my baby (s11n) is now portable :). It also means our questions
about how best to integrate s11n support are answered.
--
----- st...@s1... http://s11n.net
"...pleasure is a grace and is not obedient to the commands
of the will." -- Alan W. Watts
|