Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CEGUI::XMLAttributes Class Reference

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

#include <CEGUIXMLAttributes.h>

List of all members.

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.
void remove (const String &attrName)
 Removes an attribute from the attribute block.
bool exists (const String &attrName) const
 Return whether the named attribute exists within the attribute block.
size_t getCount (void) const
 Return the number of attributes in the attribute block.
const StringgetName (size_t index) const
 Return the name of an attribute based upon its index within the attribute block.
const StringgetValue (size_t index) const
 Return the value string of an attribute based upon its index within the attribute block.
const StringgetValue (const String &attrName) const
 Return the value string for attribute attrName.
const StringgetValueAsString (const String &attrName, const String &def="") const
 Return the value of attribute attrName as a string.
bool getValueAsBool (const String &attrName, bool def=false) const
 Return the value of attribute attrName as a boolean value.
int getValueAsInteger (const String &attrName, int def=0) const
 Return the value of attribute attrName as a integer value.
float getValueAsFloat (const String &attrName, float def=0.0f) const
 Return the value of attribute attrName as a floating point value.

Protected Types

typedef std::map< String,
String
AttributeMap

Protected Attributes

AttributeMap d_attrs


Detailed Description

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

Definition at line 43 of file CEGUIXMLAttributes.h.


Member Typedef Documentation

typedef std::map<String, String> CEGUI::XMLAttributes::AttributeMap [protected]
 

Definition at line 233 of file CEGUIXMLAttributes.h.


Constructor & Destructor Documentation

CEGUI::XMLAttributes::XMLAttributes void   ) 
 

XMLAttributes constructor.

Definition at line 32 of file CEGUIXMLAttributes.cpp.

CEGUI::XMLAttributes::~XMLAttributes void   )  [virtual]
 

XMLAttributes Destructor.

Definition at line 35 of file CEGUIXMLAttributes.cpp.


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:
attrName String object holding the name of the attribute to be added.
attrValue String object holding a string representation of the attribute value.
Returns:
Nothing.

Definition at line 38 of file CEGUIXMLAttributes.cpp.

References d_attrs.

Referenced by CEGUI::XercesParser::populateAttributesBlock(), and CEGUI::TinyXMLDocument::processElement().

bool CEGUI::XMLAttributes::exists const String attrName  )  const
 

Return whether the named attribute exists within the attribute block.

Parameters:
attrName String 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.

Definition at line 51 of file CEGUIXMLAttributes.cpp.

References d_attrs.

Referenced by getValueAsBool(), getValueAsFloat(), getValueAsInteger(), and getValueAsString().

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.

Definition at line 56 of file CEGUIXMLAttributes.cpp.

References d_attrs.

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:
index zero 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:
IllegalRequestException thrown if index is out of range for this attribute block.

Definition at line 61 of file CEGUIXMLAttributes.cpp.

References d_attrs.

const String & CEGUI::XMLAttributes::getValue const String attrName  )  const
 

Return the value string for attribute attrName.

Parameters:
attrName String 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:
UnknownObjectException thrown if no attribute named attrName is present in the attribute block.

Definition at line 87 of file CEGUIXMLAttributes.cpp.

References d_attrs.

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:
index zero 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:
IllegalRequestException thrown if index is out of range for this attribute block.

Definition at line 74 of file CEGUIXMLAttributes.cpp.

References d_attrs.

Referenced by getValueAsBool(), getValueAsFloat(), getValueAsInteger(), and getValueAsString().

bool CEGUI::XMLAttributes::getValueAsBool const String attrName,
bool  def = false
const
 

Return the value of attribute attrName as a boolean value.

Parameters:
attrName String object holding the name of the attribute whos value is to be returned.
def bool 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:
IllegalRequestException thrown if the attribute value string coul dnot be converted to the requested type.

Definition at line 107 of file CEGUIXMLAttributes.cpp.

References exists(), and getValue().

Referenced by CEGUI::Imageset_xmlHandler::elementStart(), CEGUI::Font_xmlHandler::elementStart(), and CEGUI::Falagard_xmlHandler::elementStart().

float CEGUI::XMLAttributes::getValueAsFloat const String attrName,
float  def = 0.0f
const
 

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

Parameters:
attrName String object holding the name of the attribute whos value is to be returned.
def float 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:
IllegalRequestException thrown if the attribute value string coul dnot be converted to the requested type.

Definition at line 151 of file CEGUIXMLAttributes.cpp.

References exists(), and getValue().

Referenced by CEGUI::Falagard_xmlHandler::elementStart().

int CEGUI::XMLAttributes::getValueAsInteger const String attrName,
int  def = 0
const
 

Return the value of attribute attrName as a integer value.

Parameters:
attrName String object holding the name of the attribute whos value is to be returned.
def integer 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:
IllegalRequestException thrown if the attribute value string coul dnot be converted to the requested type.

Definition at line 130 of file CEGUIXMLAttributes.cpp.

References exists(), and getValue().

Referenced by CEGUI::Imageset_xmlHandler::elementStart(), CEGUI::Font_xmlHandler::elementStart(), and CEGUI::Falagard_xmlHandler::elementStart().

const String & CEGUI::XMLAttributes::getValueAsString const String attrName,
const String def = ""
const
 

Return the value of attribute attrName as a string.

Parameters:
attrName String object holding the name of the attribute whos value is to be returned.
def String 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.

Definition at line 101 of file CEGUIXMLAttributes.cpp.

References exists(), and getValue().

Referenced by CEGUI::Scheme_xmlHandler::elementStart(), CEGUI::Imageset_xmlHandler::elementStart(), CEGUI::GUILayout_xmlHandler::elementStart(), CEGUI::Font_xmlHandler::elementStart(), CEGUI::Falagard_xmlHandler::elementStart(), and CEGUI::Config_xmlHandler::elementStart().

void CEGUI::XMLAttributes::remove const String attrName  ) 
 

Removes an attribute from the attribute block.

Parameters:
attrName String object holding the name of the attribute to be removed.
Returns:
Nothing.

Definition at line 43 of file CEGUIXMLAttributes.cpp.

References d_attrs.


Member Data Documentation

AttributeMap CEGUI::XMLAttributes::d_attrs [protected]
 

Definition at line 234 of file CEGUIXMLAttributes.h.

Referenced by add(), exists(), getCount(), getName(), getValue(), and remove().


The documentation for this class was generated from the following files:
Generated on Wed Sep 7 10:07:49 2005 for Crazy Eddies GUI System by  doxygen 1.4.3