#include <tinyxml.h>
Inheritance diagram for TiXmlAttribute:

Public Member Functions | |
| 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 * | Name () const |
| Return the name of this attribute. | |
| const char * | Value () const |
| Return the value of this attribute. | |
| const std::string & | ValueStr () 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 |
| 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. | |
| void | SetName (const std::string &_name) |
| STL std::string form. | |
| void | SetValue (const std::string &_value) |
| STL std::string form. | |
| 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 |
| 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) |
Private Attributes | |
| TiXmlDocument * | document |
| TIXML_STRING | name |
| TIXML_STRING | value |
| TiXmlAttribute * | prev |
| TiXmlAttribute * | next |
Friends | |
| class | TiXmlAttributeSet |
Definition at line 777 of file tinyxml.h.
|
|
Construct an empty attribute.
Definition at line 783 of file tinyxml.h. References document, next, and prev.
|
|
||||||||||||
|
std::string constructor.
Definition at line 791 of file tinyxml.h. References document, name, next, prev, and value. 00792 {
00793 name = _name;
00794 value = _value;
00795 document = 0;
00796 prev = next = 0;
00797 }
|
|
||||||||||||
|
Construct an attribute with a name and value.
Definition at line 801 of file tinyxml.h. References document, name, next, prev, and value. 00802 {
00803 name = _name;
00804 value = _value;
00805 document = 0;
00806 prev = next = 0;
00807 }
|
|
|
|
|
|
Return the value of this attribute, converted to a double.
Definition at line 1263 of file tinyxml.cpp. References value. 01264 {
01265 return atof (value.c_str ());
01266 }
|
|
|
Return the value of this attribute, converted to an integer.
Definition at line 1258 of file tinyxml.cpp. References value. 01259 {
01260 return atoi (value.c_str ());
01261 }
|
|
|
Return the name of this attribute.
Definition at line 809 of file tinyxml.h. References name. Referenced by TiXmlAttributeSet::Add(), TiXmlElement::CopyTo(), and TiXmlElement::Parse(). |
|
|
Definition at line 818 of file tinyxml.h. References TIXML_STRING. Referenced by TiXmlElement::Parse(). 00818 { return name; }
|
|
|
Definition at line 848 of file tinyxml.h. 00848 {
00849 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
00850 }
|
|
|
Get the next sibling attribute in the DOM. Returns null at end.
Definition at line 1156 of file tinyxml.cpp. References name, next, and value. Referenced by TiXmlElement::CopyTo(), TiXmlElement::Print(), and TiXmlPrinter::VisitEnter(). 01157 {
01158 // We are using knowledge of the sentinel. The sentinel
01159 // have a value or name.
01160 if ( next->value.empty() && next->name.empty() )
01161 return 0;
01162 return next;
01163 }
|
|
|
Definition at line 859 of file tinyxml.h. References name.
|
|
|
|
|
|
Definition at line 858 of file tinyxml.h. References name. 00858 { return rhs.name == name; }
|
|
|
Definition at line 860 of file tinyxml.h. References name.
|
|
||||||||||||||||
|
Implements TiXmlBase. Definition at line 1357 of file tinyxmlparser.cpp. References TiXmlParsingData::Cursor(), document, TiXmlBase::IsWhiteSpace(), name, TiXmlBase::ReadName(), TiXmlBase::ReadText(), TiXmlDocument::SetError(), TiXmlBase::SkipWhiteSpace(), TiXmlParsingData::Stamp(), and value. Referenced by TiXmlDeclaration::Parse(), and TiXmlElement::Parse(). 01358 {
01359 p = SkipWhiteSpace( p, encoding );
01360 if ( !p || !*p ) return 0;
01361
01362 // int tabsize = 4;
01363 // if ( document )
01364 // tabsize = document->TabSize();
01365
01366 if ( data )
01367 {
01368 data->Stamp( p, encoding );
01369 location = data->Cursor();
01370 }
01371 // Read the name, the '=' and the value.
01372 const char* pErr = p;
01373 p = ReadName( p, &name, encoding );
01374 if ( !p || !*p )
01375 {
01376 if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
01377 return 0;
01378 }
01379 p = SkipWhiteSpace( p, encoding );
01380 if ( !p || !*p || *p != '=' )
01381 {
01382 if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
01383 return 0;
01384 }
01385
01386 ++p; // skip '='
01387 p = SkipWhiteSpace( p, encoding );
01388 if ( !p || !*p )
01389 {
01390 if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
01391 return 0;
01392 }
01393
01394 const char* end;
01395 const char SINGLE_QUOTE = '\'';
01396 const char DOUBLE_QUOTE = '\"';
01397
01398 if ( *p == SINGLE_QUOTE )
01399 {
01400 ++p;
01401 end = "\'"; // single quote in string
01402 p = ReadText( p, &value, false, end, false, encoding );
01403 }
01404 else if ( *p == DOUBLE_QUOTE )
01405 {
01406 ++p;
01407 end = "\""; // double quote in string
01408 p = ReadText( p, &value, false, end, false, encoding );
01409 }
01410 else
01411 {
01412 // All attribute values should be in single or double quotes.
01413 // But this is such a common error that the parser will try
01414 // its best, even without them.
01415 value = "";
01416 while ( p && *p // existence
01417 && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace
01418 && *p != '/' && *p != '>' ) // tag end
01419 {
01420 if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
01421 // [ 1451649 ] Attribute values with trailing quotes not handled correctly
01422 // We did not have an opening quote but seem to have a
01423 // closing one. Give up and throw an error.
01424 if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
01425 return 0;
01426 }
01427 value += *p;
01428 ++p;
01429 }
01430 }
01431 return p;
01432 }
|
|
|
Definition at line 854 of file tinyxml.h. 00854 {
00855 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
00856 }
|
|
|
Get the previous sibling attribute in the DOM. Returns null at beginning.
Definition at line 1176 of file tinyxml.cpp. References name, prev, and value. 01177 {
01178 // We are using knowledge of the sentinel. The sentinel
01179 // have a value or name.
01180 if ( prev->value.empty() && prev->name.empty() )
01181 return 0;
01182 return prev;
01183 }
|
|
||||||||||||||||
|
Definition at line 1196 of file tinyxml.cpp. References name, TiXmlBase::PutString(), TIXML_STRING, and value. 01197 {
01198 TIXML_STRING n, v;
01199
01200 PutString( name, &n );
01201 PutString( value, &v );
01202
01203 if (value.find ('\"') == TIXML_STRING::npos) {
01204 if ( cfile ) {
01205 fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
01206 }
01207 if ( str ) {
01208 (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\"";
01209 }
01210 }
01211 else {
01212 if ( cfile ) {
01213 fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
01214 }
01215 if ( str ) {
01216 (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'";
01217 }
01218 }
01219 }
|
|
||||||||||||
|
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 868 of file tinyxml.h. Referenced by TiXmlElement::Print(), and TiXmlPrinter::VisitEnter(). 00868 {
00869 Print( cfile, depth, 0 );
00870 }
|
|
|
QueryDoubleValue examines the value string. See QueryIntValue().
Definition at line 1229 of file tinyxml.cpp. References value. Referenced by TiXmlElement::QueryDoubleAttribute(). 01230 {
01231 if ( sscanf( value.c_str(), "%lf", dval ) == 1 )
01232 return TIXML_SUCCESS;
01233 return TIXML_WRONG_TYPE;
01234 }
|
|
|
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 1222 of file tinyxml.cpp. References value. Referenced by TiXmlElement::QueryIntAttribute(). 01223 {
01224 if ( sscanf( value.c_str(), "%d", ival ) == 1 )
01225 return TIXML_SUCCESS;
01226 return TIXML_WRONG_TYPE;
01227 }
|
|
|
Definition at line 875 of file tinyxml.h. References document. Referenced by TiXmlElement::Parse(). 00875 { document = doc; }
|
|
|
Set the value from a double.
Definition at line 1247 of file tinyxml.cpp. References SetValue(). 01248 {
01249 char buf [256];
01250 #if defined(TIXML_SNPRINTF)
01251 TIXML_SNPRINTF( buf, sizeof(buf), "%f", _value);
01252 #else
01253 sprintf (buf, "%f", _value);
01254 #endif
01255 SetValue (buf);
01256 }
|
|
|
Set the value from an integer.
Definition at line 1236 of file tinyxml.cpp. References SetValue(). 01237 {
01238 char buf [64];
01239 #if defined(TIXML_SNPRINTF)
01240 TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value);
01241 #else
01242 sprintf (buf, "%d", _value);
01243 #endif
01244 SetValue (buf);
01245 }
|
|
|
STL std::string form.
Definition at line 841 of file tinyxml.h. References name. 00841 { name = _name; }
|
|
|
Set the name of this attribute.
Definition at line 833 of file tinyxml.h. References name. |
|
|
STL std::string form.
Definition at line 843 of file tinyxml.h. References value. 00843 { value = _value; }
|
|
|
Set the value.
Definition at line 834 of file tinyxml.h. References value. Referenced by TiXmlElement::Parse(), TiXmlElement::SetAttribute(), SetDoubleValue(), and SetIntValue(). |
|
|
Return the value of this attribute.
Definition at line 810 of file tinyxml.h. References value. Referenced by TiXmlElement::Attribute(), TiXmlElement::CopyTo(), TiXmlDeclaration::Parse(), and TiXmlElement::Parse(). |
|
|
Return the value of this attribute.
Definition at line 812 of file tinyxml.h. Referenced by TiXmlElement::Attribute(), and TiXmlElement::QueryValueAttribute(). |
|
|
|
|
|
Definition at line 881 of file tinyxml.h. Referenced by Parse(), SetDocument(), and TiXmlAttribute(). |
|
|
Definition at line 882 of file tinyxml.h. Referenced by TiXmlAttributeSet::Find(), Name(), Next(), operator<(), operator==(), operator>(), Parse(), Previous(), Print(), SetName(), and TiXmlAttribute(). |
|
|
Definition at line 885 of file tinyxml.h. Referenced by TiXmlAttributeSet::Add(), TiXmlAttributeSet::Find(), Next(), TiXmlAttributeSet::Remove(), TiXmlAttribute(), TiXmlAttributeSet::TiXmlAttributeSet(), and TiXmlAttributeSet::~TiXmlAttributeSet(). |
|
|
Definition at line 884 of file tinyxml.h. Referenced by TiXmlAttributeSet::Add(), Previous(), TiXmlAttributeSet::Remove(), TiXmlAttribute(), TiXmlAttributeSet::TiXmlAttributeSet(), and TiXmlAttributeSet::~TiXmlAttributeSet(). |
|
|
Definition at line 883 of file tinyxml.h. Referenced by DoubleValue(), IntValue(), Next(), Parse(), Previous(), Print(), QueryDoubleValue(), QueryIntValue(), SetValue(), TiXmlAttribute(), and Value(). |
1.3.9.1