UQTk: Uncertainty Quantification Toolkit 3.1.5
XMLAttributeList Class Reference

#include <XMLAttributeList.h>

Inheritance diagram for XMLAttributeList:
Object

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.
 
XMLAttributeListoperator= (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
 

Detailed Description

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

Member Typedef Documentation

◆ const_iterator

Map_t::const_iterator XMLAttributeList::const_iterator

◆ iterator

Map_t::iterator XMLAttributeList::iterator

The iterator type returned by this implementation.

◆ Map_t

std::map< std::string, std::string > XMLAttributeList::Map_t

The container type used to hold the attributes.

Constructor & Destructor Documentation

◆ XMLAttributeList() [1/2]

XMLAttributeList::XMLAttributeList ( )

Construct a blank attribute list.

◆ XMLAttributeList() [2/2]

XMLAttributeList::XMLAttributeList ( const XMLAttributeList & )
private

Blocked copy constructor. Throws an exception.

◆ ~XMLAttributeList()

XMLAttributeList::~XMLAttributeList ( )
virtual

Destroy this list.

Member Function Documentation

◆ begin() [1/2]

XMLAttributeList::iterator XMLAttributeList::begin ( )

Get an iterator to the first element.

◆ begin() [2/2]

XMLAttributeList::const_iterator XMLAttributeList::begin ( ) const

Get an iterator to the first element in a const context.

◆ boolean_value()

bool XMLAttributeList::boolean_value ( const std::string & str,
const char * where ) const
private

Return the boolean value of the given string.

Exceptions
MyExceptionif the string is not a valid boolean value.

◆ end() [1/2]

XMLAttributeList::iterator XMLAttributeList::end ( )

Get an iterator past the last element.

◆ end() [2/2]

XMLAttributeList::const_iterator XMLAttributeList::end ( ) const

Get an iterator past the last element in a const context.

◆ get() [1/2]

const std::string & XMLAttributeList::get ( const std::string & key) const

Get the attribute associated with the given key.

Exceptions
MyExceptionif the key is not defined.

◆ get() [2/2]

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.

◆ get_bool() [1/2]

bool XMLAttributeList::get_bool ( const std::string & key) const

Get the given attribute as a boolean value.

Exceptions
MyExceptionif the key is not defined.
MyExceptionif 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.

◆ get_bool() [2/2]

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.

Exceptions
MyExceptionif the value is not a valid boolean value.

◆ get_double() [1/2]

double XMLAttributeList::get_double ( const std::string & key) const

Get the given attribute as a real value.

Exceptions
MyExceptionif the key is not defined.
MyExceptionif the value is not a valid number.

◆ get_double() [2/2]

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.

Exceptions
MyExceptionif the value is set and is not a valid number.

◆ get_int() [1/2]

int XMLAttributeList::get_int ( const std::string & key) const

Get the given attribute as an integer value.

Exceptions
MyExceptionif the key is not defined.
MyExceptionif the value is not a valid integer.

◆ get_int() [2/2]

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.

Exceptions
MyExceptionif the value is set and is not a valid integer.

◆ get_location() [1/2]

XMLAttributeList::iterator XMLAttributeList::get_location ( const std::string & key)
private

Get an iterator pointing to the location of the given string.

◆ get_location() [2/2]

XMLAttributeList::const_iterator XMLAttributeList::get_location ( const std::string & key) const
private

Get an iterator to a location in a const context.

◆ has()

bool XMLAttributeList::has ( const std::string & key) const

Return true if the given key is defined.

◆ make_lower_case()

void XMLAttributeList::make_lower_case ( std::string & str) const
private

Convert a string to lower case (conversion in place). (needed to handle boolean values)

◆ operator=()

XMLAttributeList & XMLAttributeList::operator= ( const XMLAttributeList & )
private

Blocked assignment operator.

Exceptions
MyException

◆ set()

void XMLAttributeList::set ( const std::string & key,
const std::string & val )

Assign a text attribute to the given key.

◆ set_bool()

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"

◆ set_double()

void XMLAttributeList::set_double ( const std::string & key,
double val )

Assign a numerical value to the given key.

◆ set_int()

void XMLAttributeList::set_int ( const std::string & key,
int val )

Assign an integer value to the given key.

◆ size()

int XMLAttributeList::size ( ) const

Get the number of attributes in the list.

Friends And Related Symbol Documentation

◆ ConstRefPtr

template<class T >
friend class ConstRefPtr
friend

◆ RefPtr

template<class T >
friend class RefPtr
friend

Member Data Documentation

◆ attribute_

Map_t XMLAttributeList::attribute_
private

The attributes.


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