[Qt-interest] How to deal with pointers for a QDataStream?
Thiago Macieira
thiago at kde.org
Mon Apr 19 15:12:38 CEST 2010
Em Segunda-feira 19 Abril 2010, às 14:41:45, Oliver Heins escreveu:
> I have a data structure which holds some pointers:
>
> class Token
> {
> public:
> enum Type { Space, Paragraph, Kern, Char, Format, Note, End };
> enum SubType { Bold, Italic,
> Header1, Header2, Header3, Header4, Header5, Header6,
> Itemize, Enumerate, Description, Item,
> Note1, Note2, Note3, Note4, Note5 };
>
> [...]
>
> Type type;
> SubType subType;
> QChar chr;
> Token *parent;
> QLinkedList<Token *> children;
> Token *partner;
> };
>
> As saving pointers directly to a QDataStream will obviously not work,
> what would be a good strategy to save the structure?
Save pointed-to children, then restore it later by creating objects.
I don't think it makes sense to save the parent. Instead, the parent should
set itself in its children when loading them.
As for the partners, it's your structure. Probably the parent should save the
partnership relations after the children stream and then set them after
loading them.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100419/88be6f98/attachment.bin
More information about the Qt-interest-old
mailing list