aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/config/utility.ixx
blob: d8348bdd42bb96cc3b6a435e8d6eaf90caf2ca89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// 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&, uint64_t);

    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, uint64_t sflags)
    {
      return lookup_config_impl (rs, var, sflags).first;
    }

    inline lookup
    lookup_config (bool& new_value,
                   scope& rs,
                   const variable& var,
                   uint64_t sflags)
    {
      auto r (lookup_config_impl (rs, var, sflags));
      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;
    }
  }
}