Commit 7c111303 by Maarten L. Hekkelman

explicitly export what needs to be exported

parent 151915be
...@@ -194,7 +194,7 @@ enum class ionic_radius_type ...@@ -194,7 +194,7 @@ enum class ionic_radius_type
effective, crystal effective, crystal
}; };
struct atom_type_info struct CIFPP_EXPORT atom_type_info
{ {
atom_type type; atom_type type;
std::string name; std::string name;
...@@ -204,12 +204,12 @@ struct atom_type_info ...@@ -204,12 +204,12 @@ struct atom_type_info
float radii[kRadiusTypeCount]; float radii[kRadiusTypeCount];
}; };
extern const atom_type_info kKnownAtoms[]; CIFPP_EXPORT extern const atom_type_info kKnownAtoms[];
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// AtomTypeTraits // AtomTypeTraits
class atom_type_traits class CIFPP_EXPORT atom_type_traits
{ {
public: public:
atom_type_traits(atom_type a); atom_type_traits(atom_type a);
......
...@@ -45,7 +45,7 @@ namespace cif ...@@ -45,7 +45,7 @@ namespace cif
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// special exception // special exception
class duplicate_key_error : public std::runtime_error class CIFPP_EXPORT duplicate_key_error : public std::runtime_error
{ {
public: public:
duplicate_key_error(const std::string &msg) duplicate_key_error(const std::string &msg)
...@@ -54,7 +54,7 @@ class duplicate_key_error : public std::runtime_error ...@@ -54,7 +54,7 @@ class duplicate_key_error : public std::runtime_error
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class category class CIFPP_EXPORT category
{ {
public: public:
friend class row_handle; friend class row_handle;
......
...@@ -67,7 +67,7 @@ bond_type from_string(const std::string &bondType); ...@@ -67,7 +67,7 @@ bond_type from_string(const std::string &bondType);
/// \brief struct containing information about an atom in a chemical compound. /// \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. /// This is a subset of the available information. Contact the author if you need more fields.
struct compound_atom struct CIFPP_EXPORT compound_atom
{ {
std::string id; std::string id;
atom_type type_symbol; atom_type type_symbol;
...@@ -86,7 +86,7 @@ struct compound_atom ...@@ -86,7 +86,7 @@ struct compound_atom
/// -------------------------------------------------------------------- /// --------------------------------------------------------------------
/// \brief struct containing information about the bonds /// \brief struct containing information about the bonds
struct compound_bond struct CIFPP_EXPORT compound_bond
{ {
std::string atom_id[2]; std::string atom_id[2];
bond_type type; bond_type type;
...@@ -101,7 +101,7 @@ struct compound_bond ...@@ -101,7 +101,7 @@ struct compound_bond
/// compound definitions by calling the addExtraComponents function and /// compound definitions by calling the addExtraComponents function and
/// pass it a valid CCD formatted file. /// pass it a valid CCD formatted file.
class compound class CIFPP_EXPORT compound
{ {
public: public:
// accessors // accessors
...@@ -149,7 +149,7 @@ class compound ...@@ -149,7 +149,7 @@ class compound
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Factory class for compound and Link objects // Factory class for compound and Link objects
class compound_factory class CIFPP_EXPORT compound_factory
{ {
public: public:
/// \brief Initialise a singleton instance. /// \brief Initialise a singleton instance.
......
...@@ -40,16 +40,16 @@ namespace cif ...@@ -40,16 +40,16 @@ namespace cif
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// let's make life easier // let's make life easier
iset get_category_fields(const category &cat); CIFPP_EXPORT iset get_category_fields(const category &cat);
uint16_t get_column_ix(const category &cat, std::string_view col); CIFPP_EXPORT uint16_t get_column_ix(const category &cat, std::string_view col);
bool is_column_type_uchar(const category &cat, std::string_view col); CIFPP_EXPORT bool is_column_type_uchar(const category &cat, std::string_view col);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// some more templates to be able to do querying // some more templates to be able to do querying
namespace detail namespace detail
{ {
struct condition_impl struct CIFPP_EXPORT condition_impl
{ {
virtual ~condition_impl() {} virtual ~condition_impl() {}
...@@ -61,7 +61,7 @@ namespace detail ...@@ -61,7 +61,7 @@ namespace detail
virtual bool equals(const condition_impl *rhs) const { return false; } virtual bool equals(const condition_impl *rhs) const { return false; }
}; };
struct all_condition_impl : public condition_impl struct CIFPP_EXPORT all_condition_impl : public condition_impl
{ {
bool test(row_handle) const override { return true; } bool test(row_handle) const override { return true; }
void str(std::ostream &os) const override { os << "*"; } void str(std::ostream &os) const override { os << "*"; }
...@@ -72,7 +72,7 @@ namespace detail ...@@ -72,7 +72,7 @@ namespace detail
struct not_condition_impl; struct not_condition_impl;
} // namespace detail } // namespace detail
class condition class CIFPP_EXPORT condition
{ {
public: public:
using condition_impl = detail::condition_impl; using condition_impl = detail::condition_impl;
...@@ -155,7 +155,7 @@ class condition ...@@ -155,7 +155,7 @@ class condition
namespace detail namespace detail
{ {
struct key_is_empty_condition_impl : public condition_impl struct CIFPP_EXPORT key_is_empty_condition_impl : public condition_impl
{ {
key_is_empty_condition_impl(const std::string &item_tag) key_is_empty_condition_impl(const std::string &item_tag)
: m_item_tag(item_tag) : m_item_tag(item_tag)
...@@ -182,7 +182,7 @@ namespace detail ...@@ -182,7 +182,7 @@ namespace detail
uint16_t m_item_ix = 0; uint16_t m_item_ix = 0;
}; };
struct key_equals_condition_impl : public condition_impl struct CIFPP_EXPORT key_equals_condition_impl : public condition_impl
{ {
key_equals_condition_impl(item &&i) key_equals_condition_impl(item &&i)
: m_item_tag(i.name()) : m_item_tag(i.name())
...@@ -228,7 +228,7 @@ namespace detail ...@@ -228,7 +228,7 @@ namespace detail
std::optional<row_handle> m_single_hit; std::optional<row_handle> m_single_hit;
}; };
struct key_equals_or_empty_condition_impl : public condition_impl struct CIFPP_EXPORT key_equals_or_empty_condition_impl : public condition_impl
{ {
key_equals_or_empty_condition_impl(key_equals_condition_impl *equals) key_equals_or_empty_condition_impl(key_equals_condition_impl *equals)
: m_item_tag(equals->m_item_tag) : m_item_tag(equals->m_item_tag)
...@@ -286,7 +286,7 @@ namespace detail ...@@ -286,7 +286,7 @@ namespace detail
std::optional<row_handle> m_single_hit; std::optional<row_handle> m_single_hit;
}; };
struct key_compare_condition_impl : public condition_impl struct CIFPP_EXPORT key_compare_condition_impl : public condition_impl
{ {
template <typename COMP> template <typename COMP>
key_compare_condition_impl(const std::string &item_tag, COMP &&comp, const std::string &s) key_compare_condition_impl(const std::string &item_tag, COMP &&comp, const std::string &s)
...@@ -320,7 +320,7 @@ namespace detail ...@@ -320,7 +320,7 @@ namespace detail
std::string m_str; std::string m_str;
}; };
struct key_matches_condition_impl : public condition_impl struct CIFPP_EXPORT key_matches_condition_impl : public condition_impl
{ {
key_matches_condition_impl(const std::string &item_tag, const std::regex &rx) key_matches_condition_impl(const std::string &item_tag, const std::regex &rx)
: m_item_tag(item_tag) : m_item_tag(item_tag)
...@@ -352,7 +352,7 @@ namespace detail ...@@ -352,7 +352,7 @@ namespace detail
}; };
template <typename T> template <typename T>
struct any_is_condition_impl : public condition_impl struct CIFPP_EXPORT any_is_condition_impl : public condition_impl
{ {
typedef T valueType; typedef T valueType;
...@@ -392,7 +392,7 @@ namespace detail ...@@ -392,7 +392,7 @@ namespace detail
valueType mValue; valueType mValue;
}; };
struct any_matches_condition_impl : public condition_impl struct CIFPP_EXPORT any_matches_condition_impl : public condition_impl
{ {
any_matches_condition_impl(const std::regex &rx) any_matches_condition_impl(const std::regex &rx)
: mRx(rx) : mRx(rx)
...@@ -434,7 +434,7 @@ namespace detail ...@@ -434,7 +434,7 @@ namespace detail
// TODO: Optimize and_condition by having a list of sub items. // TODO: Optimize and_condition by having a list of sub items.
// That way you can also collapse multiple _is_ conditions in // That way you can also collapse multiple _is_ conditions in
// case they make up an indexed tuple. // case they make up an indexed tuple.
struct and_condition_impl : public condition_impl struct CIFPP_EXPORT and_condition_impl : public condition_impl
{ {
and_condition_impl() = default; and_condition_impl() = default;
...@@ -537,7 +537,7 @@ namespace detail ...@@ -537,7 +537,7 @@ namespace detail
std::vector<condition_impl *> m_sub; std::vector<condition_impl *> m_sub;
}; };
struct or_condition_impl : public condition_impl struct CIFPP_EXPORT or_condition_impl : public condition_impl
{ {
or_condition_impl(condition &&a, condition &&b) or_condition_impl(condition &&a, condition &&b)
{ {
...@@ -628,7 +628,7 @@ namespace detail ...@@ -628,7 +628,7 @@ namespace detail
std::vector<condition_impl *> m_sub; std::vector<condition_impl *> m_sub;
}; };
struct not_condition_impl : public condition_impl struct CIFPP_EXPORT not_condition_impl : public condition_impl
{ {
not_condition_impl(condition &&a) not_condition_impl(condition &&a)
: mA(nullptr) : mA(nullptr)
...@@ -705,7 +705,7 @@ inline condition operator or(condition &&a, condition &&b) ...@@ -705,7 +705,7 @@ inline condition operator or(condition &&a, condition &&b)
return condition(std::move(b)); return condition(std::move(b));
} }
struct empty_type struct CIFPP_EXPORT empty_type
{ {
}; };
...@@ -713,7 +713,7 @@ struct empty_type ...@@ -713,7 +713,7 @@ struct empty_type
inline constexpr empty_type null = empty_type(); inline constexpr empty_type null = empty_type();
struct key struct CIFPP_EXPORT key
{ {
explicit key(const std::string &itemTag) explicit key(const std::string &itemTag)
: m_item_tag(itemTag) : m_item_tag(itemTag)
...@@ -829,7 +829,7 @@ inline condition operator not(condition &&rhs) ...@@ -829,7 +829,7 @@ inline condition operator not(condition &&rhs)
return condition(new detail::not_condition_impl(std::move(rhs))); return condition(new detail::not_condition_impl(std::move(rhs)));
} }
struct any_type struct CIFPP_EXPORT any_type
{ {
}; };
......
...@@ -34,7 +34,7 @@ namespace cif ...@@ -34,7 +34,7 @@ namespace cif
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class datablock : public std::list<category> class CIFPP_EXPORT datablock : public std::list<category>
{ {
public: public:
datablock() = default; datablock() = default;
......
...@@ -31,6 +31,6 @@ ...@@ -31,6 +31,6 @@
namespace cif namespace cif
{ {
validator parse_dictionary(std::string_view name, std::istream &is); CIFPP_EXPORT validator parse_dictionary(std::string_view name, std::istream &is);
} // namespace cif } // namespace cif
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <list> #include <list>
#include <cif++/exports.hpp>
#include <cif++/datablock.hpp> #include <cif++/datablock.hpp>
#include <cif++/parser.hpp> #include <cif++/parser.hpp>
...@@ -36,7 +37,7 @@ namespace cif ...@@ -36,7 +37,7 @@ namespace cif
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class file : public std::list<datablock> class CIFPP_EXPORT file : public std::list<datablock>
{ {
public: public:
file() = default; file() = default;
......
...@@ -39,7 +39,7 @@ namespace cif ...@@ -39,7 +39,7 @@ namespace cif
namespace detail namespace detail
{ {
template <typename T> template <typename T>
struct to_varg struct CIFPP_EXPORT to_varg
{ {
using type = T; using type = T;
...@@ -54,7 +54,7 @@ namespace detail ...@@ -54,7 +54,7 @@ namespace detail
}; };
template <> template <>
struct to_varg<const char *> struct CIFPP_EXPORT to_varg<const char *>
{ {
using type = const char *; using type = const char *;
...@@ -69,7 +69,7 @@ namespace detail ...@@ -69,7 +69,7 @@ namespace detail
}; };
template <> template <>
struct to_varg<std::string> struct CIFPP_EXPORT to_varg<std::string>
{ {
using type = const char *; using type = const char *;
...@@ -86,7 +86,7 @@ namespace detail ...@@ -86,7 +86,7 @@ namespace detail
} // namespace } // namespace
template <typename... Args> template <typename... Args>
class format_plus_arg class CIFPP_EXPORT format_plus_arg
{ {
public: public:
using args_vector_type = std::tuple<detail::to_varg<Args>...>; using args_vector_type = std::tuple<detail::to_varg<Args>...>;
...@@ -141,7 +141,7 @@ constexpr auto format(std::string_view fmt, Args... 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 /// A streambuf that fills out lines with spaces up until a specified width
class fill_out_streambuf : public std::streambuf class CIFPP_EXPORT fill_out_streambuf : public std::streambuf
{ {
public: public:
using base_type = std::streambuf; using base_type = std::streambuf;
......
...@@ -26,21 +26,23 @@ ...@@ -26,21 +26,23 @@
#pragma once #pragma once
#include <cif++/exports.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
namespace cif namespace cif
{ {
class category; class CIFPP_EXPORT category;
class datablock; class CIFPP_EXPORT datablock;
class file; class CIFPP_EXPORT file;
class parser; class CIFPP_EXPORT parser;
class row; class CIFPP_EXPORT row;
class row_handle; class CIFPP_EXPORT row_handle;
class item; class CIFPP_EXPORT item;
struct item_handle; struct CIFPP_EXPORT item_handle;
} // namespace cif } // namespace cif
\ No newline at end of file
...@@ -51,7 +51,7 @@ namespace cif ...@@ -51,7 +51,7 @@ namespace cif
// -------------------------------------------------------------------- // --------------------------------------------------------------------
/// \brief item is a transient class that is used to pass data into rows /// \brief item is a transient class that is used to pass data into rows
/// but it also takes care of formatting data. /// but it also takes care of formatting data.
class item class CIFPP_EXPORT item
{ {
public: public:
/// \brief Default constructor, empty item /// \brief Default constructor, empty item
...@@ -188,7 +188,7 @@ class item ...@@ -188,7 +188,7 @@ class item
/// Typically, more than 99% of the strings in an mmCIF file are less /// Typically, more than 99% of the strings in an mmCIF file are less
/// than 8 bytes in length. /// than 8 bytes in length.
struct item_value struct CIFPP_EXPORT item_value
{ {
item_value() = default; item_value() = default;
...@@ -265,7 +265,7 @@ struct item_value ...@@ -265,7 +265,7 @@ struct item_value
/// \brief This is item_handle, it is used to access the data stored in item_value. /// \brief This is item_handle, it is used to access the data stored in item_value.
struct item_handle struct CIFPP_EXPORT item_handle
{ {
public: public:
// conversion helper class // conversion helper class
......
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 NKI/AVL, Netherlands Cancer Institute
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <memory>
namespace cif
{
// --------------------------------------------------------------------
template<typename Allocator = std::allocator<void>>
class list
{
public:
protected:
struct list_item
{
list_item *m_next = nullptr;
};
using list_item_allocator_type = typename std::allocator_traits<Alloc>::template rebind_alloc<list_item>;
using list_item_allocator_traits = std::allocator_traits<item_allocator_type>;
list_item_allocator_traits::pointer get_item()
{
list_item_allocator_type ia(get_allocator());
return list_item_allocator_traits::allocate(ia, 1);
}
template<typename ...Arguments>
list_item *create_list_item(uint16_t column_ix, Arguments... args)
{
auto p = this->get_item();
list_item_allocator_type ia(get_allocator());
list_item_allocator_traits::construct(ia, p, std::forward<Arguments>(args)...);
return p;
}
void delete_list_item(list_item *iv)
{
list_item_allocator_type ia(get_allocator());
list_item_allocator_traits::destroy(ia, iv);
list_item_allocator_traits::deallocate(ia, iv, 1);
}
list_item *m_head = nullptr, *m_tail = nullptr;
};
} // namespace cif
...@@ -45,7 +45,7 @@ class structure; ...@@ -45,7 +45,7 @@ class structure;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class atom class CIFPP_EXPORT atom
{ {
private: private:
struct atom_impl : public std::enable_shared_from_this<atom_impl> struct atom_impl : public std::enable_shared_from_this<atom_impl>
...@@ -388,7 +388,7 @@ enum class EntityType ...@@ -388,7 +388,7 @@ enum class EntityType
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class residue class CIFPP_EXPORT residue
{ {
public: public:
friend class structure; friend class structure;
...@@ -499,7 +499,7 @@ class residue ...@@ -499,7 +499,7 @@ class residue
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// a monomer models a single residue in a protein chain // a monomer models a single residue in a protein chain
class monomer : public residue class CIFPP_EXPORT monomer : public residue
{ {
public: public:
// monomer(); // monomer();
...@@ -570,7 +570,7 @@ class monomer : public residue ...@@ -570,7 +570,7 @@ class monomer : public residue
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class polymer : public std::vector<monomer> class CIFPP_EXPORT polymer : public std::vector<monomer>
{ {
public: public:
polymer(structure &s, const std::string &entityID, const std::string &asymID, const std::string &auth_asym_id); polymer(structure &s, const std::string &entityID, const std::string &asymID, const std::string &auth_asym_id);
...@@ -599,9 +599,9 @@ class polymer : public std::vector<monomer> ...@@ -599,9 +599,9 @@ class polymer : public std::vector<monomer>
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// sugar and branch, to describe glycosylation sites // sugar and branch, to describe glycosylation sites
class branch; class CIFPP_EXPORT branch;
class sugar : public residue class CIFPP_EXPORT sugar : public residue
{ {
public: public:
sugar(branch &branch, const std::string &compoundID, sugar(branch &branch, const std::string &compoundID,
...@@ -638,7 +638,7 @@ class sugar : public residue ...@@ -638,7 +638,7 @@ class sugar : public residue
atom m_link; atom m_link;
}; };
class branch : public std::vector<sugar> class CIFPP_EXPORT branch : public std::vector<sugar>
{ {
public: public:
branch(structure &structure, const std::string &asym_id, const std::string &entity_id); branch(structure &structure, const std::string &asym_id, const std::string &entity_id);
...@@ -724,7 +724,7 @@ inline bool operator&(StructureOpenOptions a, StructureOpenOptions b) ...@@ -724,7 +724,7 @@ inline bool operator&(StructureOpenOptions a, StructureOpenOptions b)
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class structure class CIFPP_EXPORT structure
{ {
public: public:
structure(file &p, size_t modelNr = 1, StructureOpenOptions options = {}); structure(file &p, size_t modelNr = 1, StructureOpenOptions options = {});
......
...@@ -36,7 +36,7 @@ namespace cif ...@@ -36,7 +36,7 @@ namespace cif
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class parse_error : public std::runtime_error class CIFPP_EXPORT parse_error : public std::runtime_error
{ {
public: public:
parse_error(uint32_t line_nr, const std::string &message) parse_error(uint32_t line_nr, const std::string &message)
...@@ -49,7 +49,7 @@ class parse_error : public std::runtime_error ...@@ -49,7 +49,7 @@ class parse_error : public std::runtime_error
// TODO: Need to implement support for transformed long lines // TODO: Need to implement support for transformed long lines
class sac_parser class CIFPP_EXPORT sac_parser
{ {
public: public:
using datablock_index = std::map<std::string, std::size_t>; using datablock_index = std::map<std::string, std::size_t>;
...@@ -267,7 +267,7 @@ class sac_parser ...@@ -267,7 +267,7 @@ class sac_parser
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class parser : public sac_parser class CIFPP_EXPORT parser : public sac_parser
{ {
public: public:
parser(std::istream &is, file &file) parser(std::istream &is, file &file)
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#pragma once #pragma once
#include <cif++/exports.hpp>
#include <cmath> #include <cmath>
#include <complex> #include <complex>
#include <functional> #include <functional>
...@@ -49,7 +51,7 @@ const double ...@@ -49,7 +51,7 @@ const double
// We use quaternions to do rotations in 3d space // We use quaternions to do rotations in 3d space
template <typename T> template <typename T>
class quaternion_type class CIFPP_EXPORT quaternion_type
{ {
public: public:
using value_type = T; using value_type = T;
...@@ -353,7 +355,7 @@ using quaternion = quaternion_type<float>; ...@@ -353,7 +355,7 @@ using quaternion = quaternion_type<float>;
// tie(x, y, z) = atom.loc(); // tie(x, y, z) = atom.loc();
template <typename F> template <typename F>
struct point_type struct CIFPP_EXPORT point_type
{ {
using value_type = F; using value_type = F;
...@@ -680,21 +682,21 @@ constexpr auto distance_point_to_line(const point_type<F> &l1, const point_type< ...@@ -680,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 // a random direction with a distance randomly chosen from a normal
// distribution with a stddev of offset. // distribution with a stddev of offset.
point nudge(point p, float offset); CIFPP_EXPORT point nudge(point p, float offset);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
quaternion construct_from_angle_axis(float angle, point axis); CIFPP_EXPORT quaternion construct_from_angle_axis(float angle, point axis);
std::tuple<double, point> quaternion_to_angle_axis(quaternion q); CIFPP_EXPORT std::tuple<double, point> quaternion_to_angle_axis(quaternion q);
/// @brief Given four points and an angle, return the quaternion required to rotate /// @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 /// point p4 along the p2-p3 axis and around point p3 to obtain the required within
/// an accuracy of esd /// an accuracy of esd
quaternion construct_for_dihedral_angle(point p1, point p2, point p3, point p4, CIFPP_EXPORT quaternion construct_for_dihedral_angle(point p1, point p2, point p3, point p4,
float angle, float esd); float angle, float esd);
point centroid(const std::vector<point> &Points); CIFPP_EXPORT point centroid(const std::vector<point> &Points);
point center_points(std::vector<point> &Points); CIFPP_EXPORT point center_points(std::vector<point> &Points);
/// \brief Returns how the two sets of points \a a and \b b can be aligned /// \brief Returns how the two sets of points \a a and \b b can be aligned
/// ///
...@@ -702,10 +704,10 @@ point center_points(std::vector<point> &Points); ...@@ -702,10 +704,10 @@ point center_points(std::vector<point> &Points);
/// \param b The second set of points /// \param b The second set of points
/// \result The quaternion which should be applied to the points in \a a to /// \result The quaternion which should be applied to the points in \a a to
/// obtain the best superposition. /// obtain the best superposition.
quaternion align_points(const std::vector<point> &a, const std::vector<point> &b); CIFPP_EXPORT 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 /// \brief The RMSd for the points in \a a and \a b
double RMSd(const std::vector<point> &a, const std::vector<point> &b); CIFPP_EXPORT double RMSd(const std::vector<point> &a, const std::vector<point> &b);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Helper class to generate evenly divided points on a sphere // Helper class to generate evenly divided points on a sphere
......
...@@ -103,7 +103,7 @@ auto tie(Ts &...v) ...@@ -103,7 +103,7 @@ auto tie(Ts &...v)
// -------------------------------------------------------------------- // --------------------------------------------------------------------
/// \brief the row class, this one is not directly accessible from the outside /// \brief the row class, this one is not directly accessible from the outside
class row : public std::vector<item_value> class CIFPP_EXPORT row : public std::vector<item_value>
{ {
public: public:
row() = default; row() = default;
...@@ -145,7 +145,7 @@ class row : public std::vector<item_value> ...@@ -145,7 +145,7 @@ class row : public std::vector<item_value>
// -------------------------------------------------------------------- // --------------------------------------------------------------------
/// \brief row_handle is the way to access data stored in rows /// \brief row_handle is the way to access data stored in rows
class row_handle class CIFPP_EXPORT row_handle
{ {
public: public:
friend struct item_handle; friend struct item_handle;
...@@ -265,7 +265,7 @@ class row_handle ...@@ -265,7 +265,7 @@ class row_handle
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class row_initializer : public std::vector<item> class CIFPP_EXPORT row_initializer : public std::vector<item>
{ {
public: public:
friend class category; friend class category;
......
...@@ -44,7 +44,7 @@ enum class space_group_name ...@@ -44,7 +44,7 @@ enum class space_group_name
Hall Hall
}; };
struct space_group struct CIFPP_EXPORT space_group
{ {
const char *name; const char *name;
const char *xHM; const char *xHM;
...@@ -57,7 +57,7 @@ extern CIFPP_EXPORT const std::size_t kNrOfSpaceGroups; ...@@ -57,7 +57,7 @@ extern CIFPP_EXPORT const std::size_t kNrOfSpaceGroups;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
struct symop_data struct CIFPP_EXPORT symop_data
{ {
constexpr symop_data(const std::array<int, 15> &data) constexpr symop_data(const std::array<int, 15> &data)
: m_packed((data[0] & 0x03ULL) << 34 bitor : m_packed((data[0] & 0x03ULL) << 34 bitor
...@@ -122,7 +122,7 @@ struct symop_data ...@@ -122,7 +122,7 @@ struct symop_data
uint64_t m_packed; uint64_t m_packed;
}; };
struct symop_datablock struct CIFPP_EXPORT symop_datablock
{ {
constexpr symop_datablock(int spacegroup, int rotational_number, const std::array<int, 15> &rt_data) constexpr symop_datablock(int spacegroup, int rotational_number, const std::array<int, 15> &rt_data)
: m_v((spacegroup & 0xffffULL) << 48 bitor : m_v((spacegroup & 0xffffULL) << 48 bitor
...@@ -141,12 +141,12 @@ struct symop_datablock ...@@ -141,12 +141,12 @@ struct symop_datablock
static_assert(sizeof(symop_datablock) == sizeof(uint64_t), "Size of symop_data is wrong"); static_assert(sizeof(symop_datablock) == sizeof(uint64_t), "Size of symop_data is wrong");
extern const symop_datablock kSymopNrTable[]; CIFPP_EXPORT extern const symop_datablock kSymopNrTable[];
extern const std::size_t kSymopNrTableSize; CIFPP_EXPORT extern const std::size_t kSymopNrTableSize;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
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); // 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 CIFPP_EXPORT int get_space_group_number(std::string spacegroup, space_group_name type); // alternative for clipper's parsing code
} // namespace cif } // namespace cif
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#pragma once #pragma once
#include <cif++/exports.hpp>
#include <charconv> #include <charconv>
#include <cmath> #include <cmath>
#include <limits> #include <limits>
...@@ -107,16 +109,16 @@ namespace cif ...@@ -107,16 +109,16 @@ namespace cif
// some basic utilities: Since we're using ASCII input only, we define for optimisation // some basic utilities: Since we're using ASCII input only, we define for optimisation
// our own case conversion routines. // our own case conversion routines.
bool iequals(std::string_view a, std::string_view b); CIFPP_EXPORT bool iequals(std::string_view a, std::string_view b);
int icompare(std::string_view a, std::string_view b); CIFPP_EXPORT int icompare(std::string_view a, std::string_view b);
bool iequals(const char *a, const char *b); CIFPP_EXPORT bool iequals(const char *a, const char *b);
int icompare(const char *a, const char *b); CIFPP_EXPORT int icompare(const char *a, const char *b);
void to_lower(std::string &s); CIFPP_EXPORT void to_lower(std::string &s);
std::string to_lower_copy(std::string_view s); CIFPP_EXPORT std::string to_lower_copy(std::string_view s);
void to_upper(std::string &s); CIFPP_EXPORT void to_upper(std::string &s);
// std::string toUpperCopy(const std::string &s); // std::string toUpperCopy(const std::string &s);
template <typename IterType> template <typename IterType>
...@@ -179,7 +181,7 @@ std::vector<StringType> split(std::string_view s, std::string_view separators, b ...@@ -179,7 +181,7 @@ std::vector<StringType> split(std::string_view s, std::string_view separators, b
return result; return result;
} }
void replace_all(std::string &s, std::string_view what, std::string_view with = {}); CIFPP_EXPORT void replace_all(std::string &s, std::string_view what, std::string_view with = {});
#if defined(__cpp_lib_starts_ends_with) #if defined(__cpp_lib_starts_ends_with)
...@@ -223,15 +225,15 @@ inline bool contains(std::string_view s, std::string_view q) ...@@ -223,15 +225,15 @@ inline bool contains(std::string_view s, std::string_view q)
#endif #endif
bool icontains(std::string_view s, std::string_view q); CIFPP_EXPORT bool icontains(std::string_view s, std::string_view q);
void trim_left(std::string &s); CIFPP_EXPORT void trim_left(std::string &s);
void trim_right(std::string &s); CIFPP_EXPORT void trim_right(std::string &s);
void trim(std::string &s); CIFPP_EXPORT void trim(std::string &s);
std::string trim_left_copy(std::string_view s); CIFPP_EXPORT std::string trim_left_copy(std::string_view s);
std::string trim_right_copy(std::string_view s); CIFPP_EXPORT std::string trim_right_copy(std::string_view s);
std::string trim_copy(std::string_view s); CIFPP_EXPORT std::string trim_copy(std::string_view s);
// To make life easier, we also define iless and iset using iequals // To make life easier, we also define iless and iset using iequals
...@@ -257,17 +259,17 @@ inline char tolower(int ch) ...@@ -257,17 +259,17 @@ inline char tolower(int ch)
// -------------------------------------------------------------------- // --------------------------------------------------------------------
std::tuple<std::string, std::string> split_tag_name(std::string_view tag); CIFPP_EXPORT std::tuple<std::string, std::string> split_tag_name(std::string_view tag);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// generate a cif name, mainly used to generate asym_id's // generate a cif name, mainly used to generate asym_id's
std::string cif_id_for_number(int number); CIFPP_EXPORT std::string cif_id_for_number(int number);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// custom wordwrapping routine // custom wordwrapping routine
std::vector<std::string> word_wrap(const std::string &text, size_t width); CIFPP_EXPORT std::vector<std::string> word_wrap(const std::string &text, size_t width);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
/// std::from_chars for floating point types. /// std::from_chars for floating point types.
......
...@@ -55,18 +55,18 @@ namespace cif ...@@ -55,18 +55,18 @@ namespace cif
extern CIFPP_EXPORT int VERBOSE; extern CIFPP_EXPORT int VERBOSE;
// the git 'build' number // the git 'build' number
std::string get_version_nr(); CIFPP_EXPORT std::string get_version_nr();
// std::string get_version_date(); // std::string get_version_date();
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Code helping with terminal i/o // Code helping with terminal i/o
uint32_t get_terminal_width(); CIFPP_EXPORT uint32_t get_terminal_width();
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Path of the current executable // Path of the current executable
std::string get_executable_path(); CIFPP_EXPORT std::string get_executable_path();
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// some manipulators to write coloured text to terminals // some manipulators to write coloured text to terminals
...@@ -157,7 +157,7 @@ inline auto coloured(std::basic_string<CharT, Traits, Alloc> &s, StringColour fo ...@@ -157,7 +157,7 @@ inline auto coloured(std::basic_string<CharT, Traits, Alloc> &s, StringColour fo
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// A progress bar // A progress bar
class Progress class CIFPP_EXPORT Progress
{ {
public: public:
Progress(int64_t inMax, const std::string &inAction); Progress(int64_t inMax, const std::string &inAction);
...@@ -178,8 +178,8 @@ class Progress ...@@ -178,8 +178,8 @@ class Progress
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Resources // Resources
std::unique_ptr<std::istream> load_resource(std::filesystem::path name); CIFPP_EXPORT std::unique_ptr<std::istream> load_resource(std::filesystem::path name);
void add_file_resource(const std::string &name, std::filesystem::path dataFile); CIFPP_EXPORT void add_file_resource(const std::string &name, std::filesystem::path dataFile);
void add_data_directory(std::filesystem::path dataDir); CIFPP_EXPORT void add_data_directory(std::filesystem::path dataDir);
} // namespace cif } // namespace cif
...@@ -40,7 +40,7 @@ struct category_validator; ...@@ -40,7 +40,7 @@ struct category_validator;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class validation_error : public std::exception class CIFPP_EXPORT validation_error : public std::exception
{ {
public: public:
validation_error(const std::string &msg); validation_error(const std::string &msg);
...@@ -59,11 +59,11 @@ enum class DDL_PrimitiveType ...@@ -59,11 +59,11 @@ enum class DDL_PrimitiveType
Numb Numb
}; };
DDL_PrimitiveType map_to_primitive_type(std::string_view s); CIFPP_EXPORT DDL_PrimitiveType map_to_primitive_type(std::string_view s);
struct regex_impl; struct regex_impl;
struct type_validator struct CIFPP_EXPORT type_validator
{ {
std::string m_name; std::string m_name;
DDL_PrimitiveType m_primitive_type; DDL_PrimitiveType m_primitive_type;
...@@ -100,7 +100,7 @@ struct type_validator ...@@ -100,7 +100,7 @@ struct type_validator
int compare(std::string_view a, std::string_view b) const; int compare(std::string_view a, std::string_view b) const;
}; };
struct item_validator struct CIFPP_EXPORT item_validator
{ {
std::string m_tag; std::string m_tag;
bool m_mandatory; bool m_mandatory;
...@@ -133,7 +133,7 @@ struct item_validator ...@@ -133,7 +133,7 @@ struct item_validator
void operator()(std::string_view value) const; void operator()(std::string_view value) const;
}; };
struct category_validator struct CIFPP_EXPORT category_validator
{ {
std::string m_name; std::string m_name;
std::vector<std::string> m_keys; std::vector<std::string> m_keys;
...@@ -156,7 +156,7 @@ struct category_validator ...@@ -156,7 +156,7 @@ struct category_validator
} }
}; };
struct link_validator struct CIFPP_EXPORT link_validator
{ {
int m_link_group_id; int m_link_group_id;
std::string m_parent_category; std::string m_parent_category;
...@@ -168,7 +168,7 @@ struct link_validator ...@@ -168,7 +168,7 @@ struct link_validator
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class validator class CIFPP_EXPORT validator
{ {
public: public:
validator(std::string_view name) validator(std::string_view name)
...@@ -217,7 +217,7 @@ class validator ...@@ -217,7 +217,7 @@ class validator
}; };
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class validator_factory class CIFPP_EXPORT validator_factory
{ {
public: public:
static validator_factory &instance() static validator_factory &instance()
......
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