From 73a9ca5ad8925511354ce294e7b061e0262a1f98 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 May 2022 13:11:59 +0200 Subject: Add ability to iterate over variable pool --- libbuild2/variable.hxx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx index 15e0074..ae3c9ab 100644 --- a/libbuild2/variable.hxx +++ b/libbuild2/variable.hxx @@ -1301,6 +1301,20 @@ namespace build2 LIBBUILD2_SYMEXPORT const variable& insert_alias (const variable& var, string name); + // Iteration. + // + public: + using key = butl::map_key; + using map = std::unordered_map; + + using const_iterator = butl::map_iterator_adapter; + + const_iterator begin () const {return const_iterator (map_.begin ());} + const_iterator end () const {return const_iterator (map_.end ());} + + // Variable patterns. + // + public: // Insert a variable pattern. Any variable that matches this pattern will // have the specified type, visibility, and overridability. If match is // true, then individual insertions of the matching variable must match @@ -1327,7 +1341,6 @@ namespace build2 // to have been applied). So if you use this functionality, watch out // for the insertion order (you probably want more specific first). // - public: LIBBUILD2_SYMEXPORT void insert_pattern (const string& pattern, optional type, @@ -1349,9 +1362,6 @@ namespace build2 } public: - void - clear () {map_.clear ();} - variable_pool (): variable_pool (nullptr) {} // RW access (only for the global pool). @@ -1391,9 +1401,6 @@ namespace build2 // Variable map. // private: - using key = butl::map_key; - using map = std::unordered_map; - pair insert (variable&& var) { -- cgit v1.1