[Qt-interest] How to serialize objects
Arnold Krille
arnold at arnoldarts.de
Sun Mar 22 23:13:44 CET 2009
On Sunday 22 March 2009 22:32:12 Raja Sekharan wrote:
> I've searched everywhere but I am not able to find an answer to this, how
> do you serialize an object in Qt C++?
By hand. Plain C++ doesn't (at least to my knowledge) contain a way of
serialization. If you where really stupid, you read bytes from the objects
adress to objects address + sizeof(object). But that would give you lots of
runtime-specific pointers and not the child data referenced by pointers. So
don't even try to write it in code.
I don't know why you want to serialize, but you have to add the functions to
store and restore yourself. Depending on what you want, you can add >>- and
<<-operators or some toXml()/fromXml() functions or something like that...
Have fun,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090322/69ab2141/attachment.bin
More information about the Qt-interest-old
mailing list