// file : build/config/utility.txx -*- C++ -*- // copyright : Copyright (c) 2014-2015 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file #include // move() #include #include namespace build { namespace config { template std::pair required (scope& root, const char* name, const T& def_value) { T r; const variable& var (variable_pool.find (name)); if (auto v = root[var]) { const T& s (v.as ()); if (!v.belongs (*global_scope)) // A value from (some) config.build. return std::pair (s, false); r = s; } else r = def_value; auto v (root.assign (var)); v = std::move (r); return std::pair (v.as (), true); } template const T* optional (scope& root, const char* name) { const T* r (nullptr); const variable& var (variable_pool.find (name)); auto v (root[var]); if (v.defined ()) { if (v.belongs (*global_scope)) root.assign (var) = v; r = v.null () ? nullptr : &v.as (); } else root.assign (var) = nullptr; return r; } } }