ADTF
Loading...
Searching...
No Matches
a_util::regex::RegularExpression Class Reference

Basic regular expression matching. More...

#include <regularexpression.h>

Public Types

enum  AnchorType { AT_Unanchored , AT_Start , AT_Both }
 Anchor type. More...
 

Public Member Functions

 RegularExpression ()
 
 RegularExpression (const std::string &pattern, bool case_sensitive=true)
 
 ~RegularExpression ()
 
 RegularExpression (const RegularExpression &other)
 
RegularExpressionoperator= (const RegularExpression &other)
 
bool setPattern (const std::string &pattern, bool case_sensitive=true)
 
std::string getPattern () const
 
const std::string & getError () const
 
bool fullMatch (const std::string &text) const
 
bool fullMatch (const std::string &text, std::string &arg1, std::string &arg2=noArg(), std::string &arg3=noArg(), std::string &arg4=noArg(), std::string &arg5=noArg(), std::string &arg6=noArg(), std::string &arg7=noArg(), std::string &arg8=noArg(), std::string &arg9=noArg(), std::string &arg10=noArg(), std::string &arg11=noArg(), std::string &arg12=noArg(), std::string &arg13=noArg(), std::string &arg14=noArg(), std::string &arg15=noArg(), std::string &arg16=noArg()) const
 
bool match (const std::string &text, AnchorType anchor, int &consumed) const
 

Detailed Description

Basic regular expression matching.

Member Enumeration Documentation

◆ AnchorType

Anchor type.

Enumerator
AT_Unanchored 

No anchoring.

AT_Start 

Anchor at start only.

AT_Both 

Anchor at start and end.

Constructor & Destructor Documentation

◆ RegularExpression() [1/3]

a_util::regex::RegularExpression::RegularExpression ( )

Default constructor

◆ RegularExpression() [2/3]

a_util::regex::RegularExpression::RegularExpression ( const std::string & pattern,
bool case_sensitive = true )

Constructor with a preinitialized pattern

Parameters
[in]patternThe regular expression pattern
[in]case_sensitiveWhether or not the match is case sensitive
Note
On error, the instance is initialized to the default state/the pattern is not set

◆ ~RegularExpression()

a_util::regex::RegularExpression::~RegularExpression ( )

DTOR

◆ RegularExpression() [3/3]

a_util::regex::RegularExpression::RegularExpression ( const RegularExpression & other)

Copy constructor

Parameters
[in]otherThe object to copy.

Member Function Documentation

◆ fullMatch() [1/2]

bool a_util::regex::RegularExpression::fullMatch ( const std::string & text) const

Check if the whole string matches the pattern.

Parameters
[in]textThe string to match
Returns
true if the string matches, false otherwise

◆ fullMatch() [2/2]

bool a_util::regex::RegularExpression::fullMatch ( const std::string & text,
std::string & arg1,
std::string & arg2 = noArg(),
std::string & arg3 = noArg(),
std::string & arg4 = noArg(),
std::string & arg5 = noArg(),
std::string & arg6 = noArg(),
std::string & arg7 = noArg(),
std::string & arg8 = noArg(),
std::string & arg9 = noArg(),
std::string & arg10 = noArg(),
std::string & arg11 = noArg(),
std::string & arg12 = noArg(),
std::string & arg13 = noArg(),
std::string & arg14 = noArg(),
std::string & arg15 = noArg(),
std::string & arg16 = noArg() ) const

Check if the whole string matches the pattern, extracting up to 16 capture groups

Parameters
[in]textThe string to match
[out]arg1Capture argument 1
[out]arg2Capture argument 2
[out]arg3Capture argument 3
[out]arg4Capture argument 4
[out]arg5Capture argument 5
[out]arg6Capture argument 6
[out]arg7Capture argument 7
[out]arg8Capture argument 8
[out]arg9Capture argument 9
[out]arg10Capture argument 10
[out]arg11Capture argument 11
[out]arg12Capture argument 12
[out]arg13Capture argument 13
[out]arg14Capture argument 14
[out]arg15Capture argument 15
[out]arg16Capture argument 16
Returns
@ true if the string matches, false otherwise

◆ getError()

const std::string & a_util::regex::RegularExpression::getError ( ) const

Get any error description for the pattern.

Returns
The current error. Might be empty if the pattern is valid.

◆ getPattern()

std::string a_util::regex::RegularExpression::getPattern ( ) const

Get the current pattern (expression).

Returns
The current pattern.

◆ match()

bool a_util::regex::RegularExpression::match ( const std::string & text,
AnchorType anchor,
int & consumed ) const

Matches a string

Parameters
[in]textThe string to match
[in]anchorSee AnchorType
[out]consumedThe length of the match
Returns
true if the string matches, false otherwise

◆ operator=()

RegularExpression & a_util::regex::RegularExpression::operator= ( const RegularExpression & other)

Copy assignment operator

Parameters
[in]otherThe element to copy to.
Returns
A reference of the local object.

◆ setPattern()

bool a_util::regex::RegularExpression::setPattern ( const std::string & pattern,
bool case_sensitive = true )

Set the regular expression pattern

Parameters
[in]patternThe regular expression string
[in]case_sensitiveWhether or not the match is case sensitive
Returns
false if the pattern is invalid, see getError for details

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