OBT::TiXmlElement Class Reference

The element is a container class. More...

#include <OBTtinyxml.h>

Inheritance diagram for OBT::TiXmlElement:

Inheritance graph
[legend]
Collaboration diagram for OBT::TiXmlElement:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 TiXmlElement (const char *in_value)
 Construct an element.
 TiXmlElement (const std::string &_value)
 std::string constructor.
 TiXmlElement (const TiXmlElement &)
void operator= (const TiXmlElement &base)
virtual ~TiXmlElement ()
const char * 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 * 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.
const char * 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.
int QueryIntAttribute (const char *name, int *_value) const
 QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking.
int QueryDoubleAttribute (const char *name, double *_value) const
 QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
int QueryFloatAttribute (const char *name, float *_value) const
 QueryFloatAttribute examines the attribute - see QueryIntAttribute().
template<typename T>
int QueryValueAttribute (const std::string &name, T *outValue) const
 Template form of the attribute query which will try to read the attribute into the specified type.
void SetAttribute (const char *name, const char *_value)
 Sets an attribute of name to a given value.
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
int QueryIntAttribute (const std::string &name, int *_value) const
int QueryDoubleAttribute (const std::string &name, double *_value) const
void SetAttribute (const std::string &name, const std::string &_value)
 STL std::string form.
void SetAttribute (const std::string &name, int _value)
void SetAttribute (const char *name, int value)
 Sets an attribute of name to a given value.
void SetDoubleAttribute (const char *name, double value)
 Sets an attribute of name to a given value.
void RemoveAttribute (const char *name)
 Deletes an attribute with the given name.
void RemoveAttribute (const std::string &name)
 STL std::string form.
const TiXmlAttributeFirstAttribute () const
 Access the first attribute in this element.
TiXmlAttributeFirstAttribute ()
const TiXmlAttributeLastAttribute () const
 Access the last attribute in this element.
TiXmlAttributeLastAttribute ()
const char * GetText () const
 Convenience function for easy access to the text inside an element.
virtual TiXmlNodeClone () const
 Creates a new Element and returns it - the returned element is a copy.
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.
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual const
TiXmlElement
ToElement () 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 bool Accept (TiXmlVisitor *visitor) const
 Walk the XML tree visiting this node and all of its children.
 TiXmlElement (const char *in_value)
 Construct an element.
 TiXmlElement (const std::string &_value)
 std::string constructor.
 TiXmlElement (const TiXmlElement &)
void operator= (const TiXmlElement &base)
virtual ~TiXmlElement ()
const char * 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 * 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.
const char * 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.
int QueryIntAttribute (const char *name, int *_value) const
 QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking.
int QueryDoubleAttribute (const char *name, double *_value) const
 QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
int QueryFloatAttribute (const char *name, float *_value) const
 QueryFloatAttribute examines the attribute - see QueryIntAttribute().
template<typename T>
int QueryValueAttribute (const std::string &name, T *outValue) const
 Template form of the attribute query which will try to read the attribute into the specified type.
void SetAttribute (const char *name, const char *_value)
 Sets an attribute of name to a given value.
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
int QueryIntAttribute (const std::string &name, int *_value) const
int QueryDoubleAttribute (const std::string &name, double *_value) const
void SetAttribute (const std::string &name, const std::string &_value)
 STL std::string form.
void SetAttribute (const std::string &name, int _value)
void SetAttribute (const char *name, int value)
 Sets an attribute of name to a given value.
void SetDoubleAttribute (const char *name, double value)
 Sets an attribute of name to a given value.
void RemoveAttribute (const char *name)
 Deletes an attribute with the given name.
void RemoveAttribute (const std::string &name)
 STL std::string form.
const TiXmlAttributeFirstAttribute () const
 Access the first attribute in this element.
TiXmlAttributeFirstAttribute ()
const TiXmlAttributeLastAttribute () const
 Access the last attribute in this element.
TiXmlAttributeLastAttribute ()
const char * GetText () const
 Convenience function for easy access to the text inside an element.
virtual TiXmlNodeClone () const
 Creates a new Element and returns it - the returned element is a copy.
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.
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual const
TiXmlElement
ToElement () 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 bool Accept (TiXmlVisitor *visitor) const
 Walk the XML tree visiting this node and all of its children.

Protected Member Functions

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

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 951 of file OBTtinyxml.h.


Constructor & Destructor Documentation

OBT::TiXmlElement::TiXmlElement ( const char *  in_value  ) 

Construct an element.

Definition at line 506 of file OBTtinyxml.cpp.

References OBT::TiXmlNode::firstChild, OBT::TiXmlNode::lastChild, and OBT::TiXmlNode::value.

Referenced by Clone().

00507         : TiXmlNode( TiXmlNode::ELEMENT )
00508 {
00509         firstChild = lastChild = 0;
00510         value = _value;
00511 }

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

std::string constructor.

Definition at line 515 of file OBTtinyxml.cpp.

References OBT::TiXmlNode::firstChild, OBT::TiXmlNode::lastChild, and OBT::TiXmlNode::value.

00516         : TiXmlNode( TiXmlNode::ELEMENT )
00517 {
00518         firstChild = lastChild = 0;
00519         value = _value;
00520 }

OBT::TiXmlElement::TiXmlElement ( const TiXmlElement copy  ) 

Definition at line 524 of file OBTtinyxml.cpp.

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

00525         : TiXmlNode( TiXmlNode::ELEMENT )
00526 {
00527         firstChild = lastChild = 0;
00528         copy.CopyTo( this );    
00529 }

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

Definition at line 539 of file OBTtinyxml.cpp.

References ClearThis().

00540 {
00541         ClearThis();
00542 }

OBT::TiXmlElement::TiXmlElement ( const char *  in_value  ) 

Construct an element.

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

std::string constructor.

OBT::TiXmlElement::TiXmlElement ( const TiXmlElement  ) 

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


Member Function Documentation

void OBT::TiXmlElement::operator= ( const TiXmlElement base  ) 

Definition at line 532 of file OBTtinyxml.cpp.

References ClearThis(), and CopyTo().

00533 {
00534         ClearThis();
00535         base.CopyTo( this );
00536 }

const char * OBT::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 557 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlAttributeSet::Find(), and OBT::TiXmlAttribute::Value().

Referenced by Attribute().

00558 {
00559         const TiXmlAttribute* node = attributeSet.Find( name );
00560         if ( node )
00561                 return node->Value();
00562         return 0;
00563 }

const char * OBT::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 577 of file OBTtinyxml.cpp.

References Attribute().

00578 {
00579         const char* s = Attribute( name );
00580         if ( i )
00581         {
00582                 if ( s ) {
00583                         *i = atoi( s );
00584                 }
00585                 else {
00586                         *i = 0;
00587                 }
00588         }
00589         return s;
00590 }

const char * OBT::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 611 of file OBTtinyxml.cpp.

References Attribute().

00612 {
00613         const char* s = Attribute( name );
00614         if ( d )
00615         {
00616                 if ( s ) {
00617                         *d = atof( s );
00618                 }
00619                 else {
00620                         *d = 0;
00621                 }
00622         }
00623         return s;
00624 }

int OBT::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 645 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlAttributeSet::Find(), OBT::TiXmlAttribute::QueryIntValue(), and OBT::TIXML_NO_ATTRIBUTE.

00646 {
00647         const TiXmlAttribute* node = attributeSet.Find( name );
00648         if ( !node )
00649                 return TIXML_NO_ATTRIBUTE;
00650         return node->QueryIntValue( ival );
00651 }

int OBT::TiXmlElement::QueryDoubleAttribute ( const char *  name,
double *  _value 
) const

QueryDoubleAttribute examines the attribute - see QueryIntAttribute().

Definition at line 665 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlAttributeSet::Find(), OBT::TiXmlAttribute::QueryDoubleValue(), and OBT::TIXML_NO_ATTRIBUTE.

Referenced by QueryFloatAttribute().

00666 {
00667         const TiXmlAttribute* node = attributeSet.Find( name );
00668         if ( !node )
00669                 return TIXML_NO_ATTRIBUTE;
00670         return node->QueryDoubleValue( dval );
00671 }

int OBT::TiXmlElement::QueryFloatAttribute ( const char *  name,
float *  _value 
) const [inline]

QueryFloatAttribute examines the attribute - see QueryIntAttribute().

Definition at line 1000 of file OBTtinyxml.h.

References OBT::TIXML_SUCCESS.

01000                                                                          {
01001                 double d;
01002                 int result = QueryDoubleAttribute( name, &d );
01003                 if ( result == TIXML_SUCCESS ) {
01004                         *_value = (float)d;
01005                 }
01006                 return result;
01007         }

template<typename T>
int OBT::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 1018 of file OBTtinyxml.h.

References OBT::TIXML_NO_ATTRIBUTE, OBT::TIXML_SUCCESS, OBT::TIXML_WRONG_TYPE, and OBT::TiXmlAttribute::ValueStr().

01019         {
01020                 const TiXmlAttribute* node = attributeSet.Find( name );
01021                 if ( !node )
01022                         return TIXML_NO_ATTRIBUTE;
01023 
01024                 std::stringstream sstream( node->ValueStr() );
01025                 sstream >> *outValue;
01026                 if ( !sstream.fail() )
01027                         return TIXML_SUCCESS;
01028                 return TIXML_WRONG_TYPE;
01029         }

void OBT::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 719 of file OBTtinyxml.cpp.

References OBT::TiXmlAttributeSet::Add(), attributeSet, OBT::TiXmlAttributeSet::Find(), OBT::TiXmlNode::GetDocument(), OBT::TiXmlDocument::SetError(), OBT::TiXmlAttribute::setValue(), OBT::TIXML_ENCODING_UNKNOWN, OBT::TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY, and TIXML_STRING.

Referenced by CopyTo(), SetAttribute(), and SetDoubleAttribute().

00720 {
00721     #ifdef TIXML_USE_STL
00722         TIXML_STRING _name( cname );
00723         TIXML_STRING _value( cvalue );
00724         #else
00725         const char* _name = cname;
00726         const char* _value = cvalue;
00727         #endif
00728 
00729         TiXmlAttribute* node = attributeSet.Find( _name );
00730         if ( node )
00731         {
00732                 node->setValue( _value );
00733                 return;
00734         }
00735 
00736         TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue );
00737         if ( attrib )
00738         {
00739                 attributeSet.Add( attrib );
00740         }
00741         else
00742         {
00743                 TiXmlDocument* document = GetDocument();
00744                 if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
00745         }
00746 }

const std::string * OBT::TiXmlElement::Attribute ( const std::string &  name  )  const

Definition at line 567 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlAttributeSet::Find(), and OBT::TiXmlAttribute::ValueStr().

00568 {
00569         const TiXmlAttribute* node = attributeSet.Find( name );
00570         if ( node )
00571                 return &node->ValueStr();
00572         return 0;
00573 }

const std::string * OBT::TiXmlElement::Attribute ( const std::string &  name,
int *  i 
) const

Definition at line 594 of file OBTtinyxml.cpp.

References Attribute().

00595 {
00596         const std::string* s = Attribute( name );
00597         if ( i )
00598         {
00599                 if ( s ) {
00600                         *i = atoi( s->c_str() );
00601                 }
00602                 else {
00603                         *i = 0;
00604                 }
00605         }
00606         return s;
00607 }

const std::string * OBT::TiXmlElement::Attribute ( const std::string &  name,
double *  d 
) const

Definition at line 628 of file OBTtinyxml.cpp.

References Attribute().

00629 {
00630         const std::string* s = Attribute( name );
00631         if ( d )
00632         {
00633                 if ( s ) {
00634                         *d = atof( s->c_str() );
00635                 }
00636                 else {
00637                         *d = 0;
00638                 }
00639         }
00640         return s;
00641 }

int OBT::TiXmlElement::QueryIntAttribute ( const std::string &  name,
int *  _value 
) const

Definition at line 655 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlAttributeSet::Find(), OBT::TiXmlAttribute::QueryIntValue(), and OBT::TIXML_NO_ATTRIBUTE.

00656 {
00657         const TiXmlAttribute* node = attributeSet.Find( name );
00658         if ( !node )
00659                 return TIXML_NO_ATTRIBUTE;
00660         return node->QueryIntValue( ival );
00661 }

int OBT::TiXmlElement::QueryDoubleAttribute ( const std::string &  name,
double *  _value 
) const

Definition at line 675 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlAttributeSet::Find(), OBT::TiXmlAttribute::QueryDoubleValue(), and OBT::TIXML_NO_ATTRIBUTE.

00676 {
00677         const TiXmlAttribute* node = attributeSet.Find( name );
00678         if ( !node )
00679                 return TIXML_NO_ATTRIBUTE;
00680         return node->QueryDoubleValue( dval );
00681 }

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

STL std::string form.

STL std::string form.

Definition at line 750 of file OBTtinyxml.cpp.

References OBT::TiXmlAttributeSet::Add(), attributeSet, OBT::TiXmlAttributeSet::Find(), OBT::TiXmlNode::GetDocument(), OBT::TiXmlDocument::SetError(), OBT::TiXmlAttribute::setValue(), OBT::TIXML_ENCODING_UNKNOWN, and OBT::TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY.

00751 {
00752         TiXmlAttribute* node = attributeSet.Find( name );
00753         if ( node )
00754         {
00755                 node->setValue( _value );
00756                 return;
00757         }
00758 
00759         TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
00760         if ( attrib )
00761         {
00762                 attributeSet.Add( attrib );
00763         }
00764         else
00765         {
00766                 TiXmlDocument* document = GetDocument();
00767                 if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
00768         }
00769 }

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

Definition at line 698 of file OBTtinyxml.cpp.

References SetAttribute().

00699 {       
00700    std::ostringstream oss;
00701    oss << val;
00702    SetAttribute( name, oss.str() );
00703 }

void OBT::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 685 of file OBTtinyxml.cpp.

References SetAttribute().

00686 {       
00687         char buf[64];
00688         #if defined(TIXML_SNPRINTF)             
00689                 TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
00690         #else
00691                 sprintf( buf, "%d", val );
00692         #endif
00693         SetAttribute( name, buf );
00694 }

void OBT::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 707 of file OBTtinyxml.cpp.

References SetAttribute().

00708 {       
00709         char buf[256];
00710         #if defined(TIXML_SNPRINTF)             
00711                 TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
00712         #else
00713                 sprintf( buf, "%f", val );
00714         #endif
00715         SetAttribute( name, buf );
00716 }

void OBT::TiXmlElement::RemoveAttribute ( const char *  name  ) 

Deletes an attribute with the given name.

Definition at line 418 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlAttributeSet::Find(), OBT::TiXmlAttributeSet::Remove(), and TIXML_STRING.

Referenced by RemoveAttribute().

00419 {
00420     #ifdef TIXML_USE_STL
00421         TIXML_STRING str( name );
00422         TiXmlAttribute* node = attributeSet.Find( str );
00423         #else
00424         TiXmlAttribute* node = attributeSet.Find( name );
00425         #endif
00426         if ( node )
00427         {
00428                 attributeSet.Remove( node );
00429                 delete node;
00430         }
00431 }

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

STL std::string form.

Definition at line 1079 of file OBTtinyxml.h.

const TiXmlAttribute* OBT::TiXmlElement::FirstAttribute (  )  const [inline]

Access the first attribute in this element.

Definition at line 1082 of file OBTtinyxml.h.

Referenced by OBT::XMLConfigurationFileParser::AddChildren().

TiXmlAttribute* OBT::TiXmlElement::FirstAttribute (  )  [inline]

Definition at line 1083 of file OBTtinyxml.h.

01083 { return attributeSet.First(); }

const TiXmlAttribute* OBT::TiXmlElement::LastAttribute (  )  const [inline]

Access the last attribute in this element.

Definition at line 1084 of file OBTtinyxml.h.

TiXmlAttribute* OBT::TiXmlElement::LastAttribute (  )  [inline]

Definition at line 1085 of file OBTtinyxml.h.

01085 { return attributeSet.Last(); }

const char * OBT::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 873 of file OBTtinyxml.cpp.

References OBT::TiXmlNode::FirstChild(), OBT::TiXmlNode::ToText(), and OBT::TiXmlNode::Value().

00874 {
00875         const TiXmlNode* child = this->FirstChild();
00876         if ( child ) {
00877                 const TiXmlText* childText = child->ToText();
00878                 if ( childText ) {
00879                         return childText->Value();
00880                 }
00881         }
00882         return 0;
00883 }

TiXmlNode * OBT::TiXmlElement::Clone (  )  const [virtual]

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

Implements OBT::TiXmlNode.

Definition at line 862 of file OBTtinyxml.cpp.

References CopyTo(), TiXmlElement(), and OBT::TiXmlNode::Value().

00863 {
00864         TiXmlElement* clone = new TiXmlElement( Value() );
00865         if ( !clone )
00866                 return 0;
00867 
00868         CopyTo( clone );
00869         return clone;
00870 }

void OBT::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 OBT::TiXmlBase.

Definition at line 773 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlAttributeSet::First(), OBT::TiXmlNode::firstChild, OBT::TiXmlNode::lastChild, OBT::TiXmlAttribute::Next(), OBT::TiXmlNode::NextSibling(), OBT::TiXmlBase::Print(), OBT::TiXmlNode::ToText(), and OBT::TiXmlNode::value.

00774 {
00775         int i;
00776         assert( cfile );
00777         for ( i=0; i<depth; i++ ) {
00778                 fprintf( cfile, "    " );
00779         }
00780 
00781         fprintf( cfile, "<%s", value.c_str() );
00782 
00783         const TiXmlAttribute* attrib;
00784         for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
00785         {
00786                 fprintf( cfile, " " );
00787                 attrib->Print( cfile, depth );
00788         }
00789 
00790         // There are 3 different formatting approaches:
00791         // 1) An element without children is printed as a <foo /> node
00792         // 2) An element with only a text child is printed as <foo> text </foo>
00793         // 3) An element with children is printed on multiple lines.
00794         TiXmlNode* node;
00795         if ( !firstChild )
00796         {
00797                 fprintf( cfile, " />" );
00798         }
00799         else if ( firstChild == lastChild && firstChild->ToText() )
00800         {
00801                 fprintf( cfile, ">" );
00802                 firstChild->Print( cfile, depth + 1 );
00803                 fprintf( cfile, "</%s>", value.c_str() );
00804         }
00805         else
00806         {
00807                 fprintf( cfile, ">" );
00808 
00809                 for ( node = firstChild; node; node=node->NextSibling() )
00810                 {
00811                         if ( !node->ToText() )
00812                         {
00813                                 fprintf( cfile, "\n" );
00814                         }
00815                         node->Print( cfile, depth+1 );
00816                 }
00817                 fprintf( cfile, "\n" );
00818                 for( i=0; i<depth; ++i ) {
00819                         fprintf( cfile, "    " );
00820                 }
00821                 fprintf( cfile, "</%s>", value.c_str() );
00822         }
00823 }

const char * OBT::TiXmlElement::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
) [virtual]

Implements OBT::TiXmlBase.

Definition at line 1051 of file OBTtinyxmlparser.cpp.

References OBT::TiXmlAttributeSet::Add(), attributeSet, OBT::TiXmlParsingData::Cursor(), OBT::TiXmlAttributeSet::Find(), OBT::TiXmlNode::GetDocument(), OBT::TiXmlBase::location, OBT::TiXmlAttribute::Name(), OBT::TiXmlAttribute::NameTStr(), OBT::TiXmlAttribute::Parse(), OBT::TiXmlBase::ReadName(), ReadValue(), OBT::TiXmlAttribute::SetDocument(), OBT::TiXmlDocument::SetError(), OBT::TiXmlAttribute::setValue(), OBT::TiXmlBase::SkipWhiteSpace(), OBT::TiXmlParsingData::Stamp(), OBT::TiXmlBase::StringEqual(), OBT::TiXmlBase::TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, OBT::TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY, OBT::TiXmlBase::TIXML_ERROR_PARSING_ELEMENT, OBT::TiXmlBase::TIXML_ERROR_PARSING_EMPTY, OBT::TiXmlBase::TIXML_ERROR_READING_ATTRIBUTES, OBT::TiXmlBase::TIXML_ERROR_READING_END_TAG, TIXML_STRING, OBT::TiXmlAttribute::Value(), and OBT::TiXmlNode::value.

01052 {
01053         p = SkipWhiteSpace( p, encoding );
01054         TiXmlDocument* document = GetDocument();
01055 
01056         if ( !p || !*p )
01057         {
01058                 if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding );
01059                 return 0;
01060         }
01061 
01062         if ( data )
01063         {
01064                 data->Stamp( p, encoding );
01065                 location = data->Cursor();
01066         }
01067 
01068         if ( *p != '<' )
01069         {
01070                 if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding );
01071                 return 0;
01072         }
01073 
01074         p = SkipWhiteSpace( p+1, encoding );
01075 
01076         // Read the name.
01077         const char* pErr = p;
01078 
01079     p = ReadName( p, &value, encoding );
01080         if ( !p || !*p )
01081         {
01082                 if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding );
01083                 return 0;
01084         }
01085 
01086     TIXML_STRING endTag ("</");
01087         endTag += value;
01088         endTag += ">";
01089 
01090         // Check for and read attributes. Also look for an empty
01091         // tag or an end tag.
01092         while ( p && *p )
01093         {
01094                 pErr = p;
01095                 p = SkipWhiteSpace( p, encoding );
01096                 if ( !p || !*p )
01097                 {
01098                         if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
01099                         return 0;
01100                 }
01101                 if ( *p == '/' )
01102                 {
01103                         ++p;
01104                         // Empty tag.
01105                         if ( *p  != '>' )
01106                         {
01107                                 if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );             
01108                                 return 0;
01109                         }
01110                         return (p+1);
01111                 }
01112                 else if ( *p == '>' )
01113                 {
01114                         // Done with attributes (if there were any.)
01115                         // Read the value -- which can include other
01116                         // elements -- read the end tag, and return.
01117                         ++p;
01118                         p = ReadValue( p, data, encoding );             // Note this is an Element method, and will set the error if one happens.
01119                         if ( !p || !*p ) {
01120                                 // We were looking for the end tag, but found nothing.
01121                                 // Fix for [ 1663758 ] Failure to report error on bad XML
01122                                 if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
01123                                 return 0;
01124                         }
01125 
01126                         // We should find the end tag now
01127                         if ( StringEqual( p, endTag.c_str(), false, encoding ) )
01128                         {
01129                                 p += endTag.length();
01130                                 return p;
01131                         }
01132                         else
01133                         {
01134                                 if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
01135                                 return 0;
01136                         }
01137                 }
01138                 else
01139                 {
01140                         // Try to read an attribute:
01141                         TiXmlAttribute* attrib = new TiXmlAttribute();
01142                         if ( !attrib )
01143                         {
01144                                 if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
01145                                 return 0;
01146                         }
01147 
01148                         attrib->SetDocument( document );
01149                         pErr = p;
01150                         p = attrib->Parse( p, data, encoding );
01151 
01152                         if ( !p || !*p )
01153                         {
01154                                 if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
01155                                 delete attrib;
01156                                 return 0;
01157                         }
01158 
01159                         // Handle the strange case of double attributes:
01160                         #ifdef TIXML_USE_STL
01161                         TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() );
01162                         #else
01163                         TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
01164                         #endif
01165                         if ( node )
01166                         {
01167                                 node->setValue( attrib->Value() );
01168                                 delete attrib;
01169                                 return 0;
01170                         }
01171 
01172                         attributeSet.Add( attrib );
01173                 }
01174         }
01175         return p;
01176 }

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

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1131 of file OBTtinyxml.h.

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

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1132 of file OBTtinyxml.h.

bool OBT::TiXmlElement::Accept ( TiXmlVisitor visitor  )  const [virtual]

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

Implements OBT::TiXmlNode.

Definition at line 848 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlAttributeSet::First(), OBT::TiXmlNode::FirstChild(), OBT::TiXmlNode::NextSibling(), OBT::TiXmlVisitor::VisitEnter(), and OBT::TiXmlVisitor::VisitExit().

00849 {
00850         if ( visitor->VisitEnter( *this, attributeSet.First() ) ) 
00851         {
00852                 for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
00853                 {
00854                         if ( !node->Accept( visitor ) )
00855                                 break;
00856                 }
00857         }
00858         return visitor->VisitExit( *this );
00859 }

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

Definition at line 826 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlNode::Clone(), OBT::TiXmlNode::CopyTo(), OBT::TiXmlAttributeSet::First(), OBT::TiXmlNode::firstChild, OBT::TiXmlNode::LinkEndChild(), OBT::TiXmlAttribute::Name(), OBT::TiXmlAttribute::Next(), OBT::TiXmlNode::NextSibling(), SetAttribute(), and OBT::TiXmlAttribute::Value().

Referenced by Clone(), operator=(), and TiXmlElement().

00827 {
00828         // superclass:
00829         TiXmlNode::CopyTo( target );
00830 
00831         // Element class: 
00832         // Clone the attributes, then clone the children.
00833         const TiXmlAttribute* attribute = 0;
00834         for(    attribute = attributeSet.First();
00835         attribute;
00836         attribute = attribute->Next() )
00837         {
00838                 target->SetAttribute( attribute->Name(), attribute->Value() );
00839         }
00840 
00841         TiXmlNode* node = 0;
00842         for ( node = firstChild; node; node = node->NextSibling() )
00843         {
00844                 target->LinkEndChild( node->Clone() );
00845         }
00846 }

void OBT::TiXmlElement::ClearThis (  )  [protected]

Definition at line 545 of file OBTtinyxml.cpp.

References attributeSet, OBT::TiXmlNode::Clear(), OBT::TiXmlAttributeSet::First(), and OBT::TiXmlAttributeSet::Remove().

Referenced by operator=(), and ~TiXmlElement().

00546 {
00547         Clear();
00548         while( attributeSet.First() )
00549         {
00550                 TiXmlAttribute* node = attributeSet.First();
00551                 attributeSet.Remove( node );
00552                 delete node;
00553         }
00554 }

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

Implements OBT::TiXmlNode.

Definition at line 911 of file OBTtinyxmlparser.cpp.

References OBT::TiXmlNode::GetDocument(), OBT::TiXmlNode::Identify(), OBT::TiXmlBase::IsWhiteSpace(), OBT::TiXmlDocument::SetError(), OBT::TiXmlNode::StreamIn(), OBT::TiXmlText::StreamIn(), OBT::TiXmlBase::StreamWhiteSpace(), OBT::TIXML_DEFAULT_ENCODING, OBT::TIXML_ENCODING_UNKNOWN, and OBT::TiXmlBase::TIXML_ERROR_EMBEDDED_NULL.

00912 {
00913         // We're called with some amount of pre-parsing. That is, some of "this"
00914         // element is in "tag". Go ahead and stream to the closing ">"
00915         while( in->good() )
00916         {
00917                 int c = in->get();
00918                 if ( c <= 0 )
00919                 {
00920                         TiXmlDocument* document = GetDocument();
00921                         if ( document )
00922                                 document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
00923                         return;
00924                 }
00925                 (*tag) += (char) c ;
00926                 
00927                 if ( c == '>' )
00928                         break;
00929         }
00930 
00931         if ( tag->length() < 3 ) return;
00932 
00933         // Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
00934         // If not, identify and stream.
00935 
00936         if (    tag->at( tag->length() - 1 ) == '>' 
00937                  && tag->at( tag->length() - 2 ) == '/' )
00938         {
00939                 // All good!
00940                 return;
00941         }
00942         else if ( tag->at( tag->length() - 1 ) == '>' )
00943         {
00944                 // There is more. Could be:
00945                 //              text
00946                 //              cdata text (which looks like another node)
00947                 //              closing tag
00948                 //              another node.
00949                 for ( ;; )
00950                 {
00951                         StreamWhiteSpace( in, tag );
00952 
00953                         // Do we have text?
00954                         if ( in->good() && in->peek() != '<' ) 
00955                         {
00956                                 // Yep, text.
00957                                 TiXmlText text( "" );
00958                                 text.StreamIn( in, tag );
00959 
00960                                 // What follows text is a closing tag or another node.
00961                                 // Go around again and figure it out.
00962                                 continue;
00963                         }
00964 
00965                         // We now have either a closing tag...or another node.
00966                         // We should be at a "<", regardless.
00967                         if ( !in->good() ) return;
00968                         assert( in->peek() == '<' );
00969                         int tagIndex = (int) tag->length();
00970 
00971                         bool closingTag = false;
00972                         bool firstCharFound = false;
00973 
00974                         for( ;; )
00975                         {
00976                                 if ( !in->good() )
00977                                         return;
00978 
00979                                 int c = in->peek();
00980                                 if ( c <= 0 )
00981                                 {
00982                                         TiXmlDocument* document = GetDocument();
00983                                         if ( document )
00984                                                 document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
00985                                         return;
00986                                 }
00987                                 
00988                                 if ( c == '>' )
00989                                         break;
00990 
00991                                 *tag += (char) c;
00992                                 in->get();
00993 
00994                                 // Early out if we find the CDATA id.
00995                                 if ( c == '[' && tag->size() >= 9 )
00996                                 {
00997                                         size_t len = tag->size();
00998                                         const char* start = tag->c_str() + len - 9;
00999                                         if ( strcmp( start, "<![CDATA[" ) == 0 ) {
01000                                                 assert( !closingTag );
01001                                                 break;
01002                                         }
01003                                 }
01004 
01005                                 if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) )
01006                                 {
01007                                         firstCharFound = true;
01008                                         if ( c == '/' )
01009                                                 closingTag = true;
01010                                 }
01011                         }
01012                         // If it was a closing tag, then read in the closing '>' to clean up the input stream.
01013                         // If it was not, the streaming will be done by the tag.
01014                         if ( closingTag )
01015                         {
01016                                 if ( !in->good() )
01017                                         return;
01018 
01019                                 int c = in->get();
01020                                 if ( c <= 0 )
01021                                 {
01022                                         TiXmlDocument* document = GetDocument();
01023                                         if ( document )
01024                                                 document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
01025                                         return;
01026                                 }
01027                                 assert( c == '>' );
01028                                 *tag += (char) c;
01029 
01030                                 // We are done, once we've found our closing tag.
01031                                 return;
01032                         }
01033                         else
01034                         {
01035                                 // If not a closing tag, id it, and stream.
01036                                 const char* tagloc = tag->c_str() + tagIndex;
01037                                 TiXmlNode* node = Identify( tagloc, TIXML_DEFAULT_ENCODING );
01038                                 if ( !node )
01039                                         return;
01040                                 node->StreamIn( in, tag );
01041                                 delete node;
01042                                 node = 0;
01043 
01044                                 // No return: go around from the beginning: text, closing tag, or node.
01045                         }
01046                 }
01047         }
01048 }

const char * OBT::TiXmlElement::ReadValue ( const char *  in,
TiXmlParsingData prevData,
TiXmlEncoding  encoding 
) [protected]

Definition at line 1179 of file OBTtinyxmlparser.cpp.

References OBT::TiXmlText::Blank(), OBT::TiXmlNode::GetDocument(), OBT::TiXmlNode::Identify(), OBT::TiXmlBase::IsWhiteSpaceCondensed(), OBT::TiXmlNode::LinkEndChild(), OBT::TiXmlBase::Parse(), OBT::TiXmlText::Parse(), OBT::TiXmlDocument::SetError(), OBT::TiXmlBase::SkipWhiteSpace(), OBT::TiXmlBase::StringEqual(), OBT::TiXmlBase::TIXML_ERROR_OUT_OF_MEMORY, and OBT::TiXmlBase::TIXML_ERROR_READING_ELEMENT_VALUE.

Referenced by Parse().

01180 {
01181         TiXmlDocument* document = GetDocument();
01182 
01183         // Read in text and elements in any order.
01184         const char* pWithWhiteSpace = p;
01185         p = SkipWhiteSpace( p, encoding );
01186 
01187         while ( p && *p )
01188         {
01189                 if ( *p != '<' )
01190                 {
01191                         // Take what we have, make a text element.
01192                         TiXmlText* textNode = new TiXmlText( "" );
01193 
01194                         if ( !textNode )
01195                         {
01196                                 if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
01197                                     return 0;
01198                         }
01199 
01200                         if ( TiXmlBase::IsWhiteSpaceCondensed() )
01201                         {
01202                                 p = textNode->Parse( p, data, encoding );
01203                         }
01204                         else
01205                         {
01206                                 // Special case: we want to keep the white space
01207                                 // so that leading spaces aren't removed.
01208                                 p = textNode->Parse( pWithWhiteSpace, data, encoding );
01209                         }
01210 
01211                         if ( !textNode->Blank() )
01212                                 LinkEndChild( textNode );
01213                         else
01214                                 delete textNode;
01215                 } 
01216                 else 
01217                 {
01218                         // We hit a '<'
01219                         // Have we hit a new element or an end tag? This could also be
01220                         // a TiXmlText in the "CDATA" style.
01221                         if ( StringEqual( p, "</", false, encoding ) )
01222                         {
01223                                 return p;
01224                         }
01225                         else
01226                         {
01227                                 TiXmlNode* node = Identify( p, encoding );
01228                                 if ( node )
01229                                 {
01230                                         p = node->Parse( p, data, encoding );
01231                                         LinkEndChild( node );
01232                                 }                               
01233                                 else
01234                                 {
01235                                         return 0;
01236                                 }
01237                         }
01238                 }
01239                 pWithWhiteSpace = p;
01240                 p = SkipWhiteSpace( p, encoding );
01241         }
01242 
01243         if ( !p )
01244         {
01245                 if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
01246         }       
01247         return p;
01248 }

void OBT::TiXmlElement::operator= ( const TiXmlElement base  ) 

const char* OBT::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* OBT::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* OBT::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.

int OBT::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 OBT::TiXmlElement::QueryDoubleAttribute ( const char *  name,
double *  _value 
) const

QueryDoubleAttribute examines the attribute - see QueryIntAttribute().

int OBT::TiXmlElement::QueryFloatAttribute ( const char *  name,
float *  _value 
) const [inline]

QueryFloatAttribute examines the attribute - see QueryIntAttribute().

Definition at line 999 of file tiny/OBTtinyxml.h.

References QueryDoubleAttribute(), and OBT::TIXML_SUCCESS.

00999                                                                          {
01000                 double d;
01001                 int result = QueryDoubleAttribute( name, &d );
01002                 if ( result == TIXML_SUCCESS ) {
01003                         *_value = (float)d;
01004                 }
01005                 return result;
01006         }

template<typename T>
int OBT::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 1017 of file tiny/OBTtinyxml.h.

References attributeSet, OBT::TiXmlAttributeSet::Find(), OBT::TIXML_NO_ATTRIBUTE, OBT::TIXML_SUCCESS, OBT::TIXML_WRONG_TYPE, and OBT::TiXmlAttribute::ValueStr().

01018         {
01019                 const TiXmlAttribute* node = attributeSet.Find( name );
01020                 if ( !node )
01021                         return TIXML_NO_ATTRIBUTE;
01022 
01023                 std::stringstream sstream( node->ValueStr() );
01024                 sstream >> *outValue;
01025                 if ( !sstream.fail() )
01026                         return TIXML_SUCCESS;
01027                 return TIXML_WRONG_TYPE;
01028         }

void OBT::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.

const std::string* OBT::TiXmlElement::Attribute ( const std::string &  name  )  const

const std::string* OBT::TiXmlElement::Attribute ( const std::string &  name,
int *  i 
) const

const std::string* OBT::TiXmlElement::Attribute ( const std::string &  name,
double *  d 
) const

int OBT::TiXmlElement::QueryIntAttribute ( const std::string &  name,
int *  _value 
) const

int OBT::TiXmlElement::QueryDoubleAttribute ( const std::string &  name,
double *  _value 
) const

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

STL std::string form.

STL std::string form.

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

void OBT::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 OBT::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 OBT::TiXmlElement::RemoveAttribute ( const char *  name  ) 

Deletes an attribute with the given name.

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

STL std::string form.

Definition at line 1078 of file tiny/OBTtinyxml.h.

References RemoveAttribute().

const TiXmlAttribute* OBT::TiXmlElement::FirstAttribute (  )  const [inline]

Access the first attribute in this element.

Definition at line 1081 of file tiny/OBTtinyxml.h.

References attributeSet, and OBT::TiXmlAttributeSet::First().

TiXmlAttribute* OBT::TiXmlElement::FirstAttribute (  )  [inline]

Definition at line 1082 of file tiny/OBTtinyxml.h.

References attributeSet, and OBT::TiXmlAttributeSet::First().

01082 { return attributeSet.First(); }

const TiXmlAttribute* OBT::TiXmlElement::LastAttribute (  )  const [inline]

Access the last attribute in this element.

Definition at line 1083 of file tiny/OBTtinyxml.h.

References attributeSet, and OBT::TiXmlAttributeSet::Last().

TiXmlAttribute* OBT::TiXmlElement::LastAttribute (  )  [inline]

Definition at line 1084 of file tiny/OBTtinyxml.h.

References attributeSet, and OBT::TiXmlAttributeSet::Last().

01084 { return attributeSet.Last(); }

const char* OBT::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.

virtual TiXmlNode* OBT::TiXmlElement::Clone (  )  const [virtual]

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

Implements OBT::TiXmlNode.

virtual void OBT::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 OBT::TiXmlBase.

virtual const char* OBT::TiXmlElement::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
) [virtual]

Implements OBT::TiXmlBase.

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

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1130 of file tiny/OBTtinyxml.h.

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

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1131 of file tiny/OBTtinyxml.h.

virtual bool OBT::TiXmlElement::Accept ( TiXmlVisitor visitor  )  const [virtual]

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

Implements OBT::TiXmlNode.

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

void OBT::TiXmlElement::ClearThis (  )  [protected]

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

Implements OBT::TiXmlNode.

const char* OBT::TiXmlElement::ReadValue ( const char *  in,
TiXmlParsingData prevData,
TiXmlEncoding  encoding 
) [protected]


Member Data Documentation

TiXmlAttributeSet OBT::TiXmlElement::attributeSet [private]

Definition at line 1155 of file OBTtinyxml.h.

Referenced by Accept(), Attribute(), ClearThis(), CopyTo(), FirstAttribute(), LastAttribute(), Parse(), Print(), QueryDoubleAttribute(), QueryIntAttribute(), QueryValueAttribute(), RemoveAttribute(), and SetAttribute().


Generated on Wed Oct 1 11:34:20 2008 for OBT by  doxygen 1.5.3