2018-11-03 17:12:20 +01:00
|
|
|
#ifndef IPARSER_H
|
|
|
|
#define IPARSER_H
|
|
|
|
#include <vector>
|
|
|
|
#include <string_view>
|
2022-03-27 08:31:59 +02:00
|
|
|
#include <functional>
|
2018-11-03 17:12:20 +01:00
|
|
|
#include "headline.h"
|
|
|
|
#include "database/pagedao.h"
|
|
|
|
#include "urlprovider.h"
|
|
|
|
class IParser
|
|
|
|
{
|
2022-03-27 08:31:59 +02:00
|
|
|
protected:
|
|
|
|
static std::string empty(std::string_view key, std::string_view content)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2018-11-03 17:12:20 +01:00
|
|
|
public:
|
2023-11-27 21:37:54 +01:00
|
|
|
virtual std::string extractFirstTag(std::string tagname, const std::string &content) const = 0;
|
2022-01-23 10:12:37 +01:00
|
|
|
virtual std::string extractCommand(std::string cmdname, const std::string &content) const = 0;
|
2023-07-28 15:04:58 +02:00
|
|
|
virtual std::vector<std::string> extractCommands(std::string cmdname, const std::string &content) const = 0;
|
|
|
|
|
2022-01-23 10:12:37 +01:00
|
|
|
virtual std::vector<Headline> extractHeadlines(const std::string &content) const = 0;
|
2022-03-27 08:31:59 +02:00
|
|
|
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;
|
2022-03-29 22:35:45 +02:00
|
|
|
|
|
|
|
virtual std::string parseDynamics(
|
|
|
|
const std::string &content,
|
|
|
|
const std::function<std::string(std::string_view, std::string_view)> &callback) const = 0;
|
2022-01-23 10:12:37 +01:00
|
|
|
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
|