diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-08-12 13:54:21 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-08-12 13:54:21 +0200 |
commit | d72e5f95e70976f9b8bc29a7ace3c354e815ca49 (patch) | |
tree | 4ac1f39941be5c6cd57287e15a049ec4d62eb126 /libbuild2/variable.cxx | |
parent | 446c6548a1b61a18a27e24320a53a66a3ef7008a (diff) |
Add int64 and int64s variable types
Diffstat (limited to 'libbuild2/variable.cxx')
-rw-r--r-- | libbuild2/variable.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx index 79d0018..a4c3ef3 100644 --- a/libbuild2/variable.cxx +++ b/libbuild2/variable.cxx @@ -480,6 +480,54 @@ namespace build2 nullptr // Never empty. }; + // int64_t value + // + int64_t value_traits<int64_t>:: + convert (const name& n, const name* r) + { + if (r == nullptr && n.simple ()) + { + try + { + // May throw invalid_argument or out_of_range. + // + size_t i; + int64_t r (stoll (n.value, &i)); + + if (i == n.value.size ()) + return r; + + // Fall through. + } + catch (const std::exception&) + { + // Fall through. + } + } + + throw_invalid_argument (n, r, "int64"); + } + + const char* const value_traits<int64_t>::type_name = "int64"; + + const value_type value_traits<int64_t>::value_type + { + type_name, + sizeof (int64_t), + nullptr, // No base. + nullptr, // No element. + nullptr, // No dtor (POD). + nullptr, // No copy_ctor (POD). + nullptr, // No copy_assign (POD). + &simple_assign<int64_t>, + &simple_append<int64_t>, + &simple_append<int64_t>, // Prepend same as append. + &simple_reverse<int64_t>, + nullptr, // No cast (cast data_ directly). + nullptr, // No compare (compare as POD). + nullptr // Never empty. + }; + // uint64_t value // uint64_t value_traits<uint64_t>:: @@ -1759,6 +1807,7 @@ namespace build2 template struct LIBBUILD2_DEFEXPORT value_traits<vector<name>>; template struct LIBBUILD2_DEFEXPORT value_traits<paths>; template struct LIBBUILD2_DEFEXPORT value_traits<dir_paths>; + template struct LIBBUILD2_DEFEXPORT value_traits<int64s>; template struct LIBBUILD2_DEFEXPORT value_traits<uint64s>; template struct LIBBUILD2_DEFEXPORT |