ADTF  3.18.2
RegularExpression

Basic regular expression matching. More...

Public Types

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

Public Member Functions

 RegularExpression ()
 Default constructor.
 
 RegularExpression (const std::string &pattern, bool case_sensitive=true)
 Constructor with a preinitialized pattern. More...
 
 ~RegularExpression ()
 DTOR.
 
 RegularExpression (const RegularExpression &other)
 Copy constructor. More...
 
RegularExpressionoperator= (const RegularExpression &other)
 Copy assignment operator. More...
 
bool setPattern (const std::string &pattern, bool case_sensitive=true)
 Set the regular expression pattern. More...
 
std::string getPattern () const
 Get the current pattern (expression). More...
 
const std::string & getError () const
 Get any error description for the pattern. More...
 
bool fullMatch (const std::string &text) const
 Check if the whole string matches the pattern. More...
 
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
 Check if the whole string matches the pattern, extracting up to 16 capture groups. More...
 
bool match (const std::string &text, AnchorType anchor, int &consumed) const
 Matches a string. More...
 

Static Private Member Functions

static std::string & noArg ()
 Empty argument.
 

Private Attributes

std::unique_ptr< Implementation > _impl
 

Detailed Description

Member Enumeration Documentation

◆ AnchorType

enum AnchorType

Anchor type.

Enumerator
AT_Unanchored 

No anchoring.

AT_Start 

Anchor at start only.

AT_Both 

Anchor at start and end.

Definition at line 27 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/a_util/regex/regularexpression.h.

Constructor & Destructor Documentation

◆ RegularExpression() [1/2]

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() [2/2]

Copy constructor.

Parameters
[in]otherThe object to copy.

Member Function Documentation

◆ fullMatch() [1/2]

bool 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 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& getError ( ) const

Get any error description for the pattern.

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

◆ getPattern()

std::string getPattern ( ) const

Get the current pattern (expression).

Returns
The current pattern.

◆ match()

bool 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& operator= ( const RegularExpression other)

Copy assignment operator.

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

◆ setPattern()

bool 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