diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-05-23 13:11:59 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-05-23 13:11:59 +0200 |
commit | 73a9ca5ad8925511354ce294e7b061e0262a1f98 (patch) | |
tree | d39ed4f4ff8f984611057cc1b7f0747242b12edd | |
parent | b7f6c386e0396bd242d0ec42f820db4ea0f6760b (diff) |
Add ability to iterate over variable pool
-rw-r--r-- | libbuild2/variable.hxx | 21 |
1 files 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<string>; + using map = std::unordered_map<key, variable>; + + using const_iterator = butl::map_iterator_adapter<map::const_iterator>; + + 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<const value_type*> 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<string>; - using map = std::unordered_map<key, variable>; - pair<map::iterator, bool> insert (variable&& var) { |