2
3
4
5
6
7
8
9
10
12#ifndef GIMBAL_PATTERN_HPP
13#define GIMBAL_PATTERN_HPP
23
24
25
26
27
28
29
30
33 const GblPattern* pPattern_ =
nullptr;
36 Pattern(
const char* pRegExp)
noexcept:
39 Pattern(
const GblPattern* pPattern)
noexcept:
40 pPattern_(pPattern) {}
42 Pattern(
const Pattern& rhs)
noexcept:
45 Pattern(
Pattern&& rhs)
noexcept:
46 pPattern_(rhs.pPattern_)
48 rhs.pPattern_ =
nullptr;
55 bool isValid()
const noexcept {
return pPattern_; }
61 std::string string()
const noexcept;
63 operator
const GblPattern*()
const noexcept {
return pPattern_; }
65 Pattern& operator=(
const char* pPattern)
noexcept {
71 Pattern& operator=(
const GblPattern* pPattern)
noexcept {
85 pPattern_ = rhs.pPattern_;
86 rhs.pPattern_ =
nullptr;
90 bool match(
const char* pString,
91 GblStringView* pView=
nullptr,
92 int* pCount=
nullptr)
const noexcept
94 return GblPattern_match(*
this, pString, pView, pCount);
97 bool matchNot(
const char* pString,
98 GblStringView* pView=
nullptr,
99 int* pCount=
nullptr)
const noexcept
101 return GblPattern_matchNot(*
this, pString, pView, pCount);
104 bool matchExact(
const char* pString)
const noexcept {
108 bool matchCount(
const char* pString)
const noexcept {
112 friend std::ostream& operator<<(std::ostream &os,
const Pattern& pat) {
118inline auto operator<=>(
const Pattern& lhs,
const GblPattern* pRhs)
noexcept {
119 const auto result = GblPattern_compare(lhs, pRhs);
122 return std::strong_ordering::less;
124 return std::strong_ordering::greater;
126 return std::strong_ordering::equal;
OO C++ binding object around GblPattern.
const GblPattern * GblPattern_ref(const GblPattern *pSelf)
Returns a new reference to an existing pattern, incrementing its refcount.
GblRefCount GblPattern_refCount(const GblPattern *pSelf)
Returns the number of active references held to the given compiled pattern.
size_t GblPattern_matchCount(const GblPattern *pSelf, const char *pString)
Returns the number of pattern matches found in pString.
GblBool GblPattern_matchExact(const GblPattern *pSelf, const char *pString)
Returns GBL_TRUE if the given string EXACTLY matches the given pattern or GBL_FALSE otherwise.
const GblPattern * GblPattern_create(const char *pRegExp)
Compiles the given regular expression into a pre-processed GblPattern.
size_t GblPattern_bytes(const GblPattern *pSelf)
Counts the total size of a compiled pattern and returns it in bytes.
GblRefCount GblPattern_unref(const GblPattern *pSelf)
Releases a reference to a pattern, deallocating it upon reaching zero.