aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/functions-string.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-02-19 12:23:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-02-20 16:01:40 +0200
commit88640e677fa0695783eac68014d7d8d5bc42d117 (patch)
treeb1de045dc2d8d290422aaebbfbdbe184e8074dfd /libbuild2/functions-string.cxx
parentbed6b6a9170253e010cbffd59202add4edfd1c2b (diff)
Add string_set buildfile value type
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 ...
Diffstat (limited to 'libbuild2/functions-string.cxx')
-rw-r--r--libbuild2/functions-string.cxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/libbuild2/functions-string.cxx b/libbuild2/functions-string.cxx
index b332efa..367923f 100644
--- a/libbuild2/functions-string.cxx
+++ b/libbuild2/functions-string.cxx
@@ -119,14 +119,16 @@ namespace build2
};
// $size(<strings>)
+ // $size(<string-set>)
// $size(<string-map>)
// $size(<string>)
//
- // First two forms: return the number of elements in the sequence.
+ // First three forms: return the number of elements in the sequence.
//
- // Third form: return the number of characters (bytes) in the string.
+ // Fourth form: return the number of characters (bytes) in the string.
//
f["size"] += [] (strings v) {return v.size ();};
+ f["size"] += [] (set<string> v) {return v.size ();};
f["size"] += [] (map<string, string> v) {return v.size ();};
f["size"] += [] (string v) {return v.size ();};