From: stephan b. <st...@s1...> - 2004-12-26 09:12:37
|
Yo! You didn't think i'd gone to bed yet, did you? ;) Unhappy with all the template work necessary for working with the s11n core, i've wrapped it up in a small, easily-understand client-side interface: <pclasses/s11n/SIO.h> declares namespace P::SIO, which encapsulates the majority of the client-side s11n API. It's functions and typedefs follow PNamingConventions, not s11n_naming_conventions. This should allow a decent compromise for the non-conforming naming conventions in s11n's code. To save any Serializable object in P is now trivial: #include <pclasses/s11n/SIO.h> ... using P::SIO; save( obj, string|stream ); Saves using the SIO::serializerClass() Serializer, which is set via serializerClass(classname). Default is of course expat, because that's all we have at the moment. Loading has 3 options: #1: MyType * t = 0; S11nNode * node = loadNode( file|stream ); if( node ) { t = deserialize<MyType>( *node ); delete node; } Reminder: you don't need to know the input format: any loaded/loadable format will do. #2: MyType t; S11nNode * node = loadNode( file|stream ); if( node ) { bool worked = deserialize<MyType>( *node, t ); delete node; } #3: MyType * t = loadSerializable<MyType>( file|stream ); Once the IOManager support is ready this will also support protocol-based dispatching. Also, as the IODev/IOStream support gets all ported in i will add overloads to de/serialize from/to those types. Any comments on the interface would be helpful! src/s11n/SIO.h. See ya! -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |