Class ScriptReader

Nested Relationships

Nested Types

Class Documentation

class ScriptReader

This class handles reading script files parsing special instructions that will get replaced.

When parsing the script code, it is supported to have

  • Variable replacements using {{ VARIABLE_NAME }}

  • Including other files using {% include <filename> %}. The filename has to be relative to the root script file’s folder

  • Conditionals using

    {% if <condition %}
      ...
    {% elif <condition> %}
      ...
    {% else %}
      ...
    {% endif %}
    

Those directives use Jinja2 notation.

Public Types

using DataVariant = std::variant<std::string, double, int, bool, VersionInformation>
using DataDict = std::unordered_map<std::string, DataVariant>

Public Functions

ScriptReader() = default
std::string readScriptFile(const std::string &file_path, const DataDict &data = DataDict())

Reads a script file and applies variable replacements, includes, and conditionals.

Parameters:
  • file_path – Path of the script file to be loaded.

  • data – Data dictionary used for variable replacements and expression evaluation.

Returns:

The Script code with all replacements, includes and conditionals applied.

Public Static Functions

static bool evaluateExpression(const std::string &expression, const DataDict &data)

Evaluate a boolean expression.

Parameters:
  • expression – The boolean expression to be evaluated.

  • data – A data dictionary that will be used when evaluating the expressions

Returns:

The result of evaluating the boolean expression