qswiki/iparser.h

36 righe
1.1 KiB
C

2018-11-03 17:12:20 +01:00
#ifndef IPARSER_H
#define IPARSER_H
#include <vector>
#include <string_view>
#include <functional>
2018-11-03 17:12:20 +01:00
#include "headline.h"
#include "database/pagedao.h"
#include "urlprovider.h"
class IParser
{
protected:
static std::string empty(std::string_view key, std::string_view content)
{
return "";
}
2018-11-03 17:12:20 +01:00
public:
virtual std::string extractCommand(std::string cmdname, const std::string &content) const = 0;
virtual std::vector<Headline> extractHeadlines(const std::string &content) const = 0;
virtual inline std::string parse(const PageDao &pagedao, UrlProvider &provider, const std::string &content) const
{
return parse(pagedao, provider, content, empty);
}
virtual std::string parse(const PageDao &pagedao, UrlProvider &provider, const std::string &content,
const std::function<std::string(std::string_view, std::string_view)> &callback) const = 0;
virtual std::string parseDynamics(
const std::string &content,
const std::function<std::string(std::string_view, std::string_view)> &callback) const = 0;
virtual std::vector<std::string> extractCategories(const std::string &content) const = 0;
2018-11-03 17:12:20 +01:00
virtual ~IParser(){};
};
#endif // PARSER_H