summaryrefslogtreecommitdiff
path: root/src/xml.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-08-21 21:38:37 +0100
committerCarl Hetherington <cth@carlh.net>2012-08-21 21:38:37 +0100
commitfd23bf276facab3892a00f010ac7e991bc79af09 (patch)
tree2ee3c0e6cfd318bfc14c5fca7c29c9031a570a69 /src/xml.cc
parent3541f4c9bd91169e55a82b9fa46767b46ca06188 (diff)
Pick up effect and effect color.
Diffstat (limited to 'src/xml.cc')
-rw-r--r--src/xml.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/xml.cc b/src/xml.cc
index 1d524738..b9ee56a8 100644
--- a/src/xml.cc
+++ b/src/xml.cc
@@ -140,6 +140,22 @@ XMLNode::string_attribute (string name)
{
xmlpp::Element const * e = dynamic_cast<const xmlpp::Element *> (_node);
if (!e) {
+ throw XMLError ("missing attribute");
+ }
+
+ xmlpp::Attribute* a = e->get_attribute (name);
+ if (!a) {
+ throw XMLError ("missing attribute");
+ }
+
+ return a->get_value ();
+}
+
+string
+XMLNode::optional_string_attribute (string name)
+{
+ xmlpp::Element const * e = dynamic_cast<const xmlpp::Element *> (_node);
+ if (!e) {
return "";
}
@@ -166,7 +182,7 @@ XMLNode::int64_attribute (string name)
int64_t
XMLNode::optional_int64_attribute (string name)
{
- string const s = string_attribute (name);
+ string const s = optional_string_attribute (name);
if (s.empty ()) {
return 0;
}
@@ -177,7 +193,7 @@ XMLNode::optional_int64_attribute (string name)
optional<bool>
XMLNode::optional_bool_attribute (string name)
{
- string const s = string_attribute (name);
+ string const s = optional_string_attribute (name);
if (s.empty ()) {
return optional<bool> ();
}
@@ -192,7 +208,7 @@ XMLNode::optional_bool_attribute (string name)
optional<Color>
XMLNode::optional_color_attribute (string name)
{
- string const s = string_attribute (name);
+ string const s = optional_string_attribute (name);
if (s.empty ()) {
return optional<Color> ();
}