1 #ifndef CASM_database_json_io_impl
2 #define CASM_database_json_io_impl
29 template <
typename DataObject>
32 std::string name_key, std::string sel_key,
34 std::vector<std::string> obj_names;
36 kwargs.
get_else(obj_names, name_key, std::vector<std::string>());
37 kwargs.
get_else(sel_name, sel_key, std::string(
"NONE"));
40 for (
const auto &
name : obj_names) {
42 if (!sel.
db().count(
name)) {
44 std::string msg =
"Error in make_selection<" + type_name<DataObject>() +
45 ">: \"" +
name +
"\" is not in the database.";
46 throw std::runtime_error(msg);
50 std::string msg =
"Error in make_selection<" + type_name<DataObject>() +
52 throw std::runtime_error(msg);
Database< ObjType > & db() const
bool get_else(T &t, const std::string &key, const T &default_value, Args &&... args) const
DB::Selection< DataObject > make_selection(DB::Database< DataObject > &db, const jsonParser &kwargs, std::string name_key, std::string sel_key, OnError on_error=OnError::THROW)
Make a DB::Selection from JSON input.
GenericDatumFormatter< std::string, DataObject > name()