Results 1 to 16 of 16

Thread: Best way of creating an XML node from an object

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Best way of creating an XML node from an object

    Quote Originally Posted by xtal256 View Post
    Yeah, but i can always add it then. It's just a matter of how much functionality i want right now. If i ever need to make subclasses use their own element name or add attributes, then i can quite simply override the open and close tag methods.
    I guess you're not used to working in a team... Happy you
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Aug 2010
    Posts
    99
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Best way of creating an XML node from an object

    Actually, that is probably what most teams would do
    Besides, this is a personal project i am working on, so i can do whatever i want.
    [Window Detective] - Windows UI spy utility
    [War Thunder]

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Best way of creating an XML node from an object

    Quote Originally Posted by xtal256 View Post
    Actually, that is probably what most teams would do
    Where I work I have to think two steps ahead. Since most of what I do there is meant to be ready for "two weeks ago", before even the code is stable it is already being used by others who sometimes abuse it and changing my API (or just the code logic) without breaking their code is hard, so I have to first think how they might abuse my code tomorrow and then how to make sure them doing that will not break the code I will be writing next week. I'd certainly go for three methods in this case if I had to do it the way you do it. Well... I wouldn't do it like that but that's another thing. I'd probably either subclass QXmlStreamWriter or write a set of overloaded standalone functions for serialization just like QDataStream does. Especially that with XML you can implement inheritance by using subnodes which is much more readable.

    xml Code:
    1. <SubObject>
    2. <parent>
    3. <Object>
    4. <!-- ... -->
    5. </Object>
    6. </parent>
    7. <attributes>
    8. <!-- ... -->
    9. </attributes>
    10. </SubObject>
    To copy to clipboard, switch view to plain text mode 

    On a side note, this is also how ECMAScript implements "inheritance" - by using prototypes.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 21
    Last Post: 28th September 2010, 10:59
  2. Replies: 10
    Last Post: 17th September 2009, 20:12
  3. how to justfy a node is leaf node or not
    By weixj2003ld in forum Qt Programming
    Replies: 4
    Last Post: 9th April 2009, 07:40
  4. Creating a QAccessibleWidget object for widget
    By Rakesh_Kumar in forum Qt Programming
    Replies: 0
    Last Post: 27th January 2009, 08:13
  5. Creating object of other class in Run() method
    By santosh.kumar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 15:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.