namespace alps {
class XMLAttribute
{
public:
typedef std::string key_type;
typedef std::string value_type;
XMLAttribute();
XMLAttribute(const XMLAttribute& attr);
XMLAttribute(const key_type& k);
XMLAttribute(const key_type& k, const value_type& v);
XMLAttribute(const key_type& k, const char * v);
template<class T> XMLAttribute(const key_type& k, const T& v);
key_type& key();
const key_type& key() const;
value_type& value();
const value_type& value() const;
};
class XMLAttributes
{
public:
typedef XMLAttribute::key_type key_type;
typedef XMLAttribute::value_type value_type;
typedef std::vector<XMLAttribute> list_type;
typedef list_type::size_type size_type;
typedef list_type::iterator iterator;
typedef list_type::const_iterator const_iterator;
XMLAttributes();
void clear();
size_type size() const;
bool defined(const key_type& k);
// accessing elements by key
value_type& operator[](const key_type& k);
const value_type& operator[](const key_type& k) const;
value_type value_or_default(const key_type& k, const value_type& v) const;
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
void push_back(const XMLAttribute& attr);
void push_back(const key_type& k, const value_type& v);
XMLAttributes& operator<<(const XMLAttribute& a);
XMLAttributes& operator<<(const XMLAttributes& attr);
};
} // namespace alps
the default constructorXMLAttribute();
the copy constructorXMLAttribute(const XMLAttribute& attr);
constructor with a given name (key) but an empty valueXMLAttribute(const key_type& k);
constructors from a pair of a name (key) and a valueXMLAttribute(const key_type& k, const value_type& v); XMLAttribute(const key_type& k, const char * v); template<class T> XMLAttribute(const key_type& k, const T& v);
access the name of the attributekey_type& key(); const key_type& key() const;
access the value of the attributevalue_type& value(); const value_type& value() const;
the default constructorXMLAttributes();
clears the contentsvoid clear();
returns the number of attributessize_type size();
returns true if an attribute exists for the given attribute name.bool defined(const key_type& k);
access the attribute value with a given name. Note that if the attribute does not exists, a new attribute with the given name will be created and appended at the last of the set.value_type& operator[](const key_type& k); const value_type& operator[](const key_type& k) const;
returns the attribute value with a given name. If the attribute does not exists, the default value specified by the second argument will be returned.value_type value_or_default(const key_type& k, const value_type& v) const;
return iterators pointing the first element in the set, or the next to the last element.iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const;
append a new attribute. If there already exists an attribute with the same name, an exception will be thrown.void push_back(const XMLAttribute& attr); void push_back(const key_type& k, const value_type& v);
appends a new attribute. If there already exists an attribute with the same name, the attribute value will be replaced by a new one.XMLAttributes& operator<<(const XMLAttribute& a);
appends new attributes. If there already exist attributes with the same names, the attribute values will be replaced by new ones.XMLAttributes& operator<<(const XMLAttributes& attr);
copyright (c) 1994-2010 by Matthias Troyer
Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)