Commit 1abf31ff by Maarten L. Hekkelman

no-validate option in cif::Row::assign

parent aec60829
...@@ -792,7 +792,7 @@ class Row ...@@ -792,7 +792,7 @@ class Row
} }
void assign(const std::vector<Item> &values); void assign(const std::vector<Item> &values);
void assign(std::string_view name, const std::string &value, bool updateLinked); void assign(std::string_view name, const std::string &value, bool updateLinked, bool validate = true);
bool operator==(const Row &rhs) const bool operator==(const Row &rhs) const
{ {
...@@ -814,7 +814,7 @@ class Row ...@@ -814,7 +814,7 @@ class Row
friend std::ostream &operator<<(std::ostream &os, const Row &row); friend std::ostream &operator<<(std::ostream &os, const Row &row);
private: private:
void assign(size_t column, const std::string &value, bool updateLinked); void assign(size_t column, const std::string &value, bool updateLinked, bool validate = true);
void assign(const Item &i, bool updateLinked); void assign(const Item &i, bool updateLinked);
static void swap(size_t column, ItemRow *a, ItemRow *b); static void swap(size_t column, ItemRow *a, ItemRow *b);
......
...@@ -3009,12 +3009,12 @@ void Row::assign(const Item &value, bool skipUpdateLinked) ...@@ -3009,12 +3009,12 @@ void Row::assign(const Item &value, bool skipUpdateLinked)
assign(value.name(), value.value(), skipUpdateLinked); assign(value.name(), value.value(), skipUpdateLinked);
} }
void Row::assign(std::string_view name, const std::string &value, bool skipUpdateLinked) void Row::assign(std::string_view name, const std::string &value, bool skipUpdateLinked, bool validate)
{ {
try try
{ {
auto cat = mData->mCategory; auto cat = mData->mCategory;
assign(cat->addColumn(name), value, skipUpdateLinked); assign(cat->addColumn(name), value, skipUpdateLinked, validate);
} }
catch (const std::exception &ex) catch (const std::exception &ex)
{ {
...@@ -3024,7 +3024,7 @@ void Row::assign(std::string_view name, const std::string &value, bool skipUpdat ...@@ -3024,7 +3024,7 @@ void Row::assign(std::string_view name, const std::string &value, bool skipUpdat
} }
} }
void Row::assign(size_t column, const std::string &value, bool skipUpdateLinked) void Row::assign(size_t column, const std::string &value, bool skipUpdateLinked, bool validate)
{ {
if (mData == nullptr) if (mData == nullptr)
throw std::logic_error("invalid Row, no data assigning value '" + value + "' to column with index " + std::to_string(column)); throw std::logic_error("invalid Row, no data assigning value '" + value + "' to column with index " + std::to_string(column));
...@@ -3050,7 +3050,7 @@ void Row::assign(size_t column, const std::string &value, bool skipUpdateLinked) ...@@ -3050,7 +3050,7 @@ void Row::assign(size_t column, const std::string &value, bool skipUpdateLinked)
std::string oldStrValue = oldValue ? oldValue : ""; std::string oldStrValue = oldValue ? oldValue : "";
// check the value // check the value
if (col.mValidator) if (col.mValidator and validate)
(*col.mValidator)(value); (*col.mValidator)(value);
// If the field is part of the Key for this Category, remove it from the index // If the field is part of the Key for this Category, remove it from the index
......
...@@ -109,7 +109,7 @@ void FileImpl::load_data(const char *data, size_t length) ...@@ -109,7 +109,7 @@ void FileImpl::load_data(const char *data, size_t length)
// if (mData.getValidator() == nullptr) // if (mData.getValidator() == nullptr)
mData.loadDictionary("mmcif_pdbx_v50"); mData.loadDictionary("mmcif_pdbx_v50");
if (not mData.isValid() and cif::VERBOSE >= 0) if (not mData.isValid() and cif::VERBOSE >= 0)
std::cerr << "Invalid mmCIF file" << (cif::VERBOSE ? "." : " use --verbose option to see errors") << std::endl; std::cerr << "Invalid mmCIF file" << (cif::VERBOSE > 0 ? "." : " use --verbose option to see errors") << std::endl;
} }
void FileImpl::load(const std::filesystem::path &path) void FileImpl::load(const std::filesystem::path &path)
...@@ -181,7 +181,7 @@ void FileImpl::load(const std::filesystem::path &path) ...@@ -181,7 +181,7 @@ void FileImpl::load(const std::filesystem::path &path)
// if (mData.getValidator() == nullptr) // if (mData.getValidator() == nullptr)
mData.loadDictionary("mmcif_pdbx_v50"); mData.loadDictionary("mmcif_pdbx_v50");
if (not mData.isValid() and cif::VERBOSE >= 0) if (not mData.isValid() and cif::VERBOSE >= 0)
std::cerr << "Invalid mmCIF file" << (cif::VERBOSE ? "." : " use --verbose option to see errors") << std::endl; std::cerr << "Invalid mmCIF file" << (cif::VERBOSE > 0 ? "." : " use --verbose option to see errors") << std::endl;
} }
void FileImpl::save(const std::filesystem::path &path) void FileImpl::save(const std::filesystem::path &path)
...@@ -295,17 +295,14 @@ void Atom::AtomImpl::moveTo(const Point &p) ...@@ -295,17 +295,14 @@ void Atom::AtomImpl::moveTo(const Point &p)
if (not mClone) if (not mClone)
{ {
set_property("Cartn_x", std::to_string(p.getX())); // set_property("Cartn_x", std::to_string(p.getX()));
set_property("Cartn_y", std::to_string(p.getY())); // set_property("Cartn_y", std::to_string(p.getY()));
set_property("Cartn_z", std::to_string(p.getZ())); // set_property("Cartn_z", std::to_string(p.getZ()));
mRow.assign("Cartn_x", std::to_string(p.getX()), true);
mRow.assign("Cartn_y", std::to_string(p.getY()), true);
mRow.assign("Cartn_z", std::to_string(p.getZ()), true);
} }
// boost::format kPosFmt("%.3f");
//
// mRow["Cartn_x"] = (kPosFmt % p.getX()).str();
// mRow["Cartn_y"] = (kPosFmt % p.getY()).str();
// mRow["Cartn_z"] = (kPosFmt % p.getZ()).str();
mLocation = p; mLocation = p;
} }
......
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