wddx class mapping and pretty print

php.internals

Alan Knowles

23 years ago
On one of those - xml is too difficult stints, I started thinking about using wddx as a generic storage system - perhaps thinking about things like MDB's data structure and the ability to load data.. I'm still thinking that it would be nice for wddx_deserialize to accept a stream - hence allowing the processing of huge xml files with minimal memory penalty.. This patch does 2 things. a) a deserialize class mapping - so you can map stored classes into different instantation classes. (usefull when you dont have the original - or just want to map it to something else. - eg use the data with an extended class. class tests_wddxtest { var $somearray = array(1,2,3); var $someassoc = array('dog'=>'cat','mouse'=>'cat'); var $child; function test() { foreach($this->somearray as $i) { $this->child[] = new tests_wddxtest; } } } $x = new tests_wddxtest; $x->test(); class silly { function __wakeup() { // echo "Construct silly"; print_r($this); $this = null; } } $xx = wddx_serialize_value($x, "Testing X"); wddx_map_class(array('gtk_classviewer_tests_wddxtest'=> 'silly')); $yy = wddx_deserialize($xx); var_dump($yy); in this example the wakup call can be used to commit to a database and free the memory :) - useful... b) pretty printing of the xml so that it could be hand edited if need.. - or just semi-human readable.. wddx_set_indent(2); $xx = wddx_serialize_value($x, "Testing X"); echo $xx; Comments Anyone..??? Regards Alan
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com -- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

Dan Kalowsky

23 years ago
On Wednesday, April 23, 2003, at 08:47 AM, Alan Knowles wrote:
> On one of those - xml is too difficult stints, I started thinking > about using wddx as a generic storage system - perhaps thinking about > things like MDB's data structure and the ability to load data.. > > I'm still thinking that it would be nice for wddx_deserialize to > accept a stream - hence allowing the processing of huge xml files with > minimal memory penalty.. > > This patch does 2 things. > > a) a deserialize class mapping - so you can map stored classes into > different instantation classes. (usefull when you dont have the > original - or just want to map it to something else. - eg use the data > with an extended class.
While I can't see myself using this it could be useful... once or twice.
> b) pretty printing of the xml so that it could be hand edited if > need.. - or just semi-human readable..
This I like. Patch didn't look too bad either.
>---------------------------------------------------------------<
Dan Kalowsky "Momma take this badge offa me, http://www.deadmime.org/~dank I can't use it anymore." dank-nom@aps-deadmime.org - "Knockin on Heavens Door", kalowsky@php.net Bob Dylan