View previous topic :: View next topic |
Author |
Message |
jaysistar
Joined: 30 Jun 2010 Posts: 31
|
Posted: Sat Aug 07, 2010 7:09 pm Post subject: |
|
|
doob wrote: | About the optional throwing, could you put that as a enhancement request in the ticket system so I don't forget about it. | Done. I'm duplicating the ticket opening text here:
As the Archive interface is now, the archive has only the option of throwing an Exception when given a name of a variable to deserialize that doesn't exist in the archive. This has the adverse affect of stopping deserialization, which may not be necessary.
If a variable is not found in an archive, it should tell the deserializer that it didn't find it, but it shouldn't throw. The missing variable should be initialized to its default value _by the deserializer_ not the Archive class (this is just to remove duplicating the code that does this action in all of Archive classes).
This can be done by a return value or an out parameter to each "deserialize type" function in the archive. The application must also be able to pass a parameter telling the deserializer if it wants an exception to be thrown or the missing variables to be assigned default.
Note that the Archive doesn't really ever have to throw an exception because the throwing code could then be put into the serializer (read "reused by all new Archive classes"), while the Archive could just indicate whether the variable was found.
Last edited by jaysistar on Sat Aug 07, 2010 7:19 pm; edited 1 time in total |
|
Back to top |
|
|
jaysistar
Joined: 30 Jun 2010 Posts: 31
|
Posted: Sat Aug 07, 2010 7:19 pm Post subject: |
|
|
doob wrote: | I didn't understand much of the metadata in JSON, it sounds complicated. | Don't worry about it; it's just implementation details of Arvo's binary file format. The point was that the metadata was included. The metadata is also included in your XMLArchive class as well: In your XMLArchive each variable includes its name and type as well as its value, and it doesn't rely on an outside source (like a definition file) to know what value is meant for what variable. Arvo just happens to separate name and type metadata (in JSON) from value data (in binary). doob wrote: | About the opEquals, that is just to overwrite the default comparison to show that two objects are considered equal, i.e. that they contain the same data. opEquals is not necessary for making the serializer work. As default opEquals compare the addresses of two objects and they will not be the same when the serialized object is deserialized. | I know, and that was a great idea: Now you could store the object once, and then store references to that object in other parts of the archive. |
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Thu Aug 12, 2010 3:35 pm Post subject: |
|
|
I've implemented an error callback which is now called instead of throwing an exception. You can set/get the error callback like this:
Code: | serializer.errorCallback = &someMethod; |
There serializer provides two default callbacks, which are set like this:
Code: | serializer.setThrowOnErrorCallback;
serializer.setDoNothingOnErrorCallback; |
The signature of the callback looks like this:
Code: | void delegate (ArchiveExeption, DataType[]); |
|
|
Back to top |
|
|
jaysistar
Joined: 30 Jun 2010 Posts: 31
|
Posted: Fri Aug 13, 2010 1:55 am Post subject: |
|
|
Sounds great! I'll try it out sometime today. |
|
Back to top |
|
|
doob
Joined: 06 Jan 2007 Posts: 367
|
Posted: Fri Aug 13, 2010 2:17 am Post subject: |
|
|
BTW, I think we can end this topic, we are quite far away from the original topic. Please create a new topic if you want to follow up on my answer. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|