Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
regular_expressions.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
27 #ifndef SHARED_SRC_UTIL_INCLUDE_REGULAR_EXPRESSIONS_H_
28 #define SHARED_SRC_UTIL_INCLUDE_REGULAR_EXPRESSIONS_H_
29 
30 #include "pcre.h"
31 
32 
34 #include "typedefs.h"
35 
37 const uint32 DEFAULT_NUM_REGEXP_VECTORS = 32;
38 
44 typedef struct RegExp
45 {
47  pcre *re_compiled_expression_p;
48 
50  pcre_extra *re_extra_p;
51 
53  const char *re_target_s;
54 
56  uint32 re_num_matches;
57 
59  int *re_substring_vectors_p;
60 
62  uint32 re_num_vectors;
63 
65  uint32 re_current_substring_index;
66 } RegExp;
67 
68 
69 #ifdef __cplusplus
70 extern "C"
71 {
72 #endif
73 
74 
75 
84 GRASSROOTS_UTIL_API RegExp *AllocateRegExp (uint32 num_vectors);
85 
86 
93 GRASSROOTS_UTIL_API void FreeRegExp (RegExp *reg_ex_p);
94 
95 
102 GRASSROOTS_UTIL_API void ClearRegExp (RegExp *reg_ex_p);
103 
104 
115 GRASSROOTS_UTIL_API bool SetPattern (RegExp *reg_ex_p, const char *pattern_s, int options);
116 
117 
126 GRASSROOTS_UTIL_API bool MatchPattern (RegExp *reg_ex_p, const char *value_s);
127 
128 
136 GRASSROOTS_UTIL_API uint32 GetNumberOfMatches (const RegExp *reg_ex_p);
137 
138 
149 GRASSROOTS_UTIL_API char *GetNextMatch (RegExp *reg_ex_p);
150 
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 
157 #endif /* SHARED_SRC_UTIL_INCLUDE_REGULAR_EXPRESSIONS_H_ */
grassroots_util_library.h
RegExp::GetNextMatch
char * GetNextMatch(RegExp *reg_ex_p)
Get the next match from a regular expression.
RegExp::ClearRegExp
void ClearRegExp(RegExp *reg_ex_p)
Clear a RegExp ready to re-use with a different pattern.
RegExp::MatchPattern
bool MatchPattern(RegExp *reg_ex_p, const char *value_s)
Test whether a regular expression has any matches for a given value.
typedefs.h
DEFAULT_NUM_REGEXP_VECTORS
const uint32 DEFAULT_NUM_REGEXP_VECTORS
The default upper limit for he number of matches that a RegExp can make.
Definition: regular_expressions.h:37
RegExp::SetPattern
bool SetPattern(RegExp *reg_ex_p, const char *pattern_s, int options)
Set the pattern that a given RegExp will use for its regular expression.
RegExp::GetNumberOfMatches
uint32 GetNumberOfMatches(const RegExp *reg_ex_p)
Get the number of matchers after running MatchPattern().
RegExp::FreeRegExp
void FreeRegExp(RegExp *reg_ex_p)
Free a RegExp.
RegExp::AllocateRegExp
RegExp * AllocateRegExp(uint32 num_vectors)
Allocate a RegExp.
GRASSROOTS_UTIL_API
#define GRASSROOTS_UTIL_API
Definition: grassroots_util_library.h:47
RegExp
The module used for performing regular expressions.
Definition: regular_expressions.h:44