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 ()
 
TiXmlElementoperator= (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 std::string & ValueTStr () 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, std::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 std::string &str, std::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, std::string *name, TiXmlEncoding encoding)
 
static const char * ReadText (const char *in, std::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, std::string *tag)
 
static bool StreamWhiteSpace (std::istream *in, std::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
 
std::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 947 of file tinyxml.h.

Constructor & Destructor Documentation

TiXmlElement::TiXmlElement ( const char *  in_value)

Construct an element.

Definition at line 512 of file tinyxml.cc.

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

Referenced by Clone().

514 {
515  firstChild = lastChild = 0;
516  value = _value;
517 }
TiXmlNode * firstChild
Definition: tinyxml.h:762
std::string value
Definition: tinyxml.h:765
TiXmlNode(NodeType _type)
Definition: tinyxml.cc:143
TiXmlNode * lastChild
Definition: tinyxml.h:763
TiXmlElement::TiXmlElement ( const std::string &  _value)

std::string constructor.

Definition at line 521 of file tinyxml.cc.

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

523 {
524  firstChild = lastChild = 0;
525  value = _value;
526 }
TiXmlNode * firstChild
Definition: tinyxml.h:762
std::string value
Definition: tinyxml.h:765
TiXmlNode(NodeType _type)
Definition: tinyxml.cc:143
TiXmlNode * lastChild
Definition: tinyxml.h:763
TiXmlElement::TiXmlElement ( const TiXmlElement copy)

Definition at line 530 of file tinyxml.cc.

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

532 {
533  firstChild = lastChild = 0;
534  copy.CopyTo( this );
535 }
TiXmlNode * firstChild
Definition: tinyxml.h:762
TiXmlNode(NodeType _type)
Definition: tinyxml.cc:143
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cc:833
TiXmlNode * lastChild
Definition: tinyxml.h:763
TiXmlElement::~TiXmlElement ( )
virtual

Definition at line 546 of file tinyxml.cc.

References ClearThis().

547 {
548  ClearThis();
549 }
void ClearThis()
Definition: tinyxml.cc:552

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 855 of file tinyxml.cc.

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

856 {
857  if ( visitor->VisitEnter( *this, attributeSet.First() ) )
858  {
859  for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
860  {
861  if ( !node->Accept( visitor ) )
862  break;
863  }
864  }
865  return visitor->VisitExit( *this );
866 }
const TiXmlAttribute * First() const
Definition: tinyxml.h:916
tuple node
Definition: Node.py:50
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:138
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:526
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
Definition: tinyxml.h:140
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 564 of file tinyxml.cc.

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

Referenced by Attribute(), and RivetHarvesting::getDPSXYValsErrs().

565 {
567  if ( node )
568  return node->Value();
569  return 0;
570 }
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:816
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1593
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 584 of file tinyxml.cc.

References Attribute(), and alignCSCRings::s.

585 {
586  const char* s = Attribute( name );
587  if ( i )
588  {
589  if ( s ) {
590  *i = atoi( s );
591  }
592  else {
593  *i = 0;
594  }
595  }
596  return s;
597 }
int i
Definition: DBlmapReader.cc:9
const char * Attribute(const char *name) const
Definition: tinyxml.cc:564
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 618 of file tinyxml.cc.

References Attribute(), and alignCSCRings::s.

619 {
620  const char* s = Attribute( name );
621  if ( d )
622  {
623  if ( s ) {
624  *d = atof( s );
625  }
626  else {
627  *d = 0;
628  }
629  }
630  return s;
631 }
const char * Attribute(const char *name) const
Definition: tinyxml.cc:564
const std::string * TiXmlElement::Attribute ( const std::string &  name) const

Definition at line 574 of file tinyxml.cc.

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

575 {
577  if ( node )
578  return &node->ValueStr();
579  return 0;
580 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1593
const std::string & ValueStr() const
Return the value of this attribute.
Definition: tinyxml.h:818
const std::string * TiXmlElement::Attribute ( const std::string &  name,
int *  i 
) const

Definition at line 601 of file tinyxml.cc.

References Attribute(), and alignCSCRings::s.

602 {
603  const std::string* s = Attribute( name );
604  if ( i )
605  {
606  if ( s ) {
607  *i = atoi( s->c_str() );
608  }
609  else {
610  *i = 0;
611  }
612  }
613  return s;
614 }
int i
Definition: DBlmapReader.cc:9
const char * Attribute(const char *name) const
Definition: tinyxml.cc:564
const std::string * TiXmlElement::Attribute ( const std::string &  name,
double *  d 
) const

Definition at line 635 of file tinyxml.cc.

References Attribute(), and alignCSCRings::s.

636 {
637  const std::string* s = Attribute( name );
638  if ( d )
639  {
640  if ( s ) {
641  *d = atof( s->c_str() );
642  }
643  else {
644  *d = 0;
645  }
646  }
647  return s;
648 }
const char * Attribute(const char *name) const
Definition: tinyxml.cc:564
void TiXmlElement::ClearThis ( )
protected

Definition at line 552 of file tinyxml.cc.

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

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

553 {
554  Clear();
555  while( attributeSet.First() )
556  {
558  attributeSet.Remove( node );
559  delete node;
560  }
561 }
const TiXmlAttribute * First() const
Definition: tinyxml.h:916
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
void Remove(TiXmlAttribute *attribute)
Definition: tinyxml.cc:1549
void Clear()
Delete all the children of this node. Does not affect &#39;this&#39;.
Definition: tinyxml.cc:175
TiXmlNode * TiXmlElement::Clone ( ) const
virtual

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

Implements TiXmlNode.

Definition at line 869 of file tinyxml.cc.

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

870 {
871  TiXmlElement* clone = new TiXmlElement( Value() );
872  if ( !clone )
873  return 0;
874 
875  CopyTo( clone );
876  return clone;
877 }
TiXmlElement(const char *in_value)
Construct an element.
Definition: tinyxml.cc:512
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
const char * Value() const
Definition: tinyxml.h:491
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cc:833
void TiXmlElement::CopyTo ( TiXmlElement target) const
protected

Definition at line 833 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().

834 {
835  // superclass:
836  TiXmlNode::CopyTo( target );
837 
838  // Element class:
839  // Clone the attributes, then clone the children.
840  const TiXmlAttribute* attribute = 0;
841  for( attribute = attributeSet.First();
842  attribute;
843  attribute = attribute->Next() )
844  {
845  target->SetAttribute( attribute->Name(), attribute->Value() );
846  }
847 
848  TiXmlNode* node = 0;
849  for ( node = firstChild; node; node = node->NextSibling() )
850  {
851  target->LinkEndChild( node->Clone() );
852  }
853 }
const TiXmlAttribute * First() const
Definition: tinyxml.h:916
TiXmlNode * firstChild
Definition: tinyxml.h:762
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:816
tuple node
Definition: Node.py:50
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Definition: tinyxml.cc:192
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:815
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
Definition: tinyxml.cc:1184
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:726
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:630
void CopyTo(TiXmlNode *target) const
Definition: tinyxml.cc:168
virtual TiXmlNode * Clone() const =0
const TiXmlAttribute* TiXmlElement::FirstAttribute ( ) const
inline

Access the first attribute in this element.

Definition at line 1078 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::First().

TiXmlAttribute* TiXmlElement::FirstAttribute ( )
inline

Definition at line 1079 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::First().

1079 { return attributeSet.First(); }
const TiXmlAttribute * First() const
Definition: tinyxml.h:916
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
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 880 of file tinyxml.cc.

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

881 {
882  const TiXmlNode* child = this->FirstChild();
883  if ( child ) {
884  const TiXmlText* childText = child->ToText();
885  if ( childText ) {
886  return childText->Value();
887  }
888  }
889  return 0;
890 }
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:526
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:705
const char * Value() const
Definition: tinyxml.h:491
const TiXmlAttribute* TiXmlElement::LastAttribute ( ) const
inline

Access the last attribute in this element.

Definition at line 1080 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::Last().

TiXmlAttribute* TiXmlElement::LastAttribute ( )
inline

Definition at line 1081 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::Last().

1081 { return attributeSet.Last(); }
const TiXmlAttribute * Last() const
Definition: tinyxml.h:918
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
TiXmlElement & TiXmlElement::operator= ( const TiXmlElement base)

Definition at line 538 of file tinyxml.cc.

References ClearThis(), and CopyTo().

539 {
540  ClearThis();
541  base.CopyTo( this );
542  return *this;
543 }
void ClearThis()
Definition: tinyxml.cc:552
void CopyTo(TiXmlElement *target) const
Definition: tinyxml.cc:833
const char * TiXmlElement::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
)
virtual

Implements TiXmlBase.

Definition at line 1059 of file tinyxmlparser.cc.

References TiXmlAttributeSet::Add(), attributeSet, TiXmlParsingData::Cursor(), TiXmlAttributeSet::Find(), TiXmlNode::GetDocument(), TiXmlBase::location, TiXmlAttribute::Name(), TiXmlAttribute::NameTStr(), python.Node::node, AlCaHLTBitMon_ParallelJobs::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().

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

781 {
782  int i;
783  assert( cfile );
784  for ( i=0; i<depth; i++ ) {
785  fprintf( cfile, " " );
786  }
787 
788  fprintf( cfile, "<%s", value.c_str() );
789 
790  const TiXmlAttribute* attrib;
791  for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
792  {
793  fprintf( cfile, " " );
794  attrib->Print( cfile, depth );
795  }
796 
797  // There are 3 different formatting approaches:
798  // 1) An element without children is printed as a <foo /> node
799  // 2) An element with only a text child is printed as <foo> text </foo>
800  // 3) An element with children is printed on multiple lines.
801  TiXmlNode* node;
802  if ( !firstChild )
803  {
804  fprintf( cfile, " />" );
805  }
806  else if ( firstChild == lastChild && firstChild->ToText() )
807  {
808  fprintf( cfile, ">" );
809  firstChild->Print( cfile, depth + 1 );
810  fprintf( cfile, "</%s>", value.c_str() );
811  }
812  else
813  {
814  fprintf( cfile, ">" );
815 
816  for ( node = firstChild; node; node=node->NextSibling() )
817  {
818  if ( !node->ToText() )
819  {
820  fprintf( cfile, "\n" );
821  }
822  node->Print( cfile, depth+1 );
823  }
824  fprintf( cfile, "\n" );
825  for( i=0; i<depth; ++i ) {
826  fprintf( cfile, " " );
827  }
828  fprintf( cfile, "</%s>", value.c_str() );
829  }
830 }
const TiXmlAttribute * First() const
Definition: tinyxml.h:916
int i
Definition: DBlmapReader.cc:9
TiXmlNode * firstChild
Definition: tinyxml.h:762
std::string value
Definition: tinyxml.h:765
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
Definition: tinyxml.cc:1184
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:630
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
Definition: tinyxml.h:705
TiXmlNode * lastChild
Definition: tinyxml.h:763
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 672 of file tinyxml.cc.

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

Referenced by QueryFloatAttribute().

673 {
675  if ( !node )
676  return TIXML_NO_ATTRIBUTE;
677  return node->QueryDoubleValue( dval );
678 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
Definition: tinyxml.cc:1260
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1593
int TiXmlElement::QueryDoubleAttribute ( const std::string &  name,
double *  _value 
) const

Definition at line 682 of file tinyxml.cc.

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

683 {
685  if ( !node )
686  return TIXML_NO_ATTRIBUTE;
687  return node->QueryDoubleValue( dval );
688 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
Definition: tinyxml.cc:1260
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1593
int TiXmlElement::QueryFloatAttribute ( const char *  name,
float *  _value 
) const
inline

QueryFloatAttribute examines the attribute - see QueryIntAttribute().

Definition at line 996 of file tinyxml.h.

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

996  {
997  double d;
998  int result = QueryDoubleAttribute( name, &d );
999  if ( result == TIXML_SUCCESS ) {
1000  *_value = (float)d;
1001  }
1002  return result;
1003  }
tuple result
Definition: query.py:137
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
Definition: tinyxml.cc:672
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 652 of file tinyxml.cc.

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

653 {
655  if ( !node )
656  return TIXML_NO_ATTRIBUTE;
657  return node->QueryIntValue( ival );
658 }
int QueryIntValue(int *_value) const
Definition: tinyxml.cc:1250
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1593
int TiXmlElement::QueryIntAttribute ( const std::string &  name,
int *  _value 
) const

Definition at line 662 of file tinyxml.cc.

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

663 {
665  if ( !node )
666  return TIXML_NO_ATTRIBUTE;
667  return node->QueryIntValue( ival );
668 }
int QueryIntValue(int *_value) const
Definition: tinyxml.cc:1250
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1593
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 1014 of file tinyxml.h.

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

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

Definition at line 1187 of file tinyxmlparser.cc.

References TiXmlText::Blank(), TiXmlNode::GetDocument(), TiXmlNode::Identify(), TiXmlBase::IsWhiteSpaceCondensed(), TiXmlNode::LinkEndChild(), python.Node::node, AlCaHLTBitMon_ParallelJobs::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().

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

Deletes an attribute with the given name.

Definition at line 424 of file tinyxml.cc.

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

425 {
426  #ifdef TIXML_USE_STL
427  TIXML_STRING str( name );
429  #else
431  #endif
432  if ( node )
433  {
434  attributeSet.Remove( node );
435  delete node;
436  }
437 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1593
void Remove(TiXmlAttribute *attribute)
Definition: tinyxml.cc:1549
#define TIXML_STRING
Definition: tinyxml.h:57
void TiXmlElement::RemoveAttribute ( const std::string &  name)
inline

STL std::string form.

Definition at line 1075 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 726 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::reportFallbackAttempt(), edm::JobReport::reportReadBranches(), edm::JobReport::reportSkippedFile(), SetAttribute(), and SetDoubleAttribute().

727 {
728  #ifdef TIXML_USE_STL
729  TIXML_STRING _name( cname );
730  TIXML_STRING _value( cvalue );
731  #else
732  const char* _name = cname;
733  const char* _value = cvalue;
734  #endif
735 
736  TiXmlAttribute* node = attributeSet.Find( _name );
737  if ( node )
738  {
739  node->SetValue( _value );
740  return;
741  }
742 
743  TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue );
744  if ( attrib )
745  {
746  attributeSet.Add( attrib );
747  }
748  else
749  {
750  TiXmlDocument* document = GetDocument();
751  if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
752  }
753 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1593
void Add(TiXmlAttribute *attribute)
Definition: tinyxml.cc:1534
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cc:499
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:840
#define TIXML_STRING
Definition: tinyxml.h:57
void TiXmlElement::SetAttribute ( const std::string &  name,
const std::string &  _value 
)

STL std::string form.

STL std::string form.

Definition at line 757 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.

758 {
760  if ( node )
761  {
762  node->SetValue( _value );
763  return;
764  }
765 
766  TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
767  if ( attrib )
768  {
769  attributeSet.Add( attrib );
770  }
771  else
772  {
773  TiXmlDocument* document = GetDocument();
774  if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
775  }
776 }
tuple node
Definition: Node.py:50
TiXmlAttributeSet attributeSet
Definition: tinyxml.h:1151
const TiXmlAttribute * Find(const char *_name) const
Definition: tinyxml.cc:1593
void Add(TiXmlAttribute *attribute)
Definition: tinyxml.cc:1534
const TiXmlDocument * GetDocument() const
Definition: tinyxml.cc:499
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:840
void TiXmlElement::SetAttribute ( const std::string &  name,
int  _value 
)

Definition at line 705 of file tinyxml.cc.

References SetAttribute().

706 {
707  std::ostringstream oss;
708  oss << val;
709  SetAttribute( name, oss.str() );
710 }
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:726
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 692 of file tinyxml.cc.

References SetAttribute().

693 {
694  char buf[64];
695  #if defined(TIXML_SNPRINTF)
696  TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
697  #else
698  snprintf( buf, sizeof(buf), "%d", val );
699  #endif
700  SetAttribute( name, buf );
701 }
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:726
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 714 of file tinyxml.cc.

References SetAttribute().

715 {
716  char buf[256];
717  #if defined(TIXML_SNPRINTF)
718  TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
719  #else
720  snprintf( buf, sizeof(buf), "%f", val );
721  #endif
722  SetAttribute( name, buf );
723 }
void SetAttribute(const char *name, const char *_value)
Definition: tinyxml.cc:726
void TiXmlElement::StreamIn ( std::istream *  in,
std::string *  tag 
)
protectedvirtual

Implements TiXmlNode.

Definition at line 919 of file tinyxmlparser.cc.

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

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

Referenced by RivetHarvesting::getDPSXYValsErrs().

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

Member Data Documentation

TiXmlAttributeSet TiXmlElement::attributeSet
private