struct mola::YAMLParseOptions

Overview

Options controlling which pre-processing steps parse_yaml() runs.

Pre-processing is performed in the following fixed order:

  1. ** $include{path} ** - replaced with the contents of the referenced YAML file (recursive; relative paths resolved against includesBasePath). In the SAME pass, the ** $import ** map directive is also resolved: a map whose $import key names one (scalar) or several (sequence) external YAML files is replaced by the deep-merge of those file(s) with the map’s REMAINING keys overlaid on top, so the sibling entries OVERRIDE particular entries of the imported base (nested maps merge deeply; scalars/sequences replace). Example: ` params: $import: shared-params.yaml # base (a path, or a sequence of paths) max_rate_hz: 10.0 # override one entry of the imported base `` ``Also resolved in this pass: the ** $define ** map directive, which binds ${NAME} variables for the subtree of the map it appears in, INCLUDING the files pulled in by a sibling $import / $include{} . This lets a launcher drive the ${VAR|default}` hooks an imported file already exposes, instead of duplicating a block just to change one nested value: ` $define: MOLA_DESKEW_METHOD: "MotionCompensationMethod::IMU" $import: lidar3d-default.yaml `` ``Priority is real environment > $define > inline |default`, so a variable exported on the command line still overrides the YAML file. Values are expanded against the OUTER scope only, so entries of the same $define block cannot reference each other (order-independent by design).

  2. ** ```` ** - replaced with the trimmed stdout of the shell command cmd (exit code ≠ 0 throws).

  3. ** ${VAR} ** or ** ${VAR|default} ** - replaced with the value of an environment variable, a custom variables entry, or the built-in CURRENT_YAML_FILE_PATH token (falls back to default when given, otherwise throws if the variable is not defined).

Any of these steps can be individually disabled via the boolean flags below.

#include <yaml_helpers.h>

struct YAMLParseOptions
{
    // fields

    bool doIncludes {true};
    bool doCmdRuns {true};
    bool doEnvVars {true};
    std::map<std::string, std::string> variables;
    std::string includesBasePath;
};

Fields

bool doIncludes {true}

If true (default), process $include{path} directives.

bool doCmdRuns {true}

If true (default), process ```` shell-run substitutions.

bool doEnvVars {true}

If true (default), process ${VAR} / ${VAR|default} variable substitutions from the environment, variables, and built-in tokens.

std::map<std::string, std::string> variables

User-defined variable bindings for ${name} substitutions.

Entries in this map are checked after the real environment variables and the built-in CURRENT_YAML_FILE_PATH token, but before the |default fallback syntax.

A $define block in a YAML file binds variables into this same slot for the subtree it appears in.

std::string includesBasePath

Base directory used to resolve relative $include{} paths.

When non-empty, any relative path inside a $include{} expression is resolved relative to this directory. load_yaml_file() sets this automatically to the directory of the file being loaded.