mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Switched back to using Boost.Regex.
GCC 4.6 doesn't implement C++11 <regex>.
This commit is contained in:
@@ -36,12 +36,10 @@
|
||||
#include <clocale>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <regex>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
const unsigned int loot_ok = loot::error::ok;
|
||||
|
||||
@@ -31,8 +31,6 @@ along with LOOT. If not, see
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include <regex>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace YAML {
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <alphanum.hpp>
|
||||
|
||||
@@ -41,7 +42,6 @@
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
#include <regex>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <regex>
|
||||
#include <boost/regex.hpp>
|
||||
#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::regex version_checks[7];
|
||||
extern const boost::regex version_checks[7];
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Helper functions
|
||||
|
||||
+3
-7
@@ -25,13 +25,11 @@ along with LOOT. If not, see
|
||||
#ifndef __LOOT_JSON__
|
||||
#define __LOOT_JSON__
|
||||
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
#include <regex>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
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 <http://www.json.org/>.
|
||||
// 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
|
||||
@@ -27,16 +27,19 @@
|
||||
#include "parsers.h"
|
||||
#include "streams.h"
|
||||
|
||||
#include <regex>
|
||||
|
||||
#include <src/libespm.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
using namespace std;
|
||||
using boost::regex;
|
||||
using boost::regex_match;
|
||||
using boost::regex_search;
|
||||
using boost::smatch;
|
||||
|
||||
namespace loot {
|
||||
namespace lc = boost::locale;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "error.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <regex>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
@@ -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<std::string> 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;
|
||||
|
||||
Reference in New Issue
Block a user