aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/variable.txx
AgeCommit message (Collapse)AuthorFilesLines
2024-02-21Fix issue with json null representation in containersBoris Kolpackov1-0/+4
2024-02-20Add json_map and json_set buildfile value typesBoris Kolpackov1-28/+0
These expose the std::map<json_value,json_value> and std::set<json_value> types to buildfiles. New functions: $size(<json-set>) $size(<json-map>) $keys(<json-map>) Note that the $keys() function returns the list of map key as a json array. For example: m = [json_map] 2@([json] a@1 b@2) 1@([json] 1 2) s = [json_set] ([json] x@1 y@2) ([json] a@1 b@2) print ($m[2][b]) # 2 print ($s[([json] y@2 x@1)]) # true
2024-02-20Add custom subscript, iterate functions for vector and set value typesBoris Kolpackov1-3/+80
2024-02-20Add string_set buildfile value typeBoris Kolpackov1-0/+223
This exposes the std::set<std::string> type to buildfiles. New functions: $size(<string-set>) Subscript returns true if the value is present and false otherwise (so it is mapped to std::set::contains()). For example: set = [string_set] a b c if ($set[b]) ... Note that append (+=) and prepend (=+) have the same semantics (std::set::insert()). For example: set = [string_set] a b set += c b # a b c set =+ d b # a b c d Example of iteration: set = [string_set] a b c for k: $set ...
2024-02-19Add string_map buildfile value typeBoris Kolpackov1-30/+121
This exposes the std::map<std::string,std::string> type to buildfiles. New functions: $size(<string-map>) $keys(<string-map>) Subscript can be used to lookup a value by key. The result is [null] if there is no value associated with the specified key. For example: map = [string_map] a@1 b@2 c@3 b = ($map[b]) # 2 if ($map[z] == [null]) ... Note that append (+=) is overriding (like std::map::insert_or_assign()) while prepend (=+) is not (like std::map::insert()). In a sense, whatever appears last (from left to right) is kept, which is consistent with what we expect to happen when specifying the same key repeatedly in a literal representation. For example: map = [string_map] a@0 b@2 a@1 # a@1 b@2 map += b@0 c@3 # a@1 b@0 c@3 map =+ b@1 d@4 # a@1 b@0 c@3 d@4 Example of iteration: map = [string_map] a@1 b@2 c@3 for p: $map { k = $first($p) v = $second($p) } While the subscript is mapped to key lookup only, index-based access can be implemented (with a bit of overhead) using the $keys() function: map = [string_map] a@1 b@2 c@3 keys = $keys($m) for i: $integer_sequence(0, $size($keys)) { k = ($keys[$i]) v = ($map[$k]) } Also, this commit changes the naming of other template-based value types (not exposed as buildfile value types) to use C++ template id-like names (e.g., map<string,optional<bool>>).
2024-02-06Add support for value type-specific subscript and iterationBoris Kolpackov1-3/+9
2023-04-05Allow creating context with bare minimum of initializationsBoris Kolpackov1-2/+2
This is used by bpkg to detect forwarded configurations without incurring the full context creation overhead.
2022-12-14Improve empty simple value to empty list of names reduction heuristicsBoris Kolpackov1-10/+15
Specifically, do not reduce typed RHS empty simple values for prepend/append and additionally for assignment provided LHS is typed and is a container.
2022-10-27Suppress (potential) bogus GCC 12 -Wrestrict warningsBoris Kolpackov1-1/+1
2022-06-03Reset value::extra on variable_map value change/version incrementBoris Kolpackov1-0/+1
The reset on each modification semantics is used to implement the default value distinction as currently done in the config module but later probably will be done for ?= and $origin().
2021-05-28Ban conversion of patterns to valuesBoris Kolpackov1-62/+71
Also improve conversion diagnostic.
2021-01-30Add std::{map, multimap} to types.hxxBoris Kolpackov1-12/+2
Seeing that std::map is becoming a common Buildfile variable type.
2021-01-28Make std::map prepend (=+) overriding (like insert_or_assign())Boris Kolpackov1-1/+30
2021-01-22Add support for optional pair halves in variable valuesBoris Kolpackov1-155/+358
2020-08-26Add missing symbol exportsBoris Kolpackov1-1/+1
2020-08-24Add copying version of convert<T>(value)Boris Kolpackov1-8/+14
2020-03-19Tweak lookup_config() semantics some moreBoris Kolpackov1-7/+7
2020-02-07Drop copyright notice from source codeKaren Arutyunov1-1/+0
2019-11-12Add support for vector<pair<K, V>> variable valuesBoris Kolpackov1-1/+165
2019-10-22Rename global_mutex_shards to global_mutexesBoris Kolpackov1-2/+2
2019-10-22Move global mutex shards to contextBoris Kolpackov1-3/+7
2019-09-30Allow attributes in if-else, assert directive's conditionsBoris Kolpackov1-7/+20
2019-07-01Split build system into library and driverBoris Kolpackov1-0/+670