CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

TiXmlAttribute Class Reference

#include <tinyxml.h>

Inheritance diagram for TiXmlAttribute:
TiXmlBase TiXmlBase

List of all members.

Public Member Functions

double DoubleValue () const
 Return the value of this attribute, converted to a double.
double DoubleValue () const
 Return the value of this attribute, converted to a double.
int IntValue () const
 Return the value of this attribute, converted to an integer.
int IntValue () const
 Return the value of this attribute, converted to an integer.
const char * Name () const
 Return the name of this attribute.
const char * Name () const
 Return the name of this attribute.
const TIXML_STRING & NameTStr () const
const TIXML_STRING & NameTStr () const
const TiXmlAttributeNext () const
 Get the next sibling attribute in the DOM. Returns null at end.
TiXmlAttributeNext ()
const TiXmlAttributeNext () const
 Get the next sibling attribute in the DOM. Returns null at end.
TiXmlAttributeNext ()
bool operator< (const TiXmlAttribute &rhs) const
bool operator< (const TiXmlAttribute &rhs) const
bool operator== (const TiXmlAttribute &rhs) const
bool operator== (const TiXmlAttribute &rhs) const
bool operator> (const TiXmlAttribute &rhs) const
bool operator> (const TiXmlAttribute &rhs) const
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlAttributePrevious ()
TiXmlAttributePrevious ()
const TiXmlAttributePrevious () const
 Get the previous sibling attribute in the DOM. Returns null at beginning.
const TiXmlAttributePrevious () const
 Get the previous sibling attribute in the DOM. Returns null at beginning.
virtual void Print (FILE *cfile, int depth) const
void Print (FILE *cfile, int depth, TIXML_STRING *str) const
virtual void Print (FILE *cfile, int depth) const
void Print (FILE *cfile, int depth, TIXML_STRING *str) const
int QueryDoubleValue (double *_value) const
 QueryDoubleValue examines the value string. See QueryIntValue().
int QueryDoubleValue (double *_value) const
 QueryDoubleValue examines the value string. See QueryIntValue().
int QueryIntValue (int *_value) const
int QueryIntValue (int *_value) const
void SetDocument (TiXmlDocument *doc)
void SetDocument (TiXmlDocument *doc)
void SetDoubleValue (double _value)
 Set the value from a double.
void SetDoubleValue (double _value)
 Set the value from a double.
void SetIntValue (int _value)
 Set the value from an integer.
void SetIntValue (int _value)
 Set the value from an integer.
void SetName (const std::string &_name)
 STL std::string form.
void SetName (const char *_name)
 Set the name of this attribute.
void SetName (const char *_name)
 Set the name of this attribute.
void SetName (const std::string &_name)
 STL std::string form.
void SetValue (const std::string &_value)
 STL std::string form.
void SetValue (const std::string &_value)
 STL std::string form.
void SetValue (const char *_value)
 Set the value.
void SetValue (const char *_value)
 Set the value.
 TiXmlAttribute ()
 Construct an empty attribute.
 TiXmlAttribute ()
 Construct an empty attribute.
 TiXmlAttribute (const char *_name, const char *_value)
 Construct an attribute with a name and value.
 TiXmlAttribute (const char *_name, const char *_value)
 Construct an attribute with a name and value.
 TiXmlAttribute (const std::string &_name, const std::string &_value)
 std::string constructor.
 TiXmlAttribute (const std::string &_name, const std::string &_value)
 std::string constructor.
const char * Value () const
 Return the value of this attribute.
const char * Value () const
 Return the value of this attribute.
const std::string & ValueStr () const
 Return the value of this attribute.
const std::string & ValueStr () const
 Return the value of this attribute.

Private Member Functions

TiXmlAttributeoperator= (const TiXmlAttribute &base)
void operator= (const TiXmlAttribute &base)
 TiXmlAttribute (const TiXmlAttribute &)
 TiXmlAttribute (const TiXmlAttribute &)

Private Attributes

TiXmlDocumentdocument
TIXML_STRING name
TiXmlAttributenext
TiXmlAttributeprev
TIXML_STRING value

Friends

class TiXmlAttributeSet

Detailed Description

An attribute is a name-value pair. Elements have an arbitrary number of attributes, each with a unique name.

Note:
The attributes are not TiXmlNodes, since they are not part of the tinyXML document object model. There are other suggested ways to look at this problem.

Definition at line 783 of file tinyxml.h.


Constructor & Destructor Documentation

TiXmlAttribute::TiXmlAttribute ( ) [inline]

Construct an empty attribute.

Definition at line 789 of file tinyxml.h.

References document, next, and prev.

                         : TiXmlBase()
        {
                document = 0;
                prev = next = 0;
        }
TiXmlAttribute::TiXmlAttribute ( const std::string &  _name,
const std::string &  _value 
) [inline]

std::string constructor.

Definition at line 797 of file tinyxml.h.

References document, name, next, prev, and value.

        {
                name = _name;
                value = _value;
                document = 0;
                prev = next = 0;
        }
TiXmlAttribute::TiXmlAttribute ( const char *  _name,
const char *  _value 
) [inline]

Construct an attribute with a name and value.

Definition at line 807 of file tinyxml.h.

References document, name, next, prev, and value.

        {
                name = _name;
                value = _value;
                document = 0;
                prev = next = 0;
        }
TiXmlAttribute::TiXmlAttribute ( const TiXmlAttribute ) [private]
TiXmlAttribute::TiXmlAttribute ( ) [inline]

Construct an empty attribute.

Definition at line 754 of file tinyxml.h.

References document, next, and prev.

                         : TiXmlBase()
        {
                document = 0;
                prev = next = 0;
        }
TiXmlAttribute::TiXmlAttribute ( const std::string &  _name,
const std::string &  _value 
) [inline]

std::string constructor.

Definition at line 761 of file tinyxml.h.

References document, name, next, prev, and value.

        {
                name = _name;
                value = _value;
                document = 0;
                prev = next = 0;
        }
TiXmlAttribute::TiXmlAttribute ( const char *  _name,
const char *  _value 
) [inline]

Construct an attribute with a name and value.

Definition at line 770 of file tinyxml.h.

References document, name, next, prev, and value.

        {
                name = _name;
                value = _value;
                document = 0;
                prev = next = 0;
        }
TiXmlAttribute::TiXmlAttribute ( const TiXmlAttribute ) [private]

Member Function Documentation

double TiXmlAttribute::DoubleValue ( ) const

Return the value of this attribute, converted to a double.

Definition at line 1297 of file tinyxml.cc.

References value.

{
        return atof (value.c_str ());
}
double TiXmlAttribute::DoubleValue ( ) const

Return the value of this attribute, converted to a double.

int TiXmlAttribute::IntValue ( ) const

Return the value of this attribute, converted to an integer.

Definition at line 1292 of file tinyxml.cc.

References value.

{
        return atoi (value.c_str ());
}
int TiXmlAttribute::IntValue ( ) const

Return the value of this attribute, converted to an integer.

const char* TiXmlAttribute::Name ( ) const [inline]

Return the name of this attribute.

Definition at line 815 of file tinyxml.h.

References name.

Referenced by TiXmlAttributeSet::Add(), TiXmlElement::CopyTo(), and TiXmlElement::Parse().

const char* TiXmlAttribute::Name ( ) const [inline]

Return the name of this attribute.

Definition at line 778 of file tinyxml.h.

References name.

const TIXML_STRING& TiXmlAttribute::NameTStr ( ) const [inline]

Definition at line 787 of file tinyxml.h.

References name.

{ return name; }
const TIXML_STRING& TiXmlAttribute::NameTStr ( ) const [inline]

Definition at line 824 of file tinyxml.h.

References name.

Referenced by TiXmlElement::Parse().

{ return name; }
TiXmlAttribute* TiXmlAttribute::Next ( ) [inline]

Definition at line 854 of file tinyxml.h.

                               {
                return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
        }
const TiXmlAttribute* TiXmlAttribute::Next ( ) const

Get the next sibling attribute in the DOM. Returns null at end.

TiXmlAttribute* TiXmlAttribute::Next ( ) [inline]

Definition at line 815 of file tinyxml.h.

                               {
                return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
        }
const TiXmlAttribute * TiXmlAttribute::Next ( ) const

Get the next sibling attribute in the DOM. Returns null at end.

Definition at line 1184 of file tinyxml.cc.

References name, next, and value.

Referenced by TiXmlElement::CopyTo(), TiXmlElement::Print(), and TiXmlPrinter::VisitEnter().

{
        // We are using knowledge of the sentinel. The sentinel
        // have a value or name.
        if ( next->value.empty() && next->name.empty() )
                return 0;
        return next;
}
bool TiXmlAttribute::operator< ( const TiXmlAttribute rhs) const [inline]

Definition at line 865 of file tinyxml.h.

References name.

{ return name < rhs.name; }
bool TiXmlAttribute::operator< ( const TiXmlAttribute rhs) const [inline]

Definition at line 826 of file tinyxml.h.

References name.

{ return name < rhs.name; }
TiXmlAttribute& TiXmlAttribute::operator= ( const TiXmlAttribute base) [private]
void TiXmlAttribute::operator= ( const TiXmlAttribute base) [private]
bool TiXmlAttribute::operator== ( const TiXmlAttribute rhs) const [inline]

Definition at line 864 of file tinyxml.h.

References name.

{ return rhs.name == name; }
bool TiXmlAttribute::operator== ( const TiXmlAttribute rhs) const [inline]

Definition at line 825 of file tinyxml.h.

References name.

{ return rhs.name == name; }
bool TiXmlAttribute::operator> ( const TiXmlAttribute rhs) const [inline]

Definition at line 827 of file tinyxml.h.

References name.

{ return name > rhs.name; }
bool TiXmlAttribute::operator> ( const TiXmlAttribute rhs) const [inline]

Definition at line 866 of file tinyxml.h.

References name.

{ return name > rhs.name; }
const char * TiXmlAttribute::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
) [virtual]

Implements TiXmlBase.

Definition at line 1403 of file tinyxmlparser.cc.

References TiXmlParsingData::Cursor(), end, TiXmlBase::IsWhiteSpace(), TiXmlBase::location, name, AlCaHLTBitMon_ParallelJobs::p, TiXmlBase::ReadName(), TiXmlBase::ReadText(), TiXmlDocument::SetError(), TiXmlBase::SkipWhiteSpace(), TiXmlParsingData::Stamp(), TiXmlBase::TIXML_ERROR_READING_ATTRIBUTES, and value.

Referenced by TiXmlElement::Parse(), and TiXmlDeclaration::Parse().

{
        p = SkipWhiteSpace( p, encoding );
        if ( !p || !*p ) return 0;

//      int tabsize = 4;
//      if ( document )
//              tabsize = document->TabSize();

        if ( data )
        {
                data->Stamp( p, encoding );
                location = data->Cursor();
        }
        // Read the name, the '=' and the value.
        const char* pErr = p;
        p = ReadName( p, &name, encoding );
        if ( !p || !*p )
        {
                if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
                return 0;
        }
        p = SkipWhiteSpace( p, encoding );
        if ( !p || !*p || *p != '=' )
        {
                if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
                return 0;
        }

        ++p;    // skip '='
        p = SkipWhiteSpace( p, encoding );
        if ( !p || !*p )
        {
                if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
                return 0;
        }

        const char* end;
        const char SINGLE_QUOTE = '\'';
        const char DOUBLE_QUOTE = '\"';

        if ( *p == SINGLE_QUOTE )
        {
                ++p;
                end = "\'";             // single quote in string
                p = ReadText( p, &value, false, end, false, encoding );
        }
        else if ( *p == DOUBLE_QUOTE )
        {
                ++p;
                end = "\"";             // double quote in string
                p = ReadText( p, &value, false, end, false, encoding );
        }
        else
        {
                // All attribute values should be in single or double quotes.
                // But this is such a common error that the parser will try
                // its best, even without them.
                value = "";
                while (    p && *p                                                                                      // existence
                                && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r'      // whitespace
                                && *p != '/' && *p != '>' )                                                     // tag end
                {
                        if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
                                // [ 1451649 ] Attribute values with trailing quotes not handled correctly
                                // We did not have an opening quote but seem to have a
                                // closing one. Give up and throw an error.
                                if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
                                return 0;
                        }
                        value += *p;
                        ++p;
                }
        }
        return p;
}
virtual const char* TiXmlAttribute::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
) [virtual]

Implements TiXmlBase.

const TiXmlAttribute * TiXmlAttribute::Previous ( ) const

Get the previous sibling attribute in the DOM. Returns null at beginning.

Definition at line 1204 of file tinyxml.cc.

References name, prev, and value.

{
        // We are using knowledge of the sentinel. The sentinel
        // have a value or name.
        if ( prev->value.empty() && prev->name.empty() )
                return 0;
        return prev;
}
TiXmlAttribute* TiXmlAttribute::Previous ( ) [inline]

Definition at line 860 of file tinyxml.h.

                                   {
                return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
        }
TiXmlAttribute* TiXmlAttribute::Previous ( ) [inline]

Definition at line 821 of file tinyxml.h.

                                   {
                return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
        }
const TiXmlAttribute* TiXmlAttribute::Previous ( ) const

Get the previous sibling attribute in the DOM. Returns null at beginning.

virtual void TiXmlAttribute::Print ( FILE *  cfile,
int  depth 
) const [inline, 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 835 of file tinyxml.h.

References Print().

                                                           {
                Print( cfile, depth, 0 );
        }
void TiXmlAttribute::Print ( FILE *  cfile,
int  depth,
TIXML_STRING *  str 
) const
void TiXmlAttribute::Print ( FILE *  cfile,
int  depth,
TIXML_STRING *  str 
) const

Definition at line 1224 of file tinyxml.cc.

References TiXmlBase::EncodeString(), n, TIXML_STRING, v, and value.

{
        TIXML_STRING n, v;

        EncodeString( name, &n );
        EncodeString( value, &v );

        if (value.find ('\"') == TIXML_STRING::npos) {
                if ( cfile ) {
                fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
                }
                if ( str ) {
                        (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\"";
                }
        }
        else {
                if ( cfile ) {
                fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
                }
                if ( str ) {
                        (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'";
                }
        }
}
virtual void TiXmlAttribute::Print ( FILE *  cfile,
int  depth 
) const [inline, 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 874 of file tinyxml.h.

Referenced by TiXmlDocument::Print(), Print(), and TiXmlPrinter::VisitEnter().

                                                           {
                Print( cfile, depth, 0 );
        }
int TiXmlAttribute::QueryDoubleValue ( double *  _value) const

QueryDoubleValue examines the value string. See QueryIntValue().

Definition at line 1260 of file tinyxml.cc.

References TIXML_SUCCESS, TIXML_WRONG_TYPE, and value.

Referenced by TiXmlElement::QueryDoubleAttribute().

{
        try {
          *dval = boost::lexical_cast<double>(value);
        } catch(boost::bad_lexical_cast const&) {
          return TIXML_WRONG_TYPE;
        }
        return TIXML_SUCCESS;
}
int TiXmlAttribute::QueryDoubleValue ( double *  _value) const

QueryDoubleValue examines the value string. See QueryIntValue().

int TiXmlAttribute::QueryIntValue ( int *  _value) const

QueryIntValue examines the value string. It is an alternative to the IntValue() method with richer error checking. If the value 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.

A specialized but useful call. Note that for success it returns 0, which is the opposite of almost all other TinyXml calls.

int TiXmlAttribute::QueryIntValue ( int *  _value) const

QueryIntValue examines the value string. It is an alternative to the IntValue() method with richer error checking. If the value 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.

A specialized but useful call. Note that for success it returns 0, which is the opposite of almost all other TinyXml calls.

Definition at line 1250 of file tinyxml.cc.

References TIXML_SUCCESS, TIXML_WRONG_TYPE, and value.

Referenced by TiXmlElement::QueryIntAttribute().

{
        try {
          *ival = boost::lexical_cast<int>(value);
        } catch(boost::bad_lexical_cast const&) {
          return TIXML_WRONG_TYPE;
        }
        return TIXML_SUCCESS;
}
void TiXmlAttribute::SetDocument ( TiXmlDocument doc) [inline]

Definition at line 881 of file tinyxml.h.

References asciidump::doc, and document.

Referenced by TiXmlElement::Parse().

{ document = doc; }
void TiXmlAttribute::SetDocument ( TiXmlDocument doc) [inline]

Definition at line 842 of file tinyxml.h.

References asciidump::doc, and document.

{ document = doc; }
void TiXmlAttribute::SetDoubleValue ( double  _value)

Set the value from a double.

void TiXmlAttribute::SetDoubleValue ( double  _value)

Set the value from a double.

Definition at line 1281 of file tinyxml.cc.

References SetValue().

{
        char buf [256];
        #if defined(TIXML_SNPRINTF)
                TIXML_SNPRINTF( buf, sizeof(buf), "%f", _value);
        #else
                snprintf (buf, sizeof(buf), "%f", _value);
        #endif
        SetValue (buf);
}
void TiXmlAttribute::SetIntValue ( int  _value)

Set the value from an integer.

void TiXmlAttribute::SetIntValue ( int  _value)

Set the value from an integer.

Definition at line 1270 of file tinyxml.cc.

References SetValue().

{
        char buf [64];
        #if defined(TIXML_SNPRINTF)
                TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value);
        #else
                snprintf (buf, sizeof(buf), "%d", _value);
        #endif
        SetValue (buf);
}
void TiXmlAttribute::SetName ( const char *  _name) [inline]

Set the name of this attribute.

Definition at line 802 of file tinyxml.h.

References name.

void TiXmlAttribute::SetName ( const char *  _name) [inline]

Set the name of this attribute.

Definition at line 839 of file tinyxml.h.

References name.

void TiXmlAttribute::SetName ( const std::string &  _name) [inline]

STL std::string form.

Definition at line 847 of file tinyxml.h.

References name.

{ name = _name; }
void TiXmlAttribute::SetName ( const std::string &  _name) [inline]

STL std::string form.

Definition at line 809 of file tinyxml.h.

References name.

{ name = _name; }       
void TiXmlAttribute::SetValue ( const char *  _value) [inline]

Set the value.

Definition at line 840 of file tinyxml.h.

References value.

Referenced by TiXmlElement::Parse(), TiXmlElement::SetAttribute(), SetDoubleValue(), and SetIntValue().

void TiXmlAttribute::SetValue ( const std::string &  _value) [inline]

STL std::string form.

Definition at line 811 of file tinyxml.h.

References value.

{ value = _value; }
void TiXmlAttribute::SetValue ( const std::string &  _value) [inline]

STL std::string form.

Definition at line 849 of file tinyxml.h.

References value.

{ value = _value; }
void TiXmlAttribute::SetValue ( const char *  _value) [inline]

Set the value.

Definition at line 803 of file tinyxml.h.

References value.

const char* TiXmlAttribute::Value ( ) const [inline]

Return the value of this attribute.

Definition at line 816 of file tinyxml.h.

References value.

Referenced by TiXmlElement::Attribute(), TiXmlElement::CopyTo(), TiXmlElement::Parse(), and TiXmlDeclaration::Parse().

const char* TiXmlAttribute::Value ( ) const [inline]

Return the value of this attribute.

Definition at line 779 of file tinyxml.h.

References value.

const std::string& TiXmlAttribute::ValueStr ( ) const [inline]

Return the value of this attribute.

Definition at line 781 of file tinyxml.h.

References value.

const std::string& TiXmlAttribute::ValueStr ( ) const [inline]

Return the value of this attribute.

Definition at line 818 of file tinyxml.h.

References value.

Referenced by TiXmlElement::QueryValueAttribute().


Friends And Related Function Documentation

Definition at line 785 of file tinyxml.h.


Member Data Documentation

Definition at line 887 of file tinyxml.h.

Referenced by SetDocument(), and TiXmlAttribute().

TIXML_STRING TiXmlAttribute::name [private]
TIXML_STRING TiXmlAttribute::value [private]