hi all,

I have a little question about serialization, shown by the following example:
Qt Code:
  1. class MyClass
  2. {
  3. public:
  4. MyClass(){}
  5. ~MyClass(){}
  6. void save(QDataStream &out){
  7. out << (qint32)_id;
  8. out << (qint32)_sizeX;
  9. out << (qint32)_sizeY;
  10. out << (qint32)_sizeZ;
  11. }
  12. void load_Version1(QDataStream &in){
  13. qint32 id, sizeX, sizeY, sizeZ;
  14. in >> id;
  15. in >> sizeX;
  16. in >> sizeY;
  17. in >> sizeZ;
  18. _id = id;
  19. _sizeX = sizeX;
  20. _sizeY = sizeY;
  21. _sizeZ = sizeZ;
  22. }
  23. void load_Version2(QDataStream &in){
  24. in >> _id;
  25. in >> _sizeX;
  26. in >> _sizeY;
  27. in >> _sizeZ;
  28. }
  29. private:
  30. int _id;
  31. int _sizeX;
  32. int _sizeY;
  33. int _sizeZ;
  34. };
To copy to clipboard, switch view to plain text mode 

using load_Version1 to load my data should be safe in terms of data integrity, afaik

doing things like in load_Version1 is a little longish, imo, especially when the list of various types of private members grows

so, would it be ok & safe to use load_Version2 to shorten things???
personally I don't think it is safe...

if load_Version2 isn't ok, as i assume, is there another possibility to shorten the amount of code?
would something like
Qt Code:
  1. in >> (qint32)_id;
To copy to clipboard, switch view to plain text mode 
work?

I hope you get, what I talk about

greetz
darksaga