CASM  1.1.0
A Clusters Approach to Statistical Mechanics
enumerate_supercells_json_io.cc
Go to the documentation of this file.
2 
7 
8 namespace CASM {
9 
17  jsonParser const &json_options, jsonParser const &cli_options_as_json) {
18  // combine JSON options and CLI options
19  jsonParser json_combined{json_options};
20 
21  if (cli_options_as_json.contains("min")) {
22  json_combined["min"] = cli_options_as_json["min"];
23  }
24  if (cli_options_as_json.contains("max")) {
25  json_combined["max"] = cli_options_as_json["max"];
26  }
27  if (cli_options_as_json.contains("filter")) {
28  json_combined["filter"] = cli_options_as_json["filter"];
29  }
30  if (cli_options_as_json.contains("dry_run")) {
31  json_combined["dry_run"] = cli_options_as_json["dry_run"];
32  }
33  if (cli_options_as_json.contains("verbosity")) {
34  json_combined["verbosity"] = cli_options_as_json["verbosity"];
35  }
36 
37  return json_combined;
38 }
39 
40 // Enable InputParser<EnumerateSupercellsOptions>
42  std::string method_name, PrimClex const &primclex,
44  parser.value = notstd::make_unique<EnumerateSupercellsOptions>(primclex);
45  auto &options = *parser.value;
46 
47  options.method_name = method_name;
48 
49  parser.optional_else(options.dry_run, "dry_run", false);
50 
51  options.verbosity = parse_verbosity(parser);
52 
53  std::vector<std::string> filter_expression;
54  parser.optional(filter_expression, "filter");
55  if (filter_expression.size()) {
56  options.filter = make_data_formatter_filter(filter_expression, dict);
57  }
58 }
59 
60 } // namespace CASM
Parsing dictionary for constructing a DataFormatter<DataObject> object.
std::unique_ptr< RequiredType > optional(fs::path option, Args &&... args)
RequiredType optional_else(fs::path option, const RequiredType &_default, Args &&... args)
std::unique_ptr< T > value
Definition: InputParser.hh:234
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
Definition: jsonParser.cc:601
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser combine_supercell_enum_json_options(jsonParser const &json_options, jsonParser const &cli_options_as_json)
DataFormatterFilter< DataObject > make_data_formatter_filter(std::string const &filter_expr, DataFormatterDictionary< DataObject > const &_dict)
int parse_verbosity(KwargsParser &parser, int default_verbosity=10)
Definition: InputParser.cc:123
void parse(InputParser< ConfigEnumOptions > &parser, std::string method_name, PrimClex const &primclex, DataFormatterDictionary< Configuration > const &dict)
PrimClex * primclex
Definition: settings.cc:135