From 5a8c3e11ae8a9c75ba5caac895f0f9fdee4be6c6 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 26 Mar 2016 17:18:12 -0400 Subject: [PATCH] Rules: ::all now matches keys against a stem --- src/Rules.cpp | 8 +++++--- src/Rules.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Rules.cpp b/src/Rules.cpp index cc39e6b6..8ba84a26 100644 --- a/src/Rules.cpp +++ b/src/Rules.cpp @@ -146,12 +146,14 @@ void Rules::set (const std::string& key, const std::string& value) } //////////////////////////////////////////////////////////////////////////////// -// Provide a vector of all configuration keys. -std::vector Rules::all () const +// Provide a vector of all configuration keys. If a stem is provided, only +// return matching keys. +std::vector Rules::all (const std::string& stem) const { std::vector items; for (const auto& it : _settings) - items.push_back (it.first); + if (stem == "" || it.first.find (stem) == 0) + items.push_back (it.first); return items; } diff --git a/src/Rules.h b/src/Rules.h index 88d9f782..5766b40b 100644 --- a/src/Rules.h +++ b/src/Rules.h @@ -49,7 +49,7 @@ public: void set (const std::string&, const double); void set (const std::string&, const std::string&); - std::vector all () const; + std::vector all (const std::string& stem = "") const; std::string dump () const;