From 227e0bd8c861c810310178b8b4e7bae44183e158 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 14 Oct 2014 00:45:04 -0400 Subject: [PATCH] CLI - Implemented ::exactMatch. --- src/CLI.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/CLI.cpp b/src/CLI.cpp index 2b558e6e4..1c5e71ccc 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -105,6 +105,29 @@ void CLI::aliasExpansion () dump ("CLI::aliasExpansion"); } +//////////////////////////////////////////////////////////////////////////////// +// Search for exact 'value' in _entities category. +bool CLI::exactMatch ( + const std::string& category, + const std::string& value) const +{ + // Find the category. + std::pair ::const_iterator, std::multimap ::const_iterator> c; + c = _entities.equal_range (category); + + // Extract a list of entities for category. + std::vector options; + std::multimap ::const_iterator e; + for (e = c.first; e != c.second; ++e) + { + // Shortcut: if an exact match is found, success. + if (value == e->second) + return true; + } + + return false; +} + //////////////////////////////////////////////////////////////////////////////// void CLI::dump (const std::string& label) const {