aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/functions-string.cxx
AgeCommit message (Collapse)AuthorFilesLines
2024-04-01Add missing std::move() callBoris Kolpackov1-1/+1
2024-04-01Add $string.replace() functionBoris Kolpackov1-1/+131
2024-02-20Add string_set buildfile value typeBoris Kolpackov1-2/+4
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-4/+21
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>>).
2023-08-09Complete and cleanup function documentation in preparation for auto-extractionBoris Kolpackov1-14/+26
Also: - Move the $target.*() function family from functions-name.cxx to separate functions-target.cxx. - Get rid of the separate $process_path_ex.*() family, merging it with $process_path.*().
2022-12-14Handle NULL values in $string() and $concat() functionsBoris Kolpackov1-13/+21
This is relied upon by the parser to provide conversion/concatenation semantics consistent with untyped values. Note that we handle NULL values only for types that have empty representation.
2022-10-27Suppress (potential) bogus GCC 12 -Wrestrict warningsBoris Kolpackov1-2/+2
2022-09-29Add $find(<sequence>, <value>), $find_index(<sequence>, <value>) functionsBoris Kolpackov1-0/+56
The $find() function returns true if the sequence contains the specified value. The $find_index() function returns the index of the first element in the sequence that is equal to the specified value or $size(<sequence>) if none is found. For string sequences, it's possible to request case- insensitive comparison with a flag.
2021-11-26Add $size(string), $size(path), and $size(dir_path) functionsBoris Kolpackov1-0/+6
2021-11-04Add $size() function to get size of sequence (names, strings, etc)Boris Kolpackov1-0/+6
2021-11-02Add $sort() functionBoris Kolpackov1-0/+46
Available overloads: $sort(<names> [, <flags>]) $sort(<ints> [, <flags>]) $sort(<strings> [, <flags>]) $sort(<paths> [, <flags>]) $sort(<dir_paths> [, <flags>]) The following flag is supported by the all overloads: dedup - in addition to sorting also remove duplicates Additionally, the strings overload also support the following flag: icase - sort ignoring case Note that on case-insensitive filesystem the paths and dir_paths overload's order is case-insensitive.
2020-12-04Mark Buildfile functions as pure or impureBoris Kolpackov1-15/+15
2020-11-23Add $string.lcase() and $string.ucase() functionsKaren Arutyunov1-0/+22
2020-09-28Add $string.trim() functionBoris Kolpackov1-0/+12
2020-02-07Drop copyright notice from source codeKaren Arutyunov1-1/+0
2019-10-01Add support for $string.icasecmp()Karen Arutyunov1-0/+23
2019-08-23Introduce notion of build contextBoris Kolpackov1-3/+3
All non-const global state is now in class context and we can now have multiple independent builds going on at the same time.
2019-07-01Split build system into library and driverBoris Kolpackov1-0/+43