Crazy Eddie's GUI System  0.8.7
CEGUI::XMLAttributes Class Reference

Class representing a block of attributes associated with an XML element. More...

+ Inheritance diagram for CEGUI::XMLAttributes:
+ Collaboration diagram for CEGUI::XMLAttributes:

Public Member Functions

 XMLAttributes (void)
 XMLAttributes constructor.
 
virtual ~XMLAttributes (void)
 XMLAttributes Destructor.
 
void add (const String &attrName, const String &attrValue)
 Adds an attribute to the attribute block. If the attribute value already exists, it is replaced with the new value. More...
 
void remove (const String &attrName)
 Removes an attribute from the attribute block. More...
 
bool exists (const String &attrName) const
 Return whether the named attribute exists within the attribute block. More...
 
size_t getCount (void) const
 Return the number of attributes in the attribute block. More...
 
const StringgetName (size_t index) const
 Return the name of an attribute based upon its index within the attribute block. More...
 
const StringgetValue (size_t index) const
 Return the value string of an attribute based upon its index within the attribute block. More...
 
const StringgetValue (const String &attrName) const
 Return the value string for attribute attrName. More...
 
const StringgetValueAsString (const String &attrName, const String &def="") const
 Return the value of attribute attrName as a string. More...
 
bool getValueAsBool (const String &attrName, bool def=false) const
 Return the value of attribute attrName as a boolean value. More...
 
int getValueAsInteger (const String &attrName, int def=0) const
 Return the value of attribute attrName as a integer value. More...
 
float getValueAsFloat (const String &attrName, float def=0.0f) const
 Return the value of attribute attrName as a floating point value. More...
 

Protected Types

typedef std::map< String, String, StringFastLessCompareAttributeMap
 

Protected Attributes

AttributeMap d_attrs
 

Detailed Description

Class representing a block of attributes associated with an XML element.

Member Function Documentation

void CEGUI::XMLAttributes::add ( const String attrName,
const String attrValue 
)

Adds an attribute to the attribute block. If the attribute value already exists, it is replaced with the new value.

Parameters
attrNameString object holding the name of the attribute to be added.
attrValueString object holding a string representation of the attribute value.
Returns
Nothing.
bool CEGUI::XMLAttributes::exists ( const String attrName) const

Return whether the named attribute exists within the attribute block.

Parameters
attrNameString object holding the name of the attribute to be checked.
Returns
  • true if an attribute with the name attrName is present in the attribute block.
  • false if no attribute named attrName is present in the attribute block.
size_t CEGUI::XMLAttributes::getCount ( void  ) const

Return the number of attributes in the attribute block.

Returns
value specifying the number of attributes in this attribute block.
const String& CEGUI::XMLAttributes::getName ( size_t  index) const

Return the name of an attribute based upon its index within the attribute block.

Note
Nothing is specified about the order of elements within the attribute block. Elements may not, for example, appear in the order they were specified in the XML file.
Parameters
indexzero based index of the attribute whos name is to be returned.
Returns
String object holding the name of the attribute at the requested index.
Exceptions
IllegalRequestExceptionthrown if index is out of range for this attribute block.
const String& CEGUI::XMLAttributes::getValue ( size_t  index) const

Return the value string of an attribute based upon its index within the attribute block.

Note
Nothing is specified about the order of elements within the attribute block. Elements may not, for example, appear in the order they were specified in the XML file.
Parameters
indexzero based index of the attribute whos value string is to be returned.
Returns
String object holding the string value of the attribute at the requested index.
Exceptions
IllegalRequestExceptionthrown if index is out of range for this attribute block.
const String& CEGUI::XMLAttributes::getValue ( const String attrName) const

Return the value string for attribute attrName.

Parameters
attrNameString object holding the name of the attribute whos value string is to be returned
Returns
String object hilding the value string for attribute attrName.
Exceptions
UnknownObjectExceptionthrown if no attribute named attrName is present in the attribute block.
bool CEGUI::XMLAttributes::getValueAsBool ( const String attrName,
bool  def = false 
) const

Return the value of attribute attrName as a boolean value.

Parameters
attrNameString object holding the name of the attribute whos value is to be returned.
defbool value specifying the default value to be returned if attrName does not exist in the attribute block. For some parsers, defaults can be gotten from schemas and such like, though for others this may not be desired or possible, so this parameter is used to ensure a default is available in the abscence of other mechanisms.
Returns
bool value equal to the value of attribute attrName if present, or def if not.
Exceptions
IllegalRequestExceptionthrown if the attribute value string coul dnot be converted to the requested type.
float CEGUI::XMLAttributes::getValueAsFloat ( const String attrName,
float  def = 0.0f 
) const

Return the value of attribute attrName as a floating point value.

Parameters
attrNameString object holding the name of the attribute whos value is to be returned.
deffloat value specifying the default value to be returned if attrName does not exist in the attribute block. For some parsers, defaults can be gotten from schemas and such like, though for others this may not be desired or possible, so this parameter is used to ensure a default is available in the abscence of other mechanisms.
Returns
float value equal to the value of attribute attrName if present, or def if not.
Exceptions
IllegalRequestExceptionthrown if the attribute value string coul dnot be converted to the requested type.
int CEGUI::XMLAttributes::getValueAsInteger ( const String attrName,
int  def = 0 
) const

Return the value of attribute attrName as a integer value.

Parameters
attrNameString object holding the name of the attribute whos value is to be returned.
definteger value specifying the default value to be returned if attrName does not exist in the attribute block. For some parsers, defaults can be gotten from schemas and such like, though for others this may not be desired or possible, so this parameter is used to ensure a default is available in the abscence of other mechanisms.
Returns
integer value equal to the value of attribute attrName if present, or def if not.
Exceptions
IllegalRequestExceptionthrown if the attribute value string coul dnot be converted to the requested type.
const String& CEGUI::XMLAttributes::getValueAsString ( const String attrName,
const String def = "" 
) const

Return the value of attribute attrName as a string.

Parameters
attrNameString object holding the name of the attribute whos value is to be returned.
defString object holding the default value to be returned if attrName does not exist in the attribute block. For some parsers, defaults can be gotten from schemas and such like, though for others this may not be desired or possible, so this parameter is used to ensure a default is available in the abscence of other mechanisms.
Returns
String object containing the value of attribute attrName if present, or def if not.
void CEGUI::XMLAttributes::remove ( const String attrName)

Removes an attribute from the attribute block.

Parameters
attrNameString object holding the name of the attribute to be removed.
Returns
Nothing.