ldas-tools-al 2.6.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
RegexMatch Class Reference

Regular Expression Match. More...

#include <regexmatch.hh>

Public Types

typedef size_t off_type
 
typedef int flag_type
 
typedef size_t off_type
 
typedef int flag_type
 

Public Member Functions

 RegexMatch (off_type nmatches=0)
 Constructor.
 
 ~RegexMatch ()
 Destructor.
 
bool match (const Regex &r, const char *string, flag_type eflags=0)
 Perform a Regex Match.
 
off_type capacity () const
 
off_type size () const
 
bool isSubValid (off_type m)
 Check Substring Match Validity.
 
const char * getSubStart (off_type m)
 Get Substring Start.
 
const char * getSubEnd (off_type m)
 Get Substring End.
 
int getSubStartOffset (off_type m)
 Get Substring Starting Offset.
 
int getSubEndOffset (off_type m)
 Get Substring Ending Offset.
 
off_type getSubLength (off_type m)
 Get Substring Length.
 
std::string getSubString (off_type m)
 Get Substring.
 
off_type getNMatches () const
 Get Number of Matches.
 
 RegexMatch (off_type nmatches=0)
 
 ~RegexMatch ()
 
bool match (const Regex &r, const char *string, flag_type eflags=0)
 
off_type capacity () const
 
off_type size () const
 
bool isSubValid (off_type m)
 
const char * getSubStart (off_type m)
 
const char * getSubEnd (off_type m)
 
int getSubStartOffset (off_type m)
 
int getSubEndOffset (off_type m)
 
off_type getSubLength (off_type m)
 
std::string getSubString (off_type m)
 
off_type getNMatches () const
 

Private Attributes

regmatch_t * mMatches
 
off_type mNMatches
 
const char * mString
 
off_type found
 

Detailed Description

Regular Expression Match.

This class represents a regular expression match. It attempts to match a string with a regular expression, storing the information resulting from captures (the parenthesis expressions).

Member Typedef Documentation

◆ flag_type [1/2]

◆ flag_type [2/2]

◆ off_type [1/2]

◆ off_type [2/2]

Constructor & Destructor Documentation

◆ RegexMatch() [1/2]

RegexMatch::RegexMatch ( off_type  nmatches = 0)

Constructor.

Parameters
nmatches

◆ ~RegexMatch() [1/2]

RegexMatch::~RegexMatch ( )

Destructor.

◆ RegexMatch() [2/2]

RegexMatch::RegexMatch ( off_type  nmatches = 0)

◆ ~RegexMatch() [2/2]

RegexMatch::~RegexMatch ( )

Member Function Documentation

◆ capacity() [1/2]

RegexMatch::off_type RegexMatch::capacity ( ) const
inline

Returns the maximum number of matches which this object can hold. This is equal to the number of matches which was passed to the constructor.

Returns
off_type

◆ capacity() [2/2]

off_type RegexMatch::capacity ( ) const

◆ getNMatches() [1/2]

RegexMatch::off_type RegexMatch::getNMatches ( ) const
inline

Get Number of Matches.

Returns the maximum number of matches which this object can hold. This is equal to the number of matches which was passed to the constructor.

Returns
off_type

◆ getNMatches() [2/2]

off_type RegexMatch::getNMatches ( ) const

◆ getSubEnd() [1/2]

const char * RegexMatch::getSubEnd ( off_type  m)
inline

Get Substring End.

Returns a pointer to the end of a substring match. If the requested match is not valid, a null pointer is returned.

Parameters
m
Returns
const char*

◆ getSubEnd() [2/2]

const char * RegexMatch::getSubEnd ( off_type  m)

◆ getSubEndOffset() [1/2]

int RegexMatch::getSubEndOffset ( off_type  m)
inline

Get Substring Ending Offset.

Returns the offset to the end of a substring match. If the requested match is not valid, then -1 is returned.

Parameters
m
Returns
const char*

◆ getSubEndOffset() [2/2]

int RegexMatch::getSubEndOffset ( off_type  m)

◆ getSubLength() [1/2]

RegexMatch::off_type RegexMatch::getSubLength ( off_type  m)
inline

Get Substring Length.

Returns the number of characters in a substring match.

Parameters
m
Returns
off_type

◆ getSubLength() [2/2]

off_type RegexMatch::getSubLength ( off_type  m)

◆ getSubStart() [1/2]

const char * RegexMatch::getSubStart ( off_type  m)
inline

Get Substring Start.

Returns a pointer to the beginning of a substring match. If the requested match is not valid, a null pointer is returned.

Parameters
m
Returns
const char*

◆ getSubStart() [2/2]

const char * RegexMatch::getSubStart ( off_type  m)

◆ getSubStartOffset() [1/2]

int RegexMatch::getSubStartOffset ( off_type  m)
inline

Get Substring Starting Offset.

Returns the offset to the beginning of a substring match. If the requested match is not valid, then -1 is returned.

Parameters
m
Returns
const char*

◆ getSubStartOffset() [2/2]

int RegexMatch::getSubStartOffset ( off_type  m)

◆ getSubString() [1/2]

std::string RegexMatch::getSubString ( off_type  m)

Get Substring.

Return a substring as a C++ string object.

Parameters
mIndex of match starting from zero.
Returns
std::string - Value of the match if m is within the number of
  • matches, the empty string otherwise.

◆ getSubString() [2/2]

std::string RegexMatch::getSubString ( off_type  m)

◆ isSubValid() [1/2]

bool RegexMatch::isSubValid ( off_type  m)
inline

Check Substring Match Validity.

This returns whether or not a substring match exists at the specified index.

Parameters
m
Returns
bool

◆ isSubValid() [2/2]

bool RegexMatch::isSubValid ( off_type  m)

◆ match() [1/2]

bool RegexMatch::match ( const Regex r,
const char *  string,
flag_type  eflags = 0 
)

Perform a Regex Match.

Parameters
rPrecompiled pattern buffer
stringText string containing the input text
eflagsflag which cause changes in matching behavior
  • (see: man regexec).
Returns
bool true if match was found, false otherwise

◆ match() [2/2]

bool RegexMatch::match ( const Regex r,
const char *  string,
flag_type  eflags = 0 
)

◆ size() [1/2]

RegexMatch::off_type RegexMatch::size ( ) const
inline

Returns the number of matches that were found after the call to match()

Returns
off_type

◆ size() [2/2]

off_type RegexMatch::size ( ) const

Member Data Documentation

◆ found

off_type RegexMatch::found
private

◆ mMatches

regmatch_t * RegexMatch::mMatches
private

◆ mNMatches

off_type RegexMatch::mNMatches
private

◆ mString

const char * RegexMatch::mString
private

The documentation for this class was generated from the following files: