42 static std::string error_string(
const std::regex_error& err)
46 case std::regex_constants::error_collate :
47 return "invalid collating element name";
50 case std::regex_constants::error_ctype :
51 return "invalid character class name";
54 case std::regex_constants::error_escape :
55 return "invalid escaped character or a trailing escape";
58 case std::regex_constants::error_backref :
59 return "invalid back reference";
62 case std::regex_constants::error_brack :
63 return "mismatched [ and ]";
66 case std::regex_constants::error_paren :
67 return "mismatched ( and )";
70 case std::regex_constants::error_brace :
71 return "mismatched { and }";
74 case std::regex_constants::error_badbrace :
75 return "invalid range in a {..}";
78 case std::regex_constants::error_range :
79 return "invalid [..] character range";
82 case std::regex_constants::error_space :
83 return "memory error";
86 case std::regex_constants::error_badrepeat :
87 return "bad '*?+{' repeat";
90 case std::regex_constants::error_complexity :
91 return "expression too complex";
94 case std::regex_constants::error_stack :
95 return "memory stack error";
111 bool Foam::regExpCxx::set_pattern
120 const char* pat = pattern;
121 bool doNegate =
false;
124 if (len > 2 && pat[0] ==
'(' && pat[1] ==
'?')
129 for (
bool done =
false; !done && len; ++pat, --len)
158 std::regex::flag_type flags = syntax();
161 flags |= std::regex::icase;
166 re_.assign(pat, len, flags);
167 ctrl_ = (doNegate ? ctrlType::NEGATED : ctrlType::NORMAL);
170 catch (
const std::regex_error& err)
173 <<
"Failed to compile regular expression '" 174 << pattern <<
"'" <<
nl 175 << err.what() <<
": " << error_string(err).c_str() <<
nl errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
bool clear()
Clear expression.
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
static int grammar
The default grammar (extended | ECMAScript).