Revision 8a16b7a0
Added by david.sorber over 2 years ago
| src/Catalog.cc | ||
|---|---|---|
|
|
||
|
void Catalog::filter(const std::string& criteria)
|
||
|
{
|
||
|
// TODO: would be nice if there were a more efficient way to do this
|
||
|
for (auto& item : m_catalog)
|
||
|
// Tokenize the filter criteria
|
||
|
std::vector<std::string_view> tokens;
|
||
|
tokenize(criteria, " ", tokens);
|
||
|
|
||
|
// Iterate over the filter criteria tokens
|
||
|
for (auto& token : tokens)
|
||
|
{
|
||
|
if (item.match(criteria))
|
||
|
{
|
||
|
item.setVisibilty(true);
|
||
|
}
|
||
|
else
|
||
|
// Attempt to match each catalog item
|
||
|
for (auto& item : m_catalog)
|
||
|
{
|
||
|
item.setVisibilty(false);
|
||
|
if (item.match(token))
|
||
|
{
|
||
|
item.setVisibilty(true);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
item.setVisibilty(false);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
Tokenize a filter criteria and then search the catalog for feach filter
criteria token.