Home » U++ Library support » U++ Core » Value and Serialize
Value and Serialize [message #8849] |
Tue, 03 April 2007 17:33 |
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 #8890 is a reply to message #8868] |
Thu, 05 April 2007 16:12 |
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.
|
|
|
|
Goto Forum:
Current Time: Fri Mar 29 11:41:46 CET 2024
Total time taken to generate the page: 0.02087 seconds
|