Removed Boost.Regex usage.

I thought I'd already switched to using C++11 std::regex, but there were
a lot of places it was missing. I also removed Boost.ProgramOptions
since we're using CEF to handle that now.
This commit is contained in:
WrinklyNinja
2014-07-16 11:37:19 +01:00
parent 072d5eb955
commit 70bdc1c91e
6 changed files with 29 additions and 22 deletions
+1 -2
View File
@@ -65,7 +65,7 @@ set (LOOT_GUI_SRC ${LOOT_SRC}
set (LOOT_API_SRC ${LOOT_SRC}
"${CMAKE_SOURCE_DIR}/src/api/api.cpp")
find_package(Boost REQUIRED COMPONENTS log log_setup locale thread chrono date_time filesystem program_options system regex iostreams)
find_package(Boost REQUIRED COMPONENTS log log_setup locale thread chrono date_time filesystem system regex iostreams)
# Include source and library directories.
include_directories ("${CMAKE_SOURCE_DIR}/src"
@@ -114,7 +114,6 @@ IF (MINGW)
boost_chrono
boost_date_time
boost_filesystem
boost_program_options
boost_system
boost_regex
version
+8 -8
View File
@@ -363,16 +363,16 @@ LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language)
for (auto it=temp.begin(); it != temp.end();) {
it->EvalAllConditions(db->game, language);
if (it->IsRegexPlugin()) {
boost::regex regex;
std::regex reg;
try {
regex = boost::regex(it->Name(), boost::regex::perl|boost::regex::icase);
} catch (boost::regex_error& e) {
reg = std::regex(it->Name(), std::regex::ECMAScript | std::regex::icase);
} catch (std::exception& e) {
return c_error(loot_error_regex_eval_fail, e.what());
}
for (boost::filesystem::directory_iterator itr(db->game.DataPath()); itr != boost::filesystem::directory_iterator(); ++itr) {
const std::string filename = itr->path().filename().string();
if (boost::regex_match(filename, regex)) {
if (std::regex_match(filename, reg)) {
loot::Plugin p = *it;
p.Name(filename);
temp.push_back(p);
@@ -393,16 +393,16 @@ LOOT_API unsigned int loot_eval_lists (loot_db db, const unsigned int language)
for (auto it=temp.begin(); it != temp.end();) {
it->EvalAllConditions(db->game, language);
if (it->IsRegexPlugin()) {
boost::regex regex;
std::regex reg;
try {
regex = boost::regex(it->Name(), boost::regex::perl|boost::regex::icase);
} catch (boost::regex_error& e) {
reg = std::regex(it->Name(), std::regex::ECMAScript | std::regex::icase);
} catch (std::exception& e) {
return c_error(loot_error_regex_eval_fail, e.what());
}
for (boost::filesystem::directory_iterator itr(db->game.DataPath()); itr != boost::filesystem::directory_iterator(); ++itr) {
const std::string filename = itr->path().filename().string();
if (boost::regex_match(filename, regex)) {
if (std::regex_match(filename, reg)) {
loot::Plugin p = *it;
p.Name(filename);
temp.push_back(p);
+7 -3
View File
@@ -31,6 +31,10 @@ along with LOOT. If not, see
#include <boost/algorithm/string.hpp>
#include <boost/locale.hpp>
#include <regex>
using namespace std;
namespace loot {
//LOOT Report generation stuff.
void GetOldReportDetails(const boost::filesystem::path& filepath, YAML::Node& node) {
@@ -87,16 +91,16 @@ namespace loot {
void WriteMessage(YAML::Emitter& out, const Message& message) {
//Look for Markdown URL syntax and convert any found.
boost::regex regex("(\\[([^\\]]+)\\]\\s?\\(|<)((file|https?)://\\S+)(\\)|>)", boost::regex::perl | boost::regex::icase); // \2 is the label, \3 is the URL.
regex reg("(\\[([^\\]]+)\\]\\s?\\(|<)((file|https?)://\\S+)(\\)|>)", regex::ECMAScript | regex::icase); // \2 is the label, \3 is the URL.
boost::match_results<std::string::iterator> results;
std::match_results<std::string::iterator> results;
std::string content = message.Content().front().Str();
std::string converted;
std::string::iterator start, end;
start = content.begin();
end = content.end();
while (boost::regex_search(start, end, results, regex)) {
while (regex_search(start, end, results, reg)) {
//Get data from match.
std::string url, label;
+1 -1
View File
@@ -377,7 +377,7 @@ namespace loot {
regex reg1("(\\d+\\.?)+"); //a.b.c.d.e.f.... where the letters are all integers, and 'a' is the shortest possible match.
//boost::regex reg2("(\\d+\\.?)+([a-zA-Z\\-]+(\\d+\\.?)*)+"); //Matches a mix of letters and numbers - from "0.99.xx", "1.35Alpha2", "0.9.9MB8b1", "10.52EV-D", "1.62EV" to "10.0EV-D1.62EV".
//regex reg2("(\\d+\\.?)+([a-zA-Z\\-]+(\\d+\\.?)*)+"); //Matches a mix of letters and numbers - from "0.99.xx", "1.35Alpha2", "0.9.9MB8b1", "10.52EV-D", "1.62EV" to "10.0EV-D1.62EV".
if (regex_match(verString, reg1) && regex_match(ver.AsString(), reg1)) {
//First type: numbers separated by periods. If two versions have a different number of numbers, then the shorter should be padded
+2 -2
View File
@@ -645,8 +645,8 @@ namespace loot {
bool Plugin::operator == (const Plugin& rhs) const {
return (boost::iequals(name, rhs.Name())
|| (IsRegexPlugin() && boost::regex_match(rhs.Name(), boost::regex(name, boost::regex::perl|boost::regex::icase)))
|| (rhs.IsRegexPlugin() && boost::regex_match(name, boost::regex(rhs.Name(), boost::regex::perl|boost::regex::icase))));
|| (IsRegexPlugin() && regex_match(rhs.Name(), regex(name, regex::ECMAScript | regex::icase)))
|| (rhs.IsRegexPlugin() && regex_match(name, regex(rhs.Name(), regex::ECMAScript | regex::icase))));
}
bool Plugin::operator != (const Plugin& rhs) const {
+10 -6
View File
@@ -498,10 +498,14 @@ namespace loot {
BOOST_LOG_TRIVIAL(trace) << "Checking to see if any files matching the regex \"" << regexStr << "\" exist.";
boost::regex sepReg("/|(\\\\\\\\)", boost::regex::perl);
regex sepReg("/|(\\\\\\\\)", regex::ECMAScript | regex::icase);
std::vector<std::string> components;
boost::algorithm::split_regex(components, regexStr, sepReg);
std::sregex_token_iterator it(regexStr.begin(), regexStr.end(), sepReg, -1);
std::sregex_token_iterator itend;
for (; it != itend; ++it) {
components.push_back(*it);
}
std::string filename = components.back();
components.pop_back();
@@ -528,16 +532,16 @@ namespace loot {
return;
}
boost::regex regex;
regex reg;
try {
regex = boost::regex(filename, boost::regex::perl|boost::regex::icase);
} catch (boost::regex_error& /*e*/) {
reg = regex(filename, regex::ECMAScript | regex::icase);
} catch (exception& /*e*/) {
BOOST_LOG_TRIVIAL(error) << "Invalid regex string:" << filename;
throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid regex string:").str() + " " + filename);
}
for (boost::filesystem::directory_iterator itr(parent_path); itr != boost::filesystem::directory_iterator(); ++itr) {
if (boost::regex_match(itr->path().filename().string(), regex)) {
if (regex_match(itr->path().filename().string(), reg)) {
result = true;
BOOST_LOG_TRIVIAL(trace) << "Matching file found: " << itr->path();
return;