Class representing a block of attributes associated with an XML element.
More...
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 String & | getName (size_t index) const |
| Return the name of an attribute based upon its index within the attribute block.
|
const String & | getValue (size_t index) const |
| Return the value string of an attribute based upon its index within the attribute block.
|
const String & | getValue (const String &attrName) const |
| Return the value string for attribute attrName.
|
const String & | getValueAsString (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,
String::FastLessCompare > | AttributeMap |
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:
-
| 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.
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.
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:
-
| 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. |
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. |
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:
-
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. |
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. |
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. |
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.
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.