libcsdbg  1.28
C++ exception (and generic) stack trace debug library
filter & csdbg::filter::set_expr ( const i8 expr,
bool  icase 
)
virtual

Set the filter expression.

Parameters
[in]exprthe new expression
[in]icasetrue to ignore case on filtering, false otherwise
Returns
*this
Exceptions
csdbg::exception

Definition at line 96 of file filter.cpp.

References likely, m_expr, and unlikely.

Referenced by filter().

97 {
98  if ( unlikely(expr == NULL) )
99  throw exception("invalid argument: expr (=%p)", expr);
100 
101  regfree(&m_expr);
102  i32 flags = REG_EXTENDED | REG_NOSUB;
103  if ( unlikely(icase) )
104  flags |= REG_ICASE;
105 
106  /* Compile the regular expression */
107  i32 retval = regcomp(&m_expr, expr, flags);
108  if ( likely(retval == 0) )
109  return *this;
110 
111  /* If the expression compilation failed */
112  i32 len = regerror(retval, &m_expr, NULL, 0);
113  i8 errbuf[len];
114  regerror(retval, &m_expr, errbuf, len);
115  regfree(&m_expr);
116 
117  throw exception(
118  "failed to compile filter '%s' (regex errno %d - %s)",
119  expr,
120  retval,
121  errbuf
122  );
123 }
char i8
8-bit signed integer
Definition: config.hpp:72
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
regex_t m_expr
Filter expression.
Definition: filter.hpp:29
int i32
32-bit signed integer
Definition: config.hpp:82
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349

+ Here is the caller graph for this function: