Project

General

Profile

« Previous | Next » 

Revision 8a16b7a0

Added by david.sorber over 2 years ago

Tokenize a filter criteria and then search the catalog for feach filter
criteria token.

View differences:

src/Catalog.h
#include <climits>
#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
#include "CatalogItem.h"
// I mean this should go into some sort of utils
template<class T>
static inline void tokenize(
T input,
std::string delim,
std::vector<std::string_view>& tokens)
{
uint32_t prevOffset = 0;
auto pos = std::string_view::npos;
while ((pos = input.find(delim, prevOffset)) != std::string_view::npos)
{
tokens.emplace_back(input.data() + prevOffset, (pos - prevOffset));
prevOffset = pos + delim.size();
}
// Final (or only one) parameter
tokens.emplace_back(input.data() + prevOffset,
(input.size() - prevOffset));
}
class Catalog
{
public:

Also available in: Unified diff