CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
TiXmlElement Class Reference

#include <tinyxml.h>

Inheritance diagram for TiXmlElement:
TiXmlNode TiXmlBase

Public Member Functions

virtual bool Accept (TiXmlVisitor *visitor) const
 
const char * Attribute (const char *name) const
 
const char * Attribute (const char *name, int *i) const
 
const char * Attribute (const char *name, double *d) const
 
const std::string * Attribute (const std::string &name) const
 
const std::string * Attribute (const std::string &name, int *i) const
 
const std::string * Attribute (const std::string &name, double *d) const
 
virtual TiXmlNodeClone () const
 Creates a new Element and returns it - the returned element is a copy. More...
 
const TiXmlAttributeFirstAttribute () const
 Access the first attribute in this element. More...
 
TiXmlAttributeFirstAttribute ()
 
const char * GetText () const
 
const TiXmlAttributeLastAttribute () const
 Access the last attribute in this element. More...
 
TiXmlAttributeLastAttribute ()
 
void operator= (const TiXmlElement &base)
 
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
 
virtual void Print (FILE *cfile, int depth) const
 
int QueryDoubleAttribute (const char *name, double *_value) const
 QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). More...
 
int QueryDoubleAttribute (const std::string &name, double *_value) const
 
int QueryFloatAttribute (const char *name, float *_value) const
 QueryFloatAttribute examines the attribute - see QueryIntAttribute(). More...
 
int QueryIntAttribute (const char *name, int *_value) const
 
int QueryIntAttribute (const std::string &name, int *_value) const
 
template<typename T >
int QueryValueAttribute (const std::string &name, T *outValue) const
 
void RemoveAttribute (const char *name)
 
void RemoveAttribute (const std::string &name)
 STL std::string form. More...
 
void SetAttribute (const char *name, const char *_value)
 
void SetAttribute (const std::string &name, const std::string &_value)
 STL std::string form. More...
 
void SetAttribute (const std::string &name, int _value)
 
void SetAttribute (const char *name, int value)
 
void SetDoubleAttribute (const char *name, double value)
 
 TiXmlElement (const char *in_value)
 Construct an element. More...
 
 TiXmlElement (const std::string &_value)
 std::string constructor. More...
 
 TiXmlElement (const TiXmlElement &)
 
virtual const TiXmlElementToElement () const
 Cast to a more defined type. Will return null not of the requested type. More...
 
virtual TiXmlElementToElement ()
 Cast to a more defined type. Will return null not of the requested type. More...
 
virtual ~TiXmlElement ()
 
- Public Member Functions inherited from TiXmlNode
void Clear ()
 Delete all the children of this node. Does not affect 'this'. More...
 
const TiXmlNodeFirstChild () const
 The first child of this node. Will be null if there are no children. More...
 
TiXmlNodeFirstChild ()
 
const TiXmlNodeFirstChild (const char *value) const
 
TiXmlNodeFirstChild (const char *_value)
 The first child of this node with the matching 'value'. Will be null if none found. More...
 
const TiXmlNodeFirstChild (const std::string &_value) const
 STL std::string form. More...
 
TiXmlNodeFirstChild (const std::string &_value)
 STL std::string form. More...
 
const TiXmlElementFirstChildElement () const
 Convenience function to get through elements. More...
 
TiXmlElementFirstChildElement ()
 
const TiXmlElementFirstChildElement (const char *_value) const
 Convenience function to get through elements. More...
 
TiXmlElementFirstChildElement (const char *_value)
 
const TiXmlElementFirstChildElement (const std::string &_value) const
 STL std::string form. More...
 
TiXmlElementFirstChildElement (const std::string &_value)
 STL std::string form. More...
 
const TiXmlDocumentGetDocument () const
 
TiXmlDocumentGetDocument ()
 
TiXmlNodeInsertAfterChild (TiXmlNode *afterThis, const TiXmlNode &addThis)
 
TiXmlNodeInsertBeforeChild (TiXmlNode *beforeThis, const TiXmlNode &addThis)
 
TiXmlNodeInsertEndChild (const TiXmlNode &addThis)
 
const TiXmlNodeIterateChildren (const TiXmlNode *previous) const
 
TiXmlNodeIterateChildren (const TiXmlNode *previous)
 
const TiXmlNodeIterateChildren (const char *value, const TiXmlNode *previous) const
 This flavor of IterateChildren searches for children with a particular 'value'. More...
 
TiXmlNodeIterateChildren (const char *_value, const TiXmlNode *previous)
 
const TiXmlNodeIterateChildren (const std::string &_value, const TiXmlNode *previous) const
 STL std::string form. More...
 
TiXmlNodeIterateChildren (const std::string &_value, const TiXmlNode *previous)
 STL std::string form. More...
 
const TiXmlNodeLastChild () const
 
TiXmlNodeLastChild ()
 The last child of this node. Will be null if there are no children. More...
 
const TiXmlNodeLastChild (const char *value) const
 
TiXmlNodeLastChild (const char *_value)
 The last child of this node matching 'value'. Will be null if there are no children. More...
 
const TiXmlNodeLastChild (const std::string &_value) const
 STL std::string form. More...
 
TiXmlNodeLastChild (const std::string &_value)
 STL std::string form. More...
 
TiXmlNodeLinkEndChild (TiXmlNode *addThis)
 
const TiXmlNodeNextSibling (const std::string &_value) const
 STL std::string form. More...
 
TiXmlNodeNextSibling (const std::string &_value)
 STL std::string form. More...
 
const TiXmlNodeNextSibling () const
 Navigate to a sibling node. More...
 
TiXmlNodeNextSibling ()
 
const TiXmlNodeNextSibling (const char *) const
 Navigate to a sibling node with the given 'value'. More...
 
TiXmlNodeNextSibling (const char *_next)
 
const TiXmlElementNextSiblingElement () const
 
TiXmlElementNextSiblingElement ()
 
const TiXmlElementNextSiblingElement (const char *) const
 
TiXmlElementNextSiblingElement (const char *_next)
 
const TiXmlElementNextSiblingElement (const std::string &_value) const
 STL std::string form. More...
 
TiXmlElementNextSiblingElement (const std::string &_value)
 STL std::string form. More...
 
bool NoChildren () const
 Returns true if this node has no children. More...
 
TiXmlNodeParent ()
 One step up the DOM. More...
 
const TiXmlNodeParent () const
 
const TiXmlNodePreviousSibling () const
 Navigate to a sibling node. More...
 
TiXmlNodePreviousSibling ()
 
const TiXmlNodePreviousSibling (const char *) const
 Navigate to a sibling node. More...
 
TiXmlNodePreviousSibling (const char *_prev)
 
const TiXmlNodePreviousSibling (const std::string &_value) const
 STL std::string form. More...
 
TiXmlNodePreviousSibling (const std::string &_value)
 STL std::string form. More...
 
bool RemoveChild (TiXmlNode *removeThis)
 Delete a child of this node. More...
 
TiXmlNodeReplaceChild (TiXmlNode *replaceThis, const TiXmlNode &withThis)
 
void SetValue (const char *_value)
 
void SetValue (const std::string &_value)
 STL std::string form. More...
 
virtual const TiXmlCommentToComment () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlCommentToComment ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlDeclarationToDeclaration () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlDeclarationToDeclaration ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlDocumentToDocument () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlDocumentToDocument ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlTextToText () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlTextToText ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual const TiXmlUnknownToUnknown () const
 Cast to a more defined type. Will return null if not of the requested type. More...
 
virtual TiXmlUnknownToUnknown ()
 Cast to a more defined type. Will return null if not of the requested type. More...
 
int Type () const
 
const char * Value () const
 
const std::string & ValueStr () const
 
const TIXML_STRINGValueTStr () const
 
virtual ~TiXmlNode ()
 
- Public Member Functions inherited from TiXmlBase
int Column () const
 See Row() More...
 
void * GetUserData ()
 Get a pointer to arbitrary user data. More...
 
const void * GetUserData () const
 Get a pointer to arbitrary user data. More...
 
int Row () const
 
void SetUserData (void *user)
 Set a pointer to arbitrary user data. More...
 
 TiXmlBase ()
 
virtual ~TiXmlBase ()
 

Protected Member Functions

void ClearThis ()
 
void CopyTo (TiXmlElement *target) const
 
const char * ReadValue (const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
 
virtual void StreamIn (std::istream *in, TIXML_STRING *tag)
 
- Protected Member Functions inherited from TiXmlNode
void CopyTo (TiXmlNode *target) const
 
TiXmlNodeIdentify (const char *start, TiXmlEncoding encoding)
 
 TiXmlNode (NodeType _type)
 

Private Attributes

TiXmlAttributeSet attributeSet
 

Additional Inherited Members

- Public Types inherited from TiXmlNode
enum  NodeType {
  DOCUMENT, ELEMENT, COMMENT, UNKNOWN,
  TEXT, DECLARATION, TYPECOUNT
}
 
- Public Types inherited from TiXmlBase
enum  {
  TIXML_NO_ERROR = 0, TIXML_ERROR, TIXML_ERROR_OPENING_FILE, TIXML_ERROR_OUT_OF_MEMORY,
  TIXML_ERROR_PARSING_ELEMENT, TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, TIXML_ERROR_READING_ELEMENT_VALUE, TIXML_ERROR_READING_ATTRIBUTES,
  TIXML_ERROR_PARSING_EMPTY, TIXML_ERROR_READING_END_TAG, TIXML_ERROR_PARSING_UNKNOWN, TIXML_ERROR_PARSING_COMMENT,
  TIXML_ERROR_PARSING_DECLARATION, TIXML_ERROR_DOCUMENT_EMPTY, TIXML_ERROR_EMBEDDED_NULL, TIXML_ERROR_PARSING_CDATA,
  TIXML_ERROR_DOCUMENT_TOP_ONLY, TIXML_ERROR_STRING_COUNT
}
 
- Static Public Member Functions inherited from TiXmlBase
static void EncodeString (const TIXML_STRING &str, TIXML_STRING *out)
 
static bool IsWhiteSpaceCondensed ()
 Return the current white space setting. More...
 
static void SetCondenseWhiteSpace (bool condense)
 
- Static Public Attributes inherited from TiXmlBase
static const int utf8ByteTable [256]
 
- Static Protected Member Functions inherited from TiXmlBase
static void ConvertUTF32ToUTF8 (unsigned long input, char *output, int *length)
 
static const char * GetChar (const char *p, char *_value, int *length, TiXmlEncoding encoding)
 
static const char * GetEntity (const char *in, char *value, int *length, TiXmlEncoding encoding)
 
static int IsAlpha (unsigned char anyByte, TiXmlEncoding encoding)
 
static int IsAlphaNum (unsigned char anyByte, TiXmlEncoding encoding)
 
static bool IsWhiteSpace (char c)
 
static bool IsWhiteSpace (int c)
 
static const char * ReadName (const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
 
static const char * ReadText (const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
 
static const char * SkipWhiteSpace (const char *, TiXmlEncoding encoding)
 
static bool StreamTo (std::istream *in, int character, TIXML_STRING *tag)
 
static bool StreamWhiteSpace (std::istream *in, TIXML_STRING *tag)
 
static bool StringEqual (const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
 
static int ToLower (int v, TiXmlEncoding encoding)
 
- Protected Attributes inherited from TiXmlNode
TiXmlNodefirstChild
 
TiXmlNodelastChild
 
TiXmlNodenext
 
TiXmlNodeparent
 
TiXmlNodeprev
 
NodeType type
 
TIXML_STRING value
 
- Protected Attributes inherited from TiXmlBase
TiXmlCursor location
 
void * userData
 Field containing a generic user pointer. More...
 
- Static Protected Attributes inherited from TiXmlBase
static const char * errorString [TIXML_ERROR_STRING_COUNT]
 

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 945 of file tinyxml.h.

Constructor & Destructor Documentation

TiXmlElement::TiXmlElement ( const char *  in_value)

Construct an element.

Definition at line 506 of file tinyxml.cc.

References TiXmlNode::firstChild, TiXmlNode::lastChild, and TiXmlNode::value.

Referenced by Clone().

508 {
509  firstChild = lastChild = 0;
510  value = _value;
511 }
TiXmlNode * firstChild
Definition: tinyxml.h:760
TiXmlNode(NodeType _type)
Definition: tinyxml.cc:137
TIXML_STRING value
Definition: tinyxml.h:763
TiXmlNode * lastChild
Definition: tinyxml.h:761
TiXmlElement::TiXmlElement ( const std::string &  _value)

std::string constructor.

Definition at line 515 of file tinyxml.cc.

References TiXmlNode::firstChild, TiXmlNode::lastChild, and TiXmlNode::value.

517 {
518  firstChild = lastChild = 0;
519  value = _value;
520 }
TiXmlNode * firstChild
Definition: tinyxml.h:760
TiXmlNode(NodeType _type)
Definition: tinyxml.cc:137
TIXML_STRING value
Definition: tinyxml.h:763
TiXmlNode * lastChild
Definition: tinyxml.h:761
TiXmlElement::TiXmlElement ( const TiXmlElement copy)

Definition at line 524 of file tinyxml.cc.

References CopyTo(), TiXmlNode::firstChild, and TiXmlNode::lastChild.

526 {
527  firstChild = lastChild = 0;
528  copy.CopyTo( this );
529 }
TiXmlNode * firstChild
Definition: tinyxml.h:760
TiXmlNode(NodeType _type)
Definition: tinyxml.cc:137
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cc:826
TiXmlNode * lastChild
Definition: tinyxml.h:761
TiXmlElement::~TiXmlElement ( )
virtual

Definition at line 539 of file tinyxml.cc.

References ClearThis().

540 {
541  ClearThis();
542 }
void ClearThis()
Definition: tinyxml.cc:545

Member Function Documentation

bool TiXmlElement::Accept ( TiXmlVisitor visitor) const
virtual

Walk the XML tree visiting this node and all of its children.

Implements TiXmlNode.

Definition at line 848 of file tinyxml.cc.

References attributeSet, TiXmlAttributeSet::First(), TiXmlNode::FirstChild(), python.Node::node, TiXmlVisitor::VisitEnter(), and TiXmlVisitor::VisitExit().

849 {
850  if ( visitor->VisitEnter( *this, attributeSet.First() ) )
851  {
852  for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
853  {
854  if ( !node->Accept( visitor ) )
855  break;
856  }
857  }
858  return visitor->VisitExit( *this );
859 }
const TiXmlAttribute * First() const
Definition: tinyxml.h:914
tuple node
Definition: Node.py:50
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:136
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:524
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:138
const char * TiXmlElement::Attribute ( const char *  name) const

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

Definition at line 557 of file tinyxml.cc.

References attributeSet, TiXmlAttributeSet::Find(), python.Node::node, and TiXmlAttribute::Value().

Referenced by Attribute().

558 {
560  if ( node )
561  return node->Value();
562  return 0;
563 }
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:814
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
const char * TiXmlElement::Attribute ( const char *  name,
int *  i 
) const

Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. If the attribute exists and can be converted to an integer, the integer value will be put in the return 'i', if 'i' is non-null.

Definition at line 577 of file tinyxml.cc.

References Attribute(), and asciidump::s.

578 {
579  const char* s = Attribute( name );
580  if ( i )
581  {
582  if ( s ) {
583  *i = atoi( s );
584  }
585  else {
586  *i = 0;
587  }
588  }
589  return s;
590 }
int i
Definition: DBlmapReader.cc:9
string s
Definition: asciidump.py:422
const char * Attribute(const char *name) const
Definition: tinyxml.cc:557
const char * TiXmlElement::Attribute ( const char *  name,
double *  d 
) const

Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. If the attribute exists and can be converted to an double, the double value will be put in the return 'd', if 'd' is non-null.

Definition at line 611 of file tinyxml.cc.

References Attribute(), and asciidump::s.

612 {
613  const char* s = Attribute( name );
614  if ( d )
615  {
616  if ( s ) {
617  *d = atof( s );
618  }
619  else {
620  *d = 0;
621  }
622  }
623  return s;
624 }
string s
Definition: asciidump.py:422
const char * Attribute(const char *name) const
Definition: tinyxml.cc:557
const std::string * TiXmlElement::Attribute ( const std::string &  name) const

Definition at line 567 of file tinyxml.cc.

References attributeSet, TiXmlAttributeSet::Find(), python.Node::node, and TiXmlAttribute::ValueStr().

568 {
570  if ( node )
571  return &node->ValueStr();
572  return 0;
573 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
const std::string & ValueStr() const
Return the value of this attribute.
Definition: tinyxml.h:816
const std::string * TiXmlElement::Attribute ( const std::string &  name,
int *  i 
) const

Definition at line 594 of file tinyxml.cc.

References Attribute(), and asciidump::s.

595 {
596  const std::string* s = Attribute( name );
597  if ( i )
598  {
599  if ( s ) {
600  *i = atoi( s->c_str() );
601  }
602  else {
603  *i = 0;
604  }
605  }
606  return s;
607 }
int i
Definition: DBlmapReader.cc:9
string s
Definition: asciidump.py:422
const char * Attribute(const char *name) const
Definition: tinyxml.cc:557
const std::string * TiXmlElement::Attribute ( const std::string &  name,
double *  d 
) const

Definition at line 628 of file tinyxml.cc.

References Attribute(), and asciidump::s.

629 {
630  const std::string* s = Attribute( name );
631  if ( d )
632  {
633  if ( s ) {
634  *d = atof( s->c_str() );
635  }
636  else {
637  *d = 0;
638  }
639  }
640  return s;
641 }
string s
Definition: asciidump.py:422
const char * Attribute(const char *name) const
Definition: tinyxml.cc:557
void TiXmlElement::ClearThis ( )
protected

Definition at line 545 of file tinyxml.cc.

References attributeSet, TiXmlNode::Clear(), TiXmlAttributeSet::First(), python.Node::node, and TiXmlAttributeSet::Remove().

Referenced by operator=(), and ~TiXmlElement().

546 {
547  Clear();
548  while( attributeSet.First() )
549  {
551  attributeSet.Remove( node );
552  delete node;
553  }
554 }
const TiXmlAttribute * First() const
Definition: tinyxml.h:914
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
void Remove(TiXmlAttribute *attribute)
Definition: tinyxml.cc:1533
void Clear()
Delete all the children of this node. Does not affect &#39;this&#39;.
Definition: tinyxml.cc:169
TiXmlNode * TiXmlElement::Clone ( ) const
virtual

Creates a new Element and returns it - the returned element is a copy.

Implements TiXmlNode.

Definition at line 862 of file tinyxml.cc.

References clone(), CopyTo(), TiXmlElement(), and TiXmlNode::Value().

863 {
864  TiXmlElement* clone = new TiXmlElement( Value() );
865  if ( !clone )
866  return 0;
867 
868  CopyTo( clone );
869  return clone;
870 }
TiXmlElement(const char *in_value)
Construct an element.
Definition: tinyxml.cc:506
T * clone(const T *tp)
Definition: Ptr.h:42
const char * Value() const
Definition: tinyxml.h:489
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cc:826
void TiXmlElement::CopyTo ( TiXmlElement target) const
protected

Definition at line 826 of file tinyxml.cc.

References attributeSet, TiXmlNode::Clone(), TiXmlNode::CopyTo(), TiXmlAttributeSet::First(), TiXmlNode::firstChild, TiXmlNode::LinkEndChild(), TiXmlAttribute::Name(), TiXmlAttribute::Next(), TiXmlNode::NextSibling(), python.Node::node, SetAttribute(), and TiXmlAttribute::Value().

Referenced by Clone(), operator=(), and TiXmlElement().

827 {
828  // superclass:
829  TiXmlNode::CopyTo( target );
830 
831  // Element class:
832  // Clone the attributes, then clone the children.
833  const TiXmlAttribute* attribute = 0;
834  for( attribute = attributeSet.First();
835  attribute;
836  attribute = attribute->Next() )
837  {
838  target->SetAttribute( attribute->Name(), attribute->Value() );
839  }
840 
841  TiXmlNode* node = 0;
842  for ( node = firstChild; node; node = node->NextSibling() )
843  {
844  target->LinkEndChild( node->Clone() );
845  }
846 }
const TiXmlAttribute * First() const
Definition: tinyxml.h:914
TiXmlNode * firstChild
Definition: tinyxml.h:760
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:814
tuple node
Definition: Node.py:50
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Definition: tinyxml.cc:186
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:813
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
Definition: tinyxml.cc:1176
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:719
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:628
void CopyTo(TiXmlNode *target) const
Definition: tinyxml.cc:162
virtual TiXmlNode * Clone() const =0
const TiXmlAttribute* TiXmlElement::FirstAttribute ( ) const
inline

Access the first attribute in this element.

Definition at line 1076 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::First().

TiXmlAttribute* TiXmlElement::FirstAttribute ( )
inline

Definition at line 1077 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::First().

1077 { return attributeSet.First(); }
const TiXmlAttribute * First() const
Definition: tinyxml.h:914
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const char * TiXmlElement::GetText ( ) const

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 ".

WARNING: GetText() accesses a child node - don't become confused with the similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are safe type casts on the referenced node.

Definition at line 873 of file tinyxml.cc.

References TiXmlNode::FirstChild(), TiXmlNode::ToText(), and TiXmlNode::Value().

874 {
875  const TiXmlNode* child = this->FirstChild();
876  if ( child ) {
877  const TiXmlText* childText = child->ToText();
878  if ( childText ) {
879  return childText->Value();
880  }
881  }
882  return 0;
883 }
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:524
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:703
const char * Value() const
Definition: tinyxml.h:489
const TiXmlAttribute* TiXmlElement::LastAttribute ( ) const
inline

Access the last attribute in this element.

Definition at line 1078 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::Last().

TiXmlAttribute* TiXmlElement::LastAttribute ( )
inline

Definition at line 1079 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::Last().

1079 { return attributeSet.Last(); }
const TiXmlAttribute * Last() const
Definition: tinyxml.h:916
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
void TiXmlElement::operator= ( const TiXmlElement base)

Definition at line 532 of file tinyxml.cc.

References ClearThis(), and CopyTo().

533 {
534  ClearThis();
535  base.CopyTo( this );
536 }
void ClearThis()
Definition: tinyxml.cc:545
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cc:826
const char * TiXmlElement::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
)
virtual

Implements TiXmlBase.

Definition at line 1054 of file tinyxmlparser.cc.

References TiXmlAttributeSet::Add(), attributeSet, TiXmlParsingData::Cursor(), TiXmlAttributeSet::Find(), TiXmlNode::GetDocument(), TiXmlBase::location, TiXmlAttribute::Name(), TiXmlAttribute::NameTStr(), python.Node::node, L1TEmulatorMonitor_cff::p, TiXmlAttribute::Parse(), TiXmlBase::ReadName(), ReadValue(), TiXmlAttribute::SetDocument(), TiXmlDocument::SetError(), TiXmlAttribute::SetValue(), TiXmlBase::SkipWhiteSpace(), TiXmlParsingData::Stamp(), TiXmlBase::StringEqual(), TiXmlBase::TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY, TiXmlBase::TIXML_ERROR_PARSING_ELEMENT, TiXmlBase::TIXML_ERROR_PARSING_EMPTY, TiXmlBase::TIXML_ERROR_READING_ATTRIBUTES, TiXmlBase::TIXML_ERROR_READING_END_TAG, TIXML_STRING, TiXmlNode::value, and TiXmlAttribute::Value().

1055 {
1056  p = SkipWhiteSpace( p, encoding );
1057  TiXmlDocument* document = GetDocument();
1058 
1059  if ( !p || !*p )
1060  {
1061  if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding );
1062  return 0;
1063  }
1064 
1065  if ( data )
1066  {
1067  data->Stamp( p, encoding );
1068  location = data->Cursor();
1069  }
1070 
1071  if ( *p != '<' )
1072  {
1073  if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding );
1074  return 0;
1075  }
1076 
1077  p = SkipWhiteSpace( p+1, encoding );
1078 
1079  // Read the name.
1080  const char* pErr = p;
1081 
1082  p = ReadName( p, &value, encoding );
1083  if ( !p || !*p )
1084  {
1085  if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding );
1086  return 0;
1087  }
1088 
1089  TIXML_STRING endTag ("</");
1090  endTag += value;
1091  endTag += ">";
1092 
1093  // Check for and read attributes. Also look for an empty
1094  // tag or an end tag.
1095  while ( p && *p )
1096  {
1097  pErr = p;
1098  p = SkipWhiteSpace( p, encoding );
1099  if ( !p || !*p )
1100  {
1101  if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
1102  return 0;
1103  }
1104  if ( *p == '/' )
1105  {
1106  ++p;
1107  // Empty tag.
1108  if ( *p != '>' )
1109  {
1110  if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
1111  return 0;
1112  }
1113  return (p+1);
1114  }
1115  else if ( *p == '>' )
1116  {
1117  // Done with attributes (if there were any.)
1118  // Read the value -- which can include other
1119  // elements -- read the end tag, and return.
1120  ++p;
1121  p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens.
1122  if ( !p || !*p ) {
1123  // We were looking for the end tag, but found nothing.
1124  // Fix for [ 1663758 ] Failure to report error on bad XML
1125  if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
1126  return 0;
1127  }
1128 
1129  // We should find the end tag now
1130  if ( StringEqual( p, endTag.c_str(), false, encoding ) )
1131  {
1132  p += endTag.length();
1133  return p;
1134  }
1135  else
1136  {
1137  if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
1138  return 0;
1139  }
1140  }
1141  else
1142  {
1143  // Try to read an attribute:
1144  TiXmlAttribute* attrib = new TiXmlAttribute();
1145  if ( !attrib )
1146  {
1147  if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
1148  return 0;
1149  }
1150 
1151  attrib->SetDocument( document );
1152  pErr = p;
1153  p = attrib->Parse( p, data, encoding );
1154 
1155  if ( !p || !*p )
1156  {
1157  if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
1158  delete attrib;
1159  return 0;
1160  }
1161 
1162  // Handle the strange case of double attributes:
1163  #ifdef TIXML_USE_STL
1164  TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() );
1165  #else
1166  TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
1167  #endif
1168  if ( node )
1169  {
1170  node->SetValue( attrib->Value() );
1171  delete attrib;
1172  return 0;
1173  }
1174 
1175  attributeSet.Add( attrib );
1176  }
1177  }
1178  return p;
1179 }
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
const TIXML_STRING & NameTStr() const
Definition: tinyxml.h:822
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:814
const TiXmlCursor & Cursor()
tuple node
Definition: Node.py:50
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:813
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
TiXmlCursor location
Definition: tinyxml.h:375
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
const char * ReadValue(const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
void Add(TiXmlAttribute *attribute)
Definition: tinyxml.cc:1518
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cc:493
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
void Stamp(const char *now, TiXmlEncoding encoding)
TIXML_STRING value
Definition: tinyxml.h:763
void SetDocument(TiXmlDocument *doc)
Definition: tinyxml.h:879
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:838
#define TIXML_STRING
Definition: tinyxml.h:51
void TiXmlElement::Print ( FILE *  cfile,
int  depth 
) const
virtual

All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.) Either or both cfile and str can be null.

This is a formatted print, and will insert tabs and newlines.

(For an unformatted stream, use the << operator.)

Implements TiXmlBase.

Definition at line 773 of file tinyxml.cc.

References attributeSet, TiXmlAttributeSet::First(), TiXmlNode::firstChild, i, TiXmlNode::lastChild, TiXmlAttribute::Next(), TiXmlNode::NextSibling(), python.Node::node, TiXmlBase::Print(), TiXmlNode::ToText(), and TiXmlNode::value.

774 {
775  int i;
776  assert( cfile );
777  for ( i=0; i<depth; i++ ) {
778  fprintf( cfile, " " );
779  }
780 
781  fprintf( cfile, "<%s", value.c_str() );
782 
783  const TiXmlAttribute* attrib;
784  for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
785  {
786  fprintf( cfile, " " );
787  attrib->Print( cfile, depth );
788  }
789 
790  // There are 3 different formatting approaches:
791  // 1) An element without children is printed as a <foo /> node
792  // 2) An element with only a text child is printed as <foo> text </foo>
793  // 3) An element with children is printed on multiple lines.
794  TiXmlNode* node;
795  if ( !firstChild )
796  {
797  fprintf( cfile, " />" );
798  }
799  else if ( firstChild == lastChild && firstChild->ToText() )
800  {
801  fprintf( cfile, ">" );
802  firstChild->Print( cfile, depth + 1 );
803  fprintf( cfile, "</%s>", value.c_str() );
804  }
805  else
806  {
807  fprintf( cfile, ">" );
808 
809  for ( node = firstChild; node; node=node->NextSibling() )
810  {
811  if ( !node->ToText() )
812  {
813  fprintf( cfile, "\n" );
814  }
815  node->Print( cfile, depth+1 );
816  }
817  fprintf( cfile, "\n" );
818  for( i=0; i<depth; ++i ) {
819  fprintf( cfile, " " );
820  }
821  fprintf( cfile, "</%s>", value.c_str() );
822  }
823 }
const TiXmlAttribute * First() const
Definition: tinyxml.h:914
int i
Definition: DBlmapReader.cc:9
TiXmlNode * firstChild
Definition: tinyxml.h:760
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
Definition: tinyxml.cc:1176
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:628
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:703
TIXML_STRING value
Definition: tinyxml.h:763
TiXmlNode * lastChild
Definition: tinyxml.h:761
virtual void Print(FILE *cfile, int depth) const =0
int TiXmlElement::QueryDoubleAttribute ( const char *  name,
double *  _value 
) const

QueryDoubleAttribute examines the attribute - see QueryIntAttribute().

Definition at line 665 of file tinyxml.cc.

References attributeSet, TiXmlAttributeSet::Find(), python.Node::node, TiXmlAttribute::QueryDoubleValue(), and TIXML_NO_ATTRIBUTE.

Referenced by QueryFloatAttribute().

666 {
668  if ( !node )
669  return TIXML_NO_ATTRIBUTE;
670  return node->QueryDoubleValue( dval );
671 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
Definition: tinyxml.cc:1249
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
int TiXmlElement::QueryDoubleAttribute ( const std::string &  name,
double *  _value 
) const

Definition at line 675 of file tinyxml.cc.

References attributeSet, TiXmlAttributeSet::Find(), python.Node::node, TiXmlAttribute::QueryDoubleValue(), and TIXML_NO_ATTRIBUTE.

676 {
678  if ( !node )
679  return TIXML_NO_ATTRIBUTE;
680  return node->QueryDoubleValue( dval );
681 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
Definition: tinyxml.cc:1249
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
int TiXmlElement::QueryFloatAttribute ( const char *  name,
float *  _value 
) const
inline

QueryFloatAttribute examines the attribute - see QueryIntAttribute().

Definition at line 994 of file tinyxml.h.

References QueryDoubleAttribute(), query::result, and TIXML_SUCCESS.

994  {
995  double d;
996  int result = QueryDoubleAttribute( name, &d );
997  if ( result == TIXML_SUCCESS ) {
998  *_value = (float)d;
999  }
1000  return result;
1001  }
tuple result
Definition: query.py:137
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.cc:665
int TiXmlElement::QueryIntAttribute ( const char *  name,
int *  _value 
) const

QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking. If the attribute is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE. If the attribute does not exist, then TIXML_NO_ATTRIBUTE is returned.

Definition at line 645 of file tinyxml.cc.

References attributeSet, TiXmlAttributeSet::Find(), python.Node::node, TiXmlAttribute::QueryIntValue(), and TIXML_NO_ATTRIBUTE.

646 {
648  if ( !node )
649  return TIXML_NO_ATTRIBUTE;
650  return node->QueryIntValue( ival );
651 }
int QueryIntValue(int *_value) const
Definition: tinyxml.cc:1242
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
int TiXmlElement::QueryIntAttribute ( const std::string &  name,
int *  _value 
) const

Definition at line 655 of file tinyxml.cc.

References attributeSet, TiXmlAttributeSet::Find(), python.Node::node, TiXmlAttribute::QueryIntValue(), and TIXML_NO_ATTRIBUTE.

656 {
658  if ( !node )
659  return TIXML_NO_ATTRIBUTE;
660  return node->QueryIntValue( ival );
661 }
int QueryIntValue(int *_value) const
Definition: tinyxml.cc:1242
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
template<typename T >
int TiXmlElement::QueryValueAttribute ( const std::string &  name,
T outValue 
) const
inline

Template form of the attribute query which will try to read the attribute into the specified type. Very easy, very powerful, but be careful to make sure to call this with the correct type.

NOTE: This method doesn't work correctly for 'string' types.

Returns
TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE

Definition at line 1012 of file tinyxml.h.

References attributeSet, TiXmlAttributeSet::Find(), python.Node::node, TIXML_NO_ATTRIBUTE, TIXML_SUCCESS, TIXML_WRONG_TYPE, and TiXmlAttribute::ValueStr().

1013  {
1015  if ( !node )
1016  return TIXML_NO_ATTRIBUTE;
1017 
1018  std::stringstream sstream( node->ValueStr() );
1019  sstream >> *outValue;
1020  if ( !sstream.fail() )
1021  return TIXML_SUCCESS;
1022  return TIXML_WRONG_TYPE;
1023  }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
const std::string & ValueStr() const
Return the value of this attribute.
Definition: tinyxml.h:816
const char * TiXmlElement::ReadValue ( const char *  in,
TiXmlParsingData prevData,
TiXmlEncoding  encoding 
)
protected

Definition at line 1182 of file tinyxmlparser.cc.

References TiXmlText::Blank(), TiXmlNode::GetDocument(), TiXmlNode::Identify(), TiXmlBase::IsWhiteSpaceCondensed(), TiXmlNode::LinkEndChild(), python.Node::node, L1TEmulatorMonitor_cff::p, TiXmlBase::Parse(), TiXmlText::Parse(), TiXmlDocument::SetError(), TiXmlBase::SkipWhiteSpace(), TiXmlBase::StringEqual(), TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY, and TiXmlBase::TIXML_ERROR_READING_ELEMENT_VALUE.

Referenced by Parse().

1183 {
1184  TiXmlDocument* document = GetDocument();
1185 
1186  // Read in text and elements in any order.
1187  const char* pWithWhiteSpace = p;
1188  p = SkipWhiteSpace( p, encoding );
1189 
1190  while ( p && *p )
1191  {
1192  if ( *p != '<' )
1193  {
1194  // Take what we have, make a text element.
1195  TiXmlText* textNode = new TiXmlText( "" );
1196 
1197  if ( !textNode )
1198  {
1199  if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
1200  return 0;
1201  }
1202 
1204  {
1205  p = textNode->Parse( p, data, encoding );
1206  }
1207  else
1208  {
1209  // Special case: we want to keep the white space
1210  // so that leading spaces aren't removed.
1211  p = textNode->Parse( pWithWhiteSpace, data, encoding );
1212  }
1213 
1214  if ( !textNode->Blank() )
1215  LinkEndChild( textNode );
1216  else
1217  delete textNode;
1218  }
1219  else
1220  {
1221  // We hit a '<'
1222  // Have we hit a new element or an end tag? This could also be
1223  // a TiXmlText in the "CDATA" style.
1224  if ( StringEqual( p, "</", false, encoding ) )
1225  {
1226  return p;
1227  }
1228  else
1229  {
1230  TiXmlNode* node = Identify( p, encoding );
1231  if ( node )
1232  {
1233  p = node->Parse( p, data, encoding );
1234  LinkEndChild( node );
1235  }
1236  else
1237  {
1238  return 0;
1239  }
1240  }
1241  }
1242  pWithWhiteSpace = p;
1243  p = SkipWhiteSpace( p, encoding );
1244  }
1245 
1246  if ( !p )
1247  {
1248  if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
1249  }
1250  return p;
1251 }
tuple node
Definition: Node.py:50
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Definition: tinyxml.cc:186
bool Blank() const
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition: tinyxml.h:226
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cc:493
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
void TiXmlElement::RemoveAttribute ( const char *  name)

Deletes an attribute with the given name.

Definition at line 418 of file tinyxml.cc.

References attributeSet, TiXmlAttributeSet::Find(), python.Node::node, TiXmlAttributeSet::Remove(), and TIXML_STRING.

419 {
420  #ifdef TIXML_USE_STL
421  TIXML_STRING str( name );
423  #else
425  #endif
426  if ( node )
427  {
428  attributeSet.Remove( node );
429  delete node;
430  }
431 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
void Remove(TiXmlAttribute *attribute)
Definition: tinyxml.cc:1533
#define TIXML_STRING
Definition: tinyxml.h:51
void TiXmlElement::RemoveAttribute ( const std::string &  name)
inline

STL std::string form.

Definition at line 1073 of file tinyxml.h.

References RemoveAttribute().

Referenced by RemoveAttribute().

void TiXmlElement::SetAttribute ( const char *  name,
const char *  _value 
)

Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does.

Definition at line 719 of file tinyxml.cc.

References TiXmlAttributeSet::Add(), attributeSet, TiXmlAttributeSet::Find(), TiXmlNode::GetDocument(), python.Node::node, TiXmlDocument::SetError(), TiXmlAttribute::SetValue(), TIXML_ENCODING_UNKNOWN, TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY, and TIXML_STRING.

Referenced by CopyTo(), edm::JobReport::reportSkippedFile(), SetAttribute(), and SetDoubleAttribute().

720 {
721  #ifdef TIXML_USE_STL
722  TIXML_STRING _name( cname );
723  TIXML_STRING _value( cvalue );
724  #else
725  const char* _name = cname;
726  const char* _value = cvalue;
727  #endif
728 
729  TiXmlAttribute* node = attributeSet.Find( _name );
730  if ( node )
731  {
732  node->SetValue( _value );
733  return;
734  }
735 
736  TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue );
737  if ( attrib )
738  {
739  attributeSet.Add( attrib );
740  }
741  else
742  {
743  TiXmlDocument* document = GetDocument();
744  if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
745  }
746 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
void Add(TiXmlAttribute *attribute)
Definition: tinyxml.cc:1518
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cc:493
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:838
#define TIXML_STRING
Definition: tinyxml.h:51
void TiXmlElement::SetAttribute ( const std::string &  name,
const std::string &  _value 
)

STL std::string form.

STL std::string form.

Definition at line 750 of file tinyxml.cc.

References TiXmlAttributeSet::Add(), attributeSet, TiXmlAttributeSet::Find(), TiXmlNode::GetDocument(), python.Node::node, TiXmlDocument::SetError(), TiXmlAttribute::SetValue(), TIXML_ENCODING_UNKNOWN, and TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY.

751 {
753  if ( node )
754  {
755  node->SetValue( _value );
756  return;
757  }
758 
759  TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
760  if ( attrib )
761  {
762  attributeSet.Add( attrib );
763  }
764  else
765  {
766  TiXmlDocument* document = GetDocument();
767  if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
768  }
769 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1149
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1577
void Add(TiXmlAttribute *attribute)
Definition: tinyxml.cc:1518
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cc:493
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:838
void TiXmlElement::SetAttribute ( const std::string &  name,
int  _value 
)

Definition at line 698 of file tinyxml.cc.

References SetAttribute().

699 {
700  std::ostringstream oss;
701  oss << val;
702  SetAttribute( name, oss.str() );
703 }
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:719
void TiXmlElement::SetAttribute ( const char *  name,
int  value 
)

Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does.

Definition at line 685 of file tinyxml.cc.

References SetAttribute().

686 {
687  char buf[64];
688  #if defined(TIXML_SNPRINTF)
689  TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
690  #else
691  sprintf( buf, "%d", val );
692  #endif
693  SetAttribute( name, buf );
694 }
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:719
void TiXmlElement::SetDoubleAttribute ( const char *  name,
double  value 
)

Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does.

Definition at line 707 of file tinyxml.cc.

References SetAttribute().

708 {
709  char buf[256];
710  #if defined(TIXML_SNPRINTF)
711  TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
712  #else
713  sprintf( buf, "%f", val );
714  #endif
715  SetAttribute( name, buf );
716 }
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:719
void TiXmlElement::StreamIn ( std::istream *  in,
TIXML_STRING tag 
)
protectedvirtual

Implements TiXmlNode.

Definition at line 914 of file tinyxmlparser.cc.

References trackerHits::c, TiXmlNode::GetDocument(), TiXmlNode::Identify(), TiXmlBase::IsWhiteSpace(), python.Node::node, TiXmlDocument::SetError(), TiXmlNode::StreamIn(), TiXmlText::StreamIn(), TiXmlBase::StreamWhiteSpace(), runonSM::text, TIXML_DEFAULT_ENCODING, TIXML_ENCODING_UNKNOWN, and TiXmlBase::TIXML_ERROR_EMBEDDED_NULL.

915 {
916  // We're called with some amount of pre-parsing. That is, some of "this"
917  // element is in "tag". Go ahead and stream to the closing ">"
918  while( in->good() )
919  {
920  int c = in->get();
921  if ( c <= 0 )
922  {
923  TiXmlDocument* document = GetDocument();
924  if ( document )
926  return;
927  }
928  (*tag) += (char) c ;
929 
930  if ( c == '>' )
931  break;
932  }
933 
934  if ( tag->length() < 3 ) return;
935 
936  // Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
937  // If not, identify and stream.
938 
939  if ( tag->at( tag->length() - 1 ) == '>'
940  && tag->at( tag->length() - 2 ) == '/' )
941  {
942  // All good!
943  return;
944  }
945  else if ( tag->at( tag->length() - 1 ) == '>' )
946  {
947  // There is more. Could be:
948  // text
949  // cdata text (which looks like another node)
950  // closing tag
951  // another node.
952  for ( ;; )
953  {
954  StreamWhiteSpace( in, tag );
955 
956  // Do we have text?
957  if ( in->good() && in->peek() != '<' )
958  {
959  // Yep, text.
960  TiXmlText text( "" );
961  text.StreamIn( in, tag );
962 
963  // What follows text is a closing tag or another node.
964  // Go around again and figure it out.
965  continue;
966  }
967 
968  // We now have either a closing tag...or another node.
969  // We should be at a "<", regardless.
970  if ( !in->good() ) return;
971  assert( in->peek() == '<' );
972  int tagIndex = (int) tag->length();
973 
974  bool closingTag = false;
975  bool firstCharFound = false;
976 
977  for( ;; )
978  {
979  if ( !in->good() )
980  return;
981 
982  int c = in->peek();
983  if ( c <= 0 )
984  {
985  TiXmlDocument* document = GetDocument();
986  if ( document )
988  return;
989  }
990 
991  if ( c == '>' )
992  break;
993 
994  *tag += (char) c;
995  in->get();
996 
997  // Early out if we find the CDATA id.
998  if ( c == '[' && tag->size() >= 9 )
999  {
1000  size_t len = tag->size();
1001  const char* start = tag->c_str() + len - 9;
1002  if ( strcmp( start, "<![CDATA[" ) == 0 ) {
1003  assert( !closingTag );
1004  break;
1005  }
1006  }
1007 
1008  if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) )
1009  {
1010  firstCharFound = true;
1011  if ( c == '/' )
1012  closingTag = true;
1013  }
1014  }
1015  // If it was a closing tag, then read in the closing '>' to clean up the input stream.
1016  // If it was not, the streaming will be done by the tag.
1017  if ( closingTag )
1018  {
1019  if ( !in->good() )
1020  return;
1021 
1022  int c = in->get();
1023  if ( c <= 0 )
1024  {
1025  TiXmlDocument* document = GetDocument();
1026  if ( document )
1028  return;
1029  }
1030  assert( c == '>' );
1031  *tag += (char) c;
1032 
1033  // We are done, once we've found our closing tag.
1034  return;
1035  }
1036  else
1037  {
1038  // If not a closing tag, id it, and stream.
1039  const char* tagloc = tag->c_str() + tagIndex;
1041  if ( !node )
1042  return;
1043  node->StreamIn( in, tag );
1044  delete node;
1045  node = 0;
1046 
1047  // No return: go around from the beginning: text, closing tag, or node.
1048  }
1049  }
1050  }
1051 }
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
tuple node
Definition: Node.py:50
static bool IsWhiteSpace(char c)
Definition: tinyxml.h:292
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition: tinyxml.h:172
tuple text
Definition: runonSM.py:42
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cc:493
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
static bool StreamWhiteSpace(std::istream *in, TIXML_STRING *tag)
virtual const TiXmlElement* TiXmlElement::ToElement ( ) const
inlinevirtual

Cast to a more defined type. Will return null not of the requested type.

Reimplemented from TiXmlNode.

Definition at line 1125 of file tinyxml.h.

virtual TiXmlElement* TiXmlElement::ToElement ( )
inlinevirtual

Cast to a more defined type. Will return null not of the requested type.

Reimplemented from TiXmlNode.

Definition at line 1126 of file tinyxml.h.

Member Data Documentation

TiXmlAttributeSet TiXmlElement::attributeSet
private