mola-yaml: YAML parsing helper functions

Overview

// structs

struct mola::YAMLParseOptions;

// global functions

std::string mola::parse_yaml(const std::string& text, const YAMLParseOptions& opts = YAMLParseOptions());

mrpt::containers::yaml mola::parse_yaml(
    const mrpt::containers::yaml& input,
    const YAMLParseOptions& opts = YAMLParseOptions()
    );

mrpt::containers::yaml mola::load_yaml_file(const std::string& fileName, const YAMLParseOptions& opts = YAMLParseOptions());
std::string mola::yaml_to_string(const mrpt::containers::yaml& cfg);

// macros

#define ENSURE_YAML_ENTRY_EXISTS( \
    _c, \
    _name \
    )

#define YAML_LOAD_MEMBER_OPT( \
    _varname, \
    _type \
    )

#define YAML_LOAD_MEMBER_REQ( \
    _varname, \
    _type \
    )

#define YAML_LOAD_OPT(...)

#define YAML_LOAD_OPT2( \
    _varname, \
    _type \
    )

#define YAML_LOAD_OPT3( \
    _param_str, \
    _varname, \
    _type \
    )

#define YAML_LOAD_OPT_DEG(...)

#define YAML_LOAD_OPT_DEG2( \
    _varname, \
    _type \
    )

#define YAML_LOAD_OPT_DEG3( \
    _param_str, \
    _varname, \
    _type \
    )

#define YAML_LOAD_REQ(...)

#define YAML_LOAD_REQ2( \
    _varname, \
    _type \
    )

#define YAML_LOAD_REQ3( \
    _param_str, \
    _varname, \
    _type \
    )

#define YAML_LOAD_REQ_DEG(...)

#define YAML_LOAD_REQ_DEG2( \
    _varname, \
    _type \
    )

#define YAML_LOAD_REQ_DEG3( \
    _param_str, \
    _varname, \
    _type \
    )

Global Functions

std::string mola::parse_yaml(const std::string& text, const YAMLParseOptions& opts = YAMLParseOptions())

Parses: system run expressions ``, environment variables ``${VAR}.

mrpt::containers::yaml mola::load_yaml_file(
    const std::string& fileName,
    const YAMLParseOptions& opts = YAMLParseOptions()
    )

Loads and parses a YAML file.

This is equivalent to calling mrpt::containers::yaml::FromFile(), setting the relative path in YAMLParseOptions, calling parseYaml(), and reparsing as a mrpt::containers::yaml class again.

See also:

parseYaml

std::string mola::yaml_to_string(const mrpt::containers::yaml& cfg)

Converts a yaml node into a string

Macros

#define YAML_LOAD_MEMBER_OPT(_varname, _type)

Use YAML_LOAD_MEMBER_OPT(foo,double); to load YAML var foo into foo_

#define YAML_LOAD_MEMBER_REQ(_varname, _type)

Use YAML_LOAD_MEMBER_REQ(foo,double); to load YAML var foo into foo_

#define YAML_LOAD_OPT3(_param_str, _varname, _type)

Loads (optional) variable named “_varname” from the YAML config named cfg into the variable _param_str._varname

#define YAML_LOAD_OPT_DEG3(_param_str, _varname, _type)

like YAML_LOAD_OPT, values in the YAML file in “degrees” stored in rads

#define YAML_LOAD_REQ3(_param_str, _varname, _type)

Loads (required) variable named “_varname” from the YAML config named cfg into the variable _param_str._varname

#define YAML_LOAD_REQ_DEG3(_param_str, _varname, _type)

like YAML_LOAD_REQ, values in the YAML file in “degrees” stored in rads