aboutsummaryrefslogtreecommitdiff
path: root/build2/variable
diff options
context:
space:
mode:
Diffstat (limited to 'build2/variable')
-rw-r--r--build2/variable24
1 files changed, 22 insertions, 2 deletions
diff --git a/build2/variable b/build2/variable
index fb44bb4..000ac9c 100644
--- a/build2/variable
+++ b/build2/variable
@@ -80,9 +80,13 @@ namespace build2
enum class variable_visibility
{
+ target, // Target and target type/pattern-specific.
scope, // This scope (no outer scopes).
project, // This project (no outer projects).
normal // All outer scopes.
+
+ // Note that the search for target type/pattern-specific terminates at
+ // the project boundary.
};
// variable
@@ -119,6 +123,9 @@ namespace build2
inline bool
operator== (const variable& x, const variable& y) {return x.name == y.name;}
+ inline ostream&
+ operator<< (ostream& os, const variable& v) {return os << v.name;}
+
//
//
class value
@@ -697,8 +704,14 @@ namespace build2
struct variable_pool: private variable_pool_base
{
const variable&
+ insert (string name, variable_visibility v = variable_visibility::normal)
+ {
+ return insert (move (name), nullptr, v, false);
+ }
+
+ const variable&
insert (string name,
- bool overridable = false,
+ bool overridable,
variable_visibility v = variable_visibility::normal)
{
return insert (move (name), nullptr, v, overridable);
@@ -706,8 +719,15 @@ namespace build2
template <typename T>
const variable&
+ insert (string name, variable_visibility v = variable_visibility::normal)
+ {
+ return insert (move (name), &value_traits<T>::value_type, v, false);
+ }
+
+ template <typename T>
+ const variable&
insert (string name,
- bool overridable = false,
+ bool overridable,
variable_visibility v = variable_visibility::normal)
{
return insert (