aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-06-04 14:29:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-06-04 14:29:50 +0200
commit15370d2f54f9a6a286897715d74ffbf3bdf3e02e (patch)
tree7de4bde64ff69b40af604217dfafff9d992df77d
parent6730152baa777fa04d7c494fa4fb53552f65c703 (diff)
Make regex_replace_match_results() part of public API
-rw-r--r--libbutl/regex.ixx9
-rw-r--r--libbutl/regex.mxx14
-rw-r--r--libbutl/regex.txx5
3 files changed, 24 insertions, 4 deletions
diff --git a/libbutl/regex.ixx b/libbutl/regex.ixx
index 805acd1..f55cb07 100644
--- a/libbutl/regex.ixx
+++ b/libbutl/regex.ixx
@@ -38,4 +38,13 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
return regex_replace_parse (
s, std::basic_string<C>::traits_type::length (s), f);
}
+
+ template <typename C>
+ inline std::basic_string<C>
+ regex_replace_match_results (
+ const std::match_results<typename std::basic_string<C>::const_iterator>& m,
+ const std::basic_string<C>& fmt)
+ {
+ return regex_replace_match_results (m, fmt.c_str (), fmt.size ());
+ }
}
diff --git a/libbutl/regex.mxx b/libbutl/regex.mxx
index b5490b1..b1ba1b9 100644
--- a/libbutl/regex.mxx
+++ b/libbutl/regex.mxx
@@ -95,6 +95,20 @@ LIBBUTL_MODEXPORT namespace butl
const std::basic_regex<C>&,
const std::basic_string<C>& fmt);
+ // As above but using match_results.
+ //
+ template <typename C>
+ std::basic_string<C>
+ regex_replace_match_results (
+ const std::match_results<typename std::basic_string<C>::const_iterator>&,
+ const std::basic_string<C>& fmt);
+
+ template <typename C>
+ std::basic_string<C>
+ regex_replace_match_results (
+ const std::match_results<typename std::basic_string<C>::const_iterator>&,
+ const C* fmt, std::size_t fmt_n);
+
// Parse the '/<regex>/<format>/' replacement string into the regex/format
// pair. Other character can be used as a delimiter instead of '/'. Throw
// std::invalid_argument or std::regex_error on parsing error.
diff --git a/libbutl/regex.txx b/libbutl/regex.txx
index aa845be..8fe5308 100644
--- a/libbutl/regex.txx
+++ b/libbutl/regex.txx
@@ -3,13 +3,11 @@
LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
{
- // Replace the regex match results using the format string.
- //
template <typename C>
std::basic_string<C>
regex_replace_match_results (
const std::match_results<typename std::basic_string<C>::const_iterator>& m,
- const std::basic_string<C>& fmt)
+ const C* fmt, std::size_t n)
{
using namespace std;
@@ -60,7 +58,6 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
}
};
- size_t n (fmt.size ());
for (size_t i (0); i < n; ++i)
{
C c (fmt[i]);