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 » serialization
serialization [message #2144] Sun, 02 April 2006 13:18 Go to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member

In the serialize reference example, this code appears to cleverly handle both the saving and restoring - is that correct?

	void Serialize(Stream& s)
	{
		s % q % text % data;
	}


Suppose you have 100 items to save/restore - is there any reason not to chain all together in one long expression?

Comparing with .ini file, suppose some objects get removed - is there any alternative to having "dummy" objects of the correct type so that you can still read in data that was saved with now obsolete items?

Graeme
Re: serialization [message #2161 is a reply to message #2144] Sun, 02 April 2006 17:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
gprentice wrote on Sun, 02 April 2006 07:18


In the serialize reference example, this code appears to cleverly handle both the saving and restoring - is that correct?

	void Serialize(Stream& s)
	{
		s % q % text % data;
	}




Yes.

Quote:


Suppose you have 100 items to save/restore - is there any reason not to chain all together in one long expression?



Usually not (see e.g. ide/idewin.cpp line 41 Smile

Quote:


Comparing with .ini file, suppose some objects get removed - is there any alternative to having "dummy" objects of the correct type so that you can still read in data that was saved with now obsolete items?



Well, not really. Binary serialization has its limitations. In fact, I would not recommend it for "robust" data storage, e.g. for storing documents. We are using it for e.g. configuration files, passing data over network or backuping data for implementation reasons (e.g. Cancel in dialogs can be implemented using serialization - before stating dialog, its content is serialized into String, Cancel serializes it back).

Mirek
Re: serialization [message #2284 is a reply to message #2161] Wed, 05 April 2006 19:28 Go to previous messageGo to next message
barpas is currently offline  barpas
Messages: 13
Registered: March 2006
Location: Poland
Promising Member
halo everybody Smile

i have problem with serialization - some time ago i writen application in upp where i use serialization mechanism to save options & parameters (there is a lot of serialize functions) - now i have problem user told that anybody can edit that files and read (change) information abaut program
so i need to code it - is there simple metod to do it fast (i have litle bit of time)

[Updated on: Wed, 05 April 2006 20:22]

Report message to a moderator

Re: serialization [message #2285 is a reply to message #2284] Wed, 05 April 2006 20:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
barpas wrote on Wed, 05 April 2006 13:28

halo everybody Smile

i have problem with serialization - some time ago i writen application in upp where i use serialization mechanism to save options & parameters (there is a lot of serialize functions) - now i have problem user told that anybody can edit that files and read (change) information abaut program
so i need to code it - is there simple metod to do it fast (i have litle bit of time)


Interesting...

Well, the most simple approach that comes to mind is to serialize using StringStream to String, then encrypt and save (and reverse for load).

Mirek
Re: serialization [message #14926 is a reply to message #2161] Thu, 20 March 2008 16:34 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Hi,

What would you recommend for robust data storage please?

At present I am thinking in terms of oversizing the storage for all my classes i.e. setting a size for each class for it to grow into.

Is there a way to search for specific "key" values in the stream which might then act as delimiters between classes?

I am getting close to launch and people are testing and already asking for backwards compatibility which I know from experience just leads to more and more complication.

If anyone has a solution, I would be extremely eager to hear it Smile

Nick
Re: serialization [message #14927 is a reply to message #14926] Thu, 20 March 2008 17:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nixnixnix wrote on Thu, 20 March 2008 11:34

Hi,

What would you recommend for robust data storage please?



Depends. In theide, some text format with C lexical basics is prefered (e.g. for .upp files).

Maybe XML.

Quote:


Is there a way to search for specific "key" values in the stream which might then act as delimiters between classes?



No.

Quote:


I am getting close to launch and people are testing and already asking for backwards compatibility which I know from experience just leads to more and more complication.



Hehe, I know that pretty well Wink

Mirek
Re: serialization [message #14932 is a reply to message #14927] Thu, 20 March 2008 18:42 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
Quote:

If anyone has a solution, I would be extremely eager to hear it

I'm using per class versioning in serialize methods and I have no problems with it at all.
I have to increase version number and put some "if"s into my code after changing classes.
Re: serialization [message #14939 is a reply to message #14932] Thu, 20 March 2008 21:54 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Ok thanks. This is what I was using before but if thats the standard method then its all good.

XML is not really suitable because even in binary my saved documents can be easily 100s of MB and more. Also lots of my classes contain Arrays so they don't have fixed sizes.

Ach well I just need to "suck it up" I guess Smile

Cheers,

Nick
Re: serialization [message #14941 is a reply to message #14939] Thu, 20 March 2008 22:23 Go to previous messageGo to next message
chickenk is currently offline  chickenk
Messages: 169
Registered: May 2007
Location: Grenoble, France
Experienced Member
What about YAML? (http://www.yaml.org)

It can embed base64 encoded binary chunks...

I believe a C implementation is present here: http://pyyaml.org/wiki/LibYAML

I'm quite fond of YAML when talking about serialization tasks, but maybe it's not suited for you... If I had more time, I would consider making a C++ wrapper around libYAML using U++ technology.

If anyone interested... Wink

Lionel
Re: serialization [message #16804 is a reply to message #14941] Sat, 12 July 2008 11:43 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

chickenk wrote on Thu, 20 March 2008 23:23

What about YAML? (http://www.yaml.org)

It can embed base64 encoded binary chunks...

I believe a C implementation is present here: http://pyyaml.org/wiki/LibYAML

I'm quite fond of YAML when talking about serialization tasks, but maybe it's not suited for you... If I had more time, I would consider making a C++ wrapper around libYAML using U++ technology.

If anyone interested... Wink

Lionel


Good idea!
Re: serialization [message #16819 is a reply to message #14941] Mon, 14 July 2008 16:26 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
chickenk wrote on Thu, 20 March 2008 17:23

What about YAML? (http://www.yaml.org)

It can embed base64 encoded binary chunks...

I believe a C implementation is present here: http://pyyaml.org/wiki/LibYAML

I'm quite fond of YAML when talking about serialization tasks, but maybe it's not suited for you... If I had more time, I would consider making a C++ wrapper around libYAML using U++ technology.

If anyone interested... Wink

Lionel

Yes, definitely interested!
Re: serialization [message #53971 is a reply to message #16819] Mon, 18 May 2020 20:09 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Does anybody has used a YAML reader/writer?

Best regards
IƱaki
Previous Topic: c++ 17 support
Next Topic: strange behaviour of Vector serialization
Goto Forum:
  


Current Time: Fri Mar 29 02:30:46 CET 2024

Total time taken to generate the page: 0.01429 seconds