8#ifndef INCLUDED_BDLPCRE_REGEX
9#define INCLUDED_BDLPCRE_REGEX
716#include <bdlscm_version.h>
729#include <bsl_cstddef.h>
730#include <bsl_string.h>
731#include <bsl_string_view.h>
732#include <bsl_utility.h>
733#include <bsl_vector.h>
739#define PCRE2_CODE_UNIT_WIDTH 8
741#include <pcre2/pcre2.h>
744#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
751class RegEx_MatchContext;
772 bsls::AtomicOperations::AtomicTypes::Int s_depthLimit;
782 pcre2_general_context *d_pcre2Context_p;
784 pcre2_compile_context *d_compileContext_p;
786 pcre2_code *d_patternCode_p;
790 size_t d_jitStackSize;
828 int prepareImp(
char *errorBuffer,
829 size_t errorBufferLength,
853 template <
class RESULT_EXTRACTOR>
854 int matchImp(
const RESULT_EXTRACTOR& extractor,
856 size_t subjectLength,
857 size_t subjectOffset,
858 bool skipUTF8Validation)
const;
861 template <
class Vector>
862 void namedSubpatternsImp(Vector *result)
const;
890 template <
class STRING>
891 int replaceImp(STRING *result,
896 bool skipUTF8Validation)
const;
1033 size_t *errorOffset,
1070 template <
class STRING>
1073#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
1078 size_t *errorOffset,
1140 size_t subjectOffset = 0)
const;
1161 size_t subjectLength,
1162 size_t subjectOffset = 0)
const;
1184 const char *subject,
1185 size_t subjectLength,
1186 size_t subjectOffset = 0)
const;
1188 const char *subject,
1189 size_t subjectLength,
1190 size_t subjectOffset = 0)
const;
1211 size_t subjectOffset = 0)
const;
1249 const char *subject,
1250 size_t subjectLength,
1251 size_t subjectOffset = 0)
1254 const char *subject,
1255 size_t subjectLength,
1256 size_t subjectOffset = 0)
1261 size_t subjectOffset = 0)
const;
1262 int match(std::vector<bsl::string_view> *result,
1264 size_t subjectOffset = 0)
const;
1265#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR
1266 int match(std::pmr::vector<bsl::string_view> *result,
1268 size_t subjectOffset = 0)
const;
1313 size_t subjectOffset = 0)
const;
1330 size_t subjectLength,
1331 size_t subjectOffset = 0)
const;
1349 const char *subject,
1350 size_t subjectLength,
1351 size_t subjectOffset = 0)
const;
1353 const char *subject,
1354 size_t subjectLength,
1355 size_t subjectOffset = 0)
const;
1372 size_t subjectOffset = 0)
const;
1407 const char *subject,
1408 size_t subjectLength,
1409 size_t subjectOffset = 0)
1412 const char *subject,
1413 size_t subjectLength,
1414 size_t subjectOffset = 0)
1419 size_t subjectOffset = 0)
1423 size_t subjectOffset = 0)
1425#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR
1426 int matchRaw(std::pmr::vector<bsl::string_view> *result,
1428 size_t subjectOffset = 0)
1461 std::vector<std::pair<bsl::string_view, int> > *result)
const;
1462#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR
1464 std::pmr::vector<std::pair<bsl::string_view, int> > *result)
const;
1515 size_t options = 0)
const;
1520 size_t options = 0)
const;
1521#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
1522 int replace(std::pmr::string *result,
1526 size_t options = 0)
const;
1560 size_t options = 0)
const;
1565 size_t options = 0)
const;
1566#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
1571 size_t options = 0)
const;
1618 pcre2_compile_context_free(d_compileContext_p);
1619 pcre2_general_context_free(d_pcre2Context_p);
1623template <
class STRING>
1626#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
1631 size_t *errorOffset,
1632 const char *pattern,
1634 size_t jitStackSize)
1636 const int k_BUFFER_LEN = 256;
1637 char buffer[k_BUFFER_LEN] = {0};
1640 int ret = prepareImp(&buffer[0],
1649 errorMessage->assign(&buffer[0]);
1652 *errorOffset = offset;
1663 return d_depthLimit;
1675 return (0 != d_patternCode_p);
1681 return d_jitStackSize;
Definition bdlpcre_regex.h:768
void namedSubpatterns(std::vector< std::pair< bsl::string_view, int > > *result) const
int matchRaw(std::vector< bsl::string_view > *result, const bsl::string_view &subject, size_t subjectOffset=0) const
int setDepthLimit(int depthLimit)
int match(bsl::string_view *result, const bsl::string_view &subject, size_t subjectOffset=0) const
int matchRaw(const bsl::string_view &subject, size_t subjectOffset=0) const
int matchRaw(bsl::vector< bsl::string_view > *result, const bsl::string_view &subject, size_t subjectOffset=0) const
static const size_t k_INVALID_OFFSET
Definition bdlpcre_regex.h:988
int match(bsl::pair< size_t, size_t > *result, const char *subject, size_t subjectLength, size_t subjectOffset=0) const
int matchRaw(bsl::pair< size_t, size_t > *result, const char *subject, size_t subjectLength, size_t subjectOffset=0) const
static bool isJitAvailable()
int matchRaw(bsl::string_view *result, const bsl::string_view &subject, size_t subjectOffset=0) const
@ k_STATUS_UTF8_TRUNCATED_CHARACTER_FAILURE
the UTF-8 string ends with a truncated UTF-8 character
Definition bdlpcre_regex.h:958
@ k_STATUS_DEPTH_LIMIT_FAILURE
depthLimit() was exceeded
Definition bdlpcre_regex.h:951
@ k_STATUS_UTF8_5_OR_6_BYTES_CHARACTER_FAILURE
a UTF-8 character is either 5 or 6 bytes long
Definition bdlpcre_regex.h:965
@ k_STATUS_UTF8_4_BYTES_CHARACTER_RANGE_FAILURE
a 4-byte UTF-8 character has a value greater than 0x10ffff
Definition bdlpcre_regex.h:968
@ k_STATUS_SUCCESS
successful completion of the operation
Definition bdlpcre_regex.h:945
@ k_STATUS_UTF8_FIRST_BYTE_WRONG_VALUE_FAILURE
the first byte of a UTF-8 character has the value 0xfe or 0xff
Definition bdlpcre_regex.h:983
@ k_STATUS_NO_MATCH
the subject string did not match the pattern
Definition bdlpcre_regex.h:948
@ k_STATUS_UTF8_SIGNIFICANT_BITS_VALUE_FAILURE
Definition bdlpcre_regex.h:962
@ k_STATUS_UTF8_3_BYTES_CHARACTER_RANGE_FAILURE
Definition bdlpcre_regex.h:972
@ k_STATUS_UTF8_FIRST_BYTE_SIGNIFICANT_BITS_FAILURE
Definition bdlpcre_regex.h:980
@ k_STATUS_UTF8_OVERLONG_CHARACTER_FAILURE
Definition bdlpcre_regex.h:976
@ k_STATUS_JIT_STACK_LIMIT_FAILURE
Definition bdlpcre_regex.h:955
int depthLimit() const
Definition bdlpcre_regex.h:1661
@ k_FLAG_JIT
Definition bdlpcre_regex.h:916
@ k_FLAG_CASELESS
Definition bdlpcre_regex.h:907
@ k_FLAG_DUPNAMES
Definition bdlpcre_regex.h:919
@ k_FLAG_MULTILINE
Definition bdlpcre_regex.h:912
@ k_FLAG_UTF8
Definition bdlpcre_regex.h:914
@ k_FLAG_DOTMATCHESALL
Definition bdlpcre_regex.h:909
int prepare(bsl::nullptr_t errorMessage, size_t *errorOffset, const char *pattern, int flags=0, size_t jitStackSize=0)
int replaceRaw(bsl::string *result, int *errorOffset, const bsl::string_view &subject, const bsl::string_view &replacement, size_t options=0) const
int matchRaw(bsl::string_view *result, const char *subject, size_t subjectLength, size_t subjectOffset=0) const
int matchRaw(bsl::vector< bslstl::StringRef > *result, const char *subject, size_t subjectLength, size_t subjectOffset=0) const
BSLMF_NESTED_TRAIT_DECLARATION(RegEx, bslma::UsesBslmaAllocator)
RegEx(bslma::Allocator *basicAllocator=0)
~RegEx()
Destroy this regular-expression object.
Definition bdlpcre_regex.h:1615
int match(bsl::vector< bsl::string_view > *result, const bsl::string_view &subject, size_t subjectOffset=0) const
int replaceRaw(std::string *result, int *errorOffset, const bsl::string_view &subject, const bsl::string_view &replacement, size_t options=0) const
int match(std::vector< bsl::string_view > *result, const bsl::string_view &subject, size_t subjectOffset=0) const
int flags() const
Definition bdlpcre_regex.h:1667
static int defaultDepthLimit()
Return the process-wide default evaluation recursion depth limit.
Definition bdlpcre_regex.h:1598
int match(bsl::vector< bslstl::StringRef > *result, const char *subject, size_t subjectLength, size_t subjectOffset=0) const
const bsl::string & pattern() const
Definition bdlpcre_regex.h:1685
int match(const char *subject, size_t subjectLength, size_t subjectOffset=0) const
int matchRaw(bsl::vector< bsl::pair< size_t, size_t > > *result, const char *subject, size_t subjectLength, size_t subjectOffset=0) const
size_t jitStackSize() const
Definition bdlpcre_regex.h:1679
static int setDefaultDepthLimit(int depthLimit)
Definition bdlpcre_regex.h:1604
void namedSubpatterns(bsl::vector< bsl::pair< bsl::string_view, int > > *result) const
int match(bsl::vector< bsl::pair< size_t, size_t > > *result, const char *subject, size_t subjectLength, size_t subjectOffset=0) const
int match(bsl::string_view *result, const char *subject, size_t subjectLength, size_t subjectOffset=0) const
int match(const bsl::string_view &subject, size_t subjectOffset=0) const
int subpatternIndex(const char *name) const
bool isPrepared() const
Definition bdlpcre_regex.h:1673
int replace(bsl::string *result, int *errorOffset, const bsl::string_view &subject, const bsl::string_view &replacement, size_t options=0) const
int numSubpatterns() const
int matchRaw(const char *subject, size_t subjectLength, size_t subjectOffset=0) const
@ k_REPLACE_UNSET_EMPTY
Definition bdlpcre_regex.h:937
@ k_REPLACE_UNKNOWN_UNSET
Definition bdlpcre_regex.h:935
@ k_REPLACE_GLOBAL
Definition bdlpcre_regex.h:929
@ k_REPLACE_EXTENDED
Definition bdlpcre_regex.h:932
@ k_REPLACE_LITERAL
Definition bdlpcre_regex.h:927
int replace(std::string *result, int *errorOffset, const bsl::string_view &subject, const bsl::string_view &replacement, size_t options=0) const
Definition bslstl_stringview.h:471
Definition bslstl_string.h:1252
Definition bslstl_pair.h:1280
Definition bslstl_vector.h:1120
Definition bslma_allocator.h:545
Definition bslma_managedptr.h:1173
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlpcre_regex.h:749
BloombergLP::bsls::Nullptr_Impl::Type nullptr_t
Definition bsls_nullptr.h:283
Definition bslmf_enableif.h:530
Definition bslmf_issame.h:146
Definition bslma_usesbslmaallocator.h:344
static void setIntRelaxed(AtomicTypes::Int *atomicInt, int value)
Definition bsls_atomicoperations.h:1554
static int getIntRelaxed(AtomicTypes::Int const *atomicInt)
Definition bsls_atomicoperations.h:1536