diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-03-16 08:06:15 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-03-17 07:47:17 +0200 |
commit | 9f71deeeb0f8e6fe2c29f209fc96f466fc2831b6 (patch) | |
tree | 81e07870c7a16f12c7aca69bf70a71d69251d1fc /libbuild2/config/utility.ixx | |
parent | 1adbf7b710d52958f6c0168ccb492252c1f19d4a (diff) |
Rework config::{omitted,required,optional}() into unified config_lookup()
Diffstat (limited to 'libbuild2/config/utility.ixx')
-rw-r--r-- | libbuild2/config/utility.ixx | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/libbuild2/config/utility.ixx b/libbuild2/config/utility.ixx new file mode 100644 index 0000000..79d5470 --- /dev/null +++ b/libbuild2/config/utility.ixx @@ -0,0 +1,62 @@ +// file : libbuild2/config/utility.ixx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +namespace build2 +{ + namespace config + { + LIBBUILD2_SYMEXPORT pair<lookup, bool> + lookup_config_impl (scope&, const variable&); + + template <typename T> + pair<lookup, bool> + lookup_config_impl (scope&, const variable&, T&&, uint64_t, bool); + + inline lookup + lookup_config (scope& rs, const variable& var) + { + return lookup_config_impl (rs, var).first; + } + + inline lookup + lookup_config (bool& new_value, scope& rs, const variable& var) + { + auto r (lookup_config_impl (rs, var)); + new_value = new_value || r.second; + return r.first; + } + + template <typename T> + inline lookup + lookup_config (scope& rs, + const variable& var, + T&& def_val, + uint64_t sflags, + bool def_ovr) + { + return lookup_config_impl (rs, + var, + std::forward<T> (def_val), // VC14 + sflags, + def_ovr).first; + } + + template <typename T> + inline lookup + lookup_config (bool& new_value, + scope& rs, + const variable& var, + T&& def_val, + uint64_t sflags, + bool def_ovr) + { + auto r (lookup_config_impl (rs, + var, + std::forward<T> (def_val), // VC14 + sflags, + def_ovr)); + new_value = new_value || r.second; + return r.first; + } + } +} |