RegularExprParser Class Reference Library » Regular Expression

#include <lib_regexpr.h>

详细描述

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

注意
Has to be created with Alloc() and destroyed with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

私有成员函数

  RegularExprParser ()

Alloc/Free

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

表达式

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

构造函数 & 析构函数文档编制

◆  RegularExprParser()

RegularExprParser () private

成员函数文档编制

◆  Alloc()

static RegularExprParser * Alloc ( )
static

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

返回
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() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

参数
[in,out] p The 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 .

参数
[in] strExprssion The regular expression.
返回
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 .
使用 FindNext() to access further matches.

参数
[in] strText The text to search.
[in] mode The search mode: REGPARSEMODE
[in] bOnlyFirst true then only one match is found, so further matches will not be returned by FindNext() .
[out] lPos Assigned the position of the first match.
[out] strPattern Assigned the text of the first match.
返回
true if a match was found, otherwise false .

◆  FindNext()

Bool FindNext ( Int32 lPos ,
String strPattern  
)

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

参数
[out] lPos Assigned the position of the match.
[out] strPattern Assigned the text of the match.
返回
true if another match was returned, otherwise false .

◆  CleanUp()

void CleanUp ( )

Cleans up the memory allocated by Init() .