From fd23bf276facab3892a00f010ac7e991bc79af09 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 21 Aug 2012 21:38:37 +0100 Subject: Pick up effect and effect color. --- src/xml.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/xml.cc') diff --git a/src/xml.cc b/src/xml.cc index 1d524738..b9ee56a8 100644 --- a/src/xml.cc +++ b/src/xml.cc @@ -137,6 +137,22 @@ XMLNode::time_attribute (string name) string XMLNode::string_attribute (string name) +{ + xmlpp::Element const * e = dynamic_cast (_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 (_node); if (!e) { @@ -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 XMLNode::optional_bool_attribute (string name) { - string const s = string_attribute (name); + string const s = optional_string_attribute (name); if (s.empty ()) { return optional (); } @@ -192,7 +208,7 @@ XMLNode::optional_bool_attribute (string name) optional XMLNode::optional_color_attribute (string name) { - string const s = string_attribute (name); + string const s = optional_string_attribute (name); if (s.empty ()) { return optional (); } -- cgit v1.2.3