aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/config/utility.ixx
blob: 87f628c76285b407ef3743457b3682244d13733f (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
66
67
68
69
70
71
72
// 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,
                        save_variable_function*);

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

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