1#ifndef SQL_REGEXP_REGEXP_ENGINE_H_
2#define SQL_REGEXP_REGEXP_ENGINE_H_
26#include <unicode/uregex.h>
39class Mock_regexp_engine;
89 auto upattern = pattern.data();
90 int length = pattern.size();
91 m_re = uregex_open(pointer_cast<const UChar *>(upattern),
length,
flags,
112 void Reset(
const std::u16string &subject);
156 const std::u16string &
Replace(
const std::u16string &replacement,
int start,
System_variables variables
Definition: sql_lexer_thd.h:63
This class exposes high-level regular expression operations to the facade.
Definition: regexp_engine.h:68
UErrorCode m_error_code
Definition: regexp_engine.h:242
std::pair< int, int > MatchedSubstring()
The start of the match and its length.
Definition: regexp_engine.cc:106
void AppendTail()
Appends the trailing segment after the last match to the subject string,.
Definition: regexp_engine.cc:180
int StartOfMatch()
Returns the start position in the input string of the string where Matches() found a match.
Definition: regexp_engine.h:128
const std::u16string & Replace(const std::u16string &replacement, int start, int occurrence)
Iterates over the subject string, replacing matches.
Definition: regexp_engine.cc:64
int m_replace_buffer_pos
This is always the next index in m_replace_buffer where ICU can write data.
Definition: regexp_engine.h:249
bool IsError() const
Definition: regexp_engine.h:170
virtual ~Regexp_engine()
Definition: regexp_engine.h:173
void Reset(const std::u16string &subject)
Resets the engine with a new subject string.
Definition: regexp_engine.cc:43
std::u16string m_current_subject
Definition: regexp_engine.h:243
URegularExpression * m_re
Our handle to ICU's compiled regular expression, owned by instances of this class.
Definition: regexp_engine.h:241
bool HasWarning() const
Definition: regexp_engine.h:167
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:138
Regexp_engine(const std::u16string &pattern, uint flags, int stack_limit, int time_limit)
Compiles the URegularExpression object.
Definition: regexp_engine.h:86
friend class regexp_engine_unittest::Mock_regexp_engine
Definition: regexp_engine.h:217
uint flags()
Definition: regexp_engine.h:99
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:140
int TryToAppendTail()
Tries to append the part of the subject string after the last match to the buffer.
Definition: regexp_engine.cc:172
bool CheckError() const
Definition: regexp_engine.h:171
int SpareCapacity() const
The spare capacity in the replacement buffer, given in code points.
Definition: regexp_engine.h:213
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:117
std::u16string m_replace_buffer
Definition: regexp_engine.h:244
size_t HardLimit()
The hard limit for growing the replace buffer.
Definition: regexp_engine.h:179
void AppendReplacement(const std::u16string &replacement)
Tries to write the replacement, growing the buffer if needed.
Definition: regexp_engine.cc:149
bool Matches(int start, int occurrence)
Tries to find match number occurrence in the string, starting on start.
Definition: regexp_engine.cc:54
thread_local THD * current_thd
Definition: current_thd.cc:25
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:176
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:75
Definition: regexp_engine.h:38
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:37
bool check_icu_status(UErrorCode status, const UParseError *parse_error)
Definition: errors.cc:96
const char * icu_version_string()
Definition: regexp_engine.cc:41