- Implemented ::exactMatch.
This commit is contained in:
Paul Beckingham 2014-10-14 00:45:04 -04:00
parent b0cf4adc4e
commit 227e0bd8c8

View file

@ -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 <std::multimap <std::string, std::string>::const_iterator, std::multimap <std::string, std::string>::const_iterator> c;
c = _entities.equal_range (category);
// Extract a list of entities for category.
std::vector <std::string> options;
std::multimap <std::string, std::string>::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
{