aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-26 14:12:56 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-30 13:04:37 +0300
commitd90ac405ae50f84a3cf4ba0b806cca1c89f81cff (patch)
tree3f66be39a80a0a32cbba332e34b418fa1fc9ad02 /build2/variable.cxx
parente92a1aab0e1c7c9ba8e6ab9a7049207468ca53fc (diff)
Make project variable to be of project_name type
Diffstat (limited to 'build2/variable.cxx')
-rw-r--r--build2/variable.cxx53
1 files changed, 51 insertions, 2 deletions
diff --git a/build2/variable.cxx b/build2/variable.cxx
index 406123d..c304d0c 100644
--- a/build2/variable.cxx
+++ b/build2/variable.cxx
@@ -549,7 +549,7 @@ namespace build2
//
if (n.qualified ())
{
- string p (*n.proj);
+ string p (move (*n.proj).string ());
p += '%';
p += s;
p.swap (s);
@@ -563,7 +563,7 @@ namespace build2
if (r->qualified ())
{
- s += *r->proj;
+ s += r->proj->string ();
s += '%';
}
@@ -1080,6 +1080,55 @@ namespace build2
&default_empty<target_triplet>
};
+ // project_name value
+ //
+ project_name value_traits<project_name>::
+ convert (name&& n, name* r)
+ {
+ if (r == nullptr)
+ {
+ if (n.simple ())
+ {
+ try
+ {
+ return n.empty () ? project_name () : project_name (move (n.value));
+ }
+ catch (const invalid_argument& e)
+ {
+ throw invalid_argument (
+ string ("invalid project_name value: ") + e.what ());
+ }
+ }
+
+ // Fall through.
+ }
+
+ throw_invalid_argument (n, r, "project_name");
+ }
+
+ const project_name&
+ value_traits<project_name>::empty_instance = empty_project_name;
+
+ const char* const value_traits<project_name>::type_name = "project_name";
+
+ const value_type value_traits<project_name>::value_type
+ {
+ type_name,
+ sizeof (project_name),
+ nullptr, // No base.
+ nullptr, // No element.
+ &default_dtor<project_name>,
+ &default_copy_ctor<project_name>,
+ &default_copy_assign<project_name>,
+ &simple_assign<project_name>,
+ nullptr, // Append not supported.
+ nullptr, // Prepend not supported.
+ &simple_reverse<project_name>,
+ nullptr, // No cast (cast data_ directly).
+ &simple_compare<project_name>,
+ &default_empty<project_name>
+ };
+
// variable_pool
//
void variable_pool::