TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
Expression resolver based on the definition of symbols. More...
#include <tsExpressions.h>
Public Member Functions | |
Expressions (Report &report, int debug_level=Severity::Debug, const UString &debug_prefix=UString()) | |
Constructor. | |
bool | define (const UString &symbol, const UString &context=UString()) |
Define a symbol in the internal repository. | |
bool | error () const |
Check if errors occured (invalid symbols, invalid expressions). | |
bool | evaluate (const UString &expression, const UString &context=UString()) |
Evaluate a boolean expression using symbols. | |
bool | isDefined (const UString &symbol) const |
Check if a symbol is defined in the internal repository. | |
bool | isValidSymbolName (const UString &symbol, const UString &context=UString()) |
Check if a string is valid symbol name and report an error if not. | |
void | resetError () |
Reset the error indicator. | |
size_t | symbolCount () const |
Get the number of defined symbols. | |
bool | undefine (const UString &symbol, const UString &context=UString()) |
Undefine a symbol from the internal repository. | |
void | undefineAll () |
Undefine all symbols, clear the symbol database. | |
Static Public Member Functions | |
static bool | IsValidSymbolName (const UString &symbol) |
Check if a string is valid symbol name. | |
Expression resolver based on the definition of symbols.
Symbols are words starting with a letter and made of alphanumerical characters and underscores. Symbol names are case sensitive. Symbols can be defined and undefined in an internal repository of the Expressions object.
Boolean expressions are evaluated based on the definition of symbols. A symbol evaluates to true when it is defined and false when it is not. The unary operator '!' is the negation. The binary operators '&&' and '||' can be used. Parentheses can be used to group sub-expressions.
|
explicit |
Constructor.
[in,out] | report | Where to report errors. |
[in] | debug_level | Severity level for debug messages. |
[in] | debug_prefix | Prefix string for debug messages. |
Define a symbol in the internal repository.
[in] | symbol | The symbol to add in the internal repository. |
[in] | context | Optional context of the symbol, for error message only. |
Undefine a symbol from the internal repository.
[in] | symbol | The symbol to remove from the internal repository. |
[in] | context | Optional context of the symbol, for error message only. |
|
inline |
Get the number of defined symbols.
|
inline |
Check if a symbol is defined in the internal repository.
[in] | symbol | The symbol to check. |
bool ts::Expressions::isValidSymbolName | ( | const UString & | symbol, |
const UString & | context = UString() |
||
) |
Check if a string is valid symbol name and report an error if not.
[in] | symbol | The symbol to check. |
[in] | context | Optional context of the symbol, for error message only. |
|
static |
Check if a string is valid symbol name.
[in] | symbol | The name to check. |
Evaluate a boolean expression using symbols.
[in] | expression | The expression to evaluate. |
[in] | context | Optional context of the symbol, for error message only. |
|
inline |
Check if errors occured (invalid symbols, invalid expressions).
|
inline |
Reset the error indicator.