MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / set

Function set

src/OSspecific/POSIX/regExp.C:116–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
115
116void Foam::regExp::set(const char* pattern, const bool ignoreCase) const
117{
118 clear();
119
120 // Avoid nullptr and zero-length patterns
121 if (pattern && *pattern)
122 {
123 int cflags = REG_EXTENDED;
124 if (ignoreCase)
125 {
126 cflags |= REG_ICASE;
127 }
128
129 const char* pat = pattern;
130
131 // Check for embedded prefix for ignore-case
132 // this is the only embedded prefix we support
133 // - a simple check is sufficient
134 if (!strncmp(pattern, "(?i)", 4))
135 {
136 cflags |= REG_ICASE;
137 pat += 4;
138
139 // avoid zero-length patterns
140 if (!*pat)
141 {
142 return;
143 }
144 }
145
146 preg_ = new regex_t;
147 int err = regcomp(preg_, pat, cflags);
148
149 if (err != 0)
150 {
151 char errbuf[200];
152 regerror(err, preg_, errbuf, sizeof(errbuf));
153
154 FatalErrorInFunction
155 << "Failed to compile regular expression '" << pattern << "'"
156 << nl << errbuf
157 << exit(FatalError);
158 }
159 }
160}
161
162
163void Foam::regExp::set(const std::string& pattern, const bool ignoreCase) const

Callers 12

regExp.CFile · 0.70
preg_Function · 0.70
mainFunction · 0.50
forceList.CFile · 0.50
forAllMethod · 0.50
coalCloudList.CFile · 0.50
forAllMethod · 0.50
addTopologyModifiersFunction · 0.50

Calls 2

clearFunction · 0.50
exitFunction · 0.50

Tested by

no test coverage detected