Cinder  0.9.1
Public Member Functions | List of all members
cinder::XmlTree::Attr Class Reference

#include <Xml.h>

Public Member Functions

 Attr (XmlTree *xml, const std::string &name, const std::string &value)
 
 operator const std::string & () const
 
template<typename T >
Attroperator= (const T &val)
 
bool operator== (const char *rhs) const
 
bool operator== (const std::string &rhs) const
 
bool operator!= (const char *rhs) const
 
bool operator!= (const std::string &rhs) const
 
template<typename T >
as () const
 
bool empty () const
 
const std::string & getName () const
 
std::string getValue () const
 
template<typename T >
getValue () const
 
void setValue (const std::string &value)
 
template<typename T >
void setValue (const T &value)
 

Detailed Description

XML attribute.

Constructor & Destructor Documentation

cinder::XmlTree::Attr::Attr ( XmlTree xml,
const std::string &  name,
const std::string &  value 
)

Constructs an XML attribute named name with the value value.

Member Function Documentation

cinder::XmlTree::Attr::operator const std::string & ( ) const

Returns an empty string for a non-existent attribute.

template<typename T >
Attr& cinder::XmlTree::Attr::operator= ( const T &  val)

Assigns the Attr a new value, and creates it if it doesn't exist. The equivalent of calling setAttribute( this->getName(), toString( newValue ) ).

bool cinder::XmlTree::Attr::operator== ( const char *  rhs) const
bool cinder::XmlTree::Attr::operator== ( const std::string &  rhs) const
bool cinder::XmlTree::Attr::operator!= ( const char *  rhs) const
bool cinder::XmlTree::Attr::operator!= ( const std::string &  rhs) const
template<typename T >
T cinder::XmlTree::Attr::as ( ) const

Returns the value of the attribute cast to T using ci::fromString().

bool cinder::XmlTree::Attr::empty ( ) const

Returns true if the Attr value is empty.

const std::string& cinder::XmlTree::Attr::getName ( ) const

Returns the name of the attribute as a string.

std::string cinder::XmlTree::Attr::getValue ( ) const

Returns the value of the attribute as a string.

template<typename T >
T cinder::XmlTree::Attr::getValue ( ) const

Returns the value of the attribute parsed as a T. Requires T to support the istream>> operator.
float size = myAttr.getValue<float>( "size" );

void cinder::XmlTree::Attr::setValue ( const std::string &  value)

Sets the value of the attribute to value.

template<typename T >
void cinder::XmlTree::Attr::setValue ( const T &  value)

Sets the value of the attribute to value, which is cast to a string first. Requires T to support the ostream<< operator.


The documentation for this class was generated from the following file: