blob: 8b262397ca0050a8264386fbcfb0ed7b6f97ad47 (
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
|
// file : build/config/utility.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
#include <build/config/utility>
using namespace std;
namespace build
{
namespace config
{
// The same as the template except it is a bit more efficient
// when it comes to not creating the default value string
// unnecessarily.
//
pair<const string&, bool>
required (scope& root, const char* name, const char* def_value)
{
string r;
const variable& var (variable_pool.find (name));
if (auto v = root[var])
{
const string& s (v.as<const string&> ());
if (!v.belongs (*global_scope)) // A value from (some) config.build.
return pair<const string&, bool> (s, false);
r = s;
}
else
r = def_value;
auto v (root.assign (var));
v = move (r);
return pair<const string&, bool> (v.as<const string&> (), true);
}
}
}
|