Commit 627d3b9d by Maarten L. Hekkelman

export by default, fixes for MSVC

parent ba28ade4
......@@ -40,8 +40,8 @@ include(GenerateExportHeader)
set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
# set(CMAKE_CXX_VISIBILITY_PRESET hidden)
# set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
......
......@@ -194,7 +194,7 @@ enum class ionic_radius_type
effective, crystal
};
struct CIFPP_EXPORT atom_type_info
struct atom_type_info
{
atom_type type;
std::string name;
......@@ -204,12 +204,12 @@ struct CIFPP_EXPORT atom_type_info
float radii[kRadiusTypeCount];
};
CIFPP_EXPORT extern const atom_type_info kKnownAtoms[];
extern CIFPP_EXPORT const atom_type_info kKnownAtoms[];
// --------------------------------------------------------------------
// AtomTypeTraits
class CIFPP_EXPORT atom_type_traits
class atom_type_traits
{
public:
atom_type_traits(atom_type a);
......
......@@ -45,7 +45,7 @@ namespace cif
// --------------------------------------------------------------------
// special exception
class CIFPP_EXPORT duplicate_key_error : public std::runtime_error
class duplicate_key_error : public std::runtime_error
{
public:
duplicate_key_error(const std::string &msg)
......@@ -54,7 +54,7 @@ class CIFPP_EXPORT duplicate_key_error : public std::runtime_error
// --------------------------------------------------------------------
class CIFPP_EXPORT category
class category
{
public:
friend class row_handle;
......
......@@ -67,7 +67,7 @@ bond_type from_string(const std::string &bondType);
/// \brief struct containing information about an atom in a chemical compound.
/// This is a subset of the available information. Contact the author if you need more fields.
struct CIFPP_EXPORT compound_atom
struct compound_atom
{
std::string id;
atom_type type_symbol;
......@@ -86,7 +86,7 @@ struct CIFPP_EXPORT compound_atom
/// --------------------------------------------------------------------
/// \brief struct containing information about the bonds
struct CIFPP_EXPORT compound_bond
struct compound_bond
{
std::string atom_id[2];
bond_type type;
......@@ -101,7 +101,7 @@ struct CIFPP_EXPORT compound_bond
/// compound definitions by calling the addExtraComponents function and
/// pass it a valid CCD formatted file.
class CIFPP_EXPORT compound
class compound
{
public:
// accessors
......@@ -149,7 +149,7 @@ class CIFPP_EXPORT compound
// --------------------------------------------------------------------
// Factory class for compound and Link objects
class CIFPP_EXPORT compound_factory
class compound_factory
{
public:
/// \brief Initialise a singleton instance.
......@@ -180,7 +180,7 @@ class CIFPP_EXPORT compound_factory
~compound_factory();
static const std::map<std::string, char> kAAMap, kBaseMap;
static CIFPP_EXPORT const std::map<std::string, char> kAAMap, kBaseMap;
private:
compound_factory();
......
......@@ -40,16 +40,16 @@ namespace cif
// --------------------------------------------------------------------
// let's make life easier
CIFPP_EXPORT iset get_category_fields(const category &cat);
CIFPP_EXPORT uint16_t get_column_ix(const category &cat, std::string_view col);
CIFPP_EXPORT bool is_column_type_uchar(const category &cat, std::string_view col);
iset get_category_fields(const category &cat);
uint16_t get_column_ix(const category &cat, std::string_view col);
bool is_column_type_uchar(const category &cat, std::string_view col);
// --------------------------------------------------------------------
// some more templates to be able to do querying
namespace detail
{
struct CIFPP_EXPORT condition_impl
struct condition_impl
{
virtual ~condition_impl() {}
......@@ -61,7 +61,7 @@ namespace detail
virtual bool equals(const condition_impl *rhs) const { return false; }
};
struct CIFPP_EXPORT all_condition_impl : public condition_impl
struct all_condition_impl : public condition_impl
{
bool test(row_handle) const override { return true; }
void str(std::ostream &os) const override { os << "*"; }
......@@ -72,7 +72,7 @@ namespace detail
struct not_condition_impl;
} // namespace detail
class CIFPP_EXPORT condition
class condition
{
public:
using condition_impl = detail::condition_impl;
......@@ -155,7 +155,7 @@ class CIFPP_EXPORT condition
namespace detail
{
struct CIFPP_EXPORT key_is_empty_condition_impl : public condition_impl
struct key_is_empty_condition_impl : public condition_impl
{
key_is_empty_condition_impl(const std::string &item_tag)
: m_item_tag(item_tag)
......@@ -182,7 +182,7 @@ namespace detail
uint16_t m_item_ix = 0;
};
struct CIFPP_EXPORT key_equals_condition_impl : public condition_impl
struct key_equals_condition_impl : public condition_impl
{
key_equals_condition_impl(item &&i)
: m_item_tag(i.name())
......@@ -228,7 +228,7 @@ namespace detail
std::optional<row_handle> m_single_hit;
};
struct CIFPP_EXPORT key_equals_or_empty_condition_impl : public condition_impl
struct key_equals_or_empty_condition_impl : public condition_impl
{
key_equals_or_empty_condition_impl(key_equals_condition_impl *equals)
: m_item_tag(equals->m_item_tag)
......@@ -286,7 +286,7 @@ namespace detail
std::optional<row_handle> m_single_hit;
};
struct CIFPP_EXPORT key_compare_condition_impl : public condition_impl
struct key_compare_condition_impl : public condition_impl
{
template <typename COMP>
key_compare_condition_impl(const std::string &item_tag, COMP &&comp, const std::string &s)
......@@ -320,7 +320,7 @@ namespace detail
std::string m_str;
};
struct CIFPP_EXPORT key_matches_condition_impl : public condition_impl
struct key_matches_condition_impl : public condition_impl
{
key_matches_condition_impl(const std::string &item_tag, const std::regex &rx)
: m_item_tag(item_tag)
......@@ -352,7 +352,7 @@ namespace detail
};
template <typename T>
struct CIFPP_EXPORT any_is_condition_impl : public condition_impl
struct any_is_condition_impl : public condition_impl
{
typedef T valueType;
......@@ -392,7 +392,7 @@ namespace detail
valueType mValue;
};
struct CIFPP_EXPORT any_matches_condition_impl : public condition_impl
struct any_matches_condition_impl : public condition_impl
{
any_matches_condition_impl(const std::regex &rx)
: mRx(rx)
......@@ -434,7 +434,7 @@ namespace detail
// TODO: Optimize and_condition by having a list of sub items.
// That way you can also collapse multiple _is_ conditions in
// case they make up an indexed tuple.
struct CIFPP_EXPORT and_condition_impl : public condition_impl
struct and_condition_impl : public condition_impl
{
and_condition_impl() = default;
......@@ -537,7 +537,7 @@ namespace detail
std::vector<condition_impl *> m_sub;
};
struct CIFPP_EXPORT or_condition_impl : public condition_impl
struct or_condition_impl : public condition_impl
{
or_condition_impl(condition &&a, condition &&b)
{
......@@ -628,7 +628,7 @@ namespace detail
std::vector<condition_impl *> m_sub;
};
struct CIFPP_EXPORT not_condition_impl : public condition_impl
struct not_condition_impl : public condition_impl
{
not_condition_impl(condition &&a)
: mA(nullptr)
......@@ -705,7 +705,7 @@ inline condition operator or(condition &&a, condition &&b)
return condition(std::move(b));
}
struct CIFPP_EXPORT empty_type
struct empty_type
{
};
......@@ -713,7 +713,7 @@ struct CIFPP_EXPORT empty_type
inline constexpr empty_type null = empty_type();
struct CIFPP_EXPORT key
struct key
{
explicit key(const std::string &itemTag)
: m_item_tag(itemTag)
......@@ -829,7 +829,7 @@ inline condition operator not(condition &&rhs)
return condition(new detail::not_condition_impl(std::move(rhs)));
}
struct CIFPP_EXPORT any_type
struct any_type
{
};
......
......@@ -34,7 +34,7 @@ namespace cif
// --------------------------------------------------------------------
class CIFPP_EXPORT datablock : public std::list<category>
class datablock : public std::list<category>
{
public:
datablock() = default;
......
......@@ -31,6 +31,6 @@
namespace cif
{
CIFPP_EXPORT validator parse_dictionary(std::string_view name, std::istream &is);
validator parse_dictionary(std::string_view name, std::istream &is);
} // namespace cif
......@@ -37,7 +37,7 @@ namespace cif
// --------------------------------------------------------------------
class CIFPP_EXPORT file : public std::list<datablock>
class file : public std::list<datablock>
{
public:
file() = default;
......
......@@ -39,7 +39,7 @@ namespace cif
namespace detail
{
template <typename T>
struct CIFPP_EXPORT to_varg
struct to_varg
{
using type = T;
......@@ -54,7 +54,7 @@ namespace detail
};
template <>
struct CIFPP_EXPORT to_varg<const char *>
struct to_varg<const char *>
{
using type = const char *;
......@@ -69,7 +69,7 @@ namespace detail
};
template <>
struct CIFPP_EXPORT to_varg<std::string>
struct to_varg<std::string>
{
using type = const char *;
......@@ -86,7 +86,7 @@ namespace detail
} // namespace
template <typename... Args>
class CIFPP_EXPORT format_plus_arg
class format_plus_arg
{
public:
using args_vector_type = std::tuple<detail::to_varg<Args>...>;
......@@ -141,7 +141,7 @@ constexpr auto format(std::string_view fmt, Args... args)
// --------------------------------------------------------------------
/// A streambuf that fills out lines with spaces up until a specified width
class CIFPP_EXPORT fill_out_streambuf : public std::streambuf
class fill_out_streambuf : public std::streambuf
{
public:
using base_type = std::streambuf;
......
......@@ -34,15 +34,15 @@
namespace cif
{
class CIFPP_EXPORT category;
class CIFPP_EXPORT datablock;
class CIFPP_EXPORT file;
class CIFPP_EXPORT parser;
class category;
class datablock;
class file;
class parser;
class CIFPP_EXPORT row;
class CIFPP_EXPORT row_handle;
class row;
class row_handle;
class CIFPP_EXPORT item;
struct CIFPP_EXPORT item_handle;
class item;
struct item_handle;
} // namespace cif
\ No newline at end of file
......@@ -51,7 +51,7 @@ namespace cif
// --------------------------------------------------------------------
/// \brief item is a transient class that is used to pass data into rows
/// but it also takes care of formatting data.
class CIFPP_EXPORT item
class item
{
public:
/// \brief Default constructor, empty item
......@@ -188,7 +188,7 @@ class CIFPP_EXPORT item
/// Typically, more than 99% of the strings in an mmCIF file are less
/// than 8 bytes in length.
struct CIFPP_EXPORT item_value
struct item_value
{
item_value() = default;
......@@ -265,7 +265,7 @@ struct CIFPP_EXPORT item_value
/// \brief This is item_handle, it is used to access the data stored in item_value.
struct CIFPP_EXPORT item_handle
struct item_handle
{
public:
// conversion helper class
......@@ -354,7 +354,7 @@ struct CIFPP_EXPORT item_handle
{
}
CIFPP_EXPORT static const item_handle s_null_item;
static CIFPP_EXPORT const item_handle s_null_item;
friend void swap(item_handle a, item_handle b)
{
......
......@@ -45,7 +45,7 @@ class structure;
// --------------------------------------------------------------------
class CIFPP_EXPORT atom
class atom
{
private:
struct atom_impl : public std::enable_shared_from_this<atom_impl>
......@@ -388,7 +388,7 @@ enum class EntityType
// --------------------------------------------------------------------
class CIFPP_EXPORT residue
class residue
{
public:
friend class structure;
......@@ -499,7 +499,7 @@ class CIFPP_EXPORT residue
// --------------------------------------------------------------------
// a monomer models a single residue in a protein chain
class CIFPP_EXPORT monomer : public residue
class monomer : public residue
{
public:
// monomer();
......@@ -570,7 +570,7 @@ class CIFPP_EXPORT monomer : public residue
// --------------------------------------------------------------------
class CIFPP_EXPORT polymer : public std::vector<monomer>
class polymer : public std::vector<monomer>
{
public:
polymer(structure &s, const std::string &entityID, const std::string &asymID, const std::string &auth_asym_id);
......@@ -599,9 +599,9 @@ class CIFPP_EXPORT polymer : public std::vector<monomer>
// --------------------------------------------------------------------
// sugar and branch, to describe glycosylation sites
class CIFPP_EXPORT branch;
class branch;
class CIFPP_EXPORT sugar : public residue
class sugar : public residue
{
public:
sugar(branch &branch, const std::string &compoundID,
......@@ -638,7 +638,7 @@ class CIFPP_EXPORT sugar : public residue
atom m_link;
};
class CIFPP_EXPORT branch : public std::vector<sugar>
class branch : public std::vector<sugar>
{
public:
branch(structure &structure, const std::string &asym_id, const std::string &entity_id);
......@@ -724,7 +724,7 @@ inline bool operator&(StructureOpenOptions a, StructureOpenOptions b)
// --------------------------------------------------------------------
class CIFPP_EXPORT structure
class structure
{
public:
structure(file &p, size_t modelNr = 1, StructureOpenOptions options = {});
......
......@@ -36,7 +36,7 @@ namespace cif
// --------------------------------------------------------------------
class CIFPP_EXPORT parse_error : public std::runtime_error
class parse_error : public std::runtime_error
{
public:
parse_error(uint32_t line_nr, const std::string &message)
......@@ -49,7 +49,7 @@ class CIFPP_EXPORT parse_error : public std::runtime_error
// TODO: Need to implement support for transformed long lines
class CIFPP_EXPORT sac_parser
class sac_parser
{
public:
using datablock_index = std::map<std::string, std::size_t>;
......@@ -94,7 +94,7 @@ class CIFPP_EXPORT sac_parser
static bool is_unquoted_string(std::string_view text)
{
bool result = is_ordinary(text.front());
bool result = text.empty() or is_ordinary(text.front());
if (result)
{
......@@ -267,7 +267,7 @@ class CIFPP_EXPORT sac_parser
// --------------------------------------------------------------------
class CIFPP_EXPORT parser : public sac_parser
class parser : public sac_parser
{
public:
parser(std::istream &is, file &file)
......
......@@ -35,10 +35,6 @@
namespace cif
{
extern const int
kResidueNrWildcard,
kNoSeqNum;
struct tls_selection;
struct tls_residue;
......
......@@ -51,7 +51,7 @@ const double
// We use quaternions to do rotations in 3d space
template <typename T>
class CIFPP_EXPORT quaternion_type
class quaternion_type
{
public:
using value_type = T;
......@@ -355,7 +355,7 @@ using quaternion = quaternion_type<float>;
// tie(x, y, z) = atom.loc();
template <typename F>
struct CIFPP_EXPORT point_type
struct point_type
{
using value_type = F;
......@@ -682,21 +682,21 @@ constexpr auto distance_point_to_line(const point_type<F> &l1, const point_type<
// a random direction with a distance randomly chosen from a normal
// distribution with a stddev of offset.
CIFPP_EXPORT point nudge(point p, float offset);
point nudge(point p, float offset);
// --------------------------------------------------------------------
CIFPP_EXPORT quaternion construct_from_angle_axis(float angle, point axis);
CIFPP_EXPORT std::tuple<double, point> quaternion_to_angle_axis(quaternion q);
quaternion construct_from_angle_axis(float angle, point axis);
std::tuple<double, point> quaternion_to_angle_axis(quaternion q);
/// @brief Given four points and an angle, return the quaternion required to rotate
/// point p4 along the p2-p3 axis and around point p3 to obtain the required within
/// an accuracy of esd
CIFPP_EXPORT quaternion construct_for_dihedral_angle(point p1, point p2, point p3, point p4,
quaternion construct_for_dihedral_angle(point p1, point p2, point p3, point p4,
float angle, float esd);
CIFPP_EXPORT point centroid(const std::vector<point> &Points);
CIFPP_EXPORT point center_points(std::vector<point> &Points);
point centroid(const std::vector<point> &Points);
point center_points(std::vector<point> &Points);
/// \brief Returns how the two sets of points \a a and \b b can be aligned
///
......@@ -704,10 +704,10 @@ CIFPP_EXPORT point center_points(std::vector<point> &Points);
/// \param b The second set of points
/// \result The quaternion which should be applied to the points in \a a to
/// obtain the best superposition.
CIFPP_EXPORT quaternion align_points(const std::vector<point> &a, const std::vector<point> &b);
quaternion align_points(const std::vector<point> &a, const std::vector<point> &b);
/// \brief The RMSd for the points in \a a and \a b
CIFPP_EXPORT double RMSd(const std::vector<point> &a, const std::vector<point> &b);
double RMSd(const std::vector<point> &a, const std::vector<point> &b);
// --------------------------------------------------------------------
// Helper class to generate evenly divided points on a sphere
......
......@@ -103,7 +103,7 @@ auto tie(Ts &...v)
// --------------------------------------------------------------------
/// \brief the row class, this one is not directly accessible from the outside
class CIFPP_EXPORT row : public std::vector<item_value>
class row : public std::vector<item_value>
{
public:
row() = default;
......@@ -145,7 +145,7 @@ class CIFPP_EXPORT row : public std::vector<item_value>
// --------------------------------------------------------------------
/// \brief row_handle is the way to access data stored in rows
class CIFPP_EXPORT row_handle
class row_handle
{
public:
friend struct item_handle;
......@@ -265,7 +265,7 @@ class CIFPP_EXPORT row_handle
// --------------------------------------------------------------------
class CIFPP_EXPORT row_initializer : public std::vector<item>
class row_initializer : public std::vector<item>
{
public:
friend class category;
......
......@@ -44,7 +44,7 @@ enum class space_group_name
Hall
};
struct CIFPP_EXPORT space_group
struct space_group
{
const char *name;
const char *xHM;
......@@ -57,7 +57,7 @@ extern CIFPP_EXPORT const std::size_t kNrOfSpaceGroups;
// --------------------------------------------------------------------
struct CIFPP_EXPORT symop_data
struct symop_data
{
constexpr symop_data(const std::array<int, 15> &data)
: m_packed((data[0] & 0x03ULL) << 34 bitor
......@@ -122,7 +122,7 @@ struct CIFPP_EXPORT symop_data
uint64_t m_packed;
};
struct CIFPP_EXPORT symop_datablock
struct symop_datablock
{
constexpr symop_datablock(int spacegroup, int rotational_number, const std::array<int, 15> &rt_data)
: m_v((spacegroup & 0xffffULL) << 48 bitor
......@@ -141,12 +141,12 @@ struct CIFPP_EXPORT symop_datablock
static_assert(sizeof(symop_datablock) == sizeof(uint64_t), "Size of symop_data is wrong");
CIFPP_EXPORT extern const symop_datablock kSymopNrTable[];
CIFPP_EXPORT extern const std::size_t kSymopNrTableSize;
extern CIFPP_EXPORT const symop_datablock kSymopNrTable[];
extern CIFPP_EXPORT const std::size_t kSymopNrTableSize;
// --------------------------------------------------------------------
CIFPP_EXPORT int get_space_group_number(std::string spacegroup); // alternative for clipper's parsing code, using space_group_name::full
CIFPP_EXPORT int get_space_group_number(std::string spacegroup, space_group_name type); // alternative for clipper's parsing code
int get_space_group_number(std::string spacegroup); // alternative for clipper's parsing code, using space_group_name::full
int get_space_group_number(std::string spacegroup, space_group_name type); // alternative for clipper's parsing code
} // namespace cif
......@@ -109,16 +109,16 @@ namespace cif
// some basic utilities: Since we're using ASCII input only, we define for optimisation
// our own case conversion routines.
CIFPP_EXPORT bool iequals(std::string_view a, std::string_view b);
CIFPP_EXPORT int icompare(std::string_view a, std::string_view b);
bool iequals(std::string_view a, std::string_view b);
int icompare(std::string_view a, std::string_view b);
CIFPP_EXPORT bool iequals(const char *a, const char *b);
CIFPP_EXPORT int icompare(const char *a, const char *b);
bool iequals(const char *a, const char *b);
int icompare(const char *a, const char *b);
CIFPP_EXPORT void to_lower(std::string &s);
CIFPP_EXPORT std::string to_lower_copy(std::string_view s);
void to_lower(std::string &s);
std::string to_lower_copy(std::string_view s);
CIFPP_EXPORT void to_upper(std::string &s);
void to_upper(std::string &s);
// std::string toUpperCopy(const std::string &s);
template <typename IterType>
......@@ -181,7 +181,7 @@ std::vector<StringType> split(std::string_view s, std::string_view separators, b
return result;
}
CIFPP_EXPORT void replace_all(std::string &s, std::string_view what, std::string_view with = {});
void replace_all(std::string &s, std::string_view what, std::string_view with = {});
#if defined(__cpp_lib_starts_ends_with)
......@@ -225,15 +225,15 @@ inline bool contains(std::string_view s, std::string_view q)
#endif
CIFPP_EXPORT bool icontains(std::string_view s, std::string_view q);
bool icontains(std::string_view s, std::string_view q);
CIFPP_EXPORT void trim_left(std::string &s);
CIFPP_EXPORT void trim_right(std::string &s);
CIFPP_EXPORT void trim(std::string &s);
void trim_left(std::string &s);
void trim_right(std::string &s);
void trim(std::string &s);
CIFPP_EXPORT std::string trim_left_copy(std::string_view s);
CIFPP_EXPORT std::string trim_right_copy(std::string_view s);
CIFPP_EXPORT std::string trim_copy(std::string_view s);
std::string trim_left_copy(std::string_view s);
std::string trim_right_copy(std::string_view s);
std::string trim_copy(std::string_view s);
// To make life easier, we also define iless and iset using iequals
......@@ -250,7 +250,7 @@ typedef std::set<std::string, iless> iset;
// --------------------------------------------------------------------
// This really makes a difference, having our own tolower routines
extern const uint8_t kCharToLowerMap[256];
extern CIFPP_EXPORT const uint8_t kCharToLowerMap[256];
inline char tolower(int ch)
{
......@@ -259,17 +259,17 @@ inline char tolower(int ch)
// --------------------------------------------------------------------
CIFPP_EXPORT std::tuple<std::string, std::string> split_tag_name(std::string_view tag);
std::tuple<std::string, std::string> split_tag_name(std::string_view tag);
// --------------------------------------------------------------------
// generate a cif name, mainly used to generate asym_id's
CIFPP_EXPORT std::string cif_id_for_number(int number);
std::string cif_id_for_number(int number);
// --------------------------------------------------------------------
// custom wordwrapping routine
CIFPP_EXPORT std::vector<std::string> word_wrap(const std::string &text, size_t width);
std::vector<std::string> word_wrap(const std::string &text, size_t width);
// --------------------------------------------------------------------
/// std::from_chars for floating point types.
......@@ -449,8 +449,8 @@ std::to_chars_result to_chars(char *first, char *last, FloatType &value, chars_f
template <typename FloatType, std::enable_if_t<std::is_floating_point_v<FloatType>, int> = 0>
std::to_chars_result to_chars(char *first, char *last, FloatType &value, chars_format fmt, int precision)
{
int size = last - first;
int r;
int size = static_cast<int>(last - first);
int r = 0;
switch (fmt)
{
......
......@@ -55,18 +55,18 @@ namespace cif
extern CIFPP_EXPORT int VERBOSE;
// the git 'build' number
CIFPP_EXPORT std::string get_version_nr();
std::string get_version_nr();
// std::string get_version_date();
// --------------------------------------------------------------------
// Code helping with terminal i/o
CIFPP_EXPORT uint32_t get_terminal_width();
uint32_t get_terminal_width();
// --------------------------------------------------------------------
// Path of the current executable
CIFPP_EXPORT std::string get_executable_path();
std::string get_executable_path();
// --------------------------------------------------------------------
// some manipulators to write coloured text to terminals
......@@ -157,7 +157,7 @@ inline auto coloured(std::basic_string<CharT, Traits, Alloc> &s, StringColour fo
// --------------------------------------------------------------------
// A progress bar
class CIFPP_EXPORT Progress
class Progress
{
public:
Progress(int64_t inMax, const std::string &inAction);
......@@ -178,8 +178,8 @@ class CIFPP_EXPORT Progress
// --------------------------------------------------------------------
// Resources
CIFPP_EXPORT std::unique_ptr<std::istream> load_resource(std::filesystem::path name);
CIFPP_EXPORT void add_file_resource(const std::string &name, std::filesystem::path dataFile);
CIFPP_EXPORT void add_data_directory(std::filesystem::path dataDir);
std::unique_ptr<std::istream> load_resource(std::filesystem::path name);
void add_file_resource(const std::string &name, std::filesystem::path dataFile);
void add_data_directory(std::filesystem::path dataDir);
} // namespace cif
......@@ -40,7 +40,7 @@ struct category_validator;
// --------------------------------------------------------------------
class CIFPP_EXPORT validation_error : public std::exception
class validation_error : public std::exception
{
public:
validation_error(const std::string &msg);
......@@ -59,11 +59,11 @@ enum class DDL_PrimitiveType
Numb
};
CIFPP_EXPORT DDL_PrimitiveType map_to_primitive_type(std::string_view s);
DDL_PrimitiveType map_to_primitive_type(std::string_view s);
struct regex_impl;
struct CIFPP_EXPORT type_validator
struct type_validator
{
std::string m_name;
DDL_PrimitiveType m_primitive_type;
......@@ -100,7 +100,7 @@ struct CIFPP_EXPORT type_validator
int compare(std::string_view a, std::string_view b) const;
};
struct CIFPP_EXPORT item_validator
struct item_validator
{
std::string m_tag;
bool m_mandatory;
......@@ -133,7 +133,7 @@ struct CIFPP_EXPORT item_validator
void operator()(std::string_view value) const;
};
struct CIFPP_EXPORT category_validator
struct category_validator
{
std::string m_name;
std::vector<std::string> m_keys;
......@@ -156,7 +156,7 @@ struct CIFPP_EXPORT category_validator
}
};
struct CIFPP_EXPORT link_validator
struct link_validator
{
int m_link_group_id;
std::string m_parent_category;
......@@ -168,7 +168,7 @@ struct CIFPP_EXPORT link_validator
// --------------------------------------------------------------------
class CIFPP_EXPORT validator
class validator
{
public:
validator(std::string_view name)
......@@ -217,7 +217,7 @@ class CIFPP_EXPORT validator
};
// --------------------------------------------------------------------
class CIFPP_EXPORT validator_factory
class validator_factory
{
public:
static validator_factory &instance()
......
......@@ -1241,10 +1241,10 @@ size_t category::erase(condition &&cond, std::function<void(row_handle)> &&visit
for (auto &&[childCat, link] : m_child_links)
{
auto cond = get_children_condition(*ri, *childCat);
if (not cond)
auto ccond = get_children_condition(*ri, *childCat);
if (not ccond)
continue;
potential_orphans[childCat] = std::move(potential_orphans[childCat]) or std::move(cond);
potential_orphans[childCat] = std::move(potential_orphans[childCat]) or std::move(ccond);
}
save_value sv(m_validator);
......
......@@ -1153,7 +1153,7 @@ branch::branch(structure &structure, const std::string &asym_id, const std::stri
auto &branch_scheme = db["pdbx_branch_scheme"];
auto &branch_link = db["pdbx_entity_branch_link"];
for (const auto &entity_id : struct_asym.find<std::string>("id"_key == asym_id, "entity_id"))
for (const auto &asym_entity_id : struct_asym.find<std::string>("id"_key == asym_id, "entity_id"))
{
for (const auto &[comp_id, num] : branch_scheme.find<std::string, int>(
"asym_id"_key == asym_id, "mon_id", "pdb_seq_num"))
......@@ -1162,7 +1162,7 @@ branch::branch(structure &structure, const std::string &asym_id, const std::stri
}
for (const auto &[num1, num2, atom1, atom2] : branch_link.find<size_t, size_t, std::string, std::string>(
"entity_id"_key == entity_id, "entity_branch_list_num_1", "entity_branch_list_num_2", "atom_id_1", "atom_id_2"))
"entity_id"_key == asym_entity_id, "entity_branch_list_num_1", "entity_branch_list_num_2", "atom_id_1", "atom_id_2"))
{
// if (not iequals(atom1, "c1"))
// throw std::runtime_error("invalid pdbx_entity_branch_link");
......@@ -1236,7 +1236,7 @@ sugar &branch::construct_sugar(const std::string &compound_id)
{"type", compound->type()}});
}
sugar &result = emplace_back(*this, compound_id, m_asym_id, size() + 1);
sugar &result = emplace_back(*this, compound_id, m_asym_id, static_cast<int>(size() + 1));
db["pdbx_branch_scheme"].emplace({
{"asym_id", result.get_asym_id()},
......
......@@ -369,7 +369,7 @@ quaternion construct_for_dihedral_angle(point p1, point p2, point p3, point p4,
float dh = dihedral_angle(p1, p2, p3, p4);
for (int iteration = 0; iteration < 100; ++iteration)
{
float delta = std::fmod(angle - dh, 360);
float delta = std::fmod(angle - dh, 360.0f);
if (delta < -180)
delta += 360;
......
......@@ -407,9 +407,9 @@ struct rsrc_imp
#if _MSC_VER
extern "C" const mrsrc::rsrc_imp *gResourceIndexDefault[1] = {};
extern "C" const char *gResourceDataDefault[1] = {};
extern "C" const char *gResourceNameDefault[1] = {};
extern "C" CIFPP_EXPORT const mrsrc::rsrc_imp *gResourceIndexDefault[1] = {};
extern "C" CIFPP_EXPORT const char *gResourceDataDefault[1] = {};
extern "C" CIFPP_EXPORT const char *gResourceNameDefault[1] = {};
extern "C" const mrsrc::rsrc_imp gResourceIndex[];
extern "C" const char gResourceData[];
......
......@@ -93,13 +93,13 @@ BOOST_AUTO_TEST_CASE(t1)
const auto &&[angle0, axis0] = cif::quaternion_to_angle_axis(q);
std::vector<cif::point> p1{
{ 16.979, 13.301, 44.555 },
{ 18.150, 13.525, 43.680 },
{ 18.656, 14.966, 43.784 },
{ 17.890, 15.889, 44.078 },
{ 17.678, 13.270, 42.255 },
{ 16.248, 13.734, 42.347 },
{ 15.762, 13.216, 43.724 }
{ 16.979f, 13.301f, 44.555f },
{ 18.150f, 13.525f, 43.680f },
{ 18.656f, 14.966f, 43.784f },
{ 17.890f, 15.889f, 44.078f },
{ 17.678f, 13.270f, 42.255f },
{ 16.248f, 13.734f, 42.347f },
{ 15.762f, 13.216f, 43.724f }
};
auto p2 = p1;
......@@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(t1)
for (auto &p : p1)
p.rotate(q2);
float rmsd = cif::RMSd(p1, p2);
auto rmsd = cif::RMSd(p1, p2);
BOOST_TEST(rmsd < 1e-5);
......@@ -175,27 +175,27 @@ BOOST_AUTO_TEST_CASE(dh_q_1)
float angle;
cif::point pts[4];
} tests[] = {
{ -97.5,
{ { 68.8649979, -7.34800005, 54.3769989 },
{ 68.1350021, -8.18700027, 53.6489983 },
{ 68.7760239, -9.07335377, 52.7140236 },
{ 68.9000015, -10.3944235, 53.2217026 } } },
{ 80.3,
{ { 0.304512024, 0.531184196, 2.25860214 },
{ 0.956512451, 0.0321846008, 1.07460022 },
{ -97.5f,
{ { 68.8649979f, -7.34800005f, 54.3769989f },
{ 68.1350021f, -8.18700027f, 53.6489983f },
{ 68.7760239f, -9.07335377f, 52.7140236f },
{ 68.9000015f, -10.3944235f, 53.2217026f } } },
{ 80.3f,
{ { 0.304512024f, 0.531184196f, 2.25860214f },
{ 0.956512451f, 0.0321846008f, 1.07460022f },
{ 0, 0, 0 },
{ 0.21336633, -1.09552193, -0.878999829 } } },
{ -97.5,
{ { 0.088973999, 1.72535372, 1.66297531 },
{ -0.641021729, 0.886353493, 0.93497467 },
{ 0.21336633f, -1.09552193f, -0.878999829f } } },
{ -97.5f,
{ { 0.088973999f, 1.72535372f, 1.66297531f },
{ -0.641021729f, 0.886353493f, 0.93497467f },
{ 0, 0, 0 },
{ 1.29433727, -0.395142615, 0.432300746 } } },
{ -97.5,
{ 1.29433727f, -0.395142615f, 0.432300746f } } },
{ -97.5f,
{
{ 0.088973999, 1.72535372, 1.66297531 },
{ -0.641021729, 0.886353493, 0.93497467 },
{ 0.088973999f, 1.72535372f, 1.66297531f },
{ -0.641021729f, 0.886353493f, 0.93497467f },
{ 0, 0, 0 },
{ 1.33983064, 0.384027064, -0.275154471 },
{ 1.33983064f, 0.384027064f, -0.275154471f },
} }
};
......
......@@ -78,23 +78,23 @@ bool init_unit_test()
BOOST_AUTO_TEST_CASE(cc_1)
{
std::tuple<std::string_view, float, char> tests[] = {
{ "1.0", 1.0, 0 },
{ "1.0e10", 1.0e10, 0 },
{ "-1.1e10", -1.1e10, 0 },
{ "-.2e11", -.2e11, 0 },
{ "1.3e-10", 1.3e-10, 0 },
{ "1.0 ", 1.0, ' ' },
{ "1.0e10 ", 1.0e10, ' ' },
{ "-1.1e10 ", -1.1e10, ' ' },
{ "-.2e11 ", -.2e11, ' ' },
{ "1.3e-10 ", 1.3e-10, ' ' },
{ "3.0", 3.0, 0 },
{ "3.0 ", 3.0, ' ' },
{ "3.000000", 3.0, 0 },
{ "3.000000 ", 3.0, ' ' },
{ "1.0", 1.0f, 0 },
{ "1.0e10", 1.0e10f, 0 },
{ "-1.1e10", -1.1e10f, 0 },
{ "-.2e11", -.2e11f, 0 },
{ "1.3e-10", 1.3e-10f, 0 },
{ "1.0 ", 1.0f, ' ' },
{ "1.0e10 ", 1.0e10f, ' ' },
{ "-1.1e10 ", -1.1e10f, ' ' },
{ "-.2e11 ", -.2e11f, ' ' },
{ "1.3e-10 ", 1.3e-10f, ' ' },
{ "3.0", 3.0f, 0 },
{ "3.0 ", 3.0f, ' ' },
{ "3.000000", 3.0f, 0 },
{ "3.000000 ", 3.0f, ' ' },
};
for (const auto &[txt, val, ch] : tests)
......@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(cc_1)
BOOST_AUTO_TEST_CASE(cc_2)
{
std::tuple<float, int, std::string_view> tests[] = {
{ 1.1, 1, "1.1" }
{ 1.1f, 1, "1.1" }
};
for (const auto &[val, prec, test] : tests)
......@@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(item_1)
using namespace cif;
item i1("1", "1");
item i2("2", 2.0);
item i2("2", 2.0f);
item i3("3", '3');
item ci1(i1);
......@@ -163,23 +163,23 @@ BOOST_AUTO_TEST_CASE(r_1)
c.emplace({
{ "f-1", 1 },
{ "f-2", "two" },
{ "f-3", 3.0, 3 },
{ "f-3", 3.0f, 3 },
});
auto row = c.front();
BOOST_CHECK_EQUAL(row["f-1"].compare(1), 0);
BOOST_CHECK_EQUAL(row["f-2"].compare("two"), 0);
BOOST_CHECK_EQUAL(row["f-3"].compare(3.0), 0); // This fails when running in valgrind... sigh
BOOST_CHECK_EQUAL(row["f-3"].compare(3.0f), 0); // This fails when running in valgrind... sigh
const auto &[f1, f2, f3] = row.get<int, std::string, float>("f-1", "f-2", "f-3");
BOOST_CHECK_EQUAL(f1, 1);
BOOST_CHECK_EQUAL(f2, "two");
BOOST_CHECK_EQUAL(f3, 3.0); // This fails when running in valgrind... sigh
BOOST_CHECK_EQUAL(f3, 3.0f); // This fails when running in valgrind... sigh
BOOST_CHECK_EQUAL(row.get<int>("f-1"), 1);
BOOST_CHECK_EQUAL(row.get<std::string>("f-2"), "two");
BOOST_CHECK_EQUAL(row.get<float>("f-3"), 3.0);
BOOST_CHECK_EQUAL(row.get<float>("f-3"), 3.0f);
int f_1;
std::string f_2;
......@@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(r_1)
BOOST_CHECK_EQUAL(f_1, 1);
BOOST_CHECK_EQUAL(f_2, "two");
BOOST_CHECK_EQUAL(f_3, 3.0); // This fails when running in valgrind... sigh
BOOST_CHECK_EQUAL(f_3, 3.0f); // This fails when running in valgrind... sigh
}
BOOST_AUTO_TEST_CASE(r_2)
......@@ -486,14 +486,14 @@ _test.value
BOOST_CHECK_EQUAL(++n, 1);
BOOST_CHECK_EQUAL(r["id"].as<int>(), 1);
BOOST_CHECK_EQUAL(r["name"].as<std::string>(), "aap");
BOOST_CHECK_EQUAL(r["value"].as<float>(), 1.0);
BOOST_CHECK_EQUAL(r["value"].as<float>(), 1.0f);
}
auto t = test.find(cif::key("id") == 1);
BOOST_CHECK(not t.empty());
BOOST_CHECK_EQUAL(t.front()["name"].as<std::string>(), "aap");
auto t2 = test.find(cif::key("value") == 1.2);
auto t2 = test.find(cif::key("value") == 1.2f);
BOOST_CHECK(not t2.empty());
BOOST_CHECK_EQUAL(t2.front()["name"].as<std::string>(), "mies");
}
......
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