Changeset 54:77ebd2627b9f in rrlib_xml


Ignore:
Timestamp:
26.09.2013 16:02:15 (6 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Added method to access parent of a tNode

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tNode.cpp

    r50 r54  
    102102 
    103103//---------------------------------------------------------------------- 
     104// tNode Parent 
     105//---------------------------------------------------------------------- 
     106const tNode &tNode::Parent() const 
     107{ 
     108  if (!this->parent || this->parent->type != XML_ELEMENT_NODE) 
     109  { 
     110    throw tException("Node has no parent!"); 
     111  } 
     112  return reinterpret_cast<tNode &>(*this->parent); 
     113} 
     114 
     115//---------------------------------------------------------------------- 
    104116// tNode ChildrenEnd 
    105117//---------------------------------------------------------------------- 
  • tNode.h

    r53 r54  
    261261  const std::string Name() const; 
    262262 
     263  /*! Get access to the parent of this node 
     264   * 
     265   * This method gives access to the parent of \a this 
     266   * which is itself of type XML_ELEMENT_NODE. 
     267   * 
     268   * \exception tException is thrown if this node has no parent of type XML_ELEMENT_NODE 
     269   * 
     270   * \returns The parent node 
     271   */ 
     272  tNode &Parent(); 
     273 
     274  /*! Get access to the parent of this node in const context 
     275   * 
     276   * This method gives access to the parent of \a this 
     277   * which is itself of type XML_ELEMENT_NODE in const context. 
     278   * 
     279   * \exception tException is thrown if this node has no parent of type XML_ELEMENT_NODE 
     280   * 
     281   * \returns The parent node 
     282   */ 
     283  inline const tNode &Parent() const 
     284  { 
     285    return const_cast<tNode *>(this)->Parent(); 
     286  } 
     287 
    263288  /*! Get an iterator to the first of this node's children of type XML_ELEMENT_NODE 
    264289   * 
     
    320345   * which is itself of type XML_ELEMENT_NODE. 
    321346   * 
    322    * \exception tException is thrown if this node has not children of type XML_ELEMENT_NODE 
    323    * 
    324    * \returns Whether \a this has children or not 
     347   * \exception tException is thrown if this node has no children of type XML_ELEMENT_NODE 
     348   * 
     349   * \returns The first child 
    325350   */ 
    326351  tNode &FirstChild(); 
     
    331356   * which is itself of type XML_ELEMENT_NODE in const context. 
    332357   * 
    333    * \exception tException is thrown if this node has not children of type XML_ELEMENT_NODE 
    334    * 
    335    * \returns Whether \a this has children or not 
     358   * \exception tException is thrown if this node has no children of type XML_ELEMENT_NODE 
     359   * 
     360   * \returns The first child 
    336361   */ 
    337362  inline const tNode &FirstChild() const 
     
    424449  } 
    425450 
    426   /*! Get access to first child of this node 
    427    * 
    428    * This method gives access to the first child of \a this 
     451  /*! Get access to next sibling of this node 
     452   * 
     453   * This method gives access to the next sibling of \a this 
    429454   * which is itself of type XML_ELEMENT_NODE. 
    430455   * 
    431    * \exception tException is thrown if this node has not children of type XML_ELEMENT_NODE 
    432    * 
    433    * \returns Whether \a this has children or not 
     456   * \exception tException is thrown if this node has no siblings of type XML_ELEMENT_NODE 
     457   * 
     458   * \returns The next sibling 
    434459   */ 
    435460  tNode &NextSibling(); 
    436461 
    437   /*! Get access to first child of this node in const context 
    438    * 
    439    * This method gives access to the first child of \a this 
     462  /*! Get access to next sibling this node in const context 
     463   * 
     464   * This method gives access to the next sibling of \a this 
    440465   * which is itself of type XML_ELEMENT_NODE in const context. 
    441466   * 
    442    * \exception tException is thrown if this node has not children of type XML_ELEMENT_NODE 
    443    * 
    444    * \returns Whether \a this has children or not 
     467   * \exception tException is thrown if this node has no siblings of type XML_ELEMENT_NODE 
     468   * 
     469   * \returns The next sibling 
    445470   */ 
    446471  inline const tNode &NextSibling() const 
Note: See TracChangeset for help on using the changeset viewer.