Convert uses of boost::regex and related functions/types to their stdlib counterparts
This was put off when we first transitioned to C++11 since GCC 4.8 didn't have full regex support. Since we now support at least GCC 5, we can commit this. This covers: * boost::regex * boost::regex_match * boost::smatch * boost::sregex_iterator * boost::sregex_token_iterator boost::regex_constants::match_not_dot_null doesn't have a stdlib counterpart, but according to @celticminstrel it should be alright to remove it.
This commit is contained in:
parent
112ada179c
commit
29ee9a7150
6 changed files with 29 additions and 33 deletions
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "ai/formula/ai.hpp"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <regex>
|
||||
|
||||
namespace pathfind {
|
||||
|
||||
|
@ -141,10 +141,10 @@ static component *find_component(component *root, const std::string &path, path_
|
|||
}
|
||||
|
||||
//match path elements in [modify_ai] tag
|
||||
boost::regex re(R"""(([^\.^\[]+)(\[(\d*)\]|\[([^\]]+)\]|()))""");
|
||||
std::regex re(R"""(([^\.^\[]+)(\[(\d*)\]|\[([^\]]+)\]|()))""");
|
||||
const int sub_matches[] {1,3,4};
|
||||
boost::sregex_token_iterator i(path.begin(), path.end(), re, sub_matches);
|
||||
boost::sregex_token_iterator j;
|
||||
std::sregex_token_iterator i(path.begin(), path.end(), re, sub_matches);
|
||||
std::sregex_token_iterator j;
|
||||
|
||||
component *c = root;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "terrain/type_data.hpp"
|
||||
#include "units/unit.hpp"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <regex>
|
||||
|
||||
namespace editor
|
||||
{
|
||||
|
@ -154,11 +154,10 @@ map_context::map_context(const config& game_config, const std::string& filename)
|
|||
}
|
||||
|
||||
// 1.0 Pure map data
|
||||
boost::regex rexpression_map_data(R"""(map_data\s*=\s*"(.+?)")""");
|
||||
boost::smatch matched_map_data;
|
||||
std::regex rexpression_map_data(R"""(map_data\s*=\s*"(.+?)")""");
|
||||
std::smatch matched_map_data;
|
||||
|
||||
if(!boost::regex_search(
|
||||
file_string, matched_map_data, rexpression_map_data, boost::regex_constants::match_not_dot_null)
|
||||
if(!std::regex_search(file_string, matched_map_data, rexpression_map_data)
|
||||
) {
|
||||
map_ = editor_map::from_string(game_config, file_string); // throws on error
|
||||
pure_map_ = true;
|
||||
|
@ -170,14 +169,14 @@ map_context::map_context(const config& game_config, const std::string& filename)
|
|||
// 2.0 Embedded map
|
||||
const std::string& map_data = matched_map_data[1];
|
||||
|
||||
boost::regex rexpression_macro(R"""(\{(.+?)\})""");
|
||||
boost::smatch matched_macro;
|
||||
std::regex rexpression_macro(R"""(\{(.+?)\})""");
|
||||
std::smatch matched_macro;
|
||||
|
||||
if(!boost::regex_search(map_data, matched_macro, rexpression_macro)) {
|
||||
if(!std::regex_search(map_data, matched_macro, rexpression_macro)) {
|
||||
// We have a map_data string but no macro ---> embedded or scenario
|
||||
|
||||
boost::regex rexpression_scenario(R"""(\[(scenario|test|multiplayer|tutorial)\])""");
|
||||
if(!boost::regex_search(file_string, rexpression_scenario)) {
|
||||
std::regex rexpression_scenario(R"""(\[(scenario|test|multiplayer|tutorial)\])""");
|
||||
if(!std::regex_search(file_string, rexpression_scenario)) {
|
||||
LOG_ED << "Loading generated scenario file" << std::endl;
|
||||
// 4.0 editor generated scenario
|
||||
try {
|
||||
|
@ -548,7 +547,7 @@ config map_context::to_config()
|
|||
u["name"].write_if_not_empty(i->name());
|
||||
u["facing"] = map_location::write_direction(i->facing());
|
||||
|
||||
if(!boost::regex_match(i->id(), boost::regex(".*-[0-9]+"))) {
|
||||
if(!std::regex_match(i->id(), std::regex(".*-[0-9]+"))) {
|
||||
u["id"] = i->id();
|
||||
}
|
||||
|
||||
|
@ -617,11 +616,10 @@ bool map_context::save_map()
|
|||
} else {
|
||||
std::string map_string = filesystem::read_file(get_filename());
|
||||
|
||||
boost::regex rexpression_map_data(R"""((.*map_data\s*=\s*")(.+?)(".*))""");
|
||||
boost::smatch matched_map_data;
|
||||
std::regex rexpression_map_data(R"""((.*map_data\s*=\s*")(.+?)(".*))""");
|
||||
std::smatch matched_map_data;
|
||||
|
||||
if(boost::regex_search(map_string, matched_map_data, rexpression_map_data,
|
||||
boost::regex_constants::match_not_dot_null)) {
|
||||
if(std::regex_search(map_string, matched_map_data, rexpression_map_data)) {
|
||||
std::stringstream ss;
|
||||
ss << matched_map_data[1];
|
||||
ss << map_data;
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
#include "wml_exception.hpp"
|
||||
#include "whiteboard/manager.hpp"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <regex>
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define DBG_NG LOG_STREAM(debug, log_engine)
|
||||
|
@ -552,7 +552,7 @@ namespace {
|
|||
static const std::string s_sep = "(, |\\n)";
|
||||
static const std::string s_prefix = R"""((\d+ )?)""";
|
||||
static const std::string s_all = "(" + s_prefix + s_terrain + s_sep + ")+";
|
||||
static const boost::regex r_all(s_all);
|
||||
static const std::regex r_all(s_all);
|
||||
|
||||
const std::string& mapfile = filesystem::get_wml_location(filename_);
|
||||
std::string res = "";
|
||||
|
@ -560,7 +560,7 @@ namespace {
|
|||
res = filesystem::read_file(mapfile);
|
||||
}
|
||||
config retv;
|
||||
if(boost::regex_match(res, r_all))
|
||||
if(std::regex_match(res, r_all))
|
||||
{
|
||||
retv["map_data"] = res;
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ bool schema_validator::read_config_file(const std::string& filename)
|
|||
|
||||
for(const config& type : g.child_range("type")) {
|
||||
try {
|
||||
types_[type["name"].str()] = boost::regex(type["value"].str());
|
||||
types_[type["name"].str()] = std::regex(type["value"].str());
|
||||
} catch(std::exception&) {
|
||||
// Need to check all type values in schema-generator
|
||||
}
|
||||
|
@ -269,8 +269,8 @@ void schema_validator::validate_key(
|
|||
auto itt = types_.find(key->get_type());
|
||||
|
||||
if(itt != types_.end()) {
|
||||
boost::smatch sub;
|
||||
bool res = boost::regex_match(value, sub, itt->second);
|
||||
std::smatch sub;
|
||||
bool res = std::regex_match(value, sub, itt->second);
|
||||
|
||||
if(!res) {
|
||||
cache_.top()[&cfg].emplace_back(
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
#include "serialization/tag.hpp"
|
||||
#include "serialization/validator.hpp"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
#include <regex>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
|
||||
|
@ -147,6 +146,6 @@ private:
|
|||
std::stack<message_map> cache_;
|
||||
|
||||
/** Type validators. */
|
||||
std::map<std::string, boost::regex> types_;
|
||||
std::map<std::string, std::regex> types_;
|
||||
};
|
||||
} // namespace schema_validation{
|
||||
|
|
|
@ -32,9 +32,8 @@
|
|||
#include "gui/auxiliary/typed_formula.hpp"
|
||||
#include "gui/dialogs/loading_screen.hpp"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <locale>
|
||||
#include <regex>
|
||||
|
||||
static lg::log_domain log_config("config");
|
||||
#define ERR_CF LOG_STREAM(err, log_config)
|
||||
|
@ -1075,7 +1074,7 @@ void handle_variations(config& ut_cfg)
|
|||
ut_cfg.splice_children(variations, "variation");
|
||||
}
|
||||
|
||||
const boost::regex fai_identifier("[a-zA-Z_]+");
|
||||
const std::regex fai_identifier("[a-zA-Z_]+");
|
||||
|
||||
template<typename MoveT>
|
||||
void patch_movetype(
|
||||
|
@ -1092,8 +1091,8 @@ void patch_movetype(
|
|||
gui2::typed_formula<int> formula(formula_str);
|
||||
wfl::map_formula_callable original;
|
||||
|
||||
boost::sregex_iterator m(formula_str.begin(), formula_str.end(), fai_identifier);
|
||||
for(const boost::sregex_iterator::value_type& p : std::make_pair(m, boost::sregex_iterator())) {
|
||||
std::sregex_iterator m(formula_str.begin(), formula_str.end(), fai_identifier);
|
||||
for(const std::sregex_iterator::value_type& p : std::make_pair(m, std::sregex_iterator())) {
|
||||
const std::string var_name = p.str();
|
||||
|
||||
wfl::variant val(original_cfg[var_name].to_int(default_val));
|
||||
|
|
Loading…
Add table
Reference in a new issue