Skip to content

Commit

Permalink
Replace boost::regex with std::regex (now we make the second attempt …
Browse files Browse the repository at this point in the history
…after the first in 2014).
  • Loading branch information
codereader committed Jul 7, 2017
1 parent 929f430 commit c33b8d1
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 78 deletions.
6 changes: 3 additions & 3 deletions plugins/dm.conversation/ConversationEditor.cpp
Expand Up @@ -5,7 +5,7 @@

#include <boost/format.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/regex.hpp>
#include <regex>

#include "CommandEditor.h"
#include "ActorNodeFinder.h"
Expand Down Expand Up @@ -582,8 +582,8 @@ void ConversationEditor::onDeleteCommand(wxCommandEvent& ev)

std::string ConversationEditor::removeMarkup(const std::string& input)
{
boost::regex expr("(<[A-Za-z]+>)|(</[A-Za-z]+>)");
return boost::regex_replace(input, expr, "");
std::regex expr("(<[A-Za-z]+>)|(</[A-Za-z]+>)");
return std::regex_replace(input, expr, "");
}

} // namespace ui
14 changes: 7 additions & 7 deletions plugins/dm.conversation/ConversationKeyExtractor.cpp
Expand Up @@ -3,7 +3,7 @@
#include "itextstream.h"

#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <regex>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/predicate.hpp>
Expand All @@ -25,11 +25,11 @@ void ConversationKeyExtractor::operator()(const std::string& key, const std::str
if (key.substr(0, 4) != "conv") return;

// Extract the objective number
static const boost::regex reConvNum("conv_(\\d+)_(.*)");
boost::smatch results;
static const std::regex reConvNum("conv_(\\d+)_(.*)");
std::smatch results;
int iNum;

if (!boost::regex_match(key, results, reConvNum)) {
if (!std::regex_match(key, results, reConvNum)) {
// No match, abort
return;
}
Expand Down Expand Up @@ -70,10 +70,10 @@ void ConversationKeyExtractor::operator()(const std::string& key, const std::str
}
else if (convSubString.substr(0, 4) == "cmd_") {
// This is a conversation command, form a new regex
static const boost::regex reCommand("cmd_(\\d+)_(.*)");
boost::smatch results;
static const std::regex reCommand("cmd_(\\d+)_(.*)");
std::smatch results;

if (!boost::regex_match(convSubString, results, reCommand)) {
if (!std::regex_match(convSubString, results, reCommand)) {
return; // not matching
}

Expand Down
16 changes: 8 additions & 8 deletions plugins/dm.editing/FixupMap.cpp
Expand Up @@ -18,7 +18,7 @@
#include "SpawnargReplacer.h"
#include "DeprecatedEclassCollector.h"

#include <boost/regex.hpp>
#include <regex>
#include <boost/algorithm/string.hpp>

FixupMap::FixupMap(const std::string& filename) :
Expand Down Expand Up @@ -83,10 +83,10 @@ void FixupMap::performFixup(const std::string& line)
return;
}

boost::regex expr("^" + MATERIAL_PREFIX + "(.*)\\s=>\\s(.*)$");
boost::smatch matches;
std::regex expr("^" + MATERIAL_PREFIX + "(.*)\\s=>\\s(.*)$");
std::smatch matches;

if (boost::regex_match(line, matches, expr))
if (std::regex_match(line, matches, expr))
{
// Fixup a specific shader
std::string oldShader = matches[1];
Expand All @@ -96,9 +96,9 @@ void FixupMap::performFixup(const std::string& line)
return;
}

expr = boost::regex("^" + ENTITYDEF_PREFIX + "(.*)\\s=>\\s(.*)$");
expr = std::regex("^" + ENTITYDEF_PREFIX + "(.*)\\s=>\\s(.*)$");

if (boost::regex_match(line, matches, expr))
if (std::regex_match(line, matches, expr))
{
// Fixup a specific entitydef
std::string oldDef = matches[1];
Expand All @@ -110,9 +110,9 @@ void FixupMap::performFixup(const std::string& line)
}

// No specific prefix, this can be everything: spawnarg or texture
expr = boost::regex("^(.*)\\s=>\\s(.*)$");
expr = std::regex("^(.*)\\s=>\\s(.*)$");

if (boost::regex_match(line, matches, expr))
if (std::regex_match(line, matches, expr))
{
std::string oldStr = matches[1];
std::string newStr = matches[2];
Expand Down
8 changes: 4 additions & 4 deletions plugins/dm.objectives/ObjectiveEntity.cpp
Expand Up @@ -13,7 +13,7 @@
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/format.hpp>
#include <boost/regex.hpp>
#include <regex>

#include <wx/choice.h>

Expand Down Expand Up @@ -52,14 +52,14 @@ void ObjectiveEntity::readObjectiveConditions(Entity& ent)

Entity::KeyValuePairs condSpawnargs = ent.getKeyValuePairs(OBJ_COND_PREFIX);

static const boost::regex objCondExpr(OBJ_COND_PREFIX + "(\\d+)_(.*)");
static const std::regex objCondExpr(OBJ_COND_PREFIX + "(\\d+)_(.*)");

for (Entity::KeyValuePairs::const_iterator kv = condSpawnargs.begin();
kv != condSpawnargs.end(); kv++)
{
boost::smatch results;
std::smatch results;

if (!boost::regex_match(kv->first, results, objCondExpr))
if (!std::regex_match(kv->first, results, objCondExpr))
{
continue; // No match, abort
}
Expand Down
14 changes: 7 additions & 7 deletions plugins/dm.objectives/ObjectiveKeyExtractor.cpp
Expand Up @@ -3,7 +3,7 @@
#include "itextstream.h"

#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <regex>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/predicate.hpp>
Expand All @@ -25,11 +25,11 @@ void ObjectiveKeyExtractor::operator()(const std::string& key,
return;

// Extract the objective number
static const boost::regex reObjNum("obj(\\d+)_(.*)");
boost::smatch results;
static const std::regex reObjNum("obj(\\d+)_(.*)");
std::smatch results;
int iNum;

if (boost::regex_match(key, results, reObjNum)) {
if (std::regex_match(key, results, reObjNum)) {
// Get the objective number
iNum = string::convert<int>(results[1]);
}
Expand Down Expand Up @@ -89,10 +89,10 @@ void ObjectiveKeyExtractor::operator()(const std::string& key,
else {

// Use another regex to check for components (obj1_1_blah)
static const boost::regex reComponent("(\\d+)_(.*)");
boost::smatch results;
static const std::regex reComponent("(\\d+)_(.*)");
std::smatch results;

if (!boost::regex_match(objSubString, results, reComponent)) {
if (!std::regex_match(objSubString, results, reComponent)) {
return;
}
else {
Expand Down
6 changes: 3 additions & 3 deletions plugins/dm.stimresponse/ResponseEffect.cpp
Expand Up @@ -3,7 +3,7 @@
#include "i18n.h"
#include "string/convert.h"
#include <boost/algorithm/string/replace.hpp>
#include <boost/regex.hpp>
#include <regex>

ResponseEffect::ResponseEffect() :
_state(true),
Expand Down Expand Up @@ -186,8 +186,8 @@ void ResponseEffect::clearArgumentList() {

std::string ResponseEffect::removeMarkup(const std::string& input)
{
boost::regex expr("(<[A-Za-z]+>)|(</[A-Za-z]+>)");
return boost::regex_replace(input, expr, "");
std::regex expr("(<[A-Za-z]+>)|(</[A-Za-z]+>)");
return std::regex_replace(input, expr, "");
}

std::string ResponseEffect::getArgumentStr()
Expand Down
14 changes: 7 additions & 7 deletions plugins/dm.stimresponse/SRPropertyLoader.cpp
Expand Up @@ -6,7 +6,7 @@
#include "gamelib.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/erase.hpp>
#include <boost/regex.hpp>
#include <regex>

// Constructor
SRPropertyLoader::SRPropertyLoader(
Expand Down Expand Up @@ -43,10 +43,10 @@ void SRPropertyLoader::parseAttribute(

// Construct a regex with the number as match variable
std::string exprStr = "^" + prefix + _keys[i].key + "_([0-9])+$";
boost::regex expr(exprStr);
boost::smatch matches;
std::regex expr(exprStr);
std::smatch matches;

if (boost::regex_match(key, matches, expr)) {
if (std::regex_match(key, matches, expr)) {
// Retrieve the S/R index number
int index = string::convert<int>(matches[1]);

Expand Down Expand Up @@ -82,10 +82,10 @@ void SRPropertyLoader::parseAttribute(
// (with the optional postfix "_argN" or "_state")
std::string exprStr =
"^" + prefix + responseEffectPrefix + "([0-9]+)_([0-9]+)(_arg[0-9]+|_state)*$";
boost::regex expr(exprStr);
boost::smatch matches;
std::regex expr(exprStr);
std::smatch matches;

if (boost::regex_match(key, matches, expr)) {
if (std::regex_match(key, matches, expr)) {
// The response index
int index = string::convert<int>(matches[1]);
// The effect index
Expand Down
14 changes: 7 additions & 7 deletions plugins/dm.stimresponse/SRPropertyRemover.cpp
Expand Up @@ -5,7 +5,7 @@
#include "entitylib.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/erase.hpp>
#include <boost/regex.hpp>
#include <regex>

SRPropertyRemover::SRPropertyRemover(
Entity* target,
Expand All @@ -30,21 +30,21 @@ void SRPropertyRemover::visitKeyValue(const std::string& key, const std::string&
for (unsigned int i = 0; i < _keys.size(); i++) {
// Construct a regex with the number as match variable
std::string exprStr = "^" + prefix + _keys[i].key + "_([0-9])+$";
boost::regex expr(exprStr);
boost::smatch matches;
std::regex expr(exprStr);
std::smatch matches;

if (boost::regex_match(key, matches, expr)) {
if (std::regex_match(key, matches, expr)) {
// We have a match, set the key on the black list
_removeList.push_back(key);
}
}

// This should search for something like "sr_effect_2_3*"
std::string exprStr = "^" + prefix + "effect" + "_([0-9])+_([0-9])+(.*)$";
boost::regex expr(exprStr);
boost::smatch matches;
std::regex expr(exprStr);
std::smatch matches;

if (boost::regex_match(key, matches, expr)) {
if (std::regex_match(key, matches, expr)) {
_removeList.push_back(key);
}
}
6 changes: 3 additions & 3 deletions plugins/eventmanager/Event.h
Expand Up @@ -6,7 +6,7 @@
#include <iostream>
#include <wx/menuitem.h>
#include <wx/toolbar.h>
#include <boost/regex.hpp>
#include <regex>

namespace ui
{
Expand Down Expand Up @@ -109,8 +109,8 @@ class Event :
std::string prevHelp = tool->GetShortHelp().ToStdString();

// Use a regex to cut off the trailing " (Ctrl-X)"
boost::regex expr("\\s\\(.+\\)$");
return boost::regex_replace(prevHelp, expr, "");
std::regex expr("\\s\\(.+\\)$");
return std::regex_replace(prevHelp, expr, "");
}
};

Expand Down
14 changes: 7 additions & 7 deletions plugins/filters/XMLFilter.cpp
Expand Up @@ -3,7 +3,7 @@
#include "ientity.h"
#include "ieclass.h"
#include "ifilter.h"
#include <boost/regex.hpp>
#include <regex>
#include <boost/algorithm/string/erase.hpp>

namespace filters {
Expand Down Expand Up @@ -36,9 +36,9 @@ bool XMLFilter::isVisible(const FilterRule::Type type, const std::string& name)

// If we have a rule for this item, use boost's regex to match the query name
// against the "match" parameter
boost::regex ex(ruleIter->match);
std::regex ex(ruleIter->match);

if (boost::regex_match(name, ex))
if (std::regex_match(name, ex))
{
// Overwrite the visible flag with the value from the rule.
visible = ruleIter->show;
Expand Down Expand Up @@ -66,18 +66,18 @@ bool XMLFilter::isEntityVisible(const FilterRule::Type type, const Entity& entit

if (type == FilterRule::TYPE_ENTITYCLASS)
{
boost::regex ex(ruleIter->match);
std::regex ex(ruleIter->match);

if (boost::regex_match(eclass->getName(), ex))
if (std::regex_match(eclass->getName(), ex))
{
visible = ruleIter->show;
}
}
else if (type == FilterRule::TYPE_ENTITYKEYVALUE)
{
boost::regex ex(ruleIter->match);
std::regex ex(ruleIter->match);

if (boost::regex_match(entity.getKeyValue(ruleIter->entityKey), ex))
if (std::regex_match(entity.getKeyValue(ruleIter->entityKey), ex))
{
visible = ruleIter->show;
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/fonts/FontLoader.cpp
Expand Up @@ -3,7 +3,7 @@
#include "os/path.h"
#include "string/convert.h"

#include <boost/regex.hpp>
#include <regex>

#include "itextstream.h"
#include "FontManager.h"
Expand All @@ -16,10 +16,10 @@ void FontLoader::operator()(const std::string& filename)
// Construct the full VFS path
std::string fullPath = os::standardPath(_basePath + filename);

boost::regex expr("^/?(.*)/.*_(\\d{2})\\.dat$", boost::regex::icase);
boost::smatch matches;
std::regex expr("^/?(.*)/.*_(\\d{2})\\.dat$", std::regex::icase);
std::smatch matches;

if (boost::regex_match(filename, matches, expr))
if (std::regex_match(filename, matches, expr))
{
// Get the font name and resolution from the match
std::string fontname = matches[1];
Expand Down
8 changes: 4 additions & 4 deletions plugins/particles/ParticlesManager.cpp
Expand Up @@ -22,7 +22,7 @@
#include <fstream>
#include <iostream>
#include <functional>
#include <boost/regex.hpp>
#include <regex>
#include <boost/algorithm/string/predicate.hpp>

namespace fs = boost::filesystem;
Expand Down Expand Up @@ -432,14 +432,14 @@ void ParticlesManager::stripParticleDefFromStream(std::istream& input,
std::ostream& output, const std::string& particleName)
{
std::string line;
boost::regex pattern("^[\\s]*particle[\\s]+" + particleName + "\\s*(\\{)*\\s*$");
std::regex pattern("^[\\s]*particle[\\s]+" + particleName + "\\s*(\\{)*\\s*$");

while (std::getline(input, line))
{
boost::smatch matches;
std::smatch matches;

// See if this line contains the particle def in question
if (boost::regex_match(line, matches, pattern))
if (std::regex_match(line, matches, pattern))
{
// Line matches, march from opening brace to the other one
std::size_t openBraces = 0;
Expand Down
6 changes: 3 additions & 3 deletions radiant/model/ScaledModelExporter.cpp
Expand Up @@ -10,7 +10,7 @@
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/regex.hpp>
#include <regex>

namespace fs = boost::filesystem;

Expand Down Expand Up @@ -184,8 +184,8 @@ std::string ScaledModelExporter::generateUniqueModelFilename(
std::string modelFilename = os::getFilename(modelPath.string());

// Remove any previously existing "_scaledN" suffix
boost::regex expr("_scaled\\d+\\.");
modelFilename = boost::regex_replace(modelFilename, expr, ".");
std::regex expr("_scaled\\d+\\.");
modelFilename = std::regex_replace(modelFilename, expr, ".");

std::string filenameNoExt = fs::change_extension(modelFilename, "").string();

Expand Down

0 comments on commit c33b8d1

Please sign in to comment.