#include <tinyxml.h>
Public Member Functions | |
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. | |
const char * | Name () const |
Return the name of this attribute. | |
const TIXML_STRING & | NameTStr () const |
const TiXmlAttribute * | Next () const |
Get the next sibling attribute in the DOM. Returns null at end. | |
TiXmlAttribute * | Next () |
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) |
TiXmlAttribute * | Previous () |
const TiXmlAttribute * | Previous () const |
Get the previous sibling attribute in the DOM. Returns null at beginning. | |
void | Print (FILE *cfile, int depth, TIXML_STRING *str) const |
virtual void | Print (FILE *cfile, int depth) const |
int | QueryDoubleValue (double *_value) const |
QueryDoubleValue examines the value string. See QueryIntValue(). | |
int | QueryIntValue (int *_value) const |
void | SetDocument (TiXmlDocument *doc) |
void | SetDoubleValue (double _value) |
Set the value from a double. | |
void | SetIntValue (int _value) |
Set the value from an integer. | |
void | SetName (const char *_name) |
Set the name of this attribute. | |
void | SetName (const std::string &_name) |
STL std::string form. | |
void | SetValue (const char *_value) |
Set the value. | |
void | SetValue (const std::string &_value) |
STL std::string form. | |
TiXmlAttribute () | |
Construct an empty attribute. | |
TiXmlAttribute (const std::string &_name, const std::string &_value) | |
std::string constructor. | |
TiXmlAttribute (const char *_name, const char *_value) | |
Construct an attribute with a name and value. | |
const char * | Value () const |
Return the value of this attribute. | |
const std::string & | ValueStr () const |
Return the value of this attribute. | |
Private Member Functions | |
void | operator= (const TiXmlAttribute &base) |
TiXmlAttribute (const TiXmlAttribute &) | |
Private Attributes | |
TiXmlDocument * | document |
TIXML_STRING | name |
TiXmlAttribute * | next |
TiXmlAttribute * | prev |
TIXML_STRING | value |
Friends | |
class | TiXmlAttributeSet |
An attribute is a name-value pair. Elements have an arbitrary number of attributes, each with a unique name.
TiXmlAttribute::TiXmlAttribute | ( | ) | [inline] |
TiXmlAttribute::TiXmlAttribute | ( | const std::string & | _name, |
const std::string & | _value | ||
) | [inline] |
TiXmlAttribute::TiXmlAttribute | ( | const char * | _name, |
const char * | _value | ||
) | [inline] |
TiXmlAttribute::TiXmlAttribute | ( | const TiXmlAttribute & | ) | [private] |
double TiXmlAttribute::DoubleValue | ( | ) | const |
Return the value of this attribute, converted to a double.
Definition at line 1283 of file tinyxml.cc.
References value.
{ return atof (value.c_str ()); }
int TiXmlAttribute::IntValue | ( | ) | const |
Return the value of this attribute, converted to an integer.
Definition at line 1278 of file tinyxml.cc.
References value.
{ return atoi (value.c_str ()); }
const char* TiXmlAttribute::Name | ( | ) | const [inline] |
Return the name of this attribute.
Definition at line 813 of file tinyxml.h.
References name.
Referenced by TiXmlAttributeSet::Add(), TiXmlElement::CopyTo(), and TiXmlElement::Parse().
const TIXML_STRING& TiXmlAttribute::NameTStr | ( | ) | const [inline] |
Definition at line 822 of file tinyxml.h.
References name.
Referenced by TiXmlElement::Parse().
{ return name; }
TiXmlAttribute* TiXmlAttribute::Next | ( | ) | [inline] |
Definition at line 852 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 1176 of file tinyxml.cc.
References name, next, and value.
Referenced by TiXmlElement::CopyTo(), TiXmlElement::Print(), and TiXmlPrinter::VisitEnter().
bool TiXmlAttribute::operator< | ( | const TiXmlAttribute & | rhs | ) | const [inline] |
void TiXmlAttribute::operator= | ( | const TiXmlAttribute & | base | ) | [private] |
bool TiXmlAttribute::operator== | ( | const TiXmlAttribute & | rhs | ) | const [inline] |
bool TiXmlAttribute::operator> | ( | const TiXmlAttribute & | rhs | ) | const [inline] |
const char * TiXmlAttribute::Parse | ( | const char * | p, |
TiXmlParsingData * | data, | ||
TiXmlEncoding | encoding | ||
) | [virtual] |
Implements TiXmlBase.
Definition at line 1394 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; }
const TiXmlAttribute * TiXmlAttribute::Previous | ( | ) | const |
Get the previous sibling attribute in the DOM. Returns null at beginning.
Definition at line 1196 of file tinyxml.cc.
TiXmlAttribute* TiXmlAttribute::Previous | ( | ) | [inline] |
Definition at line 858 of file tinyxml.h.
{ return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); }
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 872 of file tinyxml.h.
Referenced by TiXmlDocument::Print(), and TiXmlPrinter::VisitEnter().
{ Print( cfile, depth, 0 ); }
void TiXmlAttribute::Print | ( | FILE * | cfile, |
int | depth, | ||
TIXML_STRING * | str | ||
) | const |
Definition at line 1216 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) += "'"; } } }
int TiXmlAttribute::QueryDoubleValue | ( | double * | _value | ) | const |
QueryDoubleValue examines the value string. See QueryIntValue().
Definition at line 1249 of file tinyxml.cc.
References TIXML_SSCANF, TIXML_SUCCESS, TIXML_WRONG_TYPE, and value.
Referenced by TiXmlElement::QueryDoubleAttribute().
{ if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; }
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 1242 of file tinyxml.cc.
References TIXML_SSCANF, TIXML_SUCCESS, TIXML_WRONG_TYPE, and value.
Referenced by TiXmlElement::QueryIntAttribute().
{ if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; }
void TiXmlAttribute::SetDocument | ( | TiXmlDocument * | doc | ) | [inline] |
Definition at line 879 of file tinyxml.h.
References asciidump::doc, and document.
Referenced by TiXmlElement::Parse().
void TiXmlAttribute::SetDoubleValue | ( | double | _value | ) |
Set the value from a double.
Definition at line 1267 of file tinyxml.cc.
References SetValue().
{ char buf [256]; #if defined(TIXML_SNPRINTF) TIXML_SNPRINTF( buf, sizeof(buf), "%f", _value); #else sprintf (buf, "%f", _value); #endif SetValue (buf); }
void TiXmlAttribute::SetIntValue | ( | int | _value | ) |
Set the value from an integer.
Definition at line 1256 of file tinyxml.cc.
References SetValue().
{ char buf [64]; #if defined(TIXML_SNPRINTF) TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); #else sprintf (buf, "%d", _value); #endif SetValue (buf); }
void TiXmlAttribute::SetName | ( | const std::string & | _name | ) | [inline] |
void TiXmlAttribute::SetName | ( | const char * | _name | ) | [inline] |
void TiXmlAttribute::SetValue | ( | const std::string & | _value | ) | [inline] |
void TiXmlAttribute::SetValue | ( | const char * | _value | ) | [inline] |
Set the value.
Definition at line 838 of file tinyxml.h.
References value.
Referenced by TiXmlElement::Parse(), TiXmlElement::SetAttribute(), SetDoubleValue(), and SetIntValue().
const char* TiXmlAttribute::Value | ( | ) | const [inline] |
Return the value of this attribute.
Definition at line 814 of file tinyxml.h.
References value.
Referenced by TiXmlElement::Attribute(), TiXmlElement::CopyTo(), TiXmlElement::Parse(), and TiXmlDeclaration::Parse().
const std::string& TiXmlAttribute::ValueStr | ( | ) | const [inline] |
Return the value of this attribute.
Definition at line 816 of file tinyxml.h.
References value.
Referenced by TiXmlElement::QueryValueAttribute().
friend class TiXmlAttributeSet [friend] |
TiXmlDocument* TiXmlAttribute::document [private] |
Definition at line 885 of file tinyxml.h.
Referenced by SetDocument(), and TiXmlAttribute().
TIXML_STRING TiXmlAttribute::name [private] |
Definition at line 886 of file tinyxml.h.
Referenced by TiXmlAttributeSet::Find(), Name(), NameTStr(), Next(), operator<(), operator==(), operator>(), Parse(), Previous(), SetName(), and TiXmlAttribute().
TiXmlAttribute* TiXmlAttribute::next [private] |
Definition at line 889 of file tinyxml.h.
Referenced by TiXmlAttributeSet::Add(), TiXmlAttributeSet::Find(), TiXmlAttributeSet::First(), Next(), TiXmlAttributeSet::Remove(), TiXmlAttribute(), TiXmlAttributeSet::TiXmlAttributeSet(), and TiXmlAttributeSet::~TiXmlAttributeSet().
TiXmlAttribute* TiXmlAttribute::prev [private] |
Definition at line 888 of file tinyxml.h.
Referenced by TiXmlAttributeSet::Add(), TiXmlAttributeSet::Last(), Previous(), TiXmlAttributeSet::Remove(), TiXmlAttribute(), TiXmlAttributeSet::TiXmlAttributeSet(), and TiXmlAttributeSet::~TiXmlAttributeSet().
TIXML_STRING TiXmlAttribute::value [private] |
Definition at line 887 of file tinyxml.h.
Referenced by DoubleValue(), IntValue(), Next(), Parse(), Previous(), Print(), QueryDoubleValue(), QueryIntValue(), SetValue(), TiXmlAttribute(), Value(), and ValueStr().