libabigail
Classes | Typedefs | Functions
abigail::regex Namespace Reference

Namespace for regex types and functions. More...

Classes

struct  escape
 A class to hold a reference to a string to regex escape. More...
 
struct  regex_t_deleter
 A delete functor for a shared_ptr of regex_t. More...
 

Typedefs

typedef std::shared_ptr< regex_t > regex_t_sptr
 A convenience typedef for a shared pointer of regex_t. More...
 

Functions

regex_t_sptr compile (const std::string &str)
 Compile a regex from a string. More...
 
std::string generate_from_strings (const std::vector< std::string > &strs)
 Generate a regex pattern equivalent to testing set membership. More...
 
bool match (const regex_t_sptr &r, const std::string &str)
 See if a string matches a regex. More...
 
std::ostream & operator<< (std::ostream &os, const escape &esc)
 Escape regex special charaters in input string. More...
 

Detailed Description

Namespace for regex types and functions.

Typedef Documentation

◆ regex_t_sptr

typedef std::shared_ptr< regex_t > regex_t_sptr

A convenience typedef for a shared pointer of regex_t.

Definition at line 88 of file abg-fwd.h.

Function Documentation

◆ compile()

regex_t_sptr compile ( const std::string &  str)

Compile a regex from a string.

The result is held in a shared pointer. This will be null if regex compilation fails.

Parameters
strthe string representation of the regex.
Returns
shared pointer holder of a compiled regex object.

Definition at line 111 of file abg-regex.cc.

◆ generate_from_strings()

std::string generate_from_strings ( const std::vector< std::string > &  strs)

Generate a regex pattern equivalent to testing set membership.

A string will match the resulting pattern regex, if and only if it was present in the vector.

Parameters
strsa vector of strings
Returns
a regex pattern

Definition at line 88 of file abg-regex.cc.

◆ match()

bool match ( const regex_t_sptr r,
const std::string &  str 
)

See if a string matches a regex.

Parameters
ra shared pointer holder of a compiled regex object.
stra string.
Returns
whether there was a match.

Definition at line 127 of file abg-regex.cc.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const escape esc 
)

Escape regex special charaters in input string.

Parameters
osthe output stream being written to.
escthe regex_escape object holding a reference to the string needing to be escaped.
Returns
the output stream.

Definition at line 64 of file abg-regex.cc.