MXS-2785: Make rewrite_src a regular expression
The use of a regular expression allows multiple rewrite rules to be combined into one. This allows more versatile conversions but, given the simple nature of regular expressions, also makes accidental changes more likely. Addd mxs::pcre2_substitute that is a more C++-friendly version of mxs_pcre2_substitute to make. This makes string replacement a lot easier to do when the source and destination are not C strings.
This commit is contained in:
@ -16,9 +16,23 @@
|
||||
#include <maxscale/pcre2.h>
|
||||
#include <maxscale/utils.hh>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace maxscale
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Overload that returns a string
|
||||
*
|
||||
* @param re Compiled pattern to use
|
||||
* @param subject Subject string
|
||||
* @param replace Replacement string
|
||||
*
|
||||
* @return The replaced string or the original string if no replacement was made
|
||||
*/
|
||||
std::string pcre2_substitute(pcre2_code* re, const std::string& subject, const std::string& replace);
|
||||
|
||||
/**
|
||||
* @class CloserTraits<pcre2_code*> pcre2.hh <maxscale/pcre2.hh>
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user