extendions and corrections

This commit is contained in:
Marc Wäckerlin
2009-04-08 15:01:48 +00:00
parent e48b91683e
commit 98334b4565
3 changed files with 25 additions and 6 deletions

View File

@@ -163,6 +163,13 @@ namespace xml {
Node* _child;
};
//----------------------------------------------------------------------------
class attribute_not_available: public exception {
public:
attribute_not_available(const Node& t, const std::string& attr) throw():
exception("attribute \""+attr+"\" not set", t) {
}
};
//----------------------------------------------------------------------------
class stream_error: public exception {
public:
stream_error(const std::string& reason, const Node& t,
@@ -248,7 +255,7 @@ namespace xml {
once. This is corect: <code>&lt;node
attribute="value"&gt;</code>, this is not allowed:
<code>&lt;node attribute="value" attribute="value"&gt;</code> */
class Attributes: public std::map<std::string, std::string> {
class Attributes: public std::map<std::string, std::string> {
public:
//! Attributes may contain a list of space separated values.
typedef std::vector<std::string> List;
@@ -324,6 +331,8 @@ namespace xml {
Node& attr(const std::string& name, bool mandatory) throw();
std::string attr(const std::string& name) const throw();
std::string& attr(const std::string& name) throw();
const Attributes::Value attribute(const std::string& name)
const throw(attribute_not_available);
List list(const std::string& name) const throw();
bool operator()(const std::string& child) const throw();
Node& operator<<(const Node& o) throw(cannot_have_children);