Commit e853cd1c by Maarten L. Hekkelman

set_validator changes

parent b9544033
...@@ -49,6 +49,7 @@ void datablock::set_validator(const validator *v) ...@@ -49,6 +49,7 @@ void datablock::set_validator(const validator *v)
} }
catch (const std::exception &) catch (const std::exception &)
{ {
m_validator = nullptr;
throw_with_nested(std::runtime_error("Error while setting validator in datablock " + m_name)); throw_with_nested(std::runtime_error("Error while setting validator in datablock " + m_name));
} }
} }
......
...@@ -31,11 +31,32 @@ namespace cif ...@@ -31,11 +31,32 @@ namespace cif
{ {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// TODO: This is wrong. A validator should be assigned to datablocks,
// not to a file. Since audit_conform is a category specifying the
// content of a datablock. Not the entire file.
void file::set_validator(const validator *v) void file::set_validator(const validator *v)
{ {
m_validator = v; m_validator = v;
for (auto &db : *this) for (bool first = true; auto &db : *this)
{
try
{
db.set_validator(v); db.set_validator(v);
}
catch (const std::exception &e)
{
if (first)
throw;
// Accept failure on secondary datablocks
// now that many mmCIF files have invalid
// restraint data concatenated.
std::cerr << e.what() << '\n';
}
first = false;
}
} }
bool file::is_valid() const bool file::is_valid() const
...@@ -125,7 +146,8 @@ void file::load_dictionary(std::string_view name) ...@@ -125,7 +146,8 @@ void file::load_dictionary(std::string_view name)
bool file::contains(std::string_view name) const bool file::contains(std::string_view name) const
{ {
return std::find_if(begin(), end(), [name](const datablock &db) { return iequals(db.name(), name); }) != end(); return std::find_if(begin(), end(), [name](const datablock &db)
{ return iequals(db.name(), name); }) != end();
} }
datablock &file::operator[](std::string_view name) datablock &file::operator[](std::string_view name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment