From 7eed858cac7e8ff78626bdc5d63a7f36ca8f8010 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 4 Mar 2015 16:33:51 +0200 Subject: Move roots and bases to appropriate scopes --- build/variable.cxx | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'build/variable.cxx') diff --git a/build/variable.cxx b/build/variable.cxx index 613cada..56d5a08 100644 --- a/build/variable.cxx +++ b/build/variable.cxx @@ -4,9 +4,56 @@ #include +#include + using namespace std; namespace build { variable_set variable_pool; + + // value_proxy + // + template <> + list_value& value_proxy:: + as () const + { + list_value* lv (dynamic_cast (p->get ())); + assert (lv != nullptr); + return *lv; + } + + template <> + const string& value_proxy:: + as () const + { + const list_value& lv (as ()); + assert (lv.data.size () < 2); + + if (lv.data.empty ()) + return empty_string; + + const name& n (lv.data.front ()); + + assert (n.type.empty () && n.dir.empty ()); + return n.value; + } + + // Note: get the name's directory. + // + template <> + const path& value_proxy:: + as () const + { + const list_value& lv (as ()); + assert (lv.data.size () < 2); + + if (lv.data.empty ()) + return empty_path; + + const name& n (lv.data.front ()); + + assert (n.type.empty () && n.value.empty ()); + return n.dir; + } } -- cgit v1.1