1#ifndef SQL_REGEXP_REGEXP_ENGINE_H_
2#define SQL_REGEXP_REGEXP_ENGINE_H_
27#include <unicode/uregex.h>
40class Mock_regexp_engine;
90 auto upattern = pattern.data();
91 int length = pattern.size();
92 m_re = uregex_open(pointer_cast<const UChar *>(upattern),
length,
flags,
113 void Reset(
const std::u16string &subject);
157 const std::u16string &
Replace(
const std::u16string &replacement,
int start,
System_variables variables
Definition: sql_lexer_thd.h:64
This class exposes high-level regular expression operations to the facade.
Definition: regexp_engine.h:69
UErrorCode m_error_code
Definition: regexp_engine.h:243
std::pair< int, int > MatchedSubstring()
The start of the match and its length.
Definition: regexp_engine.cc:107
void AppendTail()
Appends the trailing segment after the last match to the subject string,.
Definition: regexp_engine.cc:181
int StartOfMatch()
Returns the start position in the input string of the string where Matches() found a match.
Definition: regexp_engine.h:129
const std::u16string & Replace(const std::u16string &replacement, int start, int occurrence)
Iterates over the subject string, replacing matches.
Definition: regexp_engine.cc:65
int m_replace_buffer_pos
This is always the next index in m_replace_buffer where ICU can write data.
Definition: regexp_engine.h:250
bool IsError() const
Definition: regexp_engine.h:171
virtual ~Regexp_engine()
Definition: regexp_engine.h:174
void Reset(const std::u16string &subject)
Resets the engine with a new subject string.
Definition: regexp_engine.cc:44
std::u16string m_current_subject
Definition: regexp_engine.h:244
URegularExpression * m_re
Our handle to ICU's compiled regular expression, owned by instances of this class.
Definition: regexp_engine.h:242
bool HasWarning() const
Definition: regexp_engine.h:168
int TryToAppendReplacement(const std::u16string &replacement)
Preflight function: If the buffer capacity is adequate, the replacement is appended to the buffer,...
Definition: regexp_engine.cc:139
Regexp_engine(const std::u16string &pattern, uint flags, int stack_limit, int time_limit)
Compiles the URegularExpression object.
Definition: regexp_engine.h:87
friend class regexp_engine_unittest::Mock_regexp_engine
Definition: regexp_engine.h:218
uint flags()
Definition: regexp_engine.h:100
int EndOfMatch()
Returns the position in the input string right after the end of the text where Matches() found a matc...
Definition: regexp_engine.h:141
int TryToAppendTail()
Tries to append the part of the subject string after the last match to the buffer.
Definition: regexp_engine.cc:173
bool CheckError() const
Definition: regexp_engine.h:172
int SpareCapacity() const
The spare capacity in the replacement buffer, given in code points.
Definition: regexp_engine.h:214
void AppendHead(size_t size)
Fills in the prefix in case we are doing a replace operation starting on a non-first occurrence of th...
Definition: regexp_engine.cc:118
std::u16string m_replace_buffer
Definition: regexp_engine.h:245
size_t HardLimit()
The hard limit for growing the replace buffer.
Definition: regexp_engine.h:180
void AppendReplacement(const std::u16string &replacement)
Tries to write the replacement, growing the buffer if needed.
Definition: regexp_engine.cc:150
bool Matches(int start, int occurrence)
Tries to find match number occurrence in the string, starting on start.
Definition: regexp_engine.cc:55
thread_local THD * current_thd
Definition: current_thd.cc:26
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
void error(const char *format,...)
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
size_t size(const char *const c)
Definition: base64.h:46
Definition: regexp_engine.h:39
UBool QueryNotKilled(const void *thd, int32_t)
Implements a match callback function for icu that aborts execution if the query was killed.
Definition: regexp_engine.cc:38
bool check_icu_status(UErrorCode status, const UParseError *parse_error)
Definition: errors.cc:97
const char * icu_version_string()
Definition: regexp_engine.cc:42