From: stephan b. <st...@s1...> - 2004-12-18 16:06:53
|
Yo: With only about an hour's work i've put together a proof of concept for deserializing from http URLs using pclasses' HttpClient. i can't yet serialize over them, but that shouldn't be especially hard to achieve via a PHP proxy. Attached: ps11n.hpp: the entire implementation. Essentially just a wrapper around s11nlite, plus the Serializer implementation. test.cpp: demo TODOs: a) Add serialize() support. It's partially implemented, but isn't useful over http yet. It will work by POSTing content written by one of the XML Serializers. What the remote side does with it is undefined, though - depends on the proxy script running on the http server. The obvious choice is simply to dump the node into a db in one big text field. b) Genericize the Serializer dispatcher to recognize URLs. i'll see if i can work with in to s11n::io without breaking anything not requiring an explicit dep on pclasses. (Shouldn't be a big problem.) c) Implement the same for P::FtpClient. d) A couple other internal tweaks. It's is now a one-liner to deser an object over http: P::s11n::node_type * node = P::s11n::load_node( filename_or_http_url ); Reminder: we're still right at home in C++. :) :) :) The input *format* is irrelevant: any supported by s11nlite will work. Assuming node != 0, we can deserialize it to it's "complete" type with: MyType * obj = P::s11n::deserialize<MyType>( *node ); Or: MyType obj; bool worked = P::s11n::deserialize<MyType>( *node, obj ); delete node; @pclasses: i've got a couple patches to commit to IODevice and IORequest_get. May i have CVS access? (SF=sgbeal) More patches are certainly in the plan... Demo output: stephan@owl:~/cvs/s11n.net/ps11n/src> m && ./test http://s11n/P.s11n test.cpp:19 : test_ps11n() test.cpp:35 : node ? = 0x806e0d8 (s11n::parens) somenode=(NoClass (a \(\)\\b) (foo bar) (long this is a long property) fred=(FredClass (key value)) wilma=(WilmaClass (the lovely wife)) betty=(BettyClass (value the apple of Barney's eye)) deep=(Foo deeper=(Foo (how_deep really deep!) and_deeper=(Ouch) ) ) ) -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |