Config file readers#
The functions in gko::ext::config turn a JSON or YAML document into the
gko::config::pnode tree that gko::config::parse
consumes. The JSON readers in <ginkgo/extensions/config/json_config.hpp>
require nlohmann_json, and the YAML readers in
<ginkgo/extensions/config/yaml_config.hpp> require yaml-cpp.
parse_json_file and parse_json_string read a JSON document from a file or
from a string, and parse_json converts an already parsed
nlohmann::json object. parse_yaml_file reads a YAML file, and parse_yaml
converts a YAML::Node; to use one entry of a YAML file as the configuration,
call parse_yaml on that node.
- inline gko::config::pnode gko::ext::config::parse_json(
- const nlohmann::json &input,
parse_json takes the nlohmann json object to generate the property tree object
- inline gko::config::pnode gko::ext::config::parse_json_file(
- const std::string &filename,
parse_json_file takes the json file to generate the property tree object
- inline gko::config::pnode gko::ext::config::parse_json_string(
- std::string json,
parse_json_string takes a json string to generate the property tree object
- inline gko::config::pnode gko::ext::config::parse_yaml(
- const YAML::Node &input,
parse_yaml takes a yaml-cpp node object to generate the property tree object
- inline gko::config::pnode gko::ext::config::parse_yaml_file(
- std::string filename,
parse_yaml_file takes the yaml file to generate the property tree object
for example,
when passing the file to this function,reuse: &reuse_config ... actual: << *reuse ...
reuseandactualare valid entries such that we can not randomly pick one as solver.By doing so, we know the// yaml is the object from the file auto solver_factory = parse_yaml(yaml["actual"]);
actualentry is the solver to parse.Note
Because YAML always needs a entry for reusing, there will be more than one entry when putting the anchors in the top level. It is unclear which entry is the actual solver to parse, so please use the parse_yaml function and specify the actual entry.
See also