From: stephan b. <st...@s1...> - 2004-12-26 14:23:25
|
"Vanilla s11n" can do this, too, but that's not important... the important part is that P can do it now, too... list<string> ls; ... populate ls ... list<P::Util::LexT> lt; if( ! P::SIO::s11n_cast( ls, lt ) ) { ... error ...} We can use s11n to "cast" between any "semantically compatible" Serializables. That is, as long as they use compatible algorithms for structuring their data internally, they can be cast this way. Also, many algos behave the same for container<T> and container<T*>, so this also works as expected: list<int> il; list<double *> dl; ... populate il ... s11n_cast( il, dl ); dl is now populated with pointers pointing at values which equal those from il. Similarly, we can use different types of "similar" containers: vector<MyType *> v; ... populate it ... list<MyType *> l; s11n_cast( v, l ); l now contains copies (created via s11n) of the objects in v. This is not an efficient way to copy objects, but it's very generic. Note that this does no stream i/o of any sort - this performs only container and factory operations. Final tip: s11n_cast is an easy way to test your de/ser algos - if they work with this function they'll work everywhere. -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |