From 70613e9be046c9cddd2486505a44d3a0324d6d95 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 13 Jul 2015 12:20:27 +0200 Subject: Implement subproject import --- build/variable | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'build/variable') diff --git a/build/variable b/build/variable index 2bb3393..835fde1 100644 --- a/build/variable +++ b/build/variable @@ -84,6 +84,19 @@ namespace build const list_value* lv (dynamic_cast (&v)); return lv != nullptr && static_cast (*this) == *lv; } + + // Pair (i.e., key-value) search. Note that this funtion assumes + // the list contains only pairs and keys are simple names. Returns + // NULL if not found. + // + const name* + find_pair (const std::string& key) const + { + for (auto i (begin ()); i != end (); i += 2) + if (i->value == key) + return &*++i; + return nullptr; + } }; typedef std::unique_ptr list_value_ptr; -- cgit v1.1