diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-04 16:33:51 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-04 16:33:51 +0200 |
commit | 7eed858cac7e8ff78626bdc5d63a7f36ca8f8010 (patch) | |
tree | 225dd25e354c4f6234dbf2c02608ec6545dcd688 /build/variable.cxx | |
parent | c76fe316122969986103d243706dc7fa7ab6ddc1 (diff) |
Move roots and bases to appropriate scopes
Diffstat (limited to 'build/variable.cxx')
-rw-r--r-- | build/variable.cxx | 47 |
1 files changed, 47 insertions, 0 deletions
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 <build/variable> +#include <build/utility> + using namespace std; namespace build { variable_set variable_pool; + + // value_proxy + // + template <> + list_value& value_proxy:: + as<list_value&> () const + { + list_value* lv (dynamic_cast<list_value*> (p->get ())); + assert (lv != nullptr); + return *lv; + } + + template <> + const string& value_proxy:: + as<const string&> () const + { + const list_value& lv (as<list_value&> ()); + 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 path&> () const + { + const list_value& lv (as<list_value&> ()); + 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; + } } |