Common Pipeline Library Reference 7.3.2
Loading...
Searching...
No Matches
Typedefs | Enumerations | Functions
Regular Expression Filter

Typedefs

typedef struct _cpl_regex_ cpl_regex
 The opaque regular expression filter data type.
 
typedef enum _cpl_regex_syntax_option_ cpl_regex_syntax_option
 Regular expression syntax options.
 

Enumerations

enum  _cpl_regex_syntax_option_ {
  CPL_REGEX_ICASE ,
  CPL_REGEX_NOSUBS ,
  CPL_REGEX_BASIC ,
  CPL_REGEX_EXTENDED
}
 

Functions

int cpl_regex_apply (const cpl_regex *self, const char *string)
 Compare a regular expression with a given character string.
 
void cpl_regex_delete (cpl_regex *self)
 Destroys a regular expression filter object.
 
int cpl_regex_is_negated (const cpl_regex *self)
 Test whether a regular expression filter is negated.
 
void cpl_regex_negate (cpl_regex *self)
 Toggle the negation state of a regular expression filter.
 
cpl_regexcpl_regex_new (const char *expression, int negated, flag_type flags)
 Create a new regular expression filter.
 

Detailed Description

The module implements a regular expression filter type. The type cpl_regex is a compiled regular expression created with a given set of regular expression syntax options, and an optional negation of the result when it is applied to an input string.

Typedef Documentation

◆ cpl_regex

typedef struct _cpl_regex_ cpl_regex

The opaque regular expression filter data type.

◆ cpl_regex_syntax_option

Regular expression syntax options.

Enumeration Type Documentation

◆ _cpl_regex_syntax_option_

Regular expressions syntax options

Enumerator
CPL_REGEX_ICASE 

Case insensitive searches.

CPL_REGEX_NOSUBS 

No sub-expressions.

CPL_REGEX_BASIC 

Basic POSIX grammer.

CPL_REGEX_EXTENDED 

Extended POSIX grammer.

Function Documentation

◆ cpl_regex_apply()

int cpl_regex_apply ( const cpl_regex self,
const char *  string 
)

Compare a regular expression with a given character string.

Parameters
selfThe regular expression filter object to apply.
stringThe string to be tested.
Returns
The function returns 0 if the filter object does not match the input string, and a non-zero value otherwise.

The function compares the input string string with the regular expression of the filter object self. The function returns a non-zero value for positive matches, i.e. the regular expression matches the input string string and the filter is not negated, or the regular expression does not match the input string but the filter is negated. Otherwise the function reports a negative match, i.e. returns 0.

◆ cpl_regex_delete()

void cpl_regex_delete ( cpl_regex self)

Destroys a regular expression filter object.

Parameters
selfThe regular expression filter object.
Returns
Nothing.

The function destroys the given regular expression filter object self, and deallocates the memory used. If the filter object self is NULL, nothing is done and no error is set.

Referenced by cpl_multiframe_new().

◆ cpl_regex_is_negated()

int cpl_regex_is_negated ( const cpl_regex self)

Test whether a regular expression filter is negated.

Parameters
selfThe regular expression filter object to test.
Returns
The function returns 0 if the filter self is not negated, and 1 otherwise.

The function reports whether the filter self is negated or not.

◆ cpl_regex_negate()

void cpl_regex_negate ( cpl_regex self)

Toggle the negation state of a regular expression filter.

Parameters
selfThe regular expression filter object to update.
Returns
Nothing.

The function toggles the negation state of the given regular expression filter object self. If self is negated, it is not negated after this function has been called, and vice versa.

◆ cpl_regex_new()

cpl_regex * cpl_regex_new ( const char *  expression,
int  negated,
flag_type  flags 
)

Create a new regular expression filter.

Parameters
expressionRegular expression.
negatedNegate the result when applying the filter.
flagsRegular expression syntax options.
Returns
The function returns a newly allocated regular expression filter object, or NULL in case an error occurred.

The function allocates a regular expression filter object and initializes it with the compiled regular expression expression. If the flag negated is set the result when applying the filter to an input string is negated. The argument flags allows to specify regular expression syntax options for the compilation of the regular expression.

The returned regular expression filter object must be destroyed using the destructor cpl_regex_delete().

Note that the syntax option CPL_REGEX_NOSUBS is always set implicitly, since the interface does not allow to retrieve this information.

References CPL_ERROR_ILLEGAL_INPUT, CPL_REGEX_BASIC, CPL_REGEX_EXTENDED, CPL_REGEX_ICASE, and CPL_REGEX_NOSUBS.

Referenced by cpl_multiframe_new().