diff --git a/include/cif++/item.hpp b/include/cif++/item.hpp index ce29f9a..da5b029 100644 --- a/include/cif++/item.hpp +++ b/include/cif++/item.hpp @@ -30,7 +30,6 @@ #include #include -#include #include #include #include @@ -238,7 +237,7 @@ class item_value explicit operator bool() const noexcept { - bool result; + bool result = false; switch (m_data.m_type) { case item_value_type::INT: result = m_data.m_value.m_integer != 0; break; @@ -592,15 +591,15 @@ struct item_handle [[nodiscard]] item_value &value(); [[nodiscard]] const item_value &value() const; - [[nodiscard]] constexpr bool is_inapplicable() const noexcept { return value().type() == item_value_type::INAPPLICABLE; } - [[nodiscard]] constexpr bool is_missing() const noexcept { return value().type() == item_value_type::MISSING; } - [[nodiscard]] constexpr bool is_null() const noexcept { return is_inapplicable() or is_missing(); } + [[nodiscard]] bool is_inapplicable() const noexcept { return value().type() == item_value_type::INAPPLICABLE; } + [[nodiscard]] bool is_missing() const noexcept { return value().type() == item_value_type::MISSING; } + [[nodiscard]] bool is_null() const noexcept { return is_inapplicable() or is_missing(); } - [[nodiscard]] constexpr bool is_string() const noexcept { return value().type() == item_value_type::TEXT; } + [[nodiscard]] bool is_string() const noexcept { return value().type() == item_value_type::TEXT; } - [[nodiscard]] constexpr bool is_number_int() const noexcept { return value().type() == item_value_type::INT; } - [[nodiscard]] constexpr bool is_number_float() const noexcept { return value().type() == item_value_type::FLOAT; } - [[nodiscard]] constexpr bool is_number() const noexcept { return is_number_int() or is_number_float(); } + [[nodiscard]] bool is_number_int() const noexcept { return value().type() == item_value_type::INT; } + [[nodiscard]] bool is_number_float() const noexcept { return value().type() == item_value_type::FLOAT; } + [[nodiscard]] bool is_number() const noexcept { return is_number_int() or is_number_float(); } [[nodiscard]] auto type() const { return value().type(); } @@ -731,15 +730,15 @@ struct const_item_handle [[nodiscard]] const item_value &value() const; - [[nodiscard]] constexpr bool is_inapplicable() const noexcept { return value().type() == item_value_type::INAPPLICABLE; } - [[nodiscard]] constexpr bool is_missing() const noexcept { return value().type() == item_value_type::MISSING; } - [[nodiscard]] constexpr bool is_null() const noexcept { return is_inapplicable() or is_missing(); } + [[nodiscard]] bool is_inapplicable() const noexcept { return value().type() == item_value_type::INAPPLICABLE; } + [[nodiscard]] bool is_missing() const noexcept { return value().type() == item_value_type::MISSING; } + [[nodiscard]] bool is_null() const noexcept { return is_inapplicable() or is_missing(); } - [[nodiscard]] constexpr bool is_string() const noexcept { return value().type() == item_value_type::TEXT; } + [[nodiscard]] bool is_string() const noexcept { return value().type() == item_value_type::TEXT; } - [[nodiscard]] constexpr bool is_number_int() const noexcept { return value().type() == item_value_type::INT; } - [[nodiscard]] constexpr bool is_number_float() const noexcept { return value().type() == item_value_type::FLOAT; } - [[nodiscard]] constexpr bool is_number() const noexcept { return is_number_int() or is_number_float(); } + [[nodiscard]] bool is_number_int() const noexcept { return value().type() == item_value_type::INT; } + [[nodiscard]] bool is_number_float() const noexcept { return value().type() == item_value_type::FLOAT; } + [[nodiscard]] bool is_number() const noexcept { return is_number_int() or is_number_float(); } [[nodiscard]] auto type() const { return value().type(); } diff --git a/include/cif++/point.hpp b/include/cif++/point.hpp index 4ace773..d51b3d4 100644 --- a/include/cif++/point.hpp +++ b/include/cif++/point.hpp @@ -946,10 +946,10 @@ class spherical_dots const point operator[](uint32_t inIx) const { return m_points[inIx]; } /// \brief iterator pointing to the first point - iterator begin() const { return m_points.begin(); } + [[nodiscard]] iterator begin() const { return m_points.begin(); } /// \brief iterator pointing past the last point - iterator end() const { return m_points.end(); } + [[nodiscard]] iterator end() const { return m_points.end(); } /// \brief return the *weight*, [[nodiscard]] double weight() const { return W; } diff --git a/src/item.cpp b/src/item.cpp index af78e69..e5ec219 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -189,6 +190,9 @@ std::string item_value::str() const return r.ec == std::errc{} ? std::string{ s, r.ptr } : "*****"; } + + default: + throw std::runtime_error("invalid data type"); } } diff --git a/src/pdb/reconstruct.cpp b/src/pdb/reconstruct.cpp index 1dc965e..33f28e3 100644 --- a/src/pdb/reconstruct.cpp +++ b/src/pdb/reconstruct.cpp @@ -1121,8 +1121,8 @@ void createPdbxPolySeqScheme(datablock &db) auto &atom_site = db["atom_site"]; auto &entity_poly = db["entity_poly"]; - auto &entity_poly_seq = db["entity_poly_seq"]; - auto &struct_asym = db["struct_asym"]; + // auto &entity_poly_seq = db["entity_poly_seq"]; + // auto &struct_asym = db["struct_asym"]; auto &pdbx_poly_seq_scheme = db["pdbx_poly_seq_scheme"]; // Find the mapping between asym_id and pdb_strand_id first diff --git a/src/validate.cpp b/src/validate.cpp index 44c9396..70f658e 100644 --- a/src/validate.cpp +++ b/src/validate.cpp @@ -169,8 +169,6 @@ type_validator::type_validator(std::string_view name, DDL_PrimitiveType type, st int type_validator::compare(const item_value &a, const item_value &b) const { - int result = 0; - switch (m_primitive_type) { case DDL_PrimitiveType::Numb: @@ -199,6 +197,9 @@ int type_validator::compare(const item_value &a, const item_value &b) const return a.compare(b, false); return a.str().compare(b.str()); + + default: + throw std::runtime_error("invalid primitive type"); } }