![]() |
TSDuck v3.46-4964
MPEG Transport Stream Toolkit
|
#include <tsExpressions.h>
Public Member Functions | |
| Expressions (Report &report, int debug_level=Severity::Debug, const UString &debug_prefix=UString()) | |
| bool | define (const UString &symbol, const UString &context=UString()) |
| bool | error () const |
| bool | evaluate (const UString &expression, const UString &context=UString()) |
| bool | isDefined (const UString &symbol) const |
| bool | isValidSymbolName (const UString &symbol, const UString &context=UString()) |
| void | resetError () |
| void | setMaxNested (size_t max) |
| size_t | symbolCount () const |
| bool | undefine (const UString &symbol, const UString &context=UString()) |
| void | undefineAll () |
Static Public Member Functions | |
| static bool | IsValidSymbolName (const UString &symbol) |
Static Public Attributes | |
| static constexpr size_t | DEFAULT_MAX_NESTED = 256 |
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 |
Undefine all symbols, clear the symbol database.
|
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. |
|
inline |
Set the maximum number of nested levels of parentheses in an expression.
| [in] | max | Maximum number of nested levels of parentheses in an expression. |
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.
|
staticconstexpr |
Default maximum number of nested levels of parentheses in an expression.