UQTk: Uncertainty Quantification Toolkit 3.1.5
|
#include <XMLAttributeList.h>
Public Types | |
typedef std::map< std::string, std::string > | Map_t |
The container type used to hold the attributes. | |
typedef Map_t::iterator | iterator |
The iterator type returned by this implementation. | |
typedef Map_t::const_iterator | const_iterator |
Public Member Functions | |
XMLAttributeList () | |
Construct a blank attribute list. | |
virtual | ~XMLAttributeList () |
Destroy this list. | |
int | size () const |
Get the number of attributes in the list. | |
bool | has (const std::string &) const |
Return true if the given key is defined. | |
const std::string & | get (const std::string &) const |
std::string | get (const std::string &, const std::string &) const |
int | get_int (const std::string &) const |
int | get_int (const std::string &, int) const |
double | get_double (const std::string &) const |
double | get_double (const std::string &, double) const |
bool | get_bool (const std::string &) const |
bool | get_bool (const std::string &, bool) const |
void | set (const std::string &, const std::string &) |
Assign a text attribute to the given key. | |
void | set_int (const std::string &, int) |
Assign an integer value to the given key. | |
void | set_double (const std::string &, double) |
Assign a numerical value to the given key. | |
void | set_bool (const std::string &, bool) |
iterator | begin () |
Get an iterator to the first element. | |
iterator | end () |
Get an iterator past the last element. | |
const_iterator | begin () const |
Get an iterator to the first element in a const context. | |
const_iterator | end () const |
Get an iterator past the last element in a const context. | |
Public Member Functions inherited from Object | |
Object () | |
Construct a new reference counted object with a zero reference count. | |
virtual | ~Object () |
Destroy this object. | |
long int | reference_count () const |
Returns the number of references that are held to this object. | |
Private Member Functions | |
XMLAttributeList (const XMLAttributeList &) | |
Blocked copy constructor. Throws an exception. | |
XMLAttributeList & | operator= (const XMLAttributeList &) |
void | make_lower_case (std::string &) const |
iterator | get_location (const std::string &) |
Get an iterator pointing to the location of the given string. | |
const_iterator | get_location (const std::string &) const |
Get an iterator to a location in a const context. | |
bool | boolean_value (const std::string &, const char *where) const |
Private Attributes | |
Map_t | attribute_ |
The attributes. | |
Friends | |
template<class T > | |
class | RefPtr |
template<class T > | |
class | ConstRefPtr |
Additional Inherited Members | |
Protected Member Functions inherited from Object | |
long int | reference_grab () const |
long int | reference_release () const |
The implementation of a container for XML attributes.
Attributes are stored as key-value pairs, both of which are stored as text strings. The keys are stored and handled in a case-sensitive manner, whereas the values are stored exactly as given.
The order in which attributes were added is not preserved. I am not sure whether this is a problem or not.
Boolean values are a special case. They are treated in a case-insensitive manner. True boolean values are returned for the strings 'true', 'yes', and non-zero numerical values. False boolean values are returned for the strings 'false', 'no', and zero values. All other strings are considered unacceptable boolean values.
Written by Helgi Adalsteinsson Modified by Bert Debusschere, 3/13/08 to make keys case-sensitive
Map_t::const_iterator XMLAttributeList::const_iterator |
Map_t::iterator XMLAttributeList::iterator |
The iterator type returned by this implementation.
std::map< std::string, std::string > XMLAttributeList::Map_t |
The container type used to hold the attributes.
XMLAttributeList::XMLAttributeList | ( | ) |
Construct a blank attribute list.
|
private |
Blocked copy constructor. Throws an exception.
|
virtual |
Destroy this list.
XMLAttributeList::iterator XMLAttributeList::begin | ( | ) |
Get an iterator to the first element.
XMLAttributeList::const_iterator XMLAttributeList::begin | ( | ) | const |
Get an iterator to the first element in a const context.
|
private |
Return the boolean value of the given string.
MyException | if the string is not a valid boolean value. |
XMLAttributeList::iterator XMLAttributeList::end | ( | ) |
Get an iterator past the last element.
XMLAttributeList::const_iterator XMLAttributeList::end | ( | ) | const |
Get an iterator past the last element in a const context.
const std::string & XMLAttributeList::get | ( | const std::string & | key | ) | const |
Get the attribute associated with the given key.
MyException | if the key is not defined. |
std::string XMLAttributeList::get | ( | const std::string & | key, |
const std::string & | def ) const |
Get the attribute associated with the given key or return the given default value if the key is not defined.
bool XMLAttributeList::get_bool | ( | const std::string & | key | ) | const |
Get the given attribute as a boolean value.
MyException | if the key is not defined. |
MyException | if the value is not a valid boolean value. True boolean values are "yes", "true", and 'non-zero' numerical values. False boolean values are "no" "false", and 'zero' numerical values. |
bool XMLAttributeList::get_bool | ( | const std::string & | key, |
bool | def ) const |
Get the given attribute as a boolean value or return the given default value if the key is not defined.
MyException | if the value is not a valid boolean value. |
double XMLAttributeList::get_double | ( | const std::string & | key | ) | const |
Get the given attribute as a real value.
MyException | if the key is not defined. |
MyException | if the value is not a valid number. |
double XMLAttributeList::get_double | ( | const std::string & | key, |
double | def ) const |
Get the given attribute as a real value or return the given default value if the key is not defined.
MyException | if the value is set and is not a valid number. |
int XMLAttributeList::get_int | ( | const std::string & | key | ) | const |
Get the given attribute as an integer value.
MyException | if the key is not defined. |
MyException | if the value is not a valid integer. |
int XMLAttributeList::get_int | ( | const std::string & | key, |
int | def ) const |
Get the given attribute as an integer value or return the given default value if the key is not defined.
MyException | if the value is set and is not a valid integer. |
|
private |
Get an iterator pointing to the location of the given string.
|
private |
Get an iterator to a location in a const context.
bool XMLAttributeList::has | ( | const std::string & | key | ) | const |
Return true if the given key is defined.
|
private |
Convert a string to lower case (conversion in place). (needed to handle boolean values)
|
private |
Blocked assignment operator.
MyException |
void XMLAttributeList::set | ( | const std::string & | key, |
const std::string & | val ) |
Assign a text attribute to the given key.
void XMLAttributeList::set_bool | ( | const std::string & | key, |
bool | val ) |
Assign a boolean attribute to the given key. True boolean values are added as "true", false as "false"
void XMLAttributeList::set_double | ( | const std::string & | key, |
double | val ) |
Assign a numerical value to the given key.
void XMLAttributeList::set_int | ( | const std::string & | key, |
int | val ) |
Assign an integer value to the given key.
int XMLAttributeList::size | ( | ) | const |
Get the number of attributes in the list.
|
friend |
|
friend |
|
private |
The attributes.