This class implements an ALib Expression Compiler Plugin and thus enables "run-time expressions" to work with nodes of FTree
Unless multithreaded compilation of expressions is planned, an application should create one singleton of this class.
Method CreateFilter creates an object of inner type FileExpressions::Filter, which implements the FFilter interface used with scan parameters of function ScanFiles. This allows run-time evaluation of filter rules, for example rules coming from the command line, from configuration files or from interactive end-user input (hence from an UX/UI).
Of course, the expression compiler can also be used directly without using the inner Filter class for evaluation, and expressions then do not need to return a boolean "yes/no" result.
Compiler plug-in that provides expressions on filesystem entries, stored in nodes of class FTree.
All identifier and function names are defined to be matched case-insensitive. Furthermore, the matchable tokens are not hard-coded but resourced with ALib Camp singleton alib::FILES. With that, for example, language translations might be performed.
This plug-in introduces the following types to the expression compiler:
Each type is auto-cast to built-in expression type Integer to allow all common operators, especially bitwise boolean operators.
Type | Name | Min. Abbreviation | Description |
---|---|---|---|
Permissions | OwnerRead | ore | Used test result of function Permission. |
Permissions | OwnerWrite | ow | Used test result of function Permission. |
Permissions | OwnerExecute | oe | Used test result of function Permission. |
Permissions | GroupRead | gr | Used test result of function Permission. |
Permissions | GroupWrite | gw | Used test result of function Permission. |
Permissions | GroupExecute | ge | Used test result of function Permission. |
Permissions | OthersRead | otr | Used test result of function Permission. |
Permissions | OthersWrite | otw | Used test result of function Permission. |
Permissions | OthersExecute | ote | Used test result of function Permission. |
Types | Directory | dir | Used to compare the result of function Type. |
Types | SymbolicLinkDir | sld | Used to compare the result of function Type. |
Types | Regular | reg | Used to compare the result of function Type. |
Types | SymbolicLink | sl | Used to compare the result of function Type. |
Types | Block | block | Used to compare the result of function Type. |
Types | Character | character | Used to compare the result of function Type. |
Types | Fifo | fifo | Used to compare the result of function Type. |
Types | Socket | socket | Used to compare the result of function Type. |
Return Type | Name | Min. Abbreviation | Signature | Description |
---|---|---|---|---|
Integer | KiloBytes | KB | int | Returns the given number multiplied with 2^10. |
Integer | MegaBytes | MB | int | Returns the given number multiplied with 2^20. |
Integer | GigaBytes | GB | int | Returns the given number multiplied with 2^30. |
Integer | TeraBytes | TB | int | Returns the given number multiplied with 2^40. |
Integer | PetaBytes | PB | int | Returns the given number multiplied with 2^50. |
Integer | ExaBytes | EB | int | Returns the given number multiplied with 2^60. |
Return Type | Name | Min. Abbreviation | Signature | Description |
---|---|---|---|---|
String | Name | name | ./. | Returns the file name. |
Types | Type | ty | ./. | Returns the result of Type. |
Boolean | IsDirectory | isdir | ./. | Returns the result of IsDirectory. |
Boolean | IsSymbolicLink | issl | ./. | Returns the result of IsSymbolicLink. |
Integer | Size | size | ./. | Returns the result of Size. |
DateTime | Date | timestamp | ./. | Returns the result of MDate. |
DateTime | MDate | md | ./. | Returns the result of MDate. |
DateTime | BDate | bd | ./. | Returns the result of BDate. |
DateTime | CDate | cd | ./. | Returns the result of CDate. |
DateTime | ATime | ad | ./. | Returns the result of ADate. |
Permissions | Permissions | perm | ./. | Returns the result of Permissions. |
TOwnerAndGroupID | Owner | owner | ./. | Returns the result of Owner. |
TOwnerAndGroupID | Group | group | ./. | Returns the result of Group. |
TOwnerAndGroupID | UserID | uid | ./. | Returns the current user's ID (calls posix getuid()). |
TOwnerAndGroupID | GroupID | gid | ./. | Returns the current user's group ID (calls posix getgid()). |
Definition at line 106 of file fileexpressions.inl.
Inner Type Index: | |
struct | FexScope |
class | Filter |
struct | Plugin |
Public Field Index: | |
Compiler | compiler |
The expression compiler. | |
Plugin | plugin |
The file expression Plugin. | |
Public Method Index: | |
ALIB_DLL | FileExpressions () |
Default constructor. | |
ALIB_DLL SPFileFilter | CreateFilter (const String &expressionString) |
Compiler alib::files::FileExpressions::compiler |
The expression compiler.
Definition at line 181 of file fileexpressions.inl.
Plugin alib::files::FileExpressions::plugin |
The file expression Plugin.
Definition at line 182 of file fileexpressions.inl.
alib::files::FileExpressions::FileExpressions | ( | ) |
Default constructor.
Definition at line 240 of file fileexpressions.cpp.
SPFileFilter alib::files::FileExpressions::CreateFilter | ( | const String & | expressionString | ) |
Creates a file filter using the expression compiler of this instance.
expressionString | The expression string to filter files and directories. |
Definition at line 248 of file fileexpressions.cpp.