diff options
Diffstat (limited to 'build/variable')
-rw-r--r-- | build/variable | 13 |
1 files changed, 13 insertions, 0 deletions
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<const list_value*> (&v)); return lv != nullptr && static_cast<const names&> (*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> list_value_ptr; |