An attribute is a name-value pair. More...
#include <OBTtinyxml.h>
Public Member Functions | |
TiXmlAttribute () | |
Construct an empty attribute. | |
TiXmlAttribute (const char *_name, const char *_value) | |
Construct an attribute with a name and value. | |
const char * | Name () const |
Return the name of this attribute. | |
const char * | Value () const |
Return the value of this attribute. | |
int | IntValue () const |
Return the value of this attribute, converted to an integer. | |
double | DoubleValue () const |
Return the value of this attribute, converted to a double. | |
const TIXML_STRING & | NameTStr () const |
int | QueryIntValue (int *_value) const |
QueryIntValue examines the value string. | |
int | QueryDoubleValue (double *_value) const |
QueryDoubleValue examines the value string. See QueryIntValue(). | |
void | SetName (const char *_name) |
Set the name of this attribute. | |
void | setValue (const char *_value) |
Set the value. | |
void | SetIntValue (int _value) |
Set the value from an integer. | |
void | SetDoubleValue (double _value) |
Set the value from a double. | |
const TiXmlAttribute * | Next () const |
Get the next sibling attribute in the DOM. Returns null at end. | |
TiXmlAttribute * | Next () |
const TiXmlAttribute * | Previous () const |
Get the previous sibling attribute in the DOM. Returns null at beginning. | |
TiXmlAttribute * | Previous () |
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 void | Print (FILE *cfile, int depth) const |
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode. | |
void | Print (FILE *cfile, int depth, TIXML_STRING *str) const |
void | SetDocument (TiXmlDocument *doc) |
TiXmlAttribute () | |
Construct an empty attribute. | |
TiXmlAttribute (const char *_name, const char *_value) | |
Construct an attribute with a name and value. | |
const char * | Name () const |
Return the name of this attribute. | |
const char * | Value () const |
Return the value of this attribute. | |
int | IntValue () const |
Return the value of this attribute, converted to an integer. | |
double | DoubleValue () const |
Return the value of this attribute, converted to a double. | |
const TIXML_STRING & | NameTStr () const |
int | QueryIntValue (int *_value) const |
QueryIntValue examines the value string. | |
int | QueryDoubleValue (double *_value) const |
QueryDoubleValue examines the value string. See QueryIntValue(). | |
void | SetName (const char *_name) |
Set the name of this attribute. | |
void | SetValue (const char *_value) |
Set the value. | |
void | SetIntValue (int _value) |
Set the value from an integer. | |
void | SetDoubleValue (double _value) |
Set the value from a double. | |
const TiXmlAttribute * | Next () const |
Get the next sibling attribute in the DOM. Returns null at end. | |
TiXmlAttribute * | Next () |
const TiXmlAttribute * | Previous () const |
Get the previous sibling attribute in the DOM. Returns null at beginning. | |
TiXmlAttribute * | Previous () |
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 void | Print (FILE *cfile, int depth) const |
All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode. | |
void | Print (FILE *cfile, int depth, TIXML_STRING *str) const |
void | SetDocument (TiXmlDocument *doc) |
Private Member Functions | |
TiXmlAttribute (const TiXmlAttribute &) | |
void | operator= (const TiXmlAttribute &base) |
TiXmlAttribute (const TiXmlAttribute &) | |
void | operator= (const TiXmlAttribute &base) |
Private Attributes | |
TiXmlDocument * | document |
TIXML_STRING | name |
TIXML_STRING | value |
TiXmlAttribute * | prev |
TiXmlAttribute * | next |
Friends | |
class | TiXmlAttributeSet |
An attribute is a name-value pair.
Elements have an arbitrary number of attributes, each with a unique name.
Definition at line 787 of file OBTtinyxml.h.
OBT::TiXmlAttribute::TiXmlAttribute | ( | ) | [inline] |
OBT::TiXmlAttribute::TiXmlAttribute | ( | const char * | _name, | |
const char * | _value | |||
) | [inline] |
OBT::TiXmlAttribute::TiXmlAttribute | ( | const TiXmlAttribute & | ) | [private] |
OBT::TiXmlAttribute::TiXmlAttribute | ( | ) | [inline] |
OBT::TiXmlAttribute::TiXmlAttribute | ( | const char * | _name, | |
const char * | _value | |||
) | [inline] |
OBT::TiXmlAttribute::TiXmlAttribute | ( | const TiXmlAttribute & | ) | [private] |
double OBT::TiXmlAttribute::DoubleValue | ( | ) | const |
Return the value of this attribute, converted to a double.
double OBT::TiXmlAttribute::DoubleValue | ( | ) | const |
Return the value of this attribute, converted to a double.
Definition at line 1283 of file OBTtinyxml.cpp.
References value.
01284 { 01285 return atof (value.c_str ()); 01286 }
int OBT::TiXmlAttribute::IntValue | ( | ) | const |
Return the value of this attribute, converted to an integer.
int OBT::TiXmlAttribute::IntValue | ( | ) | const |
Return the value of this attribute, converted to an integer.
Definition at line 1278 of file OBTtinyxml.cpp.
References value.
01279 { 01280 return atoi (value.c_str ()); 01281 }
const char* OBT::TiXmlAttribute::Name | ( | ) | const [inline] |
Return the name of this attribute.
Definition at line 818 of file tiny/OBTtinyxml.h.
References name.
const char* OBT::TiXmlAttribute::Name | ( | ) | const [inline] |
Return the name of this attribute.
Definition at line 819 of file OBTtinyxml.h.
Referenced by OBT::TiXmlAttributeSet::Add(), OBT::TiXmlElement::CopyTo(), and OBT::TiXmlElement::Parse().
const TIXML_STRING& OBT::TiXmlAttribute::NameTStr | ( | ) | const [inline] |
const TIXML_STRING& OBT::TiXmlAttribute::NameTStr | ( | ) | const [inline] |
Definition at line 828 of file OBTtinyxml.h.
Referenced by OBT::TiXmlElement::Parse().
00828 { return name; }
TiXmlAttribute* OBT::TiXmlAttribute::Next | ( | ) | [inline] |
Definition at line 857 of file tiny/OBTtinyxml.h.
00857 { 00858 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); 00859 }
const TiXmlAttribute* OBT::TiXmlAttribute::Next | ( | ) | const |
Get the next sibling attribute in the DOM. Returns null at end.
TiXmlAttribute* OBT::TiXmlAttribute::Next | ( | ) | [inline] |
Definition at line 858 of file OBTtinyxml.h.
00858 { 00859 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); 00860 }
const TiXmlAttribute * OBT::TiXmlAttribute::Next | ( | ) | const |
Get the next sibling attribute in the DOM. Returns null at end.
Definition at line 1176 of file OBTtinyxml.cpp.
References name, next, and value.
Referenced by OBT::TiXmlElement::CopyTo(), OBT::TiXmlElement::Print(), and OBT::TiXmlPrinter::VisitEnter().
bool OBT::TiXmlAttribute::operator< | ( | const TiXmlAttribute & | rhs | ) | const [inline] |
Definition at line 868 of file tiny/OBTtinyxml.h.
References name.
00868 { return name < rhs.name; }
bool OBT::TiXmlAttribute::operator< | ( | const TiXmlAttribute & | rhs | ) | const [inline] |
void OBT::TiXmlAttribute::operator= | ( | const TiXmlAttribute & | base | ) | [private] |
Reimplemented from OBT::TiXmlBase.
void OBT::TiXmlAttribute::operator= | ( | const TiXmlAttribute & | base | ) | [private] |
Reimplemented from OBT::TiXmlBase.
bool OBT::TiXmlAttribute::operator== | ( | const TiXmlAttribute & | rhs | ) | const [inline] |
Definition at line 867 of file tiny/OBTtinyxml.h.
References name.
00867 { return rhs.name == name; }
bool OBT::TiXmlAttribute::operator== | ( | const TiXmlAttribute & | rhs | ) | const [inline] |
bool OBT::TiXmlAttribute::operator> | ( | const TiXmlAttribute & | rhs | ) | const [inline] |
Definition at line 869 of file tiny/OBTtinyxml.h.
References name.
00869 { return name > rhs.name; }
bool OBT::TiXmlAttribute::operator> | ( | const TiXmlAttribute & | rhs | ) | const [inline] |
virtual const char* OBT::TiXmlAttribute::Parse | ( | const char * | p, | |
TiXmlParsingData * | data, | |||
TiXmlEncoding | encoding | |||
) | [virtual] |
Implements OBT::TiXmlBase.
const char * OBT::TiXmlAttribute::Parse | ( | const char * | p, | |
TiXmlParsingData * | data, | |||
TiXmlEncoding | encoding | |||
) | [virtual] |
Implements OBT::TiXmlBase.
Definition at line 1391 of file OBTtinyxmlparser.cpp.
References OBT::TiXmlParsingData::Cursor(), OBT::TiXmlBase::IsWhiteSpace(), OBT::TiXmlBase::location, name, OBT::TiXmlBase::ReadName(), OBT::TiXmlBase::ReadText(), OBT::TiXmlDocument::SetError(), OBT::TiXmlBase::SkipWhiteSpace(), OBT::TiXmlParsingData::Stamp(), OBT::TiXmlBase::TIXML_ERROR_READING_ATTRIBUTES, and value.
Referenced by OBT::TiXmlDeclaration::Parse(), and OBT::TiXmlElement::Parse().
01392 { 01393 p = SkipWhiteSpace( p, encoding ); 01394 if ( !p || !*p ) return 0; 01395 01396 // int tabsize = 4; 01397 // if ( document ) 01398 // tabsize = document->TabSize(); 01399 01400 if ( data ) 01401 { 01402 data->Stamp( p, encoding ); 01403 location = data->Cursor(); 01404 } 01405 // Read the name, the '=' and the value. 01406 const char* pErr = p; 01407 p = ReadName( p, &name, encoding ); 01408 if ( !p || !*p ) 01409 { 01410 if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); 01411 return 0; 01412 } 01413 p = SkipWhiteSpace( p, encoding ); 01414 if ( !p || !*p || *p != '=' ) 01415 { 01416 if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); 01417 return 0; 01418 } 01419 01420 ++p; // skip '=' 01421 p = SkipWhiteSpace( p, encoding ); 01422 if ( !p || !*p ) 01423 { 01424 if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); 01425 return 0; 01426 } 01427 01428 const char* end; 01429 const char SINGLE_QUOTE = '\''; 01430 const char DOUBLE_QUOTE = '\"'; 01431 01432 if ( *p == SINGLE_QUOTE ) 01433 { 01434 ++p; 01435 end = "\'"; // single quote in string 01436 p = ReadText( p, &value, false, end, false, encoding ); 01437 } 01438 else if ( *p == DOUBLE_QUOTE ) 01439 { 01440 ++p; 01441 end = "\""; // double quote in string 01442 p = ReadText( p, &value, false, end, false, encoding ); 01443 } 01444 else 01445 { 01446 // All attribute values should be in single or double quotes. 01447 // But this is such a common error that the parser will try 01448 // its best, even without them. 01449 value = ""; 01450 while ( p && *p // existence 01451 && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace 01452 && *p != '/' && *p != '>' ) // tag end 01453 { 01454 if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { 01455 // [ 1451649 ] Attribute values with trailing quotes not handled correctly 01456 // We did not have an opening quote but seem to have a 01457 // closing one. Give up and throw an error. 01458 if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); 01459 return 0; 01460 } 01461 value += *p; 01462 ++p; 01463 } 01464 } 01465 return p; 01466 }
TiXmlAttribute* OBT::TiXmlAttribute::Previous | ( | ) | [inline] |
Definition at line 863 of file tiny/OBTtinyxml.h.
00863 { 00864 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); 00865 }
const TiXmlAttribute* OBT::TiXmlAttribute::Previous | ( | ) | const |
Get the previous sibling attribute in the DOM. Returns null at beginning.
TiXmlAttribute* OBT::TiXmlAttribute::Previous | ( | ) | [inline] |
Definition at line 864 of file OBTtinyxml.h.
00864 { 00865 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); 00866 }
const TiXmlAttribute * OBT::TiXmlAttribute::Previous | ( | ) | const |
Get the previous sibling attribute in the DOM. Returns null at beginning.
Definition at line 1196 of file OBTtinyxml.cpp.
void OBT::TiXmlAttribute::Print | ( | FILE * | cfile, | |
int | depth, | |||
TIXML_STRING * | str | |||
) | const |
virtual void OBT::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 OBT::TiXmlBase.
Definition at line 877 of file tiny/OBTtinyxml.h.
References Print().
00877 { 00878 Print( cfile, depth, 0 ); 00879 }
void OBT::TiXmlAttribute::Print | ( | FILE * | cfile, | |
int | depth, | |||
TIXML_STRING * | str | |||
) | const |
Definition at line 1216 of file OBTtinyxml.cpp.
References OBT::TiXmlBase::EncodeString(), TIXML_STRING, and value.
01217 { 01218 TIXML_STRING n, v; 01219 01220 EncodeString( name, &n ); 01221 EncodeString( value, &v ); 01222 01223 if (value.find ('\"') == TIXML_STRING::npos) { 01224 if ( cfile ) { 01225 fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); 01226 } 01227 if ( str ) { 01228 (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; 01229 } 01230 } 01231 else { 01232 if ( cfile ) { 01233 fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); 01234 } 01235 if ( str ) { 01236 (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; 01237 } 01238 } 01239 }
virtual void OBT::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 OBT::TiXmlBase.
Definition at line 878 of file OBTtinyxml.h.
Referenced by Print(), and OBT::TiXmlDocument::Print().
00878 { 00879 Print( cfile, depth, 0 ); 00880 }
int OBT::TiXmlAttribute::QueryDoubleValue | ( | double * | _value | ) | const |
QueryDoubleValue examines the value string. See QueryIntValue().
int OBT::TiXmlAttribute::QueryDoubleValue | ( | double * | _value | ) | const |
QueryDoubleValue examines the value string. See QueryIntValue().
Definition at line 1249 of file OBTtinyxml.cpp.
References TIXML_SSCANF, OBT::TIXML_SUCCESS, OBT::TIXML_WRONG_TYPE, and value.
Referenced by OBT::TiXmlElement::QueryDoubleAttribute().
01250 { 01251 if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) 01252 return TIXML_SUCCESS; 01253 return TIXML_WRONG_TYPE; 01254 }
int OBT::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 OBT::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 OBTtinyxml.cpp.
References TIXML_SSCANF, OBT::TIXML_SUCCESS, OBT::TIXML_WRONG_TYPE, and value.
Referenced by OBT::TiXmlElement::QueryIntAttribute().
01243 { 01244 if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) 01245 return TIXML_SUCCESS; 01246 return TIXML_WRONG_TYPE; 01247 }
void OBT::TiXmlAttribute::SetDocument | ( | TiXmlDocument * | doc | ) | [inline] |
void OBT::TiXmlAttribute::SetDocument | ( | TiXmlDocument * | doc | ) | [inline] |
Definition at line 885 of file OBTtinyxml.h.
Referenced by OBT::TiXmlElement::Parse().
00885 { document = doc; }
void OBT::TiXmlAttribute::SetDoubleValue | ( | double | _value | ) |
Set the value from a double.
void OBT::TiXmlAttribute::SetDoubleValue | ( | double | _value | ) |
Set the value from a double.
Definition at line 1267 of file OBTtinyxml.cpp.
References setValue().
01268 { 01269 char buf [256]; 01270 #if defined(TIXML_SNPRINTF) 01271 TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value); 01272 #else 01273 sprintf (buf, "%lf", _value); 01274 #endif 01275 setValue (buf); 01276 }
void OBT::TiXmlAttribute::SetIntValue | ( | int | _value | ) |
Set the value from an integer.
void OBT::TiXmlAttribute::SetIntValue | ( | int | _value | ) |
Set the value from an integer.
Definition at line 1256 of file OBTtinyxml.cpp.
References setValue().
01257 { 01258 char buf [64]; 01259 #if defined(TIXML_SNPRINTF) 01260 TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); 01261 #else 01262 sprintf (buf, "%d", _value); 01263 #endif 01264 setValue (buf); 01265 }
void OBT::TiXmlAttribute::SetName | ( | const char * | _name | ) | [inline] |
void OBT::TiXmlAttribute::SetName | ( | const char * | _name | ) | [inline] |
Set the name of this attribute.
Definition at line 843 of file OBTtinyxml.h.
void OBT::TiXmlAttribute::SetValue | ( | const char * | _value | ) | [inline] |
void OBT::TiXmlAttribute::setValue | ( | const char * | _value | ) | [inline] |
Set the value.
Definition at line 844 of file OBTtinyxml.h.
Referenced by OBT::TiXmlElement::Parse(), OBT::TiXmlElement::SetAttribute(), SetDoubleValue(), and SetIntValue().
const char* OBT::TiXmlAttribute::Value | ( | ) | const [inline] |
Return the value of this attribute.
Definition at line 819 of file tiny/OBTtinyxml.h.
References value.
const char* OBT::TiXmlAttribute::Value | ( | ) | const [inline] |
Return the value of this attribute.
Definition at line 820 of file OBTtinyxml.h.
Referenced by OBT::TiXmlElement::Attribute(), OBT::TiXmlElement::CopyTo(), OBT::TiXmlDeclaration::Parse(), and OBT::TiXmlElement::Parse().
TiXmlAttributeSet [friend] |
Definition at line 789 of file OBTtinyxml.h.
TiXmlDocument * OBT::TiXmlAttribute::document [private] |
Definition at line 891 of file OBTtinyxml.h.
Referenced by SetDocument(), and TiXmlAttribute().
TIXML_STRING OBT::TiXmlAttribute::name [private] |
Definition at line 892 of file OBTtinyxml.h.
Referenced by OBT::TiXmlAttributeSet::Find(), Name(), NameTStr(), Next(), operator<(), operator==(), operator>(), Parse(), Previous(), SetName(), and TiXmlAttribute().
TiXmlAttribute * OBT::TiXmlAttribute::next [private] |
Definition at line 895 of file OBTtinyxml.h.
Referenced by OBT::TiXmlAttributeSet::Add(), OBT::TiXmlAttributeSet::Find(), OBT::TiXmlAttributeSet::First(), Next(), OBT::TiXmlAttributeSet::Remove(), TiXmlAttribute(), OBT::TiXmlAttributeSet::TiXmlAttributeSet(), and OBT::TiXmlAttributeSet::~TiXmlAttributeSet().
TiXmlAttribute * OBT::TiXmlAttribute::prev [private] |
Definition at line 894 of file OBTtinyxml.h.
Referenced by OBT::TiXmlAttributeSet::Add(), OBT::TiXmlAttributeSet::Last(), Previous(), OBT::TiXmlAttributeSet::Remove(), TiXmlAttribute(), OBT::TiXmlAttributeSet::TiXmlAttributeSet(), and OBT::TiXmlAttributeSet::~TiXmlAttributeSet().
TIXML_STRING OBT::TiXmlAttribute::value [private] |
Definition at line 893 of file OBTtinyxml.h.
Referenced by DoubleValue(), IntValue(), Next(), Parse(), Previous(), Print(), QueryDoubleValue(), QueryIntValue(), SetValue(), TiXmlAttribute(), and Value().