Parser: Function to exstract 'commands'/attributes (e. g. visible, renaming)
This commit is contained in:
parent
099f6533f8
commit
beafde74d0
@ -8,6 +8,7 @@
|
||||
class IParser
|
||||
{
|
||||
public:
|
||||
virtual std::string extractCommand(std::string cmdname, std::string content) const = 0;
|
||||
virtual std::vector<Headline> extractHeadlines(std::string content) const = 0;
|
||||
virtual std::string parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const = 0;
|
||||
virtual std::vector<std::string> extractCategories(std::string content) const = 0;
|
||||
|
14
parser.cpp
14
parser.cpp
@ -62,6 +62,19 @@ std::vector<std::string> Parser::extractCategories(std::string content) const
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string Parser::extractCommand(std::string cmdname, std::string content) const
|
||||
{
|
||||
std::string regstr = "(\\s|\\S)*\\[cmd\\:" + cmdname + "\\](.*?)\\[/cmd\\:" + cmdname + "\\](\\s|\\S)*";
|
||||
std::regex reg{regstr};
|
||||
std::smatch match;
|
||||
if(std::regex_match(content, match, reg))
|
||||
{
|
||||
|
||||
return match.str(2);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const
|
||||
{
|
||||
std::string linktag = match.str(1);
|
||||
@ -96,6 +109,7 @@ std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider
|
||||
|
||||
return htmllink.render();
|
||||
}
|
||||
|
||||
std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const
|
||||
{
|
||||
std::string result;
|
||||
|
1
parser.h
1
parser.h
@ -9,6 +9,7 @@ class Parser : public IParser
|
||||
std::string processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const;
|
||||
|
||||
public:
|
||||
std::string extractCommand(std::string cmdname, std::string content) const;
|
||||
std::vector<Headline> extractHeadlines(std::string content) const override;
|
||||
std::vector<std::string> extractCategories(std::string content) const override;
|
||||
std::string parse(const PageDao &pagedao, UrlProvider &provider, std::string content) const override;
|
||||
|
Loading…
Reference in New Issue
Block a user