Replace boost::regex with std::regex.

This commit is contained in:
Oliver Hamlet
2015-06-29 15:46:13 +01:00
parent 7f8cd2b196
commit 62d5ad7f5c
6 changed files with 17 additions and 28 deletions
+2 -2
View File
@@ -26,13 +26,13 @@
#define __LOOT_HELPERS__
#include <string>
#include <boost/regex.hpp>
#include <regex>
#include <boost/filesystem.hpp>
namespace loot {
/// Array used to try each of the expressions defined using
/// an iteration for each of them.
extern const std::vector<boost::regex> version_checks;
extern const std::vector<std::regex> version_checks;
//////////////////////////////////////////////////////////////////////////
// Helper functions
+3 -3
View File
@@ -27,7 +27,7 @@ along with LOOT. If not, see
#include <yaml-cpp/yaml.h>
#include <boost/regex.hpp>
#include <regex>
#include <boost/algorithm/string.hpp>
namespace loot {
@@ -63,9 +63,9 @@ namespace loot {
// Using the definition at <http://www.json.org/>.
// Version numbers and revision IDs should be kept as strings though.
boost::regex numbers("\"(?!version|revision)([^\"]+)\": \"(-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)\"", boost::regex::ECMAScript);
std::regex numbers("\"(?!version|revision)([^\"]+)\": \"(-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)\"", std::regex::ECMAScript);
json = boost::regex_replace(json, numbers, "\"$1\": $2");
json = std::regex_replace(json, numbers, "\"$1\": $2");
return json;
}
+2 -5
View File
@@ -25,10 +25,9 @@
#include "helpers.h"
#include "version.h"
#include <boost/regex.hpp>
#include <alphanum.hpp>
#include <regex>
#include <sstream>
#ifdef _WIN32
@@ -45,8 +44,6 @@
namespace loot {
using namespace std;
using boost::regex;
using boost::regex_match;
Version::Version() {}
@@ -159,4 +156,4 @@ namespace loot {
bool Version::operator != (const Version& ver) const {
return !(*this == ver);
}
}
}
+7 -7
View File
@@ -40,7 +40,7 @@
#include "../error.h"
#include <cstdint>
#include <boost/regex.hpp>
#include <regex>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/regex.hpp>
@@ -188,11 +188,11 @@ namespace loot {
BOOST_LOG_TRIVIAL(trace) << "Checking to see if any files matching the regex \"" << regexStr << "\" exist.";
boost::regex sepReg("/|(\\\\\\\\)", boost::regex::ECMAScript | boost::regex::icase);
std::regex sepReg("/|(\\\\\\\\)", std::regex::ECMAScript | std::regex::icase);
std::vector<std::string> components;
boost::sregex_token_iterator it(regexStr.begin(), regexStr.end(), sepReg, -1);
boost::sregex_token_iterator itend;
std::sregex_token_iterator it(regexStr.begin(), regexStr.end(), sepReg, -1);
std::sregex_token_iterator itend;
for (; it != itend; ++it) {
components.push_back(*it);
}
@@ -222,9 +222,9 @@ namespace loot {
return;
}
boost::regex reg;
std::regex reg;
try {
reg = boost::regex(filename, boost::regex::ECMAScript | boost::regex::icase);
reg = std::regex(filename, std::regex::ECMAScript | std::regex::icase);
}
catch (std::exception& /*e*/) {
BOOST_LOG_TRIVIAL(error) << "Invalid regex string:" << filename;
@@ -232,7 +232,7 @@ namespace loot {
}
for (boost::filesystem::directory_iterator itr(parent_path); itr != boost::filesystem::directory_iterator(); ++itr) {
if (boost::regex_match(itr->path().filename().string(), reg)) {
if (std::regex_match(itr->path().filename().string(), reg)) {
result = true;
BOOST_LOG_TRIVIAL(trace) << "Matching file found: " << itr->path();
return;
+1 -5
View File
@@ -31,13 +31,9 @@
#include <boost/log/trivial.hpp>
#include <boost/format.hpp>
#include <boost/locale.hpp>
#include <boost/regex.hpp>
#include <regex>
using namespace std;
using boost::regex;
using boost::regex_match;
using boost::regex_search;
using boost::smatch;
namespace loot {
PluginMetadata::PluginMetadata() : enabled(true), _isPriorityExplicit(false), priority(0) {}
+2 -6
View File
@@ -32,13 +32,9 @@
#include <boost/log/trivial.hpp>
#include <boost/format.hpp>
#include <boost/locale.hpp>
#include <boost/regex.hpp>
#include <regex>
using namespace std;
using boost::regex;
using boost::regex_match;
using boost::regex_search;
using boost::smatch;
namespace loot {
/// REGEX expression definition
@@ -84,7 +80,7 @@ namespace loot {
/// Array used to try each of the expressions defined above using
/// an iteration for each of them.
const std::vector<boost::regex> version_checks({
const vector<regex> version_checks({
regex(regex1, regex::ECMAScript | regex::icase),
regex(regex2, regex::ECMAScript | regex::icase),
regex(regex3, regex::ECMAScript | regex::icase),