From 5df89f0491902f694e55e961781294be06c7ef57 Mon Sep 17 00:00:00 2001 From: Albert S Date: Wed, 18 Mar 2020 22:00:15 +0100 Subject: [PATCH] replace boost regex with std --- parser.cpp | 6 +++--- parser.h | 2 +- utils.cpp | 12 ++++++------ utils.h | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/parser.cpp b/parser.cpp index ffc0b46..aa79746 100644 --- a/parser.cpp +++ b/parser.cpp @@ -81,7 +81,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); @@ -120,8 +120,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); std::string justreplace[] = {"b", "i", "u", "ul", "li", "ol"}; diff --git a/parser.h b/parser.h index 13cee1f..6943840 100644 --- a/parser.h +++ b/parser.h @@ -6,7 +6,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; diff --git a/utils.cpp b/utils.cpp index a574387..03f08ad 100644 --- a/utils.cpp +++ b/utils.cpp @@ -135,16 +135,16 @@ 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 callback) +std::string utils::regex_callback_replacer(std::regex regex, const std::string &input, + std::function 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) + for(std::sregex_iterator i = tagsbegin; i != tagsend; ++i) { - boost::smatch match = *i; + std::smatch match = *i; auto matchlength = match.length(0); auto matchpos = match.position(); diff --git a/utils.h b/utils.h index 01229f6..e8746fe 100644 --- a/utils.h +++ b/utils.h @@ -58,8 +58,8 @@ template std::vector getAll(std::multimap map, T key return result; } -std::string regex_callback_replacer(boost::regex regex, const std::string &input, - std::function callback); +std::string regex_callback_replacer(std::regex regex, const std::string &input, + std::function callback); std::string readCompleteFile(std::string_view filepath);