summaryrefslogtreecommitdiff
path: root/project2/variables.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/variables.cpp')
-rw-r--r--project2/variables.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/project2/variables.cpp b/project2/variables.cpp
index 70f51b8..7e7ea2c 100644
--- a/project2/variables.cpp
+++ b/project2/variables.cpp
@@ -150,7 +150,7 @@ class VariableParent : public VariableImplDyn {
public:
VariableParent(const xmlpp::Element * e) :
VariableImplDyn(e),
- depth(atoi(e->get_attribute_value("depth").c_str())),
+ depth(e->get_attribute("depth") ? atoi(e->get_attribute_value("depth").c_str()) : 1),
attr(e->get_attribute("attribute")),
name(attr ? e->get_attribute_value("attribute") : e->get_attribute_value("name"))
{
@@ -251,6 +251,20 @@ Variable::Variable(const xmlpp::Element * e, const Glib::ustring & n, bool requi
throw NoVariableDefinition(n);
}
+Variable::Variable(const xmlpp::Element * c, const boost::optional<Glib::ustring> & defaultSource)
+{
+ xmlpp::Attribute * source = c->get_attribute("source");
+ if (source) {
+ var = LoaderBase::getLoader<VariableLoader, UnknownVariableSource>(source->get_value())->create(c);
+ }
+ else if (defaultSource) {
+ var = LoaderBase::getLoader<VariableLoader, UnknownVariableSource>(defaultSource.get())->create(c);
+ }
+ else {
+ var = new VariableLiteral(c);
+ }
+}
+
Variable::Variable(VariableImpl * v) :
var(v)
{