Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Optional serialization techniques
Re: Optional serialization techniques [message #31357 is a reply to message #31354] Fri, 25 February 2011 09:46 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
Mindtraveller wrote on Thu, 24 February 2011 10:27

I have a version 1.0 of my application which serializes a VectorMap of some object into the file with StoreToFile. We of course know that if VectorMap object is being changed, the whole de-serialization is failed.
So here is my problem: I develop 1.1 version with objects which are slightly different. And actually what I want is that 1.1 version reads everything from config file ignoring the fact that objects can't be de-serialized completely (I just add more members since 1.0).
I don't want to make object members 'dynamic' (using VectorMap<String,Value> instead of plain members).
Yes, and I really don't want to use XML as speed is the most important in this case. And there is no problem just adding new members since new version (not removing old or replacing them).

Can you please suggest the most effective way of doing it?
Effective means the most quickly working while not rewriting all of U++ serialization code Cool


I usually do:

void Foo::Serialize(Stream& s)
{
   int version = 0;
   s / version;
   s % x % y;
}


... and later I add 'z' to Foo:

void Foo::Serialize(Stream& s)
{
   int version = 1;
   s / version;
   s % x % y;
   if(version >= 1) {
      s % z;
   }
}


That said, it does not solve the problem all the time and generally, I would NOT recommend using binary serialization for permanent storage of important files. It is fine for configs (where if you loose one, it is not that bad) or for transfering data (e.g. over network).

Do not use it for documents Smile

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: do upp have an equivalent of "eval()" in Javascript
Next Topic: Core/Path.cpp: the limitation of GetCurrentDirectory for POSIX
Goto Forum:
  


Current Time: Tue Aug 26 03:46:36 CEST 2025

Total time taken to generate the page: 0.05716 seconds