From d90ac405ae50f84a3cf4ba0b806cca1c89f81cff Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 26 Jul 2018 14:12:56 +0300 Subject: Make project variable to be of project_name type --- build2/variable.cxx | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) (limited to 'build2/variable.cxx') 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 }; + // project_name value + // + project_name value_traits:: + 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::empty_instance = empty_project_name; + + const char* const value_traits::type_name = "project_name"; + + const value_type value_traits::value_type + { + type_name, + sizeof (project_name), + nullptr, // No base. + nullptr, // No element. + &default_dtor, + &default_copy_ctor, + &default_copy_assign, + &simple_assign, + nullptr, // Append not supported. + nullptr, // Prepend not supported. + &simple_reverse, + nullptr, // No cast (cast data_ directly). + &simple_compare, + &default_empty + }; + // variable_pool // void variable_pool:: -- cgit v1.1