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 » Value and Serialize
Value and Serialize [message #8849] Tue, 03 April 2007 17:33 Go to next message
mubeta is currently offline  mubeta
Messages: 77
Registered: October 2006
Member
Hi,

From long time ago, I am using the following VectorMap declaration for managing some data:

//
VectorMap<int, Vector<Value> > MyData;
//

And with the following two functions, I store a lot of this data in some database, using "Serialization":

//
VectorMap<int, Vector<Value> > StringToVector(const String &s) {

StringStream ss(s);
VectorMap<int, Vector<Value> > m;
ss.SetLoading();
m.Serialize(ss);
//LoadFromString(m, s);
return m;
}

String VectorToString(VectorMap<int, Vector<Value> > &v) {

StringStream ss;
//ss.Create();
ss.SetStoring();
v.Serialize(ss);
return ss.GetResult();
//return StoreAsString(v);
}
//

I start to do this and compiling the application with UPP605. I give the application to some peoples, and now they have a lot of user file with data stored inside.
Now I am developing this application with UPP2007, but there is a problem: when I want to read the data stored in the file created in the past, the seralization don't recreate an correct VectorMap; the key values of the VectorMap it's correct, but not the values.

I have scanned manually the string generated with the old application, and I have compared with the string generated with new application. There is one difference: before every value of type "Value" it's preceded by the hex number 08, now in the new string of serialization there is the hex number 09.
With an hex editor I have changed some files, just modifying this number, and after this I am able to read well also the old files.

So, after this test, I think: maybe, in the past, the type "Value" is recognized from the compiler with the number 0x08, now, in the last upp the "Value" type is recognized as number 0x09.
That mean that using a non "native" data type it's dangerous for future compatibility?
And how I can force the compiler to give the same identifier for Upp data type, for each release of Upp?

Thanks
Mauro Bottizzo.
Re: Value and Serialize [message #8850 is a reply to message #8849] Tue, 03 April 2007 17:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
What type do you store into the Value?

Mirek
Re: Value and Serialize [message #8851 is a reply to message #8850] Tue, 03 April 2007 18:27 Go to previous messageGo to next message
mubeta is currently offline  mubeta
Messages: 77
Registered: October 2006
Member
Integer or double for this application.

Mauro.
Re: Value and Serialize [message #8852 is a reply to message #8851] Tue, 03 April 2007 18:33 Go to previous messageGo to next message
mubeta is currently offline  mubeta
Messages: 77
Registered: October 2006
Member
Well, for more detail: the data stored in the "Value" is get from an ArrayCtrl, so, in the serialization, the number is stored as a wstring.

Mauro.
Re: Value and Serialize [message #8868 is a reply to message #8852] Wed, 04 April 2007 09:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mubeta wrote on Tue, 03 April 2007 12:33

Well, for more detail: the data stored in the "Value" is get from an ArrayCtrl, so, in the serialization, the number is stored as a wstring.

Mauro.


Why is it WString? Are you using StringEdit in ArrayCtrl?

Mirek
Re: Value and Serialize [message #8890 is a reply to message #8868] Thu, 05 April 2007 16:12 Go to previous messageGo to next message
mubeta is currently offline  mubeta
Messages: 77
Registered: October 2006
Member
Yes, in fact I use the Vector<Value> for generic array of many data. Can be integer, double, string, etc.

Note that I found an "fast2 solution for my problem:
in Core/Value.cpp file, Value::Serialize(), after

if(s.IsLoading()) {
s / type;

I have added a new line:

if(type == 7) type = 8;

I fix my problem with this, but I don't know very well why in the past the serialization of the "Value" data, is stored as type "VALUE_V" and now, after compiling with irc2, the same type is stored as type "WSTRING_V".

I give a fast look around the Pack() functions in Core/Stream files, but without understand as well how the string of serialization is created, so I don't understant if the different number in the serialization result come from a bug in the "Value" or "Stream" code. Or, otherwise, in some my problems.

Mauro Bottizzo.
Re: Value and Serialize [message #8904 is a reply to message #8890] Fri, 06 April 2007 15:32 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I have just checked - we have not done the mistake of changing those values from 605 up to now.

upp605
const int VOID_V    = 0;

const int INT_V     = 1;
const int DOUBLE_V  = 2;
const int STRING_V  = 3;
const int DATE_V    = 4;
const int TIME_V    = 5;

const int ERROR_V   = 6;

const int VALUE_V   = 7;

const int WSTRING_V = 8;

const int INT64_V  = 10;

const int UNKNOWN_V = (int)0xffffffff;


current:
const int VOID_V    = 0;

const int INT_V     = 1;
const int DOUBLE_V  = 2;
const int STRING_V  = 3;
const int DATE_V    = 4;
const int TIME_V    = 5;

const int ERROR_V   = 6;

const int VALUE_V   = 7;

const int WSTRING_V = 8;

const int INT64_V  = 10;
const int BOOL_V   = 11;

const int UNKNOWN_V = (int)0xffffffff;


There must be something else involved...

Mirek
Previous Topic: StrDbl and decimal separator
Next Topic: !USEMALLOC
Goto Forum:
  


Current Time: Fri Mar 29 11:41:46 CET 2024

Total time taken to generate the page: 0.02087 seconds