antioch-0.4.0
List of all members | Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends
tinyxml2::XMLElement Class Reference

#include <tinyxml2.h>

Inheritance diagram for tinyxml2::XMLElement:
tinyxml2::XMLNode

Public Types

enum  { OPEN, CLOSED, CLOSING }
 

Public Member Functions

const char * Name () const
 Get the name of an element (which is the Value() of the node.) More...
 
void SetName (const char *str, bool staticMem=false)
 Set the name of the element. More...
 
virtual XMLElementToElement ()
 Safely cast to an Element, or null. More...
 
virtual const XMLElementToElement () const
 
virtual bool Accept (XMLVisitor *visitor) const
 
const char * Attribute (const char *name, const char *value=0) const
 
int IntAttribute (const char *name) const
 
unsigned UnsignedAttribute (const char *name) const
 See IntAttribute() More...
 
bool BoolAttribute (const char *name) const
 See IntAttribute() More...
 
double DoubleAttribute (const char *name) const
 See IntAttribute() More...
 
float FloatAttribute (const char *name) const
 See IntAttribute() More...
 
int QueryIntAttribute (const char *name, int *_value) const
 
int QueryUnsignedAttribute (const char *name, unsigned int *_value) const
 See QueryIntAttribute() More...
 
int QueryBoolAttribute (const char *name, bool *_value) const
 See QueryIntAttribute() More...
 
int QueryDoubleAttribute (const char *name, double *_value) const
 See QueryIntAttribute() More...
 
int QueryFloatAttribute (const char *name, float *_value) const
 See QueryIntAttribute() More...
 
void SetAttribute (const char *name, const char *_value)
 Sets the named attribute to value. More...
 
void SetAttribute (const char *name, int _value)
 Sets the named attribute to value. More...
 
void SetAttribute (const char *name, unsigned _value)
 Sets the named attribute to value. More...
 
void SetAttribute (const char *name, bool _value)
 Sets the named attribute to value. More...
 
void SetAttribute (const char *name, double _value)
 Sets the named attribute to value. More...
 
void DeleteAttribute (const char *name)
 
const XMLAttributeFirstAttribute () const
 Return the first attribute in the list. More...
 
const XMLAttributeFindAttribute (const char *name) const
 Query a specific attribute in the list. More...
 
const char * GetText () const
 
int QueryIntText (int *_value) const
 
int QueryUnsignedText (unsigned *_value) const
 See QueryIntText() More...
 
int QueryBoolText (bool *_value) const
 See QueryIntText() More...
 
int QueryDoubleText (double *_value) const
 See QueryIntText() More...
 
int QueryFloatText (float *_value) const
 See QueryIntText() More...
 
int ClosingType () const
 
char * ParseDeep (char *p, StrPair *endTag)
 
virtual XMLNodeShallowClone (XMLDocument *document) const
 
virtual bool ShallowEqual (const XMLNode *compare) const
 
const XMLDocumentGetDocument () const
 Get the XMLDocument that owns this XMLNode. More...
 
XMLDocumentGetDocument ()
 Get the XMLDocument that owns this XMLNode. More...
 
virtual XMLTextToText ()
 Safely cast to Text, or null. More...
 
virtual const XMLTextToText () const
 
virtual XMLCommentToComment ()
 Safely cast to a Comment, or null. More...
 
virtual const XMLCommentToComment () const
 
virtual XMLDocumentToDocument ()
 Safely cast to a Document, or null. More...
 
virtual const XMLDocumentToDocument () const
 
virtual XMLDeclarationToDeclaration ()
 Safely cast to a Declaration, or null. More...
 
virtual const XMLDeclarationToDeclaration () const
 
virtual XMLUnknownToUnknown ()
 Safely cast to an Unknown, or null. More...
 
virtual const XMLUnknownToUnknown () const
 
const char * Value () const
 
void SetValue (const char *val, bool staticMem=false)
 
const XMLNodeParent () const
 Get the parent of this node on the DOM. More...
 
XMLNodeParent ()
 
bool NoChildren () const
 Returns true if this node has no children. More...
 
const XMLNodeFirstChild () const
 Get the first child node, or null if none exists. More...
 
XMLNodeFirstChild ()
 
const XMLElementFirstChildElement (const char *value=0) const
 
XMLElementFirstChildElement (const char *_value=0)
 
const XMLNodeLastChild () const
 Get the last child node, or null if none exists. More...
 
XMLNodeLastChild ()
 
const XMLElementLastChildElement (const char *value=0) const
 
XMLElementLastChildElement (const char *_value=0)
 
const XMLNodePreviousSibling () const
 Get the previous (left) sibling node of this node. More...
 
XMLNodePreviousSibling ()
 
const XMLElementPreviousSiblingElement (const char *value=0) const
 Get the previous (left) sibling element of this node, with an opitionally supplied name. More...
 
XMLElementPreviousSiblingElement (const char *_value=0)
 
const XMLNodeNextSibling () const
 Get the next (right) sibling node of this node. More...
 
XMLNodeNextSibling ()
 
const XMLElementNextSiblingElement (const char *value=0) const
 Get the next (right) sibling element of this node, with an opitionally supplied name. More...
 
XMLElementNextSiblingElement (const char *_value=0)
 
XMLNodeInsertEndChild (XMLNode *addThis)
 
XMLNodeLinkEndChild (XMLNode *addThis)
 
XMLNodeInsertFirstChild (XMLNode *addThis)
 
XMLNodeInsertAfterChild (XMLNode *afterThis, XMLNode *addThis)
 
void DeleteChildren ()
 
void DeleteChild (XMLNode *node)
 

Protected Attributes

XMLDocumentdocument
 
XMLNodeparent
 
StrPair value
 
XMLNodefirstChild
 
XMLNodelastChild
 
XMLNodeprev
 
XMLNodenext
 

Private Member Functions

 XMLElement (XMLDocument *doc)
 
virtual ~XMLElement ()
 
 XMLElement (const XMLElement &)
 
void operator= (const XMLElement &)
 
XMLAttributeFindAttribute (const char *name)
 
XMLAttributeFindOrCreateAttribute (const char *name)
 
char * ParseAttributes (char *p)
 

Private Attributes

int closingType
 
XMLAttributerootAttribute
 

Friends

class XMLBase
 
class XMLDocument
 

Detailed Description

The element is a container class. It has a value, the element name, and can contain other elements, text, comments, and unknowns. Elements also contain an arbitrary number of attributes.

Definition at line 855 of file tinyxml2.h.

Member Enumeration Documentation

anonymous enum
Enumerator
OPEN 
CLOSED 
CLOSING 

Definition at line 1020 of file tinyxml2.h.

1020  {
1021  OPEN, // <foo>
1022  CLOSED, // <foo/>
1023  CLOSING // </foo>
1024  };

Constructor & Destructor Documentation

XMLElement::XMLElement ( XMLDocument doc)
inlineprivate

Definition at line 1217 of file tinyxml2_imp.h.

1217  : XMLNode( doc ),
1218  closingType( 0 ),
1219  rootAttribute( 0 )
1220 {
1221 }
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
XMLElement::~XMLElement ( )
inlineprivatevirtual

Definition at line 1225 of file tinyxml2_imp.h.

References DELETE_ATTRIBUTE, tinyxml2::XMLNode::next, tinyxml2::XMLAttribute::next, and rootAttribute.

1226 {
1227  while( rootAttribute ) {
1230  rootAttribute = next;
1231  }
1232 }
#define DELETE_ATTRIBUTE(attrib)
Definition: tinyxml2_imp.h:63
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
XMLNode * next
Definition: tinyxml2.h:615
XMLAttribute * next
Definition: tinyxml2.h:846
tinyxml2::XMLElement::XMLElement ( const XMLElement )
private

Member Function Documentation

bool XMLElement::Accept ( XMLVisitor visitor) const
inlinevirtual

Accept a hierarchical visit of the nodes in the TinyXML DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface.

This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse the XML for the callbacks, so the performance of TinyXML is unchanged by using this interface versus any other.)

The interface has been based on ideas from:

Which are both good references for "visiting".

An example of using Accept():

    TiXmlPrinter printer;
    tinyxmlDoc.Accept( &printer );
    const char* xmlcstr = printer.CStr();

Implements tinyxml2::XMLNode.

Definition at line 1530 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::FirstChild(), tinyxml2::XMLNode::NextSibling(), rootAttribute, tinyxml2::XMLVisitor::VisitEnter(), and tinyxml2::XMLVisitor::VisitExit().

1531 {
1532  if ( visitor->VisitEnter( *this, rootAttribute ) )
1533  {
1534  for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() )
1535  {
1536  if ( !node->Accept( visitor ) )
1537  break;
1538  }
1539  }
1540  return visitor->VisitExit( *this );
1541 }
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:523
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:496
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:352
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:354
const char * XMLElement::Attribute ( const char *  name,
const char *  value = 0 
) const
inline

Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. For example:

    const char* value = ele->Attribute( "foo" );

The 'value' parameter is normally null. However, if specified, the attribute will only be returned if the 'name' and 'value' match. This allow you to write code:

    if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar();

rather than:

    if ( ele->Attribute( "foo" ) ) {
        if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar();
    }

Definition at line 1260 of file tinyxml2_imp.h.

References FindAttribute(), tinyxml2::XMLUtil::StringEqual(), tinyxml2::XMLNode::value, and tinyxml2::XMLAttribute::Value().

Referenced by Antioch::XMLParser< NumericType >::find_element_with_attribute(), ParseAttributes(), Antioch::XMLParser< NumericType >::read_thermodynamic_data_root(), and Antioch::XMLParser< NumericType >::where_is_k0().

1261 {
1262  const XMLAttribute* a = FindAttribute( name );
1263  if ( !a )
1264  return 0;
1265  if ( !value || XMLUtil::StringEqual( a->Value(), value ))
1266  return a->Value();
1267  return 0;
1268 }
const char * Value() const
The value of the attribute.
Definition: tinyxml2.h:789
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
bool tinyxml2::XMLElement::BoolAttribute ( const char *  name) const
inline

See IntAttribute()

Definition at line 903 of file tinyxml2.h.

References QueryBoolAttribute().

903 { bool b=false; QueryBoolAttribute( name, &b ); return b; }
int QueryBoolAttribute(const char *name, bool *_value) const
See QueryIntAttribute()
Definition: tinyxml2.h:926
int tinyxml2::XMLElement::ClosingType ( ) const
inline

Definition at line 1025 of file tinyxml2.h.

References closingType.

Referenced by tinyxml2::XMLNode::ParseDeep().

1025 { return closingType; }
void XMLElement::DeleteAttribute ( const char *  name)
inline

Delete an attribute.

Definition at line 1381 of file tinyxml2_imp.h.

References DELETE_ATTRIBUTE, tinyxml2::XMLAttribute::next, tinyxml2::XMLNode::prev, rootAttribute, and tinyxml2::XMLUtil::StringEqual().

1382 {
1383  XMLAttribute* prev = 0;
1384  for( XMLAttribute* a=rootAttribute; a; a=a->next ) {
1385  if ( XMLUtil::StringEqual( name, a->Name() ) ) {
1386  if ( prev ) {
1387  prev->next = a->next;
1388  }
1389  else {
1390  rootAttribute = a->next;
1391  }
1392  DELETE_ATTRIBUTE( a );
1393  break;
1394  }
1395  prev = a;
1396  }
1397 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
#define DELETE_ATTRIBUTE(attrib)
Definition: tinyxml2_imp.h:63
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
XMLAttribute * next
Definition: tinyxml2.h:846
XMLNode * prev
Definition: tinyxml2.h:614
void XMLNode::DeleteChild ( XMLNode node)
inlineinherited

Delete a child of this node.

Definition at line 661 of file tinyxml2_imp.h.

References DELETE_NODE, tinyxml2::XMLNode::parent, and TIXMLASSERT.

Referenced by tinyxml2::XMLDocument::DeleteNode().

662 {
663  TIXMLASSERT( node->parent == this );
664  DELETE_NODE( node );
665 }
#define DELETE_NODE(node)
Definition: tinyxml2_imp.h:56
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
XMLNode * parent
Definition: tinyxml2.h:608
void XMLNode::DeleteChildren ( )
inlineinherited

Delete all the children of this node.

Definition at line 629 of file tinyxml2_imp.h.

References DELETE_NODE, tinyxml2::XMLNode::firstChild, tinyxml2::XMLNode::lastChild, and tinyxml2::XMLNode::Unlink().

Referenced by tinyxml2::XMLDocument::LoadFile(), tinyxml2::XMLDocument::Parse(), tinyxml2::XMLDocument::~XMLDocument(), and tinyxml2::XMLNode::~XMLNode().

630 {
631  while( firstChild ) {
632  XMLNode* node = firstChild;
633  Unlink( node );
634 
635  DELETE_NODE( node );
636  }
637  firstChild = lastChild = 0;
638 }
#define DELETE_NODE(node)
Definition: tinyxml2_imp.h:56
void Unlink(XMLNode *child)
Definition: tinyxml2_imp.h:642
XMLNode * firstChild
Definition: tinyxml2.h:611
XMLNode * lastChild
Definition: tinyxml2.h:612
double tinyxml2::XMLElement::DoubleAttribute ( const char *  name) const
inline

See IntAttribute()

Definition at line 905 of file tinyxml2.h.

References QueryDoubleAttribute().

905 { double d=0; QueryDoubleAttribute( name, &d ); return d; }
int QueryDoubleAttribute(const char *name, double *_value) const
See QueryIntAttribute()
Definition: tinyxml2.h:928
const XMLAttribute * XMLElement::FindAttribute ( const char *  name) const
inline

Query a specific attribute in the list.

Definition at line 1248 of file tinyxml2_imp.h.

References tinyxml2::XMLAttribute::Name(), tinyxml2::XMLAttribute::next, rootAttribute, and tinyxml2::XMLUtil::StringEqual().

Referenced by Attribute(), QueryBoolAttribute(), QueryDoubleAttribute(), QueryFloatAttribute(), QueryIntAttribute(), and QueryUnsignedAttribute().

1249 {
1250  XMLAttribute* a = 0;
1251  for( a=rootAttribute; a; a = a->next ) {
1252  if ( XMLUtil::StringEqual( a->Name(), name ) )
1253  return a;
1254  }
1255  return 0;
1256 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
const char * Name() const
The name of the attribute.
Definition: tinyxml2.h:788
XMLAttribute * next
Definition: tinyxml2.h:846
XMLAttribute * XMLElement::FindAttribute ( const char *  name)
inlineprivate

Definition at line 1236 of file tinyxml2_imp.h.

References tinyxml2::XMLAttribute::Name(), tinyxml2::XMLAttribute::next, rootAttribute, and tinyxml2::XMLUtil::StringEqual().

1237 {
1238  XMLAttribute* a = 0;
1239  for( a=rootAttribute; a; a = a->next ) {
1240  if ( XMLUtil::StringEqual( a->Name(), name ) )
1241  return a;
1242  }
1243  return 0;
1244 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
const char * Name() const
The name of the attribute.
Definition: tinyxml2.h:788
XMLAttribute * next
Definition: tinyxml2.h:846
XMLAttribute * XMLElement::FindOrCreateAttribute ( const char *  name)
inlineprivate

Definition at line 1353 of file tinyxml2_imp.h.

References tinyxml2::XMLDocument::attributePool, tinyxml2::XMLNode::document, tinyxml2::XMLAttribute::memPool, tinyxml2::XMLAttribute::next, rootAttribute, tinyxml2::XMLAttribute::SetName(), and tinyxml2::XMLUtil::StringEqual().

Referenced by SetAttribute().

1354 {
1355  XMLAttribute* last = 0;
1356  XMLAttribute* attrib = 0;
1357  for( attrib = rootAttribute;
1358  attrib;
1359  last = attrib, attrib = attrib->next )
1360  {
1361  if ( XMLUtil::StringEqual( attrib->Name(), name ) ) {
1362  break;
1363  }
1364  }
1365  if ( !attrib ) {
1366  attrib = new (document->attributePool.Alloc() ) XMLAttribute();
1367  attrib->memPool = &document->attributePool;
1368  if ( last ) {
1369  last->next = attrib;
1370  }
1371  else {
1372  rootAttribute = attrib;
1373  }
1374  attrib->SetName( name );
1375  }
1376  return attrib;
1377 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
XMLDocument * document
Definition: tinyxml2.h:607
void SetName(const char *name)
MemPoolT< sizeof(XMLAttribute) > attributePool
Definition: tinyxml2.h:1225
XMLAttribute * next
Definition: tinyxml2.h:846
const XMLAttribute* tinyxml2::XMLElement::FirstAttribute ( ) const
inline

Return the first attribute in the list.

Definition at line 949 of file tinyxml2.h.

References rootAttribute.

Referenced by ShallowClone(), and ShallowEqual().

949 { return rootAttribute; }
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
const XMLNode* tinyxml2::XMLNode::FirstChild ( ) const
inlineinherited
XMLNode* tinyxml2::XMLNode::FirstChild ( )
inlineinherited

Definition at line 497 of file tinyxml2.h.

References tinyxml2::XMLNode::firstChild.

497 { return firstChild; }
XMLNode * firstChild
Definition: tinyxml2.h:611
const XMLElement * XMLNode::FirstChildElement ( const char *  value = 0) const
inlineinherited

Get the first child element, or optionally the first child element with the specified name.

Definition at line 740 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::firstChild, Name(), tinyxml2::XMLNode::next, tinyxml2::XMLUtil::StringEqual(), ToElement(), and tinyxml2::XMLNode::value.

Referenced by Antioch::XMLParser< NumericType >::efficiencies(), tinyxml2::XMLHandle::FirstChildElement(), tinyxml2::XMLConstHandle::FirstChildElement(), Antioch::XMLParser< NumericType >::get_parameter(), Antioch::XMLParser< NumericType >::products_orders(), Antioch::XMLParser< NumericType >::products_pairs(), Antioch::XMLParser< NumericType >::reactants_orders(), Antioch::XMLParser< NumericType >::reactants_pairs(), Antioch::XMLParser< NumericType >::reaction_kinetics_model(), Antioch::XMLParser< NumericType >::read_thermodynamic_data_root(), tinyxml2::XMLDocument::RootElement(), Antioch::XMLParser< NumericType >::verify_Kooij_in_place_of_Arrhenius(), and Antioch::XMLParser< NumericType >::where_is_k0().

741 {
742  for( XMLNode* node=firstChild; node; node=node->next ) {
743  XMLElement* element = node->ToElement();
744  if ( element ) {
745  if ( !value || XMLUtil::StringEqual( element->Name(), value ) ) {
746  return element;
747  }
748  }
749  }
750  return 0;
751 }
XMLNode * firstChild
Definition: tinyxml2.h:611
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:861
XMLNode * next
Definition: tinyxml2.h:615
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:865
XMLElement* tinyxml2::XMLNode::FirstChildElement ( const char *  _value = 0)
inlineinherited

Definition at line 502 of file tinyxml2.h.

References tinyxml2::XMLNode::FirstChildElement().

Referenced by tinyxml2::XMLNode::FirstChildElement().

502 { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( _value )); }
friend class XMLElement
Definition: tinyxml2.h:451
const XMLElement * FirstChildElement(const char *value=0) const
Definition: tinyxml2_imp.h:740
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
float tinyxml2::XMLElement::FloatAttribute ( const char *  name) const
inline

See IntAttribute()

Definition at line 907 of file tinyxml2.h.

References QueryFloatAttribute().

907 { float f=0; QueryFloatAttribute( name, &f ); return f; }
int QueryFloatAttribute(const char *name, float *_value) const
See QueryIntAttribute()
Definition: tinyxml2.h:930
const XMLDocument* tinyxml2::XMLNode::GetDocument ( ) const
inlineinherited

Get the XMLDocument that owns this XMLNode.

Definition at line 455 of file tinyxml2.h.

References tinyxml2::XMLNode::document.

455 { return document; }
XMLDocument * document
Definition: tinyxml2.h:607
XMLDocument* tinyxml2::XMLNode::GetDocument ( )
inlineinherited

Get the XMLDocument that owns this XMLNode.

Definition at line 457 of file tinyxml2.h.

References tinyxml2::XMLNode::document.

457 { return document; }
XMLDocument * document
Definition: tinyxml2.h:607
const char * XMLElement::GetText ( ) const
inline

Convenience function for easy access to the text inside an element. Although easy and concise, GetText() is limited compared to getting the TiXmlText child and accessing it directly.

If the first child of 'this' is a TiXmlText, the GetText() returns the character string of the Text node, else null is returned.

This is a convenient method for getting the text of simple contained text:

    <foo>This is text</foo>
        const char* str = fooElement->GetText();

'str' will be a pointer to "This is text".

Note that this function can be misleading. If the element foo was created from this XML:

        <foo><b>This is text</b></foo>

then the value of str would be null. The first child node isn't a text node, it is another element. From this XML:

        <foo>This is <b>text</b></foo>

GetText() will return "This is ".

Definition at line 1272 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::FirstChild(), tinyxml2::XMLNode::ToText(), and tinyxml2::XMLNode::Value().

Referenced by Antioch::XMLParser< NumericType >::molecules_pairs(), and Antioch::XMLParser< NumericType >::read_thermodynamic_data_root().

1273 {
1274  if ( FirstChild() && FirstChild()->ToText() ) {
1275  return FirstChild()->ToText()->Value();
1276  }
1277  return 0;
1278 }
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:460
const char * Value() const
Definition: tinyxml2.h:482
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:496
XMLNode * XMLNode::InsertAfterChild ( XMLNode afterThis,
XMLNode addThis 
)
inlineinherited

Add a node after the specified child node.

Definition at line 718 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::InsertEndChild(), tinyxml2::XMLNode::next, tinyxml2::XMLNode::parent, tinyxml2::XMLNode::prev, and TIXMLASSERT.

719 {
720  TIXMLASSERT( afterThis->parent == this );
721  if ( afterThis->parent != this )
722  return 0;
723 
724  if ( afterThis->next == 0 ) {
725  // The last node or the only node.
726  return InsertEndChild( addThis );
727  }
728  addThis->prev = afterThis;
729  addThis->next = afterThis->next;
730  afterThis->next->prev = addThis;
731  afterThis->next = addThis;
732  addThis->parent = this;
733  return addThis;
734 }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
XMLNode * parent
Definition: tinyxml2.h:608
XMLNode * InsertEndChild(XMLNode *addThis)
Definition: tinyxml2_imp.h:669
XMLNode * next
Definition: tinyxml2.h:615
XMLNode * prev
Definition: tinyxml2.h:614
XMLNode * XMLNode::InsertEndChild ( XMLNode addThis)
inlineinherited

Add a child node as the last (right) child.

Definition at line 669 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::firstChild, tinyxml2::XMLNode::lastChild, tinyxml2::XMLNode::next, tinyxml2::XMLNode::parent, tinyxml2::XMLNode::prev, and TIXMLASSERT.

Referenced by tinyxml2::XMLNode::InsertAfterChild(), tinyxml2::XMLNode::LinkEndChild(), and tinyxml2::XMLNode::ParseDeep().

670 {
671  if ( lastChild ) {
673  TIXMLASSERT( lastChild->next == 0 );
674  lastChild->next = addThis;
675  addThis->prev = lastChild;
676  lastChild = addThis;
677 
678  addThis->next = 0;
679  }
680  else {
681  TIXMLASSERT( firstChild == 0 );
682  firstChild = lastChild = addThis;
683 
684  addThis->prev = 0;
685  addThis->next = 0;
686  }
687  addThis->parent = this;
688  return addThis;
689 }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
XMLNode * firstChild
Definition: tinyxml2.h:611
XMLNode * parent
Definition: tinyxml2.h:608
XMLNode * next
Definition: tinyxml2.h:615
XMLNode * lastChild
Definition: tinyxml2.h:612
XMLNode * prev
Definition: tinyxml2.h:614
XMLNode * XMLNode::InsertFirstChild ( XMLNode addThis)
inlineinherited

Add a child node as the first (left) child.

Definition at line 693 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::firstChild, tinyxml2::XMLNode::lastChild, tinyxml2::XMLNode::next, tinyxml2::XMLNode::parent, tinyxml2::XMLNode::prev, and TIXMLASSERT.

694 {
695  if ( firstChild ) {
697  TIXMLASSERT( firstChild->prev == 0 );
698 
699  firstChild->prev = addThis;
700  addThis->next = firstChild;
701  firstChild = addThis;
702 
703  addThis->prev = 0;
704  }
705  else {
706  TIXMLASSERT( lastChild == 0 );
707  firstChild = lastChild = addThis;
708 
709  addThis->prev = 0;
710  addThis->next = 0;
711  }
712  addThis->parent = this;
713  return addThis;
714 }
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
XMLNode * firstChild
Definition: tinyxml2.h:611
XMLNode * parent
Definition: tinyxml2.h:608
XMLNode * next
Definition: tinyxml2.h:615
XMLNode * lastChild
Definition: tinyxml2.h:612
XMLNode * prev
Definition: tinyxml2.h:614
int tinyxml2::XMLElement::IntAttribute ( const char *  name) const
inline

Given an attribute name, IntAttribute() returns the value of the attribute interpreted as an integer. 0 will be returned if there is an error. For a method with error checking, see QueryIntAttribute()

Definition at line 899 of file tinyxml2.h.

References QueryIntAttribute().

899 { int i=0; QueryIntAttribute( name, &i ); return i; }
int QueryIntAttribute(const char *name, int *_value) const
Definition: tinyxml2.h:922
const XMLNode* tinyxml2::XMLNode::LastChild ( ) const
inlineinherited

Get the last child node, or null if none exists.

Definition at line 505 of file tinyxml2.h.

References tinyxml2::XMLNode::lastChild.

Referenced by tinyxml2::XMLHandle::LastChild(), and tinyxml2::XMLConstHandle::LastChild().

505 { return lastChild; }
XMLNode * lastChild
Definition: tinyxml2.h:612
XMLNode* tinyxml2::XMLNode::LastChild ( )
inlineinherited

Definition at line 506 of file tinyxml2.h.

References tinyxml2::XMLNode::LastChild().

Referenced by tinyxml2::XMLNode::LastChild().

506 { return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() ); }
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:505
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
const XMLElement * XMLNode::LastChildElement ( const char *  value = 0) const
inlineinherited

Get the last child element or optionally the last child element with the specified name.

Definition at line 755 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::lastChild, Name(), tinyxml2::XMLNode::prev, tinyxml2::XMLUtil::StringEqual(), ToElement(), and tinyxml2::XMLNode::value.

Referenced by tinyxml2::XMLHandle::LastChildElement(), and tinyxml2::XMLConstHandle::LastChildElement().

756 {
757  for( XMLNode* node=lastChild; node; node=node->prev ) {
758  XMLElement* element = node->ToElement();
759  if ( element ) {
760  if ( !value || XMLUtil::StringEqual( element->Name(), value ) ) {
761  return element;
762  }
763  }
764  }
765  return 0;
766 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:861
XMLNode * lastChild
Definition: tinyxml2.h:612
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:865
XMLNode * prev
Definition: tinyxml2.h:614
XMLElement* tinyxml2::XMLNode::LastChildElement ( const char *  _value = 0)
inlineinherited

Definition at line 512 of file tinyxml2.h.

References tinyxml2::XMLNode::LastChildElement().

Referenced by tinyxml2::XMLNode::LastChildElement().

512 { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(_value) ); }
const XMLElement * LastChildElement(const char *value=0) const
Definition: tinyxml2_imp.h:755
friend class XMLElement
Definition: tinyxml2.h:451
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
XMLNode* tinyxml2::XMLNode::LinkEndChild ( XMLNode addThis)
inlineinherited

Definition at line 535 of file tinyxml2.h.

References tinyxml2::XMLNode::InsertEndChild().

535 { return InsertEndChild( addThis ); }
XMLNode * InsertEndChild(XMLNode *addThis)
Definition: tinyxml2_imp.h:669
const char* tinyxml2::XMLElement::Name ( ) const
inline

Get the name of an element (which is the Value() of the node.)

Definition at line 861 of file tinyxml2.h.

References tinyxml2::XMLNode::Value().

Referenced by tinyxml2::XMLNode::FirstChildElement(), tinyxml2::XMLNode::LastChildElement(), ParseAttributes(), and tinyxml2::XMLPrinter::VisitEnter().

861 { return Value(); }
const char * Value() const
Definition: tinyxml2.h:482
const XMLNode* tinyxml2::XMLNode::NextSibling ( ) const
inlineinherited

Get the next (right) sibling node of this node.

Definition at line 523 of file tinyxml2.h.

References tinyxml2::XMLNode::next.

Referenced by Accept(), tinyxml2::XMLDocument::Accept(), tinyxml2::XMLHandle::NextSibling(), and tinyxml2::XMLConstHandle::NextSibling().

523 { return next; }
XMLNode * next
Definition: tinyxml2.h:615
XMLNode* tinyxml2::XMLNode::NextSibling ( )
inlineinherited

Definition at line 524 of file tinyxml2.h.

References tinyxml2::XMLNode::next.

524 { return next; }
XMLNode * next
Definition: tinyxml2.h:615
const XMLElement * XMLNode::NextSiblingElement ( const char *  value = 0) const
inlineinherited

Get the next (right) sibling element of this node, with an opitionally supplied name.

Definition at line 770 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::next, tinyxml2::XMLUtil::StringEqual(), and ToElement().

Referenced by Antioch::XMLParser< NumericType >::find_element_with_attribute(), tinyxml2::XMLHandle::NextSiblingElement(), tinyxml2::XMLConstHandle::NextSiblingElement(), Antioch::XMLParser< NumericType >::read_thermodynamic_data_root(), and Antioch::XMLParser< NumericType >::where_is_k0().

771 {
772  for( XMLNode* element=this->next; element; element = element->next ) {
773  if ( element->ToElement()
774  && (!value || XMLUtil::StringEqual( value, element->Value() )))
775  {
776  return element->ToElement();
777  }
778  }
779  return 0;
780 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
XMLNode * next
Definition: tinyxml2.h:615
XMLElement* tinyxml2::XMLNode::NextSiblingElement ( const char *  _value = 0)
inlineinherited

Definition at line 528 of file tinyxml2.h.

References tinyxml2::XMLNode::NextSiblingElement().

Referenced by tinyxml2::XMLNode::NextSiblingElement().

528 { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( _value ) ); }
friend class XMLElement
Definition: tinyxml2.h:451
const XMLElement * NextSiblingElement(const char *value=0) const
Get the next (right) sibling element of this node, with an opitionally supplied name.
Definition: tinyxml2_imp.h:770
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
bool tinyxml2::XMLNode::NoChildren ( ) const
inlineinherited

Returns true if this node has no children.

Definition at line 493 of file tinyxml2.h.

References tinyxml2::XMLNode::firstChild.

493 { return !firstChild; }
XMLNode * firstChild
Definition: tinyxml2.h:611
void tinyxml2::XMLElement::operator= ( const XMLElement )
private
const XMLNode* tinyxml2::XMLNode::Parent ( ) const
inlineinherited

Get the parent of this node on the DOM.

Definition at line 489 of file tinyxml2.h.

References tinyxml2::XMLNode::parent.

489 { return parent; }
XMLNode * parent
Definition: tinyxml2.h:608
XMLNode* tinyxml2::XMLNode::Parent ( )
inlineinherited

Definition at line 490 of file tinyxml2.h.

References tinyxml2::XMLNode::parent.

490 { return parent; }
XMLNode * parent
Definition: tinyxml2.h:608
char * XMLElement::ParseAttributes ( char *  p)
inlineprivate

Definition at line 1401 of file tinyxml2_imp.h.

References Attribute(), tinyxml2::XMLDocument::attributePool, CLOSED, closingType, DELETE_ATTRIBUTE, tinyxml2::XMLNode::document, tinyxml2::XMLUtil::IsAlpha(), tinyxml2::XMLAttribute::memPool, tinyxml2::XMLAttribute::Name(), Name(), tinyxml2::XMLAttribute::next, tinyxml2::XMLAttribute::ParseDeep(), tinyxml2::XMLDocument::ProcessEntities(), rootAttribute, tinyxml2::XMLDocument::SetError(), tinyxml2::XMLUtil::SkipWhiteSpace(), tinyxml2::XML_ERROR_PARSING_ATTRIBUTE, and tinyxml2::XML_ERROR_PARSING_ELEMENT.

Referenced by ParseDeep().

1402 {
1403  const char* start = p;
1404  XMLAttribute* prevAttribute = 0;
1405 
1406  // Read the attributes.
1407  while( p ) {
1408  p = XMLUtil::SkipWhiteSpace( p );
1409  if ( !p || !(*p) ) {
1411  return 0;
1412  }
1413 
1414  // attribute.
1415  if ( XMLUtil::IsAlpha( *p ) ) {
1416  XMLAttribute* attrib = new (document->attributePool.Alloc() ) XMLAttribute();
1417  attrib->memPool = &document->attributePool;
1418 
1419  p = attrib->ParseDeep( p, document->ProcessEntities() );
1420  if ( !p || Attribute( attrib->Name() ) ) {
1421  DELETE_ATTRIBUTE( attrib );
1423  return 0;
1424  }
1425  // There is a minor bug here: if the attribute in the source xml
1426  // document is duplicated, it will not be detected and the
1427  // attribute will be doubly added. However, tracking the 'prevAttribute'
1428  // avoids re-scanning the attribute list. Preferring performance for
1429  // now, may reconsider in the future.
1430  if ( prevAttribute ) {
1431  prevAttribute->next = attrib;
1432  }
1433  else {
1434  rootAttribute = attrib;
1435  }
1436  prevAttribute = attrib;
1437  }
1438  // end of the tag
1439  else if ( *p == '/' && *(p+1) == '>' ) {
1440  closingType = CLOSED;
1441  return p+2; // done; sealed element.
1442  }
1443  // end of the tag
1444  else if ( *p == '>' ) {
1445  ++p;
1446  break;
1447  }
1448  else {
1450  return 0;
1451  }
1452  }
1453  return p;
1454 }
const char * Attribute(const char *name, const char *value=0) const
#define DELETE_ATTRIBUTE(attrib)
Definition: tinyxml2_imp.h:63
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:861
XMLDocument * document
Definition: tinyxml2.h:607
static int IsAlpha(unsigned char anyByte)
Definition: tinyxml2.h:399
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:380
void SetError(int error, const char *str1, const char *str2)
const char * Name() const
The name of the attribute.
Definition: tinyxml2.h:788
char * ParseDeep(char *p, bool processEntities)
MemPoolT< sizeof(XMLAttribute) > attributePool
Definition: tinyxml2.h:1225
XMLAttribute * next
Definition: tinyxml2.h:846
bool ProcessEntities() const
Definition: tinyxml2.h:1115
char * XMLElement::ParseDeep ( char *  p,
StrPair endTag 
)
inlinevirtual

Reimplemented from tinyxml2::XMLNode.

Definition at line 1462 of file tinyxml2_imp.h.

References CLOSING, closingType, tinyxml2::StrPair::Empty(), ParseAttributes(), tinyxml2::XMLNode::ParseDeep(), tinyxml2::StrPair::ParseName(), tinyxml2::XMLUtil::SkipWhiteSpace(), and tinyxml2::XMLNode::value.

1463 {
1464  // Read the element name.
1465  p = XMLUtil::SkipWhiteSpace( p );
1466  if ( !p ) return 0;
1467 
1468  // The closing element is the </element> form. It is
1469  // parsed just like a regular element then deleted from
1470  // the DOM.
1471  if ( *p == '/' ) {
1472  closingType = CLOSING;
1473  ++p;
1474  }
1475 
1476  p = value.ParseName( p );
1477  if ( value.Empty() ) return 0;
1478 
1479  p = ParseAttributes( p );
1480  if ( !p || !*p || closingType )
1481  return p;
1482 
1483  p = XMLNode::ParseDeep( p, strPair );
1484  return p;
1485 }
char * ParseName(char *in)
Definition: tinyxml2_imp.h:141
char * ParseAttributes(char *p)
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:380
bool Empty() const
Definition: tinyxml2.h:143
virtual char * ParseDeep(char *, StrPair *)
Definition: tinyxml2_imp.h:798
const XMLNode* tinyxml2::XMLNode::PreviousSibling ( ) const
inlineinherited

Get the previous (left) sibling node of this node.

Definition at line 515 of file tinyxml2.h.

References tinyxml2::XMLNode::prev.

Referenced by tinyxml2::XMLHandle::PreviousSibling(), and tinyxml2::XMLConstHandle::PreviousSibling().

515 { return prev; }
XMLNode * prev
Definition: tinyxml2.h:614
XMLNode* tinyxml2::XMLNode::PreviousSibling ( )
inlineinherited

Definition at line 516 of file tinyxml2.h.

References tinyxml2::XMLNode::prev.

516 { return prev; }
XMLNode * prev
Definition: tinyxml2.h:614
const XMLElement * XMLNode::PreviousSiblingElement ( const char *  value = 0) const
inlineinherited

Get the previous (left) sibling element of this node, with an opitionally supplied name.

Definition at line 784 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::prev, tinyxml2::XMLUtil::StringEqual(), and ToElement().

Referenced by tinyxml2::XMLHandle::PreviousSiblingElement(), and tinyxml2::XMLConstHandle::PreviousSiblingElement().

785 {
786  for( XMLNode* element=this->prev; element; element = element->prev ) {
787  if ( element->ToElement()
788  && (!value || XMLUtil::StringEqual( value, element->Value() )))
789  {
790  return element->ToElement();
791  }
792  }
793  return 0;
794 }
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
XMLNode * prev
Definition: tinyxml2.h:614
XMLElement* tinyxml2::XMLNode::PreviousSiblingElement ( const char *  _value = 0)
inlineinherited

Definition at line 520 of file tinyxml2.h.

References tinyxml2::XMLNode::PreviousSiblingElement().

Referenced by tinyxml2::XMLNode::PreviousSiblingElement().

520 { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( _value ) ); }
const XMLElement * PreviousSiblingElement(const char *value=0) const
Get the previous (left) sibling element of this node, with an opitionally supplied name...
Definition: tinyxml2_imp.h:784
friend class XMLElement
Definition: tinyxml2.h:451
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
int tinyxml2::XMLElement::QueryBoolAttribute ( const char *  name,
bool *  _value 
) const
inline

See QueryIntAttribute()

Definition at line 926 of file tinyxml2.h.

References FindAttribute(), tinyxml2::XMLAttribute::QueryBoolValue(), and tinyxml2::XML_NO_ATTRIBUTE.

Referenced by BoolAttribute().

926 { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryBoolValue( _value ); }
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
int XMLElement::QueryBoolText ( bool *  _value) const
inline

See QueryIntText()

Definition at line 1310 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::FirstChild(), tinyxml2::XMLUtil::ToBool(), tinyxml2::XMLNode::ToText(), tinyxml2::XMLNode::Value(), tinyxml2::XML_CAN_NOT_CONVERT_TEXT, tinyxml2::XML_NO_TEXT_NODE, and tinyxml2::XML_SUCCESS.

1311 {
1312  if ( FirstChild() && FirstChild()->ToText() ) {
1313  const char* t = FirstChild()->ToText()->Value();
1314  if ( XMLUtil::ToBool( t, _value ) ) {
1315  return XML_SUCCESS;
1316  }
1317  return XML_CAN_NOT_CONVERT_TEXT;
1318  }
1319  return XML_NO_TEXT_NODE;
1320 }
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:460
const char * Value() const
Definition: tinyxml2.h:482
static bool ToBool(const char *str, bool *value)
Definition: tinyxml2_imp.h:466
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:496
int tinyxml2::XMLElement::QueryDoubleAttribute ( const char *  name,
double *  _value 
) const
inline

See QueryIntAttribute()

Definition at line 928 of file tinyxml2.h.

References FindAttribute(), tinyxml2::XMLAttribute::QueryDoubleValue(), and tinyxml2::XML_NO_ATTRIBUTE.

Referenced by DoubleAttribute().

928 { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryDoubleValue( _value ); }
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
int XMLElement::QueryDoubleText ( double *  _value) const
inline

See QueryIntText()

Definition at line 1324 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::FirstChild(), tinyxml2::XMLUtil::ToDouble(), tinyxml2::XMLNode::ToText(), tinyxml2::XMLNode::Value(), tinyxml2::XML_CAN_NOT_CONVERT_TEXT, tinyxml2::XML_NO_TEXT_NODE, and tinyxml2::XML_SUCCESS.

1325 {
1326  if ( FirstChild() && FirstChild()->ToText() ) {
1327  const char* t = FirstChild()->ToText()->Value();
1328  if ( XMLUtil::ToDouble( t, _value ) ) {
1329  return XML_SUCCESS;
1330  }
1331  return XML_CAN_NOT_CONVERT_TEXT;
1332  }
1333  return XML_NO_TEXT_NODE;
1334 }
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:460
static bool ToDouble(const char *str, double *value)
Definition: tinyxml2_imp.h:495
const char * Value() const
Definition: tinyxml2.h:482
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:496
int tinyxml2::XMLElement::QueryFloatAttribute ( const char *  name,
float *  _value 
) const
inline

See QueryIntAttribute()

Definition at line 930 of file tinyxml2.h.

References FindAttribute(), tinyxml2::XMLAttribute::QueryFloatValue(), and tinyxml2::XML_NO_ATTRIBUTE.

Referenced by FloatAttribute().

930 { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryFloatValue( _value ); }
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
int XMLElement::QueryFloatText ( float *  _value) const
inline

See QueryIntText()

Definition at line 1338 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::FirstChild(), tinyxml2::XMLUtil::ToFloat(), tinyxml2::XMLNode::ToText(), tinyxml2::XMLNode::Value(), tinyxml2::XML_CAN_NOT_CONVERT_TEXT, tinyxml2::XML_NO_TEXT_NODE, and tinyxml2::XML_SUCCESS.

1339 {
1340  if ( FirstChild() && FirstChild()->ToText() ) {
1341  const char* t = FirstChild()->ToText()->Value();
1342  if ( XMLUtil::ToFloat( t, _value ) ) {
1343  return XML_SUCCESS;
1344  }
1345  return XML_CAN_NOT_CONVERT_TEXT;
1346  }
1347  return XML_NO_TEXT_NODE;
1348 }
static bool ToFloat(const char *str, float *value)
Definition: tinyxml2_imp.h:486
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:460
const char * Value() const
Definition: tinyxml2.h:482
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:496
int tinyxml2::XMLElement::QueryIntAttribute ( const char *  name,
int *  _value 
) const
inline

Given an attribute name, QueryIntAttribute() returns XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion can't be performed, or XML_NO_ATTRIBUTE if the attribute doesn't exist. If successful, the result of the conversion will be written to 'value'. If not successful, nothing will be written to 'value'. This allows you to provide default value:

    int value = 10;
    QueryIntAttribute( "foo", &value );         // if "foo" isn't found, value will still be 10

Definition at line 922 of file tinyxml2.h.

References FindAttribute(), tinyxml2::XMLAttribute::QueryIntValue(), and tinyxml2::XML_NO_ATTRIBUTE.

Referenced by IntAttribute().

922 { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryIntValue( _value ); }
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
int XMLElement::QueryIntText ( int *  _value) const
inline

Convenience method to query the value of a child text node. This is probably best shown by example. Given you have a document is this form:

        <point>
                <x>1</x>
                <y>1.4</y>
        </point>

The QueryIntText() and similar functions provide a safe and easier way to get to the "value" of x and y.

        int x = 0;
        float y = 0;    // types of x and y are contrived for example
        const XMLElement* xElement = pointElement->FirstChildElement( "x" );
        const XMLElement* yElement = pointElement->FirstChildElement( "y" );
        xElement->QueryIntText( &x );
        yElement->QueryFloatText( &y );
Returns
XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted to the requested type, and XML_NO_TEXT_NODE if there is no child text to query.

Definition at line 1282 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::FirstChild(), tinyxml2::XMLUtil::ToInt(), tinyxml2::XMLNode::ToText(), tinyxml2::XMLNode::Value(), tinyxml2::XML_CAN_NOT_CONVERT_TEXT, tinyxml2::XML_NO_TEXT_NODE, and tinyxml2::XML_SUCCESS.

1283 {
1284  if ( FirstChild() && FirstChild()->ToText() ) {
1285  const char* t = FirstChild()->ToText()->Value();
1286  if ( XMLUtil::ToInt( t, _value ) ) {
1287  return XML_SUCCESS;
1288  }
1289  return XML_CAN_NOT_CONVERT_TEXT;
1290  }
1291  return XML_NO_TEXT_NODE;
1292 }
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:460
const char * Value() const
Definition: tinyxml2.h:482
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:496
static bool ToInt(const char *str, int *value)
Definition: tinyxml2_imp.h:450
int tinyxml2::XMLElement::QueryUnsignedAttribute ( const char *  name,
unsigned int *  _value 
) const
inline

See QueryIntAttribute()

Definition at line 924 of file tinyxml2.h.

References FindAttribute(), tinyxml2::XMLAttribute::QueryUnsignedValue(), and tinyxml2::XML_NO_ATTRIBUTE.

Referenced by UnsignedAttribute().

924 { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryUnsignedValue( _value ); }
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
int XMLElement::QueryUnsignedText ( unsigned *  _value) const
inline

See QueryIntText()

Definition at line 1296 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::FirstChild(), tinyxml2::XMLNode::ToText(), tinyxml2::XMLUtil::ToUnsigned(), tinyxml2::XMLNode::Value(), tinyxml2::XML_CAN_NOT_CONVERT_TEXT, tinyxml2::XML_NO_TEXT_NODE, and tinyxml2::XML_SUCCESS.

1297 {
1298  if ( FirstChild() && FirstChild()->ToText() ) {
1299  const char* t = FirstChild()->ToText()->Value();
1300  if ( XMLUtil::ToUnsigned( t, _value ) ) {
1301  return XML_SUCCESS;
1302  }
1303  return XML_CAN_NOT_CONVERT_TEXT;
1304  }
1305  return XML_NO_TEXT_NODE;
1306 }
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:460
const char * Value() const
Definition: tinyxml2.h:482
static bool ToUnsigned(const char *str, unsigned *value)
Definition: tinyxml2_imp.h:458
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:496
void tinyxml2::XMLElement::SetAttribute ( const char *  name,
const char *  _value 
)
inline

Sets the named attribute to value.

Definition at line 933 of file tinyxml2.h.

References FindOrCreateAttribute(), and tinyxml2::XMLAttribute::SetAttribute().

Referenced by ShallowClone().

933 { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
XMLAttribute * FindOrCreateAttribute(const char *name)
void tinyxml2::XMLElement::SetAttribute ( const char *  name,
int  _value 
)
inline

Sets the named attribute to value.

Definition at line 935 of file tinyxml2.h.

References FindOrCreateAttribute(), and tinyxml2::XMLAttribute::SetAttribute().

935 { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
XMLAttribute * FindOrCreateAttribute(const char *name)
void tinyxml2::XMLElement::SetAttribute ( const char *  name,
unsigned  _value 
)
inline

Sets the named attribute to value.

Definition at line 937 of file tinyxml2.h.

References FindOrCreateAttribute(), and tinyxml2::XMLAttribute::SetAttribute().

937 { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
XMLAttribute * FindOrCreateAttribute(const char *name)
void tinyxml2::XMLElement::SetAttribute ( const char *  name,
bool  _value 
)
inline

Sets the named attribute to value.

Definition at line 939 of file tinyxml2.h.

References FindOrCreateAttribute(), and tinyxml2::XMLAttribute::SetAttribute().

939 { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
XMLAttribute * FindOrCreateAttribute(const char *name)
void tinyxml2::XMLElement::SetAttribute ( const char *  name,
double  _value 
)
inline

Sets the named attribute to value.

Definition at line 941 of file tinyxml2.h.

References FindOrCreateAttribute(), and tinyxml2::XMLAttribute::SetAttribute().

941 { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
XMLAttribute * FindOrCreateAttribute(const char *name)
void tinyxml2::XMLElement::SetName ( const char *  str,
bool  staticMem = false 
)
inline

Set the name of the element.

Definition at line 863 of file tinyxml2.h.

References tinyxml2::XMLNode::SetValue().

Referenced by tinyxml2::XMLDocument::NewElement().

863 { SetValue( str, staticMem ); }
void SetValue(const char *val, bool staticMem=false)
Definition: tinyxml2_imp.h:619
void XMLNode::SetValue ( const char *  val,
bool  staticMem = false 
)
inlineinherited

Set the Value of an XML node.

See also
Value()

Definition at line 619 of file tinyxml2_imp.h.

References tinyxml2::StrPair::SetInternedStr(), tinyxml2::StrPair::SetStr(), and tinyxml2::XMLNode::value.

Referenced by tinyxml2::XMLDocument::NewComment(), tinyxml2::XMLDocument::NewDeclaration(), tinyxml2::XMLDocument::NewText(), tinyxml2::XMLDocument::NewUnknown(), and SetName().

620 {
621  if ( staticMem )
622  value.SetInternedStr( str );
623  else
624  value.SetStr( str );
625 }
void SetStr(const char *str, int flags=0)
Definition: tinyxml2_imp.h:108
void SetInternedStr(const char *str)
Definition: tinyxml2.h:145
XMLNode * XMLElement::ShallowClone ( XMLDocument document) const
inlinevirtual

Make a copy of this node, but not its children. You may pass in a Document pointer that will be the owner of the new Node. If the 'document' is null, then the node returned will be allocated from the current Document. (this->GetDocument())

Note: if called on a XMLDocument, this will return null.

Implements tinyxml2::XMLNode.

Definition at line 1490 of file tinyxml2_imp.h.

References tinyxml2::XMLNode::document, FirstAttribute(), tinyxml2::XMLDocument::NewElement(), tinyxml2::XMLAttribute::Next(), SetAttribute(), and tinyxml2::XMLNode::Value().

1491 {
1492  if ( !doc ) {
1493  doc = document;
1494  }
1495  XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern?
1496  for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) {
1497  element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern?
1498  }
1499  return element;
1500 }
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:790
XMLDocument * document
Definition: tinyxml2.h:607
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:949
const char * Value() const
Definition: tinyxml2.h:482
void SetAttribute(const char *name, const char *_value)
Sets the named attribute to value.
Definition: tinyxml2.h:933
bool XMLElement::ShallowEqual ( const XMLNode compare) const
inlinevirtual

Test if 2 nodes are the same, but don't test children. The 2 nodes do not need to be in the same Document.

Note: if called on a XMLDocument, this will return false.

Implements tinyxml2::XMLNode.

Definition at line 1504 of file tinyxml2_imp.h.

References FirstAttribute(), tinyxml2::XMLAttribute::Next(), tinyxml2::XMLUtil::StringEqual(), tinyxml2::XMLNode::ToElement(), tinyxml2::XMLNode::Value(), and tinyxml2::XMLAttribute::Value().

1505 {
1506  const XMLElement* other = compare->ToElement();
1507  if ( other && XMLUtil::StringEqual( other->Value(), Value() )) {
1508 
1509  const XMLAttribute* a=FirstAttribute();
1510  const XMLAttribute* b=other->FirstAttribute();
1511 
1512  while ( a && b ) {
1513  if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) {
1514  return false;
1515  }
1516  a = a->Next();
1517  b = b->Next();
1518  }
1519  if ( a || b ) {
1520  // different count
1521  return false;
1522  }
1523  return true;
1524  }
1525  return false;
1526 }
const char * Value() const
The value of the attribute.
Definition: tinyxml2.h:789
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:790
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:459
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:949
const char * Value() const
Definition: tinyxml2.h:482
virtual XMLComment* tinyxml2::XMLNode::ToComment ( )
inlinevirtualinherited

Safely cast to a Comment, or null.

Reimplemented in tinyxml2::XMLComment.

Definition at line 461 of file tinyxml2.h.

Referenced by tinyxml2::XMLComment::ShallowEqual().

virtual const XMLComment* tinyxml2::XMLNode::ToComment ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLComment.

Definition at line 468 of file tinyxml2.h.

468 { return 0; }
virtual XMLDeclaration* tinyxml2::XMLNode::ToDeclaration ( )
inlinevirtualinherited

Safely cast to a Declaration, or null.

Reimplemented in tinyxml2::XMLDeclaration.

Definition at line 463 of file tinyxml2.h.

Referenced by tinyxml2::XMLDeclaration::ShallowEqual(), tinyxml2::XMLHandle::ToDeclaration(), and tinyxml2::XMLConstHandle::ToDeclaration().

virtual const XMLDeclaration* tinyxml2::XMLNode::ToDeclaration ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLDeclaration.

Definition at line 470 of file tinyxml2.h.

470 { return 0; }
virtual XMLDocument* tinyxml2::XMLNode::ToDocument ( )
inlinevirtualinherited

Safely cast to a Document, or null.

Reimplemented in tinyxml2::XMLDocument.

Definition at line 462 of file tinyxml2.h.

virtual const XMLDocument* tinyxml2::XMLNode::ToDocument ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLDocument.

Definition at line 469 of file tinyxml2.h.

469 { return 0; }
virtual XMLElement* tinyxml2::XMLElement::ToElement ( )
inlinevirtual

Safely cast to an Element, or null.

Reimplemented from tinyxml2::XMLNode.

Definition at line 865 of file tinyxml2.h.

Referenced by tinyxml2::XMLNode::FirstChildElement(), tinyxml2::XMLNode::LastChildElement(), tinyxml2::XMLNode::NextSiblingElement(), and tinyxml2::XMLNode::PreviousSiblingElement().

865 { return this; }
virtual const XMLElement* tinyxml2::XMLElement::ToElement ( ) const
inlinevirtual

Reimplemented from tinyxml2::XMLNode.

Definition at line 866 of file tinyxml2.h.

866 { return this; }
virtual XMLText* tinyxml2::XMLNode::ToText ( )
inlinevirtualinherited
virtual const XMLText* tinyxml2::XMLNode::ToText ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLText.

Definition at line 467 of file tinyxml2.h.

467 { return 0; }
virtual XMLUnknown* tinyxml2::XMLNode::ToUnknown ( )
inlinevirtualinherited

Safely cast to an Unknown, or null.

Reimplemented in tinyxml2::XMLUnknown.

Definition at line 464 of file tinyxml2.h.

Referenced by tinyxml2::XMLUnknown::ShallowEqual(), tinyxml2::XMLHandle::ToUnknown(), and tinyxml2::XMLConstHandle::ToUnknown().

virtual const XMLUnknown* tinyxml2::XMLNode::ToUnknown ( ) const
inlinevirtualinherited

Reimplemented in tinyxml2::XMLUnknown.

Definition at line 471 of file tinyxml2.h.

471 { return 0; }
unsigned tinyxml2::XMLElement::UnsignedAttribute ( const char *  name) const
inline

See IntAttribute()

Definition at line 901 of file tinyxml2.h.

References QueryUnsignedAttribute().

901 { unsigned i=0; QueryUnsignedAttribute( name, &i ); return i; }
int QueryUnsignedAttribute(const char *name, unsigned int *_value) const
See QueryIntAttribute()
Definition: tinyxml2.h:924
const char* tinyxml2::XMLNode::Value ( ) const
inlineinherited

Friends And Related Function Documentation

friend class XMLBase
friend

Definition at line 857 of file tinyxml2.h.

friend class XMLDocument
friend

Definition at line 858 of file tinyxml2.h.

Member Data Documentation

int tinyxml2::XMLElement::closingType
private

Definition at line 1041 of file tinyxml2.h.

Referenced by ClosingType(), ParseAttributes(), and ParseDeep().

XMLDocument* tinyxml2::XMLNode::document
protectedinherited
XMLNode* tinyxml2::XMLNode::firstChild
protectedinherited
XMLNode* tinyxml2::XMLNode::lastChild
protectedinherited
XMLNode* tinyxml2::XMLNode::next
protectedinherited
XMLNode* tinyxml2::XMLNode::parent
protectedinherited
XMLNode* tinyxml2::XMLNode::prev
protectedinherited
XMLAttribute* tinyxml2::XMLElement::rootAttribute
private
StrPair tinyxml2::XMLNode::value
mutableprotectedinherited

The documentation for this class was generated from the following files:

Generated on Thu Jul 7 2016 11:09:52 for antioch-0.4.0 by  doxygen 1.8.8