This will work: string enc = encode_value(obj, master->Codec());
You need to implement the _encode/_decode methods for the object, for example using a generic implementation:
string _encode() { mapping enc = mkmapping(indices(this), values(this)); foreach(enc; string key; mixed value) { if(functionp(value)) { m_delete(enc, key); } } return encode_value( enc, master()->Codec() ); }
void _decode(string data) { mapping decoded = decode_value(data, master()->Codec()); foreach(decoded; string key; mixed value) { catch { this[key] = value; }; } }
There is no way to make it automatically save public variables to the best of my knowledge (unless you make your own Codec()), but I think that the above solution is easy enough.
That said, if it by default did do what the above does, that wouldn't be bad thing.
/ David Hedbor
Previous text:
2003-02-28 00:55: Subject: Save_Object
Coming from a LPC compiler background, is there anything within PIKE that would lean towards the save_object 'kfun' they have implemented in several compilers?
What I am looking for is a function to take all the variables of an object and save them to a file. Vice-Versa there would be a function to load all those variables back into a cloned object.
Anything or am I blowing smoke?
/ Brevbäraren