From 3ed2c57a6d4258de410316fd946fa24b4d0f42e4 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 11 Oct 2014 15:05:42 +0100 Subject: [PATCH] Switched back to using Boost.Regex. GCC 4.6 doesn't implement C++11 . --- src/api/api.cpp | 2 -- src/backend/generators.cpp | 2 -- src/backend/helpers.cpp | 5 ++++- src/backend/helpers.h | 4 ++-- src/backend/json.h | 10 +++------- src/backend/metadata.cpp | 7 +++++-- src/backend/parsers.h | 14 +++++++------- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/api/api.cpp b/src/api/api.cpp index 228e5884..14266ad6 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -36,12 +36,10 @@ #include #include #include -#include #include #include #include -#include #include const unsigned int loot_ok = loot::error::ok; diff --git a/src/backend/generators.cpp b/src/backend/generators.cpp index 4bdcf3bc..3dc73f8b 100644 --- a/src/backend/generators.cpp +++ b/src/backend/generators.cpp @@ -31,8 +31,6 @@ along with LOOT. If not, see #include #include -#include - using namespace std; namespace YAML { diff --git a/src/backend/helpers.cpp b/src/backend/helpers.cpp index 2d37cbf6..a3167a16 100644 --- a/src/backend/helpers.cpp +++ b/src/backend/helpers.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -41,7 +42,6 @@ #include #include #include -#include #ifdef _WIN32 # ifndef UNICODE @@ -59,6 +59,9 @@ namespace loot { using namespace std; using boost::algorithm::replace_all; using boost::algorithm::replace_first; + using boost::regex; + using boost::regex_match; + using boost::regex_search; namespace karma = boost::spirit::karma; namespace fs = boost::filesystem; namespace lc = boost::locale; diff --git a/src/backend/helpers.h b/src/backend/helpers.h index feae3c77..29f003f4 100644 --- a/src/backend/helpers.h +++ b/src/backend/helpers.h @@ -29,13 +29,13 @@ #include #include -#include +#include #include namespace loot { /// Array used to try each of the expressions defined using /// an iteration for each of them. - extern const std::regex version_checks[7]; + extern const boost::regex version_checks[7]; ////////////////////////////////////////////////////////////////////////// // Helper functions diff --git a/src/backend/json.h b/src/backend/json.h index ab9fec68..73fae02a 100644 --- a/src/backend/json.h +++ b/src/backend/json.h @@ -25,13 +25,11 @@ along with LOOT. If not, see #ifndef __LOOT_JSON__ #define __LOOT_JSON__ - #include -#include +#include namespace loot { - // Handy class for turning YAML objects into JSON and vice-versa. class JSON { public: @@ -41,7 +39,6 @@ namespace loot { } inline static std::string stringify(const YAML::Node& yaml) { - YAML::Emitter out; out.SetOutputCharset(YAML::EscapeNonAscii); out.SetStringFormat(YAML::DoubleQuoted); @@ -65,14 +62,13 @@ namespace loot { // Using the definition at . // Version numbers should be kept as strings though. - std::regex numbers("\"(?!version)([^\"]+)\": \"(-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)\"", std::regex::ECMAScript); + boost::regex numbers("\"(?!version)([^\"]+)\": \"(-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)\"", boost::regex::ECMAScript); - json = std::regex_replace(json, numbers, "\"$1\": $2"); + json = boost::regex_replace(json, numbers, "\"$1\": $2"); return json; } }; } - #endif \ No newline at end of file diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index c6c456f9..ba1774d9 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -27,16 +27,19 @@ #include "parsers.h" #include "streams.h" -#include - #include #include #include #include #include +#include using namespace std; +using boost::regex; +using boost::regex_match; +using boost::regex_search; +using boost::smatch; namespace loot { namespace lc = boost::locale; diff --git a/src/backend/parsers.h b/src/backend/parsers.h index 97d50972..4984bda2 100644 --- a/src/backend/parsers.h +++ b/src/backend/parsers.h @@ -39,7 +39,7 @@ #include "error.h" #include -#include +#include #include @@ -555,11 +555,11 @@ namespace loot { BOOST_LOG_TRIVIAL(trace) << "Checking to see if any files matching the regex \"" << regexStr << "\" exist."; - std::regex sepReg("/|(\\\\\\\\)", std::regex::ECMAScript | std::regex::icase); + boost::regex sepReg("/|(\\\\\\\\)", boost::regex::ECMAScript | boost::regex::icase); std::vector components; - std::sregex_token_iterator it(regexStr.begin(), regexStr.end(), sepReg, -1); - std::sregex_token_iterator itend; + boost::sregex_token_iterator it(regexStr.begin(), regexStr.end(), sepReg, -1); + boost::sregex_token_iterator itend; for (; it != itend; ++it) { components.push_back(*it); } @@ -589,9 +589,9 @@ namespace loot { return; } - std::regex reg; + boost::regex reg; try { - reg = std::regex(filename, std::regex::ECMAScript | std::regex::icase); + reg = boost::regex(filename, boost::regex::ECMAScript | boost::regex::icase); } catch (std::exception& /*e*/) { BOOST_LOG_TRIVIAL(error) << "Invalid regex string:" << filename; @@ -599,7 +599,7 @@ namespace loot { } for (boost::filesystem::directory_iterator itr(parent_path); itr != boost::filesystem::directory_iterator(); ++itr) { - if (regex_match(itr->path().filename().string(), reg)) { + if (boost::regex_match(itr->path().filename().string(), reg)) { result = true; BOOST_LOG_TRIVIAL(trace) << "Matching file found: " << itr->path(); return;