This class implements an ALib Expression Compiler Plugin and thus enables "run-time expressions" to work with nodes of FTree
Unless multi-threaded use 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 do not need 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 case insensitive. Furthermore, the 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 types are auto-casted to 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 | Time | time | ./. | Returns the result of MTime . |
DateTime | MTime | mt | ./. | Returns the result of MTime . |
DateTime | CTime | ct | ./. | Returns the result of CTime . |
DateTime | ATime | at | ./. | Returns the result of ATime . |
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 122 of file fileexpressions.hpp.
#include <fileexpressions.hpp>
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_API | FileExpressions () |
ALIB_API SPFileFilter | CreateFilter (const String &expressionString) |
Compiler compiler |
The expression compiler.
Definition at line 194 of file fileexpressions.hpp.
Plugin plugin |
The file expression Plugin.
Definition at line 195 of file fileexpressions.hpp.
FileExpressions | ( | ) |
Default constructor.
Definition at line 209 of file fileexpressions.cpp.
SPFileFilter 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 217 of file fileexpressions.cpp.