RegularExprParser Class Reference

#include <lib_regexpr.h>

Detailed Description

A simple regular expression parser that supports '(', ')', '*', '|', ANY_CHAR and ANY_DIGIT characters.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Private Member Functions

 RegularExprParser ()
 

Alloc/Free

static RegularExprParserAlloc ()
 
static void Free (RegularExprParser *p)
 

Expression

Bool Init (const String &strExprssion)
 
Bool FindFirst (const String &strText, REGPARSEMODE mode, Bool bOnlyFirst, Int32 &lPos, String &strPattern)
 
Bool FindNext (Int32 &lPos, String &strPattern)
 
void CleanUp ()
 

Constructor & Destructor Documentation

◆ RegularExprParser()

RegularExprParser ( )
private

Member Function Documentation

◆ Alloc()

static RegularExprParser* Alloc ( )
static

Allocates a regular expression parser. Destroy the allocated regular expression parser with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated regular expression parser, or nullptr if the allocation failed.

◆ Free()

static void Free ( RegularExprParser p)
static

Destructs regular expression parsers allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]pThe regular expression parser to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ Init()

Bool Init ( const String strExprssion)

Initializes the parser with the regular expression strExprssion.

Parameters
[in]strExprssionThe regular expression.
Returns
true if successful, otherwise false.

◆ FindFirst()

Bool FindFirst ( const String strText,
REGPARSEMODE  mode,
Bool  bOnlyFirst,
Int32 lPos,
String strPattern 
)

Performs a search using the regular expression passed to Init() in the string strText, returning the first match in lPos and strPattern.
Use FindNext() to access further matches.

Parameters
[in]strTextThe text to search.
[in]modeThe search mode: REGPARSEMODE
[in]bOnlyFirstIf true then only one match is found, so further matches will not be returned by FindNext().
[out]lPosAssigned the position of the first match.
[out]strPatternAssigned the text of the first match.
Returns
true if a match was found, otherwise false.

◆ FindNext()

Bool FindNext ( Int32 lPos,
String strPattern 
)

Retrieves further matches after the one returned by FindFirst().

Parameters
[out]lPosAssigned the position of the match.
[out]strPatternAssigned the text of the match.
Returns
true if another match was returned, otherwise false.

◆ CleanUp()

void CleanUp ( )

Cleans up the memory allocated by Init().