CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

TiXmlElement Class Reference

#include <tinyxml.h>

Inheritance diagram for TiXmlElement:
TiXmlNode TiXmlNode TiXmlBase TiXmlBase TiXmlBase TiXmlBase

List of all members.

Public Member Functions

virtual bool Accept (TiXmlVisitor *visitor) const
virtual bool Accept (TiXmlVisitor *visitor) const
const char * Attribute (const char *name) const
const char * Attribute (const char *name, double *d) const
const std::string * Attribute (const std::string &name, double *d) 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 char * Attribute (const char *name, int *i) 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
const std::string * Attribute (const std::string &name) const
const std::string * Attribute (const std::string &name, int *i) const
virtual TiXmlNodeClone () const
 Creates a new Element and returns it - the returned element is a copy.
virtual TiXmlNodeClone () const
 Creates a new Element and returns it - the returned element is a copy.
TiXmlAttributeFirstAttribute ()
const TiXmlAttributeFirstAttribute () const
 Access the first attribute in this element.
TiXmlAttributeFirstAttribute ()
const TiXmlAttributeFirstAttribute () const
 Access the first attribute in this element.
const char * GetText () const
const char * GetText () const
TiXmlAttributeLastAttribute ()
const TiXmlAttributeLastAttribute () const
 Access the last attribute in this element.
TiXmlAttributeLastAttribute ()
const TiXmlAttributeLastAttribute () const
 Access the last attribute in this element.
void operator= (const TiXmlElement &base)
TiXmlElementoperator= (const TiXmlElement &base)
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual void Print (FILE *cfile, int depth) const
virtual void Print (FILE *cfile, int depth) const
int QueryDoubleAttribute (const std::string &name, double *_value) const
int QueryDoubleAttribute (const char *name, double *_value) const
 QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
int QueryDoubleAttribute (const char *name, double *_value) const
 QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
int QueryDoubleAttribute (const std::string &name, double *_value) const
int QueryFloatAttribute (const char *name, float *_value) const
 QueryFloatAttribute examines the attribute - see QueryIntAttribute().
int QueryFloatAttribute (const char *name, float *_value) const
 QueryFloatAttribute examines the attribute - see QueryIntAttribute().
int QueryIntAttribute (const char *name, int *_value) const
int QueryIntAttribute (const char *name, int *_value) const
int QueryIntAttribute (const std::string &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
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.
void RemoveAttribute (const char *name)
void RemoveAttribute (const std::string &name)
 STL std::string form.
void SetAttribute (const std::string &name, int _value)
void SetAttribute (const std::string &name, const std::string &_value)
void SetAttribute (const char *name, int value)
void SetAttribute (const std::string &name, int _value)
void SetAttribute (const char *name, int value)
void SetAttribute (const char *name, const char *_value)
void SetAttribute (const std::string &name, const std::string &_value)
void SetAttribute (const char *name, const char *_value)
void SetDoubleAttribute (const char *name, double value)
void SetDoubleAttribute (const char *name, double value)
 TiXmlElement (const TiXmlElement &)
 TiXmlElement (const std::string &_value)
 std::string constructor.
 TiXmlElement (const TiXmlElement &)
 TiXmlElement (const std::string &_value)
 std::string constructor.
 TiXmlElement (const char *in_value)
 Construct an element.
 TiXmlElement (const char *in_value)
 Construct an element.
virtual const TiXmlElementToElement () const
 Cast to a more defined type. Will return null not of the requested type.
virtual const TiXmlElementToElement () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlElementToElement ()
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlElementToElement ()
 Cast to a more defined type. Will return null not of the requested type.
virtual ~TiXmlElement ()
virtual ~TiXmlElement ()

Protected Member Functions

void ClearThis ()
void ClearThis ()
void CopyTo (TiXmlElement *target) const
void CopyTo (TiXmlElement *target) const
const char * ReadValue (const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
const char * ReadValue (const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
virtual void StreamIn (std::istream *in, TIXML_STRING *tag)
virtual void StreamIn (std::istream *in, TIXML_STRING *tag)

Private Attributes

TiXmlAttributeSet attributeSet

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().

TiXmlElement::TiXmlElement ( const std::string &  _value)

std::string constructor.

TiXmlElement::TiXmlElement ( const TiXmlElement copy)

Definition at line 530 of file tinyxml.cc.

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

        : TiXmlNode( TiXmlNode::ELEMENT )
{
        firstChild = lastChild = 0;
        copy.CopyTo( this );
}
TiXmlElement::~TiXmlElement ( ) [virtual]

Definition at line 546 of file tinyxml.cc.

References ClearThis().

{
        ClearThis();
}
TiXmlElement::TiXmlElement ( const char *  in_value)

Construct an element.

TiXmlElement::TiXmlElement ( const std::string &  _value)

std::string constructor.

TiXmlElement::TiXmlElement ( const TiXmlElement )
virtual TiXmlElement::~TiXmlElement ( ) [virtual]

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().

{
        if ( visitor->VisitEnter( *this, attributeSet.First() ) )
        {
                for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
                {
                        if ( !node->Accept( visitor ) )
                                break;
                }
        }
        return visitor->VisitExit( *this );
}
virtual bool TiXmlElement::Accept ( TiXmlVisitor visitor) const [virtual]

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

Implements TiXmlNode.

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.

{
        const char* s = Attribute( name );
        if ( d )
        {
                if ( s ) {
                        *d = atof( s );
                }
                else {
                        *d = 0;
                }
        }
        return s;
}
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.

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.

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.

const std::string* TiXmlElement::Attribute ( const std::string &  name) const
const std::string* TiXmlElement::Attribute ( const std::string &  name,
int *  i 
) const
const std::string* TiXmlElement::Attribute ( const std::string &  name) const
const std::string* TiXmlElement::Attribute ( const std::string &  name,
int *  i 
) const
const std::string* TiXmlElement::Attribute ( const std::string &  name,
double *  d 
) const
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().

{
        const TiXmlAttribute* node = attributeSet.Find( name );
        if ( node )
                return node->Value();
        return 0;
}
const std::string* TiXmlElement::Attribute ( const std::string &  name,
double *  d 
) const
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.

{
        const char* s = Attribute( name );
        if ( i )
        {
                if ( s ) {
                        *i = atoi( s );
                }
                else {
                        *i = 0;
                }
        }
        return s;
}
void TiXmlElement::ClearThis ( ) [protected]
void TiXmlElement::ClearThis ( ) [protected]
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().

{
        TiXmlElement* clone = new TiXmlElement( Value() );
        if ( !clone )
                return 0;

        CopyTo( clone );
        return clone;
}
virtual TiXmlNode* TiXmlElement::Clone ( ) const [virtual]

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

Implements TiXmlNode.

void TiXmlElement::CopyTo ( TiXmlElement target) const [protected]

Definition at line 833 of file tinyxml.cc.

References attributeSet, TiXmlNode::Clone(), 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().

{
        // superclass:
        TiXmlNode::CopyTo( target );

        // Element class:
        // Clone the attributes, then clone the children.
        const TiXmlAttribute* attribute = 0;
        for(    attribute = attributeSet.First();
        attribute;
        attribute = attribute->Next() )
        {
                target->SetAttribute( attribute->Name(), attribute->Value() );
        }

        TiXmlNode* node = 0;
        for ( node = firstChild; node; node = node->NextSibling() )
        {
                target->LinkEndChild( node->Clone() );
        }
}
void TiXmlElement::CopyTo ( TiXmlElement target) const [protected]
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().

{ return attributeSet.First(); }
const TiXmlAttribute* TiXmlElement::FirstAttribute ( ) const [inline]

Access the first attribute in this element.

Definition at line 1012 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::First().

TiXmlAttribute* TiXmlElement::FirstAttribute ( ) [inline]

Definition at line 1013 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::First().

{ return attributeSet.First(); }
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().

{
        const TiXmlNode* child = this->FirstChild();
        if ( child ) {
                const TiXmlText* childText = child->ToText();
                if ( childText ) {
                        return childText->Value();
                }
        }
        return 0;
}
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.

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().

{ return attributeSet.Last(); }
const TiXmlAttribute* TiXmlElement::LastAttribute ( ) const [inline]

Access the last attribute in this element.

Definition at line 1014 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::Last().

TiXmlAttribute* TiXmlElement::LastAttribute ( ) [inline]

Definition at line 1015 of file tinyxml.h.

References attributeSet, and TiXmlAttributeSet::Last().

{ return attributeSet.Last(); }
TiXmlElement & TiXmlElement::operator= ( const TiXmlElement base)

Definition at line 538 of file tinyxml.cc.

References ClearThis(), and CopyTo().

{
        ClearThis();
        base.CopyTo( this );
        return *this;
}
void TiXmlElement::operator= ( const TiXmlElement base)
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(), 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().

{
        p = SkipWhiteSpace( p, encoding );
        TiXmlDocument* document = GetDocument();

        if ( !p || !*p )
        {
                if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding );
                return 0;
        }

        if ( data )
        {
                data->Stamp( p, encoding );
                location = data->Cursor();
        }

        if ( *p != '<' )
        {
                if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding );
                return 0;
        }

        p = SkipWhiteSpace( p+1, encoding );

        // Read the name.
        const char* pErr = p;

    p = ReadName( p, &value, encoding );
        if ( !p || !*p )
        {
                if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding );
                return 0;
        }

    TIXML_STRING endTag ("</");
        endTag += value;
        endTag += ">";

        // Check for and read attributes. Also look for an empty
        // tag or an end tag.
        while ( p && *p )
        {
                pErr = p;
                p = SkipWhiteSpace( p, encoding );
                if ( !p || !*p )
                {
                        if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
                        return 0;
                }
                if ( *p == '/' )
                {
                        ++p;
                        // Empty tag.
                        if ( *p  != '>' )
                        {
                                if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
                                return 0;
                        }
                        return (p+1);
                }
                else if ( *p == '>' )
                {
                        // Done with attributes (if there were any.)
                        // Read the value -- which can include other
                        // elements -- read the end tag, and return.
                        ++p;
                        p = ReadValue( p, data, encoding );             // Note this is an Element method, and will set the error if one happens.
                        if ( !p || !*p ) {
                                // We were looking for the end tag, but found nothing.
                                // Fix for [ 1663758 ] Failure to report error on bad XML
                                if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
                                return 0;
                        }

                        // We should find the end tag now
                        if ( StringEqual( p, endTag.c_str(), false, encoding ) )
                        {
                                p += endTag.length();
                                return p;
                        }
                        else
                        {
                                if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
                                return 0;
                        }
                }
                else
                {
                        // Try to read an attribute:
                        TiXmlAttribute* attrib = new TiXmlAttribute();
                        if ( !attrib )
                        {
                                if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
                                return 0;
                        }

                        attrib->SetDocument( document );
                        pErr = p;
                        p = attrib->Parse( p, data, encoding );

                        if ( !p || !*p )
                        {
                                if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
                                delete attrib;
                                return 0;
                        }

                        // Handle the strange case of double attributes:
                        #ifdef TIXML_USE_STL
                        TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() );
                        #else
                        TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
                        #endif
                        if ( node )
                        {
                                node->SetValue( attrib->Value() );
                                delete attrib;
                                return 0;
                        }

                        attributeSet.Add( attrib );
                }
        }
        return p;
}
virtual const char* TiXmlElement::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
) [virtual]

Implements TiXmlBase.

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

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.

{
        int i;
        assert( cfile );
        for ( i=0; i<depth; i++ ) {
                fprintf( cfile, "    " );
        }

        fprintf( cfile, "<%s", value.c_str() );

        const TiXmlAttribute* attrib;
        for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
        {
                fprintf( cfile, " " );
                attrib->Print( cfile, depth );
        }

        // There are 3 different formatting approaches:
        // 1) An element without children is printed as a <foo /> node
        // 2) An element with only a text child is printed as <foo> text </foo>
        // 3) An element with children is printed on multiple lines.
        TiXmlNode* node;
        if ( !firstChild )
        {
                fprintf( cfile, " />" );
        }
        else if ( firstChild == lastChild && firstChild->ToText() )
        {
                fprintf( cfile, ">" );
                firstChild->Print( cfile, depth + 1 );
                fprintf( cfile, "</%s>", value.c_str() );
        }
        else
        {
                fprintf( cfile, ">" );

                for ( node = firstChild; node; node=node->NextSibling() )
                {
                        if ( !node->ToText() )
                        {
                                fprintf( cfile, "\n" );
                        }
                        node->Print( cfile, depth+1 );
                }
                fprintf( cfile, "\n" );
                for( i=0; i<depth; ++i ) {
                        fprintf( cfile, "    " );
                }
                fprintf( cfile, "</%s>", value.c_str() );
        }
}
int TiXmlElement::QueryDoubleAttribute ( const std::string &  name,
double *  _value 
) const
int TiXmlElement::QueryDoubleAttribute ( const char *  name,
double *  _value 
) const

QueryDoubleAttribute examines the attribute - see QueryIntAttribute().

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(), TiXmlAttribute::QueryDoubleValue(), and TIXML_NO_ATTRIBUTE.

Referenced by QueryFloatAttribute().

{
        const TiXmlAttribute* node = attributeSet.Find( name );
        if ( !node )
                return TIXML_NO_ATTRIBUTE;
        return node->QueryDoubleValue( dval );
}
int TiXmlElement::QueryDoubleAttribute ( const std::string &  name,
double *  _value 
) const
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.

                                                                         {
                double d;
                int result = QueryDoubleAttribute( name, &d );
                if ( result == TIXML_SUCCESS ) {
                        *_value = (float)d;
                }
                return result;
        }
int TiXmlElement::QueryFloatAttribute ( const char *  name,
float *  _value 
) const [inline]

QueryFloatAttribute examines the attribute - see QueryIntAttribute().

Definition at line 953 of file tinyxml.h.

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

                                                                         {
                double d;
                int result = QueryDoubleAttribute( name, &d );
                if ( result == TIXML_SUCCESS ) {
                        *_value = (float)d;
                }
                return result;
        }
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.

int TiXmlElement::QueryIntAttribute ( const std::string &  name,
int *  _value 
) const
int TiXmlElement::QueryIntAttribute ( const std::string &  name,
int *  _value 
) const
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(), TiXmlAttribute::QueryIntValue(), and TIXML_NO_ATTRIBUTE.

{
        const TiXmlAttribute* node = attributeSet.Find( name );
        if ( !node )
                return TIXML_NO_ATTRIBUTE;
        return node->QueryIntValue( ival );
}
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().

        {
                const TiXmlAttribute* node = attributeSet.Find( name );
                if ( !node )
                        return TIXML_NO_ATTRIBUTE;

                std::stringstream sstream( node->ValueStr() );
                sstream >> *outValue;
                if ( !sstream.fail() )
                        return TIXML_SUCCESS;
                return TIXML_WRONG_TYPE;
        }
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.

Returns:
TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE

Definition at line 968 of file tinyxml.h.

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

        {
                const TiXmlAttribute* node = attributeSet.Find( name );
                if ( !node )
                        return TIXML_NO_ATTRIBUTE;

                std::stringstream sstream( node->ValueStr() );
                sstream >> *outValue;
                if ( !sstream.fail() )
                        return TIXML_SUCCESS;
                return TIXML_WRONG_TYPE;
        }
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(), AlCaHLTBitMon_ParallelJobs::p, TiXmlText::Parse(), TiXmlBase::Parse(), TiXmlDocument::SetError(), TiXmlBase::SkipWhiteSpace(), TiXmlBase::StringEqual(), TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY, and TiXmlBase::TIXML_ERROR_READING_ELEMENT_VALUE.

Referenced by Parse().

{
        TiXmlDocument* document = GetDocument();

        // Read in text and elements in any order.
        const char* pWithWhiteSpace = p;
        p = SkipWhiteSpace( p, encoding );

        while ( p && *p )
        {
                if ( *p != '<' )
                {
                        // Take what we have, make a text element.
                        TiXmlText* textNode = new TiXmlText( "" );

                        if ( !textNode )
                        {
                                if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
                                    return 0;
                        }

                        if ( TiXmlBase::IsWhiteSpaceCondensed() )
                        {
                                p = textNode->Parse( p, data, encoding );
                        }
                        else
                        {
                                // Special case: we want to keep the white space
                                // so that leading spaces aren't removed.
                                p = textNode->Parse( pWithWhiteSpace, data, encoding );
                        }

                        if ( !textNode->Blank() )
                                LinkEndChild( textNode );
                        else
                                delete textNode;
                }
                else
                {
                        // We hit a '<'
                        // Have we hit a new element or an end tag? This could also be
                        // a TiXmlText in the "CDATA" style.
                        if ( StringEqual( p, "</", false, encoding ) )
                        {
                                return p;
                        }
                        else
                        {
                                TiXmlNode* node = Identify( p, encoding );
                                if ( node )
                                {
                                        p = node->Parse( p, data, encoding );
                                        LinkEndChild( node );
                                }
                                else
                                {
                                        return 0;
                                }
                        }
                }
                pWithWhiteSpace = p;
                p = SkipWhiteSpace( p, encoding );
        }

        if ( !p )
        {
                if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
        }
        return p;
}
const char* TiXmlElement::ReadValue ( const char *  in,
TiXmlParsingData prevData,
TiXmlEncoding  encoding 
) [protected]
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::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.

{
    #ifdef TIXML_USE_STL
        TIXML_STRING str( name );
        TiXmlAttribute* node = attributeSet.Find( str );
        #else
        TiXmlAttribute* node = attributeSet.Find( name );
        #endif
        if ( node )
        {
                attributeSet.Remove( node );
                delete node;
        }
}
void TiXmlElement::RemoveAttribute ( const char *  name)

Deletes an attribute with the given name.

void TiXmlElement::RemoveAttribute ( const std::string &  name) [inline]

STL std::string form.

Definition at line 1010 of file tinyxml.h.

References RemoveAttribute().

Referenced by RemoveAttribute().

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.

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().

{
        char buf[64];
        #if defined(TIXML_SNPRINTF)
                TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
        #else
                snprintf( buf, sizeof(buf), "%d", val );
        #endif
        SetAttribute( name, buf );
}
void TiXmlElement::SetAttribute ( const std::string &  name,
const std::string &  _value 
)

STL std::string form.

void TiXmlElement::SetAttribute ( const std::string &  name,
int  _value 
)
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.

void TiXmlElement::SetAttribute ( const std::string &  name,
const std::string &  _value 
)

STL std::string form.

void TiXmlElement::SetAttribute ( const std::string &  name,
int  _value 
)
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(), 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().

{
    #ifdef TIXML_USE_STL
        TIXML_STRING _name( cname );
        TIXML_STRING _value( cvalue );
        #else
        const char* _name = cname;
        const char* _value = cvalue;
        #endif

        TiXmlAttribute* node = attributeSet.Find( _name );
        if ( node )
        {
                node->SetValue( _value );
                return;
        }

        TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue );
        if ( attrib )
        {
                attributeSet.Add( attrib );
        }
        else
        {
                TiXmlDocument* document = GetDocument();
                if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
        }
}
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.

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().

{
        char buf[256];
        #if defined(TIXML_SNPRINTF)
                TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
        #else
                snprintf( buf, sizeof(buf), "%f", val );
        #endif
        SetAttribute( name, buf );
}
virtual void TiXmlElement::StreamIn ( std::istream *  in,
TIXML_STRING *  tag 
) [protected, virtual]

Implements TiXmlNode.

virtual void TiXmlElement::StreamIn ( std::istream *  in,
TIXML_STRING *  tag 
) [protected, virtual]

Implements TiXmlNode.

virtual const TiXmlElement* TiXmlElement::ToElement ( ) const [inline, virtual]

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 ( ) [inline, virtual]

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.

virtual const TiXmlElement* TiXmlElement::ToElement ( ) const [inline, virtual]

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

Reimplemented from TiXmlNode.

Definition at line 1061 of file tinyxml.h.

virtual TiXmlElement* TiXmlElement::ToElement ( ) [inline, virtual]

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

Reimplemented from TiXmlNode.

Definition at line 1062 of file tinyxml.h.


Member Data Documentation