1#ifndef SQL_REGEXP_REGEXP_ENGINE_H_
2#define SQL_REGEXP_REGEXP_ENGINE_H_
27#include <unicode/uregex.h>
45class Mock_regexp_engine;
102 auto upattern = pattern.data();
103 int length = pattern.size();
104 m_re = uregex_open(pointer_cast<const UChar *>(upattern),
length,
flags,
125 void Reset(
const std::u16string &subject);
169 const std::u16string &
Replace(
const std::u16string &replacement,
int start,
System_variables variables
Definition: sql_lexer_thd.h:62
This class exposes high-level regular expression operations to the facade.
Definition: regexp_engine.h:81
UErrorCode m_error_code
Definition: regexp_engine.h:255
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:141
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:262
bool IsError() const
Definition: regexp_engine.h:183
virtual ~Regexp_engine()
Definition: regexp_engine.h:186
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:256
URegularExpression * m_re
Our handle to ICU's compiled regular expression, owned by instances of this class.
Definition: regexp_engine.h:254
bool HasWarning() const
Definition: regexp_engine.h:180
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:99
friend class regexp_engine_unittest::Mock_regexp_engine
Definition: regexp_engine.h:230
uint flags()
Definition: regexp_engine.h:112
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:153
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:184
int SpareCapacity() const
The spare capacity in the replacement buffer, given in code points.
Definition: regexp_engine.h:226
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:257
size_t HardLimit()
The hard limit for growing the replace buffer.
Definition: regexp_engine.h:192
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:177
A better implementation of the UNIX ctype(3) library.
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
Definition: regexp_engine.h:44
static constexpr CHARSET_INFO * regexp_lib_charset
Definition: regexp_engine.h:50
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
CHARSET_INFO my_charset_utf16le_general_ci
Definition: ctype-ucs2.cc:1571
CHARSET_INFO my_charset_utf16_general_ci
Definition: ctype-ucs2.cc:1415
Definition: m_ctype.h:385
unsigned int uint
Definition: uca9-dump.cc:75