Menu

tinyxml compiler-error wtih "cut and paste"

Hello Everybody.

Those of you who want to compile the sources may be interested in the following information:

In my both projects "Moritz" and "MuLanPa" I'm working sometimes with very deep xml-trees and one of my key-works is to merge 2 or more xml-trees into one. In the current implementation of the node-class a resorting of the xml-structure is done with a lot of copy-work and this is time-consuming.

Thus I added 3 new methods for the class TiXmlNode you will find in the files "TiXmlNode_ao".

1. TiXmlNode* TiXmlNode::cut(TiXmlNode* cutThis )
This methode cuts a xml-child without eraseing it, thus it is possible to paste it somewhere else.

2. TiXmlNode* TiXmlNode::pasteBeforeChild( TiXmlNode* beforeThis, TiXmlNode* addThis )
This Methode puts an independent xml-element as new xml-sibbling before an other xml-child without copying it.

3. TiXmlNode* TiXmlNode::pasteAfterChild( TiXmlNode* afterThis, TiXmlNode* addThis )
This Methode puts an independent xml-element as new xml-sibbling after an other xml-child without copying it.

I know this is a very save way to prevent pointer problems and the user of my methods has to be very careful as with every pointer-solution. But once you know how to deal with them you are able to speed up your application.

I use this additions together with the current tinixml 2.6.1 as public methodes in the interface of the node-class by inserting an inlude-line into the header "tinyxml.h" to include the header "TiXmlNode_ao.h"
directly under the definition of the current existing public-methodes I have placed the directive "#include "TiXmlNode_ao.h"
" directly over the protected-section of the class-definition of "TiXmlNode" (somewhere under line 740 under the definition of the methode " virtual bool Accept( TiXmlVisitor* visitor ) const = 0;" but over the line with "protected:").

I proposed to add this 3 methodes in the next official release in the patch-section of the tinyxml source-forge-project.

Best Regards,
Eckard Klotz.

Posted by Eckard Klotz 2010-10-29

Log in to post a comment.