ADTF
cRegularExpressionResolver

Class for resolving regular expression inside a filename or path. More...

Public Types

typedef std::vector< tTreeMembertTreeMemberList
 Definition for List of List of tTreeMember.
 

Public Member Functions

 cRegularExpressionResolver ()
 Default constructor.
 
 cRegularExpressionResolver (const cRegularExpressionResolver &oRegExpRes)
 Copy constructor. More...
 
 cRegularExpressionResolver (const cString &strExpression)
 Constructor with preset expression. More...
 
 cRegularExpressionResolver (const tChar *strExpression, tBool bCaseSensitive=tTrue)
 Constructor with preset expression. More...
 
virtual ~cRegularExpressionResolver ()
 Destructor.
 
tBool GetFilesPathList (const cString &strInput, tTreeMemberList &lstFiles)
 Retrieve all files from a directory using regular expressions. More...
 
tBool GetFolderPathList (const cString &strInput, tTreeMemberList &lstFolders, tBool bRecursive=tTrue, tUInt nRecDepth=0)
 Retrieve all subdirectories from a directory using regular expressions. More...
 
tBool GetFileFolderPathList (const cString &strInput, tTreeMemberList &lstFilesFolders, tBool bRecursive=tTrue, tUInt nRecDepth=0)
 Retrieve all files from subdirectories using regular expressions. More...
 
tBool GetFolderMatch (const cString &strInput, cFilename &strFoldername, tBool bRecursive=tTrue, tUInt nRecDepth=0)
 Retrieves a single folder, if any, from a directory using regular expressions. More...
 
tBool GetFileMatch (const cString &strInput, cFilename &strFilename)
 Retrieves a single file if any from a directory using regular expressions. More...
 
cString GetRegExFromString (const cString &strSource, cString &strPath, tBool bFull=tFalse)
 Retrieve regular expression and path. More...
 
cString GetFirstMatch (const cString &strSource)
 Retrieve first match of regular expression. More...
 

Static Public Member Functions

static tBool ContainsRegEx (const cString &strSource)
 Check if string contains regular expression. More...
 

Private Member Functions

tUInt GetRecursionDepth (cString &strRegEx)
 
cString GetFolderReplacedRegEx (const cString &strInput, const cString &strName)
 
tBool CheckFolderMatch (const cString &strPath, const cString &strRegEx)
 
tInt FindFolder (tTreeMemberList &lstFilesFolders, cFilename &strFilename)
 

Private Attributes

cRegularExpressionm_pRegEx
 

Detailed Description

Class for resolving regular expression inside a filename or path.

This class implements basic regular expression resolving functionality.

Regular expressions can be defined as %{REGEX} or %%REGEX%. You can escape % by typing \%.

The REGEX in an input string has to fullfill the following constraints:

  • The regular expression has to close the input string
  • The regular expression has to start at a concrete path or folder

Definition at line 26 of file regularexpressionresolver.h.

Constructor & Destructor Documentation

◆ cRegularExpressionResolver() [1/3]

Copy constructor.

Parameters
oRegExpRes[in] The object to copy.

◆ cRegularExpressionResolver() [2/3]

cRegularExpressionResolver ( const cString strExpression)

Constructor with preset expression.

Parameters
strExpression[in] The regular expression string.

◆ cRegularExpressionResolver() [3/3]

cRegularExpressionResolver ( const tChar strExpression,
tBool  bCaseSensitive = tTrue 
)

Constructor with preset expression.

Parameters
strExpression[in] The regular expression string.
bCaseSensitive[in] Whether or not the match case sensitive.

Member Function Documentation

◆ ContainsRegEx()

static tBool ContainsRegEx ( const cString strSource)
static

Check if string contains regular expression.

Parameters
strSource[in] The string to check. Use forward slashes a seperator. Only absolute path.
Returns
tTrue if string contains regular expression otherwise tFalse

◆ GetFileFolderPathList()

tBool GetFileFolderPathList ( const cString strInput,
tTreeMemberList lstFilesFolders,
tBool  bRecursive = tTrue,
tUInt  nRecDepth = 0 
)

Retrieve all files from subdirectories using regular expressions.

Parameters
strInput[in] The directory to check. Use forward slashes a seperator. Only absolute path.
lstFilesFolders[out] The filled list of strings.
bRecursive[in] Check folder recursive or not.
nRecDepth[in] Recursion depth.
Warning
Only paths with forward slashes are being accepted!
Returns
tTrue if matching folders and files were found, otherwise tFalse.

◆ GetFileMatch()

tBool GetFileMatch ( const cString strInput,
cFilename strFilename 
)

Retrieves a single file if any from a directory using regular expressions.

Parameters
strInput[in] The directory to check.
strFilename[out] The discovered file matching the regular expression (if matched)
Warning
Only paths with forward slashes are being accepted!
Returns
tTrue if a matching file was found, otherwise tFalse.

◆ GetFilesPathList()

tBool GetFilesPathList ( const cString strInput,
tTreeMemberList lstFiles 
)

Retrieve all files from a directory using regular expressions.

Parameters
strInput[in] The directory to check.
lstFiles[out] The filled list of strings.
Warning
Only paths with forward slashes are being accepted!
Returns
tTrue if matching files were found, otherwise tFalse.

◆ GetFirstMatch()

cString GetFirstMatch ( const cString strSource)

Retrieve first match of regular expression.

Parameters
strSource[in] The string to check. Use forward slashes a seperator. Only absolute path.
Returns
cString that contains the first match of regular expression (absolute path), if existing.

◆ GetFolderMatch()

tBool GetFolderMatch ( const cString strInput,
cFilename strFoldername,
tBool  bRecursive = tTrue,
tUInt  nRecDepth = 0 
)

Retrieves a single folder, if any, from a directory using regular expressions.

Parameters
strInput[in] The directory to check.
strFoldername[out] The discovered folder matching the regular expression (if matched)
bRecursive[in] Check folder recursive or not.
nRecDepth[in] Recursion depth.
Warning
Only paths with forward slashes are being accepted!
Returns
tTrue if a matching folder was found, otherwise tFalse.

◆ GetFolderPathList()

tBool GetFolderPathList ( const cString strInput,
tTreeMemberList lstFolders,
tBool  bRecursive = tTrue,
tUInt  nRecDepth = 0 
)

Retrieve all subdirectories from a directory using regular expressions.

Parameters
strInput[in] The directory to check. Use forward slashes a seperator. Only absolute path.
lstFolders[out] The filled list of strings.
bRecursive[in] Check folder recursive or not.
nRecDepth[in] depth number for recursion
Warning
Only paths with forward slashes are being accepted!
Returns
tTrue if mathching folders were found, otherwise tFalse.

◆ GetRegExFromString()

cString GetRegExFromString ( const cString strSource,
cString strPath,
tBool  bFull = tFalse 
)

Retrieve regular expression and path.

Parameters
strSource[in] The string to check. Use forward slashes a seperator. Only absolute path.
strPath[out] The string containing the path until regular expression starts.
bFull[in] Return only the regex or the full regex (with opening and closing characters)
Returns
string that contains the regular expression, if existing.