replace boost regex with std
This commit is contained in:
orang tua
b563f124c8
melakukan
f6258b2412
11
parser.cpp
11
parser.cpp
@ -82,7 +82,7 @@ std::string Parser::extractCommand(std::string cmdname, std::string content) con
|
||||
}
|
||||
return "";
|
||||
}
|
||||
std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider, boost::smatch &match) const
|
||||
std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider, std::smatch &match) const
|
||||
{
|
||||
std::string linktag = match.str(1);
|
||||
std::string inside = match.str(2);
|
||||
@ -123,8 +123,8 @@ std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, std::st
|
||||
{
|
||||
std::string result;
|
||||
//we don't care about commands, but we nevertheless replace them with empty strings
|
||||
boost::regex tagfinder(R"(\[(b|i|u|li||ul|ol|link|wikilink|h\d|cmd:rename|cmd:redirect)*?\]((\s|\S)*?)\[/\1])");
|
||||
result = utils::regex_callback_replacer(tagfinder, content, [&](boost::smatch &match)
|
||||
std::regex tagfinder(R"(\[(b|i|u|li||ul|ol|link|wikilink|h\d|cmd:rename|cmd:redirect)*?\]((\s|\S)*?)\[/\1])");
|
||||
result = utils::regex_callback_replacer(tagfinder, content, [&](std::smatch &match)
|
||||
{
|
||||
std::string tag = match.str(1);
|
||||
std::string content = match.str(2);
|
||||
@ -143,11 +143,6 @@ std::string Parser::parse(const PageDao &pagedao, UrlProvider &provider, std::st
|
||||
return "<" + tag + " id='" + content + "'>" + content + "</" + tag + ">";
|
||||
}
|
||||
return std::string("");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
result = utils::strreplace(result, "\r\n", "<br>");
|
||||
return result;
|
||||
|
2
parser.h
2
parser.h
@ -7,7 +7,7 @@
|
||||
class Parser : public IParser
|
||||
{
|
||||
private:
|
||||
std::string processLink(const PageDao &pageDao, UrlProvider &urlProvider, boost::smatch &match) const;
|
||||
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 ;
|
||||
|
10
utils.cpp
10
utils.cpp
@ -140,14 +140,14 @@ std::string utils::readCompleteFile(std::string_view filepath)
|
||||
return content;
|
||||
}
|
||||
|
||||
std::string utils::regex_callback_replacer(boost::regex regex, const std::string &input, std::function<std::string(boost::smatch&) > callback)
|
||||
std::string utils::regex_callback_replacer(std::regex regex, const std::string &input, std::function<std::string(std::smatch&) > callback)
|
||||
{
|
||||
std::string result;
|
||||
auto tagsbegin = boost::sregex_iterator(input.begin(), input.end(), regex);
|
||||
auto tagsend = boost::sregex_iterator();
|
||||
auto tagsbegin = std::sregex_iterator(input.begin(), input.end(), regex);
|
||||
auto tagsend = std::sregex_iterator();
|
||||
auto matchbegin = 0;
|
||||
for (boost::sregex_iterator i = tagsbegin; i != tagsend; ++i) {
|
||||
boost::smatch match = *i;
|
||||
for (std::sregex_iterator i = tagsbegin; i != tagsend; ++i) {
|
||||
std::smatch match = *i;
|
||||
|
||||
auto matchlength = match.length(0);
|
||||
auto matchpos = match.position();
|
||||
|
2
utils.h
2
utils.h
@ -62,7 +62,7 @@ namespace utils
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string regex_callback_replacer(boost::regex regex, const std::string &input, std::function<std::string(boost::smatch&) > callback);
|
||||
std::string regex_callback_replacer(std::regex regex, const std::string &input, std::function<std::string(std::smatch&) > callback);
|
||||
|
||||
std::string readCompleteFile(std::string_view filepath);
|
||||
|
||||
|
Memuat…
Reference in New Issue
Block a user