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 *const 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::getPoint2DValsErrs().

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 }
tuple d
Definition: ztail.py:151
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(), alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

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(), alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

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 }
tuple d
Definition: ztail.py:151
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 1063 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().

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

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

References assert(), EnergyCorrector::c, hitfit::char, TiXmlNode::GetDocument(), TiXmlNode::Identify(), TiXmlBase::IsWhiteSpace(), python.Node::node, TiXmlDocument::SetError(), dqm_diff::start, TiXmlNode::StreamIn(), TiXmlText::StreamIn(), TiXmlBase::StreamWhiteSpace(), runonSM::text, TIXML_DEFAULT_ENCODING, TIXML_ENCODING_UNKNOWN, and TiXmlBase::TIXML_ERROR_EMBEDDED_NULL.

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

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