class CCL::ExpressionParser

Overview

Evaluates arithmetic expressions with variables ($i), properties and constant literals. More…

#include <expressionparser.h>

class ExpressionParser: public CCL::TextParser
{
public:
    // structs

    struct DivideHelper;
    struct IVariableResolver;

    // classes

    class AttributesVariableResolver;

    // methods

    static bool evaluate (
        Variant& value,
        StringRef expression,
        const IVariableResolver& resolver
    );

    static bool evaluate (
        Variant& value,
        StringRef expression,
        const IAttributeList& variables
    );
};

Inherited Members

public:
    // methods

    void addWhitespace (uchar c);
    void addIdentifierChar (uchar c);
    uchar peek () const;
    bool advance ();
    uchar read ();
    bool read (uchar c);
    int read (String& string, int length);
    bool readUntil (CStringPtr delimiters, String& string);
    bool readUntil (uchar delimiter, String& string);
    bool readUntil (StringRef delimiter, String& string);
    String& readIdentifier (String& ident);
    void readIdentifier (char* ident, int bufferSize);
    bool readPropertyPath (MutableCString& string);
    String& readStringLiteral (String& string, uchar quote = '"');
    bool readFloat (float& value, bool withExponent = true);
    bool readFloat (double& value, bool withExponent = true);
    bool readInt (int& value);
    bool readInt (int64& value);
    void skipWhite ();
    bool skipLine ();
    bool readLine (String& line);

Detailed Documentation

Evaluates arithmetic expressions with variables ($i), properties and constant literals.

Operands can be

  • numeric integer literals: -23

  • string literals in single quotes: ‘Hamburg’

  • variables: $var

  • (absolute) property paths: ^://hostapp/DocumentManager/ActiveDocument.title

Supported operators: (highest precedence first, parenthesis “()” can be used) ! (logical NOT) / %

    • > >= < <= = (result is 1 if true, 0 otherwise) & | (logical AND, OR)