Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:pdb-redo/libcifpp into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Mar 12, 2024
2 parents 3ebceb7 + 92bd52d commit 917e0ba
Show file tree
Hide file tree
Showing 19 changed files with 168 additions and 146 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cmake_minimum_required(VERSION 3.16)
# set the project name
project(
libcifpp
VERSION 7.0.1
VERSION 7.0.2
LANGUAGES CXX)

list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down
5 changes: 5 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Version 7.0.2
- Fix in testing error_code results.

Version 7.0.1
- Various reconstruction fixes
- category order in output fixed
- better implementation of constructors for file, datablock and category
- small optimisation in iterator

Version 7.0.0
- Renaming many methods and parameters to be more
Expand Down
3 changes: 2 additions & 1 deletion include/cif++/category.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class category

/// @brief Update the links in this category
/// @param db The enclosing @ref datablock
void update_links(datablock &db);
void update_links(const datablock &db);

/// @brief Return the global @ref validator for the data
/// @return The @ref validator or nullptr if not assigned
Expand Down Expand Up @@ -1263,6 +1263,7 @@ class category
{
}

// TODO: NEED TO FIX THIS!
category *linked;
const link_validator *v;
};
Expand Down
10 changes: 5 additions & 5 deletions include/cif++/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class item
char buffer[32];

auto r = to_chars(buffer, buffer + sizeof(buffer) - 1, value, chars_format::fixed, precision);
if (r.ec != std::errc())
if ((bool)r.ec)
throw std::runtime_error("Could not format number");

m_value.assign(buffer, r.ptr - buffer);
Expand All @@ -136,7 +136,7 @@ class item
char buffer[32];

auto r = to_chars(buffer, buffer + sizeof(buffer) - 1, value, chars_format::general);
if (r.ec != std::errc())
if ((bool)r.ec)
throw std::runtime_error("Could not format number");

m_value.assign(buffer, r.ptr - buffer);
Expand All @@ -151,7 +151,7 @@ class item
char buffer[32];

auto r = std::to_chars(buffer, buffer + sizeof(buffer) - 1, value);
if (r.ec != std::errc())
if ((bool)r.ec)
throw std::runtime_error("Could not format number");

m_value.assign(buffer, r.ptr - buffer);
Expand Down Expand Up @@ -560,7 +560,7 @@ struct item_handle::item_value_as<T, std::enable_if_t<std::is_arithmetic_v<T> an

std::from_chars_result r = (b + 1 < e and *b == '+' and std::isdigit(b[1])) ? selected_charconv<value_type>::from_chars(b + 1, e, result) : selected_charconv<value_type>::from_chars(b, e, result);

if (r.ec != std::errc() or r.ptr != e)
if ((bool)r.ec or r.ptr != e)
{
result = {};
if (cif::VERBOSE)
Expand Down Expand Up @@ -595,7 +595,7 @@ struct item_handle::item_value_as<T, std::enable_if_t<std::is_arithmetic_v<T> an

std::from_chars_result r = (b + 1 < e and *b == '+' and std::isdigit(b[1])) ? selected_charconv<value_type>::from_chars(b + 1, e, v) : selected_charconv<value_type>::from_chars(b, e, v);

if (r.ec != std::errc() or r.ptr != e)
if ((bool)r.ec or r.ptr != e)
{
if (cif::VERBOSE)
{
Expand Down
2 changes: 1 addition & 1 deletion include/cif++/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ class sugar : public residue
{
int result;
auto r = std::from_chars(m_auth_seq_id.data(), m_auth_seq_id.data() + m_auth_seq_id.length(), result);
if (r.ec != std::errc())
if ((bool)r.ec)
throw std::runtime_error("The auth_seq_id should be a number for a sugar");
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions include/cif++/text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ std::from_chars_result from_chars(const char *first, const char *last, FloatType
int exponent = 0;
bool done = false;

while (not done and result.ec == std::errc())
while (not done and not (bool)result.ec)
{
char ch = result.ptr != last ? *result.ptr : 0;
++result.ptr;
Expand Down Expand Up @@ -467,7 +467,7 @@ std::from_chars_result from_chars(const char *first, const char *last, FloatType
}
}

if (result.ec == std::errc())
if (not (bool)result.ec)
{
long double v = f * vi * sign;
if (exponent != 0)
Expand Down
8 changes: 4 additions & 4 deletions src/category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ void category::set_validator(const validator *v, datablock &db)
update_links(db);
}

void category::update_links(datablock &db)
void category::update_links(const datablock &db)
{
m_child_links.clear();
m_parent_links.clear();
Expand All @@ -675,15 +675,15 @@ void category::update_links(datablock &db)
{
for (auto link : m_validator->get_links_for_parent(m_name))
{
auto childCat = db.get(link->m_child_category);
auto childCat = const_cast<category *>(db.get(link->m_child_category));
if (childCat == nullptr)
continue;
m_child_links.emplace_back(childCat, link);
}

for (auto link : m_validator->get_links_for_child(m_name))
{
auto parentCat = db.get(link->m_parent_category);
auto parentCat = const_cast<category *>(db.get(link->m_parent_category));
if (parentCat == nullptr)
continue;
m_parent_links.emplace_back(parentCat, link);
Expand Down Expand Up @@ -791,7 +791,7 @@ bool category::is_valid() const

iv->validate_value(vi->text(), ec);

if (ec != std::errc())
if ((bool)ec)
{
m_validator->report_error(ec, m_name, m_items[cix].m_name, false);
continue;
Expand Down
Loading

0 comments on commit 917e0ba

Please sign in to comment.