Menu

TiXmlHandle reuse

Developer
2004-02-25
2004-05-10
  • Ronald Fenner Jr

    I was looking at the TiXmlHandle and see there isn't really a way to declare one handle and reuse it by giving it a new node to wrap.

    Would adding a empty constructor with a function like SetNode(TiXmlNode* innode) we of interest to others.

    heres some code demostrating what i'd like to be able to do.

    node = thehand.FirstChild("SoundFile");
    if(node == NULL) return(false);

    TiXmlNode*child;

    while(node != NULL) {
      thehand.SetNode(node);
      child = thehand.FirstChild("path").FirstChild().Text();
      if(child == NULL)
        // complain
      node = node->NextSibling();
    }

    anyways that should give an idea of why it'd be nice to resue the handle.

     
    • Ronald Fenner Jr

      Looking over the code this would be all that is required I believe to add this feature.

      /// Create a empty handle
      TiXmlHandle() {this->node = 0;}

      /** Sets the node of the handle.
         This sets the node of the handle to "node" and can be null pointer.
      */
      TiXmlHandle SetNode(TiXmlNode* node) {this->node = node;}

       
    • Ronald Fenner Jr

      opps my goof SetNode should be:

      TiXmlHandle SetNode(TiXmlNode* node) {this->node = node; return(*this);}

       
    • Lee Thomason

      Lee Thomason - 2004-05-10

      TiXmlHandles are trivial in terms of data - just a pointer. Creating new ones on the stack is fast and cheap.

      theHandle = TiXmlHandle( newNode )

      is probably the best way to do a "SetNode()"

      lee

       

Log in to post a comment.

MongoDB Logo MongoDB