remove String::replace, use boost::regex_replace directly

This commit is contained in:
Maxime Coste 2013-04-12 19:16:55 +02:00
parent b6d21514e4
commit 385241d2c0
4 changed files with 5 additions and 10 deletions

View File

@ -201,7 +201,8 @@ TokenList parse(const String& line,
if (opt_token_pos_info)
opt_token_pos_info->push_back({token_start, pos});
String token = line.substr(token_start, pos - token_start);
token = token.replace(R"(\\([ \t;\n]))", "\\1");
static const Regex regex{R"(\\([ \t;\n]))"};
token = boost::regex_replace(token, regex, "\\1");
result.push_back({type, token});
}

View File

@ -50,13 +50,6 @@ std::vector<String> split(const String& str, char separator)
return res;
}
String String::replace(const String& expression,
const String& replacement) const
{
boost::regex re(expression);
return String(boost::regex_replace(*this, re, replacement));
}
String option_to_string(const Regex& re)
{
return String{re.str()};

View File

@ -56,7 +56,7 @@ public:
auto e = utf8::advance(b, end(), (int)length);
return String(b,e);
}
String replace(const String& expression, const String& replacement) const;
String replace(const Regex& expression, const String& replacement) const;
};
inline String operator+(const char* lhs, const String& rhs)

View File

@ -218,7 +218,8 @@ bool operator== (const std::unique_ptr<T>& lhs, T* rhs)
inline String escape(const String& name)
{
return name.replace("([ \\t;])", R"(\\\1)");
static Regex ex{"([ \\t;])"};
return boost::regex_replace(name, ex, R"(\\\1)");
}
template<typename T>