From 9f71deeeb0f8e6fe2c29f209fc96f466fc2831b6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 16 Mar 2020 08:06:15 +0200 Subject: Rework config::{omitted,required,optional}() into unified config_lookup() --- libbuild2/config/utility.ixx | 62 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 libbuild2/config/utility.ixx (limited to 'libbuild2/config/utility.ixx') 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_config_impl (scope&, const variable&); + + template + pair + 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 + 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 (def_val), // VC14 + sflags, + def_ovr).first; + } + + template + 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 (def_val), // VC14 + sflags, + def_ovr)); + new_value = new_value || r.second; + return r.first; + } + } +} -- cgit v1.1