2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef GIMBAL_PATTERN_H
22#define GIMBAL_PATTERN_H
24#include "../core/gimbal_decls.h"
26#define GBL_SELF_TYPE GblPattern
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
50typedef struct GblPattern GblPattern;
53
54
55
56
70
71
72
73
85
86
87
88
90
91
92
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
120 GblStringView* pMatch,
125 GblStringView* pMatch,
130
131
132
133
137 GblStringView* pMatch,
142 GblStringView* pMatch,
148
149
150
151
160
161
162
163
174#define GblPattern_match(...)
175 (GblPattern_matchDefault_
(__VA_ARGS__))
176#define GblPattern_matchDefault_(...)
178#define GblPattern_matchDefault__(pat, str, match, count, ...)
179 ((GblPattern_match
)(pat, str, match, count))
181#define GblPattern_matchStr(...)
182 (GblPattern_matchStrDefault_
(__VA_ARGS__))
183#define GblPattern_matchStrDefault_(...)
185#define GblPattern_matchStrDefault__(exp, str, match, count, ...)
186 ((GblPattern_matchStr
)(exp, str, match, count))
188#define GblPattern_matchNot(...)
189 (GblPattern_matchNotDefault_
(__VA_ARGS__))
190#define GblPattern_matchNotDefault_(...)
192#define GblPattern_matchNotDefault__(pat, str, match, count, ...)
193 ((GblPattern_matchNot
)(pat, str, match, count))
195#define GblPattern_matchNotStr(...)
196 (GblPattern_matchNotStrDefault_
(__VA_ARGS__))
197#define GblPattern_matchNotStrDefault_(...)
199#define GblPattern_matchNotStrDefault__(exp, str, match, count, ...)
200 ((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()