2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef GIMBAL_PATTERN_H
25#define GIMBAL_PATTERN_H
27#include "../core/gimbal_decls.h"
29#define GBL_SELF_TYPE GblPattern
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
53typedef struct GblPattern GblPattern;
56
57
58
59
73
74
75
76
88
89
90
91
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
123 GblStringView* pMatch,
128 GblStringView* pMatch,
133
134
135
136
140 GblStringView* pMatch,
145 GblStringView* pMatch,
151
152
153
154
163
164
165
166
177#define GblPattern_match(...)
178 (GblPattern_matchDefault_
(__VA_ARGS__))
179#define GblPattern_matchDefault_(...)
181#define GblPattern_matchDefault__(pat, str, match, count, ...)
182 ((GblPattern_match
)(pat, str, match, count))
184#define GblPattern_matchStr(...)
185 (GblPattern_matchStrDefault_
(__VA_ARGS__))
186#define GblPattern_matchStrDefault_(...)
188#define GblPattern_matchStrDefault__(exp, str, match, count, ...)
189 ((GblPattern_matchStr
)(exp, str, match, count))
191#define GblPattern_matchNot(...)
192 (GblPattern_matchNotDefault_
(__VA_ARGS__))
193#define GblPattern_matchNotDefault_(...)
195#define GblPattern_matchNotDefault__(pat, str, match, count, ...)
196 ((GblPattern_matchNot
)(pat, str, match, count))
198#define GblPattern_matchNotStr(...)
199 (GblPattern_matchNotStrDefault_
(__VA_ARGS__))
200#define GblPattern_matchNotStrDefault_(...)
202#define GblPattern_matchNotStrDefault__(exp, str, match, count, ...)
203 ((GblPattern_matchNotStr
)(exp, str, match, count))
#define GBL_FORWARD_DECLARE_STRUCT(S)
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
const GblPattern * GblPattern_ref(const GblPattern *pSelf)
Returns a new reference to an existing pattern, incrementing its refcount.
GblRefCount GblPattern_totalCount(void)
Returns the total number of active, allocated, compiled regex patterns.
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_matchStr(const char *pRegExp, const char *pString, GblStringView *pMatch, int *pCount)
Dynamically-compiled string-based version of GblPattern_match()
GblBool GblPattern_match(const GblPattern *pSelf, const char *pString, GblStringView *pMatch, int *pCount)
Finds the numbered match given by pCount, or 1 if NULL.
GblBool GblPattern_equals(const GblPattern *pSelf, const GblPattern *pRhs)
Compares two different compiled patterns for exact value equality of their regexes.
GblBool GblPattern_matchNot(const GblPattern *pSelf, const char *pString, GblStringView *pMatch, int *pCount)
Behaves like GblPattern_match() except searching for NON-MATCHES.
GblBool GblPattern_matchNotStr(const char *pRegExp, const char *pString, GblStringView *pMatch, int *pCount)
Dynamically-compiled string-based version of GblPattern_matchNot()
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.
size_t GblPattern_matchCountStr(const char *pRegExp, const char *pString)
Dynamically compiled, string-based version of GblPattern_matchExact()
const char * GblPattern_string(const GblPattern *pSelf, GblStringBuffer *pBuff)
Reconstructs an approximate string representation of the compiled pattern.
const GblPattern * GblPattern_create(const char *pRegExp)
Compiles the given regular expression into a pre-processed GblPattern.
int GblPattern_compare(const GblPattern *pSelf, const GblPattern *pRhs)
Compares two different compiled patterns to see if they are equivalent regexes.
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.
GblBool GblPattern_matchExactStr(const char *pRegExp, const char *pString)
Dynamically compiled string-based version of GblPattern_matchExact()