Compare commits

...

10 Commits

Author SHA1 Message Date
Maarten L. Hekkelman
588e075325 Fix query generation when using constant numeric values
replace size_t with std::size_t to silence warnings
2024-04-03 14:01:51 +02:00
Maarten L. Hekkelman
66717fee68 take DESTDIR into account 2024-03-28 20:31:19 +01:00
Maarten L. Hekkelman
844f52c955 Merge branch 'develop' into trunk 2024-03-28 19:04:39 +01:00
Maarten L. Hekkelman
e679cd05c1 update changelog 2024-03-27 16:19:54 +01:00
Maarten L. Hekkelman
1e72ce4830 add missing header 2024-03-19 19:53:00 +01:00
Maarten L. Hekkelman
3bb21c5403 Try one more location to locate resources 2024-03-14 11:34:36 +01:00
Maarten L. Hekkelman
6d1be23ad0 oops 2024-03-14 11:12:39 +01:00
Maarten L. Hekkelman
0472b9a4a4 Merge branch 'trunk' into develop 2024-03-14 10:55:22 +01:00
Maarten L. Hekkelman
c9acff49f9 version bump, clean up makefile 2024-03-14 10:54:54 +01:00
Maarten L. Hekkelman
7cab560595 minimum requires cmake version 2024-03-14 07:37:50 +01:00
40 changed files with 646 additions and 568 deletions

View File

@@ -22,12 +22,12 @@
# 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.
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.23)
# set the project name
project(
libcifpp
VERSION 7.0.3
VERSION 7.0.4
LANGUAGES CXX)
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@@ -40,11 +40,8 @@ include(CheckCXXSourceCompiles)
include(GenerateExportHeader)
include(CTest)
include(FetchContent)
include(ExternalProject)
set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(STATUS "DESTDIR is '${DESTDIR}'")
# When building with ninja-multiconfig, build both debug and release by default
if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
@@ -71,10 +68,7 @@ if(NOT(BUILD_FOR_CCP4 AND WIN32))
option(BUILD_SHARED_LIBS "Build a shared library instead of a static one" OFF)
endif()
if(BUILD_FOR_CCP4)
unset(CIFPP_DOWNLOAD_CCD)
unset(CIFPP_INSTALL_UPDATE_SCRIPT)
else()
if(PROJECT_IS_TOP_LEVEL AND NOT BUILD_FOR_CCP4)
# Lots of code depend on the availability of the components.cif file
option(CIFPP_DOWNLOAD_CCD
"Download the CCD file components.cif during installation" ON)
@@ -84,6 +78,9 @@ else()
option(CIFPP_INSTALL_UPDATE_SCRIPT
"Install the script to update CCD and dictionary files" ON)
endif()
else()
unset(CIFPP_DOWNLOAD_CCD)
unset(CIFPP_INSTALL_UPDATE_SCRIPT)
endif()
# When CCP4 is sourced in the environment, we can recreate the symmetry
@@ -126,6 +123,7 @@ if(WIN32)
add_definitions(-D _WIN32_WINNT=0x0501)
endif()
# Man, this is 2024 we're living in...
add_definitions(-DNOMINMAX)
# We do not want to write an export file for all our symbols...
@@ -137,6 +135,7 @@ if(MSVC)
add_compile_options(/permissive- /bigobj)
add_link_options(/NODEFAULTLIB:library)
# This is dubious...
if(BUILD_SHARED_LIBS)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
else()
@@ -221,7 +220,11 @@ if(MSVC)
endforeach()
endif()
find_package(ZLIB REQUIRED)
find_package(ZLIB QUIET)
if(NOT ZLIB_FOUND)
message(FATAL_ERROR "The zlib development files were not found you this system, please install them and try again (hint: on debian/ubuntu use apt-get install zlib1g-dev)")
endif()
# Using Eigen3 is a bit of a thing. We don't want to build it completely since
# we only need a couple of header files. Nothing special. But often, eigen3 is
@@ -247,12 +250,6 @@ else()
set(EIGEN_INCLUDE_DIR ${my-eigen3_SOURCE_DIR})
endif()
include(FindFilesystem)
list(APPEND CIFPP_REQUIRED_LIBRARIES ${STDCPPFS_LIBRARY})
include(FindAtomic)
list(APPEND CIFPP_REQUIRED_LIBRARIES ${STDCPPATOMIC_LIBRARY})
# Create a revision file, containing the current git version info
include(VersionString)
write_version_header(${CMAKE_CURRENT_SOURCE_DIR}/src/ LIB_NAME "LibCIFPP")
@@ -305,29 +302,34 @@ set(project_sources
set(project_headers
include/cif++.hpp
include/cif++/utilities.hpp
include/cif++/item.hpp
include/cif++/atom_type.hpp
include/cif++/category.hpp
include/cif++/compound.hpp
include/cif++/condition.hpp
include/cif++/datablock.hpp
include/cif++/dictionary_parser.hpp
include/cif++/exports.hpp
include/cif++/file.hpp
include/cif++/validate.hpp
include/cif++/iterator.hpp
include/cif++/parser.hpp
include/cif++/format.hpp
include/cif++/forward_decl.hpp
include/cif++/dictionary_parser.hpp
include/cif++/condition.hpp
include/cif++/category.hpp
include/cif++/row.hpp
include/cif++/atom_type.hpp
include/cif++/compound.hpp
include/cif++/point.hpp
include/cif++/symmetry.hpp
include/cif++/gzio.hpp
include/cif++/item.hpp
include/cif++/iterator.hpp
include/cif++/matrix.hpp
include/cif++/model.hpp
include/cif++/pdb.hpp
include/cif++/parser.hpp
include/cif++/pdb/cif2pdb.hpp
include/cif++/pdb.hpp
include/cif++/pdb/io.hpp
include/cif++/pdb/pdb2cif.hpp
include/cif++/pdb/tls.hpp)
include/cif++/pdb/tls.hpp
include/cif++/point.hpp
include/cif++/row.hpp
include/cif++/symmetry.hpp
include/cif++/text.hpp
include/cif++/utilities.hpp
include/cif++/validate.hpp
)
add_library(cifpp STATIC)
add_library(cifpp::cifpp ALIAS cifpp)
@@ -369,8 +371,7 @@ target_include_directories(
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "${BOOST_REGEX_INCLUDE_DIR}" "${EIGEN_INCLUDE_DIR}")
target_link_libraries(cifpp PUBLIC Threads::Threads ZLIB::ZLIB
${CIFPP_REQUIRED_LIBRARIES})
target_link_libraries(cifpp PUBLIC Threads::Threads ZLIB::ZLIB)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_link_options(cifpp PRIVATE -undefined dynamic_lookup)
@@ -463,80 +464,73 @@ else()
unset(CIFPP_CACHE_DIR)
endif()
# Install rules
install(TARGETS cifpp
EXPORT cifpp
FILE_SET cifpp_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Avoid full installation in case we are not the top level target
if(PROJECT_IS_TOP_LEVEL OR BUILD_FOR_CCP4)
# Install rules
install(TARGETS cifpp
EXPORT cifpp
FILE_SET cifpp_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if(MSVC AND BUILD_SHARED_LIBS)
install(
FILES $<TARGET_PDB_FILE:cifpp>
DESTINATION ${CMAKE_INSTALL_LIBDIR}
OPTIONAL)
endif()
# Clean up old config files (with old names)
file(GLOB OLD_CONFIG_FILES
${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cifpp/cifppConfig*.cmake
${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cifpp/cifppTargets*.cmake)
if(OLD_CONFIG_FILES)
message(
STATUS "Installation will remove old config files: ${OLD_CONFIG_FILES}")
install(CODE "file(REMOVE ${OLD_CONFIG_FILES})")
endif()
install(EXPORT cifpp
NAMESPACE cifpp::
FILE "cifpp-targets.cmake"
DESTINATION lib/cmake/cifpp)
if(CIFPP_DATA_DIR AND CIFPP_DOWNLOAD_CCD)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/rsrc/mmcif_ddl.dic
${CMAKE_CURRENT_SOURCE_DIR}/rsrc/mmcif_pdbx.dic
${CMAKE_CURRENT_SOURCE_DIR}/rsrc/mmcif_ma.dic ${COMPONENTS_CIF}
DESTINATION ${CMAKE_INSTALL_DATADIR}/libcifpp)
endif()
set(CONFIG_TEMPLATE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cifpp-config.cmake.in)
configure_package_config_file(
${CONFIG_TEMPLATE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config.cmake
INSTALL_DESTINATION lib/cmake/cifpp
PATH_VARS CIFPP_DATA_DIR)
if(MSVC AND BUILD_SHARED_LIBS)
install(
FILES $<TARGET_PDB_FILE:cifpp>
DESTINATION ${CMAKE_INSTALL_LIBDIR}
OPTIONAL)
endif()
FILES "${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config-version.cmake"
DESTINATION lib/cmake/cifpp)
# Clean up old config files (with old names)
file(GLOB OLD_CONFIG_FILES
${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cifpp/cifppConfig*.cmake
${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cifpp/cifppTargets*.cmake)
set_target_properties(
cifpp
PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
INTERFACE_cifpp_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
if(OLD_CONFIG_FILES)
message(
STATUS "Installation will remove old config files: ${OLD_CONFIG_FILES}")
install(CODE "file(REMOVE ${OLD_CONFIG_FILES})")
endif()
set_property(
TARGET cifpp
APPEND
PROPERTY COMPATIBLE_INTERFACE_STRING cifpp_MAJOR_VERSION)
install(EXPORT cifpp
NAMESPACE cifpp::
FILE "cifpp-targets.cmake"
DESTINATION lib/cmake/cifpp)
if(CIFPP_DATA_DIR AND CIFPP_DOWNLOAD_CCD)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/rsrc/mmcif_ddl.dic
${CMAKE_CURRENT_SOURCE_DIR}/rsrc/mmcif_pdbx.dic
${CMAKE_CURRENT_SOURCE_DIR}/rsrc/mmcif_ma.dic ${COMPONENTS_CIF}
DESTINATION ${CIFPP_DATA_DIR})
endif()
if(CIFPP_CACHE_DIR AND CIFPP_DOWNLOAD_CCD)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/rsrc/mmcif_ddl.dic
${CMAKE_CURRENT_SOURCE_DIR}/rsrc/mmcif_pdbx.dic
${CMAKE_CURRENT_SOURCE_DIR}/rsrc/mmcif_ma.dic ${COMPONENTS_CIF}
DESTINATION ${CIFPP_CACHE_DIR})
endif()
set(CONFIG_TEMPLATE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cifpp-config.cmake.in)
configure_package_config_file(
${CONFIG_TEMPLATE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config.cmake
INSTALL_DESTINATION lib/cmake/cifpp
PATH_VARS CIFPP_DATA_DIR)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config-version.cmake"
DESTINATION lib/cmake/cifpp)
set_target_properties(
cifpp
PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
INTERFACE_cifpp_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
set_property(
TARGET cifpp
APPEND
PROPERTY COMPATIBLE_INTERFACE_STRING cifpp_MAJOR_VERSION)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
# In case we're included as sub_directory:
if(NOT PROJECT_IS_TOP_LEVEL)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
else()
# Set this variable so that consumers can find the files in rsrc
set(CIFPP_SHARE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/rsrc PARENT_SCOPE)
endif()
@@ -546,49 +540,36 @@ endif()
# Optionally install the update scripts for CCD and dictionary files
if(CIFPP_INSTALL_UPDATE_SCRIPT)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL
"GNU")
if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
set(CIFPP_CRON_DIR
"/etc/cron.weekly"
CACHE PATH "The cron directory, for the update script")
else()
set(CIFPP_CRON_DIR
"${CIFPP_ETC_DIR}/cron.weekly"
CACHE PATH "The cron directory, for the update script")
endif()
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(CIFPP_CRON_DIR
"${CIFPP_ETC_DIR}/periodic/weekly"
CACHE PATH "The cron directory, for the update script")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/update-libcifpp-data.in
update-libcifpp-data @ONLY)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
${CMAKE_SYSTEM_NAME} STREQUAL "GNU" OR
${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/update-libcifpp-data
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cron.weekly
PERMISSIONS OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE
WORLD_READ)
else()
message(FATAL_ERROR "Don't know where to install the update script")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/update-libcifpp-data.in
update-libcifpp-data @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/update-libcifpp-data
DESTINATION ${CIFPP_CRON_DIR}
PERMISSIONS OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE
WORLD_READ)
install(DIRECTORY DESTINATION ${CIFPP_CACHE_DIR})
# a config file, to make it complete
if(NOT EXISTS "${CIFPP_ETC_DIR}/libcifpp.conf")
# install(DIRECTORY DESTINATION "${CMAKE_INSTALL_LOCALSTATEDIR}/libcifpp")
if(NOT EXISTS "${CMAKE_INSTALL_SYSCONFDIR}/libcifpp.conf")
file(
WRITE ${CMAKE_CURRENT_BINARY_DIR}/libcifpp.conf
[[# Uncomment the next line to enable automatic updates
# update=true
]])
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcifpp.conf
DESTINATION "${CIFPP_ETC_DIR}")
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR})
install(
CODE "message(\"A configuration file has been written to ${CIFPP_ETC_DIR}/libcifpp.conf, please edit this file to enable automatic updates\")"
)
install(DIRECTORY DESTINATION "${CIFPP_ETC_DIR}/libcifpp/cache-update.d")
install(DIRECTORY DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/libcifpp/cache-update.d)
endif()
target_compile_definitions(cifpp PUBLIC CACHE_DIR="${CIFPP_CACHE_DIR}")
@@ -597,13 +578,3 @@ endif()
if(BUILD_DOCUMENTATION)
add_subdirectory(docs)
endif()
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_SOURCE_TGZ ON)
set(CPACK_SOURCE_TBZ2 OFF)
set(CPACK_SOURCE_TXZ OFF)
set(CPACK_SOURCE_TZ OFF)
set(CPACK_SOURCE_IGNORE_FILES "/rsrc/components.cif;/build;/.vscode;/.git")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
include(CPack)

View File

@@ -1,3 +1,6 @@
Version 7.0.4
- Do not install headers and library in case we're not the top project
Version 7.0.3
- Fix installation, write exports.hpp again

View File

@@ -1,63 +0,0 @@
# Simple check to see if we need a library for std::atomic
if(TARGET std::atomic)
return()
endif()
cmake_minimum_required(VERSION 3.10)
include(CMakePushCheckState)
include(CheckIncludeFileCXX)
include(CheckCXXSourceRuns)
cmake_push_check_state()
check_include_file_cxx("atomic" _CXX_ATOMIC_HAVE_HEADER)
mark_as_advanced(_CXX_ATOMIC_HAVE_HEADER)
set(code [[
#include <atomic>
int main(int argc, char** argv) {
std::atomic<long long> s;
++s;
return 0;
}
]])
check_cxx_source_runs("${code}" _CXX_ATOMIC_BUILTIN)
if(_CXX_ATOMIC_BUILTIN)
set(_found 1)
else()
list(APPEND CMAKE_REQUIRED_LIBRARIES atomic)
list(APPEND FOLLY_LINK_LIBRARIES atomic)
check_cxx_source_runs("${code}" _CXX_ATOMIC_LIB_NEEDED)
if (NOT _CXX_ATOMIC_LIB_NEEDED)
message(FATAL_ERROR "unable to link C++ std::atomic code: you may need \
to install GNU libatomic")
else()
set(_found 1)
endif()
endif()
if(_found)
add_library(std::atomic INTERFACE IMPORTED)
set_property(TARGET std::atomic APPEND PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_14)
if(_CXX_ATOMIC_BUILTIN)
# Nothing to add...
elseif(_CXX_ATOMIC_LIB_NEEDED)
set_target_properties(std::atomic PROPERTIES IMPORTED_LIBNAME atomic)
set(STDCPPATOMIC_LIBRARY atomic)
endif()
endif()
cmake_pop_check_state()
set(Atomic_FOUND ${_found} CACHE BOOL "TRUE if we can run a program using std::atomic" FORCE)
mark_as_advanced(Atomic_FOUND)
if(Atomic_FIND_REQUIRED AND NOT Atomic_FOUND)
message(FATAL_ERROR "Cannot run simple program using std::atomic")
endif()

View File

@@ -1,75 +0,0 @@
# Simplistic reimplementation of https://github.com/vector-of-bool/CMakeCM/blob/master/modules/FindFilesystem.cmake
if(TARGET std::filesystem)
return()
endif()
cmake_minimum_required(VERSION 3.10)
include(CMakePushCheckState)
include(CheckIncludeFileCXX)
include(CheckCXXSourceCompiles)
cmake_push_check_state()
check_include_file_cxx("filesystem" _CXX_FILESYSTEM_HAVE_HEADER)
mark_as_advanced(_CXX_FILESYSTEM_HAVE_HEADER)
set(code [[
#include <cstdlib>
#include <filesystem>
int main() {
auto cwd = std::filesystem::current_path();
return EXIT_SUCCESS;
}
]])
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL 8.4.0)
# >> https://stackoverflow.com/questions/63902528/program-crashes-when-filesystempath-is-destroyed
set(CXX_FILESYSTEM_NO_LINK_NEEDED 0)
else()
# Check a simple filesystem program without any linker flags
check_cxx_source_compiles("${code}" CXX_FILESYSTEM_NO_LINK_NEEDED)
endif()
if(CXX_FILESYSTEM_NO_LINK_NEEDED)
set(_found 1)
else()
set(prev_libraries ${CMAKE_REQUIRED_LIBRARIES})
# Add the libstdc++ flag
set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lstdc++fs)
check_cxx_source_compiles("${code}" CXX_FILESYSTEM_STDCPPFS_NEEDED)
set(_found ${CXX_FILESYSTEM_STDCPPFS_NEEDED})
if(NOT CXX_FILESYSTEM_STDCPPFS_NEEDED)
# Try the libc++ flag
set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lc++fs)
check_cxx_source_compiles("${code}" CXX_FILESYSTEM_CPPFS_NEEDED)
set(_found ${CXX_FILESYSTEM_CPPFS_NEEDED})
endif()
endif()
if(_found)
add_library(std::filesystem INTERFACE IMPORTED)
set_property(TARGET std::filesystem APPEND PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_17)
if(CXX_FILESYSTEM_NO_LINK_NEEDED)
# Nothing to add...
elseif(CXX_FILESYSTEM_STDCPPFS_NEEDED)
set_target_properties(std::filesystem PROPERTIES IMPORTED_LIBNAME stdc++fs)
set(STDCPPFS_LIBRARY stdc++fs)
elseif(CXX_FILESYSTEM_CPPFS_NEEDED)
set_target_properties(std::filesystem PROPERTIES IMPORTED_LIBNAME c++fs)
set(STDCPPFS_LIBRARY c++fs)
endif()
endif()
cmake_pop_check_state()
set(Filesystem_FOUND ${_found} CACHE BOOL "TRUE if we can run a program using std::filesystem" FORCE)
mark_as_advanced(Filesystem_FOUND)
if(Filesystem_FIND_REQUIRED AND NOT Filesystem_FOUND)
message(FATAL_ERROR "Cannot run simple program using std::filesystem")
endif()

View File

@@ -200,7 +200,7 @@ enum class radius_type
};
/// @brief The number of radii per element which can be requested from atom_type_info
constexpr size_t kRadiusTypeCount = static_cast<size_t>(radius_type::type_count);
constexpr std::size_t kRadiusTypeCount = static_cast<std::size_t>(radius_type::type_count);
/// An enum used to select either the effective or the crystal radius of an ion.
/// See explanation on Wikipedia: https://en.wikipedia.org/wiki/Ionic_radius
@@ -276,7 +276,7 @@ class atom_type_traits
{
if (type >= radius_type::type_count)
throw std::invalid_argument("invalid radius requested");
return m_info->radii[static_cast<size_t>(type)] / 100.f;
return m_info->radii[static_cast<std::size_t>(type)] / 100.f;
}
/// \brief Return the radius for a charged version of this atom in a solid crystal

View File

@@ -293,15 +293,15 @@ class category
}
/// Return a count of the rows in this container
size_t size() const
std::size_t size() const
{
return std::distance(cbegin(), cend());
}
/// Return the theoretical maximum number or rows that can be stored
size_t max_size() const
std::size_t max_size() const
{
return std::numeric_limits<size_t>::max(); // this is a bit optimistic, I guess
return std::numeric_limits<std::size_t>::max(); // this is a bit optimistic, I guess
}
/// Return true if the category is empty
@@ -831,9 +831,9 @@ class category
/// @brief Return the total number of rows that match condition @a cond
/// @param cond The condition to match
/// @return The count
size_t count(condition &&cond) const
std::size_t count(condition &&cond) const
{
size_t result = 0;
std::size_t result = 0;
if (cond)
{
@@ -903,14 +903,14 @@ class category
/// @brief Erase all rows that match condition @a cond
/// @param cond The condition
/// @return The number of rows that have been erased
size_t erase(condition &&cond);
std::size_t erase(condition &&cond);
/// @brief Erase all rows that match condition @a cond calling
/// the visitor function @a visit for each before actually erasing it.
/// @param cond The condition
/// @param visit The visitor function
/// @return The number of rows that have been erased
size_t erase(condition &&cond, std::function<void(row_handle)> &&visit);
std::size_t erase(condition &&cond, std::function<void(row_handle)> &&visit);
/// @brief Emplace the values in @a ri in a new row
/// @param ri An object containing the values to insert

View File

@@ -29,6 +29,7 @@
#include "cif++/row.hpp"
#include <cassert>
#include <concepts>
#include <functional>
#include <iostream>
#include <regex>
@@ -470,6 +471,106 @@ namespace detail
std::optional<row_handle> m_single_hit;
};
struct key_equals_number_condition_impl : public condition_impl
{
key_equals_number_condition_impl(const std::string &name, double v)
: m_item_name(name)
, m_value(v)
{
}
condition_impl *prepare(const category &c) override;
bool test(row_handle r) const override
{
return m_single_hit.has_value() ? *m_single_hit == r : r[m_item_ix].compare(m_value) == 0;
}
void str(std::ostream &os) const override
{
os << m_item_name << " == " << m_value;
}
virtual std::optional<row_handle> single() const override
{
return m_single_hit;
}
virtual bool equals(const condition_impl *rhs) const override
{
if (typeid(*rhs) == typeid(key_equals_number_condition_impl))
{
auto ri = static_cast<const key_equals_number_condition_impl *>(rhs);
if (m_single_hit.has_value() or ri->m_single_hit.has_value())
return m_single_hit == ri->m_single_hit;
else
// watch out, both m_item_ix might be the same while item_names might be diffent (in case they both do not exist in the category)
return m_item_ix == ri->m_item_ix and m_value == ri->m_value and m_item_name == ri->m_item_name;
}
return this == rhs;
}
std::string m_item_name;
uint16_t m_item_ix = 0;
double m_value;
std::optional<row_handle> m_single_hit;
};
struct key_equals_number_or_empty_condition_impl : public condition_impl
{
key_equals_number_or_empty_condition_impl(key_equals_number_condition_impl *equals)
: m_item_name(equals->m_item_name)
, m_value(equals->m_value)
, m_single_hit(equals->m_single_hit)
{
}
condition_impl *prepare(const category &c) override
{
m_item_ix = get_item_ix(c, m_item_name);
return this;
}
bool test(row_handle r) const override
{
bool result = false;
if (m_single_hit.has_value())
result = *m_single_hit == r;
else
result = r[m_item_ix].empty() or r[m_item_ix].compare(m_value) == 0;
return result;
}
void str(std::ostream &os) const override
{
os << '(' << m_item_name << " == " << m_value << " OR " << m_item_name << " IS NULL)";
}
virtual std::optional<row_handle> single() const override
{
return m_single_hit;
}
virtual bool equals(const condition_impl *rhs) const override
{
if (typeid(*rhs) == typeid(key_equals_number_or_empty_condition_impl))
{
auto ri = static_cast<const key_equals_number_or_empty_condition_impl *>(rhs);
if (m_single_hit.has_value() or ri->m_single_hit.has_value())
return m_single_hit == ri->m_single_hit;
else
// watch out, both m_item_ix might be the same while item_names might be diffent (in case they both do not exist in the category)
return m_item_ix == ri->m_item_ix and m_value == ri->m_value and m_item_name == ri->m_item_name;
}
return this == rhs;
}
std::string m_item_name;
uint16_t m_item_ix = 0;
double m_value;
std::optional<row_handle> m_single_hit;
};
struct key_compare_condition_impl : public condition_impl
{
template <typename COMP>
@@ -876,7 +977,8 @@ inline condition operator or(condition &&a, condition &&b)
if (ci->m_item_name == ce->m_item_name)
return condition(new detail::key_equals_or_empty_condition_impl(ci));
}
else if (typeid(*b.m_impl) == typeid(detail::key_equals_condition_impl) and
if (typeid(*b.m_impl) == typeid(detail::key_equals_condition_impl) and
typeid(*a.m_impl) == typeid(detail::key_is_empty_condition_impl))
{
auto ci = static_cast<detail::key_equals_condition_impl *>(b.m_impl);
@@ -886,6 +988,26 @@ inline condition operator or(condition &&a, condition &&b)
return condition(new detail::key_equals_or_empty_condition_impl(ci));
}
if (typeid(*a.m_impl) == typeid(detail::key_equals_number_condition_impl) and
typeid(*b.m_impl) == typeid(detail::key_is_empty_condition_impl))
{
auto ci = static_cast<detail::key_equals_number_condition_impl *>(a.m_impl);
auto ce = static_cast<detail::key_is_empty_condition_impl *>(b.m_impl);
if (ci->m_item_name == ce->m_item_name)
return condition(new detail::key_equals_number_or_empty_condition_impl(ci));
}
if (typeid(*b.m_impl) == typeid(detail::key_equals_number_condition_impl) and
typeid(*a.m_impl) == typeid(detail::key_is_empty_condition_impl))
{
auto ci = static_cast<detail::key_equals_number_condition_impl *>(b.m_impl);
auto ce = static_cast<detail::key_is_empty_condition_impl *>(a.m_impl);
if (ci->m_item_name == ce->m_item_name)
return condition(new detail::key_equals_number_or_empty_condition_impl(ci));
}
return condition(new detail::or_condition_impl(std::move(a), std::move(b)));
}
@@ -959,13 +1081,16 @@ struct key
std::string m_item_name; ///< The item name
};
/**
* @brief Operator to create an equals condition based on a key @a key and a value @a v
*/
template <typename T>
concept Numeric = ((std::is_floating_point_v<T> or std::is_integral_v<T>) and not std::is_same_v<T, bool>);
/**
* @brief Operator to create an equals condition based on a key @a key and a numeric value @a v
*/
template <Numeric T>
condition operator==(const key &key, const T &v)
{
return condition(new detail::key_equals_condition_impl({ key.m_item_name, v }));
return condition(new detail::key_equals_number_condition_impl(key.m_item_name, v));
}
/**
@@ -979,6 +1104,16 @@ inline condition operator==(const key &key, std::string_view value)
return condition(new detail::key_is_empty_condition_impl(key.m_item_name));
}
/**
* @brief Operator to create an equals condition based on a key @a key and a value @a value
*/
template <typename T>
requires std::is_same_v<T, bool>
inline condition operator==(const key &key, T value)
{
return condition(new detail::key_equals_condition_impl({ key.m_item_name, value ? "y" : "n" }));
}
/**
* @brief Operator to create a not equals condition based on a key @a key and a value @a v
*/
@@ -999,7 +1134,7 @@ inline condition operator!=(const key &key, std::string_view value)
/**
* @brief Operator to create a greater than condition based on a key @a key and a value @a v
*/
template <typename T>
template <Numeric T>
condition operator>(const key &key, const T &v)
{
std::ostringstream s;
@@ -1007,14 +1142,14 @@ condition operator>(const key &key, const T &v)
return condition(new detail::key_compare_condition_impl(
key.m_item_name, [item_name = key.m_item_name, v](row_handle r, bool icase)
{ return r[item_name].template compare<T>(v, icase) > 0; },
{ return r[item_name].compare(v) > 0; },
s.str()));
}
/**
* @brief Operator to create a greater than or equals condition based on a key @a key and a value @a v
*/
template <typename T>
template <Numeric T>
condition operator>=(const key &key, const T &v)
{
std::ostringstream s;
@@ -1022,14 +1157,14 @@ condition operator>=(const key &key, const T &v)
return condition(new detail::key_compare_condition_impl(
key.m_item_name, [item_name = key.m_item_name, v](row_handle r, bool icase)
{ return r[item_name].template compare<T>(v, icase) >= 0; },
{ return r[item_name].compare(v) >= 0; },
s.str()));
}
/**
* @brief Operator to create a less than condition based on a key @a key and a value @a v
*/
template <typename T>
template <Numeric T>
condition operator<(const key &key, const T &v)
{
std::ostringstream s;
@@ -1037,14 +1172,14 @@ condition operator<(const key &key, const T &v)
return condition(new detail::key_compare_condition_impl(
key.m_item_name, [item_name = key.m_item_name, v](row_handle r, bool icase)
{ return r[item_name].template compare<T>(v, icase) < 0; },
{ return r[item_name].compare(v) < 0; },
s.str()));
}
/**
* @brief Operator to create a less than or equals condition based on a key @a key and a value @a v
*/
template <typename T>
template <Numeric T>
condition operator<=(const key &key, const T &v)
{
std::ostringstream s;
@@ -1052,7 +1187,63 @@ condition operator<=(const key &key, const T &v)
return condition(new detail::key_compare_condition_impl(
key.m_item_name, [item_name = key.m_item_name, v](row_handle r, bool icase)
{ return r[item_name].template compare<T>(v, icase) <= 0; },
{ return r[item_name].compare(v) <= 0; },
s.str()));
}
/**
* @brief Operator to create a greater than condition based on a key @a key and a value @a v
*/
inline condition operator>(const key &key, std::string_view v)
{
std::ostringstream s;
s << " > " << v;
return condition(new detail::key_compare_condition_impl(
key.m_item_name, [item_name = key.m_item_name, v](row_handle r, bool icase)
{ return r[item_name].compare(v, icase) > 0; },
s.str()));
}
/**
* @brief Operator to create a greater than or equals condition based on a key @a key and a value @a v
*/
inline condition operator>=(const key &key, std::string_view v)
{
std::ostringstream s;
s << " >= " << v;
return condition(new detail::key_compare_condition_impl(
key.m_item_name, [item_name = key.m_item_name, v](row_handle r, bool icase)
{ return r[item_name].compare(v, icase) >= 0; },
s.str()));
}
/**
* @brief Operator to create a less than condition based on a key @a key and a value @a v
*/
inline condition operator<(const key &key, std::string_view v)
{
std::ostringstream s;
s << " < " << v;
return condition(new detail::key_compare_condition_impl(
key.m_item_name, [item_name = key.m_item_name, v](row_handle r, bool icase)
{ return r[item_name].compare(v, icase) < 0; },
s.str()));
}
/**
* @brief Operator to create a less than or equals condition based on a key @a key and a value @a v
*/
inline condition operator<=(const key &key, std::string_view v)
{
std::ostringstream s;
s << " <= " << v;
return condition(new detail::key_compare_condition_impl(
key.m_item_name, [item_name = key.m_item_name, v](row_handle r, bool icase)
{ return r[item_name].compare(v, icase) <= 0; },
s.str()));
}
@@ -1146,7 +1337,7 @@ namespace literals
* @param length The length of @a text
* @return key The cif::key created
*/
inline key operator""_key(const char *text, size_t length)
inline key operator""_key(const char *text, std::size_t length)
{
return key(std::string(text, length));
}

View File

@@ -85,11 +85,11 @@ class file : public std::list<datablock>
* @param data The pointer to the character string with data to load
* @param length The length of the data
*/
explicit file(const char *data, size_t length)
explicit file(const char *data, std::size_t length)
{
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}

View File

@@ -125,7 +125,7 @@ class format_plus_arg
private:
template <size_t... I>
template <std::size_t... I>
void copy_vargs(std::index_sequence<I...>)
{
((std::get<I>(m_vargs) = *std::get<I>(m_args)), ...);

View File

@@ -36,7 +36,7 @@ namespace cif::gzio
{
/** The default buffer size to use */
const size_t kDefaultBufferSize = 256;
const std::size_t kDefaultBufferSize = 256;
// --------------------------------------------------------------------
@@ -112,7 +112,7 @@ class basic_streambuf : public std::basic_streambuf<CharT, Traits>
/// This implementation of streambuf can decompress (inflate) data compressed
/// using zlib.
template <typename CharT, typename Traits, size_t BufferSize = kDefaultBufferSize>
template <typename CharT, typename Traits, std::size_t BufferSize = kDefaultBufferSize>
class basic_igzip_streambuf : public basic_streambuf<CharT, Traits>
{
public:
@@ -317,7 +317,7 @@ class basic_igzip_streambuf : public basic_streambuf<CharT, Traits>
///
/// This implementation of streambuf can compress (deflate) data using zlib.
template <typename CharT, typename Traits, size_t BufferSize = kDefaultBufferSize>
template <typename CharT, typename Traits, std::size_t BufferSize = kDefaultBufferSize>
class basic_ogzip_streambuf : public basic_streambuf<CharT, Traits>
{
public:

View File

@@ -238,10 +238,10 @@ class item
bool is_unknown() const { return m_value == "?"; }
/// \brief the length of the value string
size_t length() const { return m_value.length(); }
std::size_t length() const { return m_value.length(); }
/// \brief support for structured binding
template <size_t N>
template <std::size_t N>
decltype(auto) get() const
{
if constexpr (N == 0)
@@ -319,7 +319,7 @@ struct item_value
return m_length != 0;
}
size_t m_length = 0; ///< Length of the data
std::size_t m_length = 0; ///< Length of the data
union
{
char m_local_data[8]; ///< Storage area for small strings (strings smaller than kBufferSize)
@@ -328,7 +328,7 @@ struct item_value
};
/** The maximum length of locally stored strings */
static constexpr size_t kBufferSize = sizeof(m_local_data);
static constexpr std::size_t kBufferSize = sizeof(m_local_data);
// By using std::string_view instead of c_str we obain a
// nice performance gain since we avoid many calls to strlen.
@@ -389,7 +389,7 @@ struct item_handle
* @param value The value
* @return reference to this item_handle
*/
template <size_t N>
template <std::size_t N>
item_handle &operator=(const char (&value)[N])
{
assign_value(item{ "", std::move(value) }.value());
@@ -662,7 +662,7 @@ struct item_handle::item_value_as<T, std::enable_if_t<std::is_same_v<T, bool>>>
}
};
template <size_t N>
template <std::size_t N>
struct item_handle::item_value_as<char[N]>
{
static std::string convert(const item_handle &ref)

View File

@@ -67,7 +67,7 @@ class iterator_impl
/** @endcond */
/** variable that contains the number of elements in the tuple */
static constexpr size_t N = sizeof...(Ts);
static constexpr std::size_t N = sizeof...(Ts);
/** @cond */
using category_type = std::remove_cv_t<Category>;
@@ -176,7 +176,7 @@ class iterator_impl
/** @endcond */
private:
template <size_t... Is>
template <std::size_t... Is>
tuple_type get(std::index_sequence<Is...>) const
{
return m_current ? tuple_type{ m_current[m_item_ix[Is]].template as<Ts>()... } : tuple_type{};
@@ -450,7 +450,7 @@ class iterator_proxy
{
public:
/** @cond */
static constexpr const size_t N = sizeof...(Ts);
static constexpr const std::size_t N = sizeof...(Ts);
using category_type = Category;
using row_type = std::conditional_t<std::is_const_v<category_type>, const row, row>;
@@ -473,7 +473,7 @@ class iterator_proxy
bool empty() const { return m_begin == m_end; } ///< Return true if the range is empty
explicit operator bool() const { return not empty(); } ///< Easy way to detect if the range is empty
size_t size() const { return std::distance(begin(), end()); } ///< Return size of the range
std::size_t size() const { return std::distance(begin(), end()); } ///< Return size of the range
// row front() { return *begin(); }
// row back() { return *(std::prev(end())); }
@@ -512,7 +512,7 @@ class conditional_iterator_proxy
{
public:
/** @cond */
static constexpr const size_t N = sizeof...(Ts);
static constexpr const std::size_t N = sizeof...(Ts);
using category_type = std::remove_cv_t<CategoryType>;
@@ -606,7 +606,7 @@ class conditional_iterator_proxy
bool empty() const; ///< Return true if the range is empty
explicit operator bool() const { return not empty(); } ///< Easy way to detect if the range is empty
size_t size() const { return std::distance(begin(), end()); } ///< Return size of the range
std::size_t size() const { return std::distance(begin(), end()); } ///< Return size of the range
row_handle front() { return *begin(); } ///< Return reference to the first row
// row_handle back() { return *begin(); }

View File

@@ -59,27 +59,27 @@ template <typename M>
class matrix_expression
{
public:
constexpr size_t dim_m() const { return static_cast<const M &>(*this).dim_m(); } ///< Return the size (dimension) in direction m
constexpr size_t dim_n() const { return static_cast<const M &>(*this).dim_n(); } ///< Return the size (dimension) in direction n
constexpr std::size_t dim_m() const { return static_cast<const M &>(*this).dim_m(); } ///< Return the size (dimension) in direction m
constexpr std::size_t dim_n() const { return static_cast<const M &>(*this).dim_n(); } ///< Return the size (dimension) in direction n
constexpr bool empty() const { return dim_m() == 0 or dim_n() == 0; } ///< Convenient way to test for empty matrices
/** Return a reference to element [ @a i, @a j ] */
constexpr auto &operator()(size_t i, size_t j)
constexpr auto &operator()(std::size_t i, std::size_t j)
{
return static_cast<M &>(*this).operator()(i, j);
}
/** Return the value of element [ @a i, @a j ] */
constexpr auto operator()(size_t i, size_t j) const
constexpr auto operator()(std::size_t i, std::size_t j) const
{
return static_cast<const M &>(*this).operator()(i, j);
}
/** Swap the contents of rows @a r1 and @a r2 */
void swap_row(size_t r1, size_t r2)
void swap_row(std::size_t r1, std::size_t r2)
{
for (size_t c = 0; c < dim_m(); ++c)
for (std::size_t c = 0; c < dim_m(); ++c)
{
auto v = operator()(r1, c);
operator()(r1, c) = operator()(r2, c);
@@ -88,9 +88,9 @@ class matrix_expression
}
/** Swap the contents of columns @a c1 and @a c2 */
void swap_col(size_t c1, size_t c2)
void swap_col(std::size_t c1, std::size_t c2)
{
for (size_t r = 0; r < dim_n(); ++r)
for (std::size_t r = 0; r < dim_n(); ++r)
{
auto &a = operator()(r, c1);
auto &b = operator()(r, c2);
@@ -103,11 +103,11 @@ class matrix_expression
{
os << '[';
for (size_t i = 0; i < m.dim_m(); ++i)
for (std::size_t i = 0; i < m.dim_m(); ++i)
{
os << '[';
for (size_t j = 0; j < m.dim_n(); ++j)
for (std::size_t j = 0; j < m.dim_n(); ++j)
{
os << m(i, j);
if (j + 1 < m.dim_n())
@@ -156,9 +156,9 @@ class matrix : public matrix_expression<matrix<F>>
, m_n(m.dim_n())
, m_data(m_m * m_n)
{
for (size_t i = 0; i < m_m; ++i)
for (std::size_t i = 0; i < m_m; ++i)
{
for (size_t j = 0; j < m_n; ++j)
for (std::size_t j = 0; j < m_n; ++j)
operator()(i, j) = m(i, j);
}
}
@@ -171,7 +171,7 @@ class matrix : public matrix_expression<matrix<F>>
* @param n Requested dimension N
* @param v Value to store in each element
*/
matrix(size_t m, size_t n, value_type v = 0)
matrix(std::size_t m, std::size_t n, value_type v = 0)
: m_m(m)
, m_n(n)
, m_data(m_m * m_n)
@@ -187,11 +187,11 @@ class matrix : public matrix_expression<matrix<F>>
matrix &operator=(const matrix &m) = default;
/** @endcond */
constexpr size_t dim_m() const { return m_m; } ///< Return dimension m
constexpr size_t dim_n() const { return m_n; } ///< Return dimension n
constexpr std::size_t dim_m() const { return m_m; } ///< Return dimension m
constexpr std::size_t dim_n() const { return m_n; } ///< Return dimension n
/** Return the value of element [ @a i, @a j ] */
constexpr value_type operator()(size_t i, size_t j) const
constexpr value_type operator()(std::size_t i, std::size_t j) const
{
assert(i < m_m);
assert(j < m_n);
@@ -199,7 +199,7 @@ class matrix : public matrix_expression<matrix<F>>
}
/** Return a reference to element [ @a i, @a j ] */
constexpr value_type &operator()(size_t i, size_t j)
constexpr value_type &operator()(std::size_t i, std::size_t j)
{
assert(i < m_m);
assert(j < m_n);
@@ -207,7 +207,7 @@ class matrix : public matrix_expression<matrix<F>>
}
private:
size_t m_m = 0, m_n = 0;
std::size_t m_m = 0, m_n = 0;
std::vector<value_type> m_data;
};
@@ -224,7 +224,7 @@ class matrix : public matrix_expression<matrix<F>>
* element m i,j is mapped to [i * n + j] and thus storage is row major
*/
template <typename F, size_t M, size_t N>
template <typename F, std::size_t M, std::size_t N>
class matrix_fixed : public matrix_expression<matrix_fixed<F, M, N>>
{
public:
@@ -232,16 +232,16 @@ class matrix_fixed : public matrix_expression<matrix_fixed<F, M, N>>
using value_type = F;
/** The storage size */
static constexpr size_t kSize = M * N;
static constexpr std::size_t kSize = M * N;
/** Copy constructor */
template <typename M2>
matrix_fixed(const M2 &m)
{
assert(M == m.dim_m() and N == m.dim_n());
for (size_t i = 0; i < M; ++i)
for (std::size_t i = 0; i < M; ++i)
{
for (size_t j = 0; j < N; ++j)
for (std::size_t j = 0; j < N; ++j)
operator()(i, j) = m(i, j);
}
}
@@ -266,18 +266,18 @@ class matrix_fixed : public matrix_expression<matrix_fixed<F, M, N>>
/** @endcond */
/** Store the values in @a a in the matrix */
template<size_t... Ixs>
template<std::size_t... Ixs>
matrix_fixed& fill(const F (&a)[kSize], std::index_sequence<Ixs...>)
{
m_data = { a[Ixs]... };
return *this;
}
constexpr size_t dim_m() const { return M; } ///< Return dimension m
constexpr size_t dim_n() const { return N; } ///< Return dimension n
constexpr std::size_t dim_m() const { return M; } ///< Return dimension m
constexpr std::size_t dim_n() const { return N; } ///< Return dimension n
/** Return the value of element [ @a i, @a j ] */
constexpr value_type operator()(size_t i, size_t j) const
constexpr value_type operator()(std::size_t i, std::size_t j) const
{
assert(i < M);
assert(j < N);
@@ -285,7 +285,7 @@ class matrix_fixed : public matrix_expression<matrix_fixed<F, M, N>>
}
/** Return a reference to element [ @a i, @a j ] */
constexpr value_type &operator()(size_t i, size_t j)
constexpr value_type &operator()(std::size_t i, std::size_t j)
{
assert(i < M);
assert(j < N);
@@ -322,7 +322,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
using value_type = F;
/** constructor for a matrix of size @a n x @a n elements with value @a v */
symmetric_matrix(size_t n, value_type v = 0)
symmetric_matrix(std::size_t n, value_type v = 0)
: m_n(n)
, m_data((m_n * (m_n + 1)) / 2)
{
@@ -337,11 +337,11 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
symmetric_matrix &operator=(const symmetric_matrix &m) = default;
/** @endcond */
constexpr size_t dim_m() const { return m_n; } ///< Return dimension m
constexpr size_t dim_n() const { return m_n; } ///< Return dimension n
constexpr std::size_t dim_m() const { return m_n; } ///< Return dimension m
constexpr std::size_t dim_n() const { return m_n; } ///< Return dimension n
/** Return the value of element [ @a i, @a j ] */
constexpr value_type operator()(size_t i, size_t j) const
constexpr value_type operator()(std::size_t i, std::size_t j) const
{
return i < j
? m_data[(j * (j + 1)) / 2 + i]
@@ -349,7 +349,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
}
/** Return a reference to element [ @a i, @a j ] */
constexpr value_type &operator()(size_t i, size_t j)
constexpr value_type &operator()(std::size_t i, std::size_t j)
{
if (i > j)
std::swap(i, j);
@@ -358,7 +358,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
}
private:
size_t m_n;
std::size_t m_n;
std::vector<value_type> m_data;
};
@@ -373,7 +373,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
* matrix is m x n, addressing i,j is 0 <= i < m and 0 <= j < n
* element m i,j is mapped to [i * n + j] and thus storage is row major
*/
template <typename F, size_t M>
template <typename F, std::size_t M>
class symmetric_matrix_fixed : public matrix_expression<symmetric_matrix_fixed<F, M>>
{
public:
@@ -393,11 +393,11 @@ class symmetric_matrix_fixed : public matrix_expression<symmetric_matrix_fixed<F
symmetric_matrix_fixed &operator=(const symmetric_matrix_fixed &m) = default;
/** @endcond */
constexpr size_t dim_m() const { return M; } ///< Return dimension m
constexpr size_t dim_n() const { return M; } ///< Return dimension n
constexpr std::size_t dim_m() const { return M; } ///< Return dimension m
constexpr std::size_t dim_n() const { return M; } ///< Return dimension n
/** Return the value of element [ @a i, @a j ] */
constexpr value_type operator()(size_t i, size_t j) const
constexpr value_type operator()(std::size_t i, std::size_t j) const
{
return i < j
? m_data[(j * (j + 1)) / 2 + i]
@@ -405,7 +405,7 @@ class symmetric_matrix_fixed : public matrix_expression<symmetric_matrix_fixed<F
}
/** Return a reference to element [ @a i, @a j ] */
constexpr value_type &operator()(size_t i, size_t j)
constexpr value_type &operator()(std::size_t i, std::size_t j)
{
if (i > j)
std::swap(i, j);
@@ -444,22 +444,22 @@ class identity_matrix : public matrix_expression<identity_matrix<F>>
using value_type = F;
/** constructor taking a dimension @a n */
identity_matrix(size_t n)
identity_matrix(std::size_t n)
: m_n(n)
{
}
constexpr size_t dim_m() const { return m_n; } ///< Return dimension m
constexpr size_t dim_n() const { return m_n; } ///< Return dimension n
constexpr std::size_t dim_m() const { return m_n; } ///< Return dimension m
constexpr std::size_t dim_n() const { return m_n; } ///< Return dimension n
/** Return the value of element [ @a i, @a j ] */
constexpr value_type operator()(size_t i, size_t j) const
constexpr value_type operator()(std::size_t i, std::size_t j) const
{
return static_cast<value_type>(i == j ? 1 : 0);
}
private:
size_t m_n;
std::size_t m_n;
};
// --------------------------------------------------------------------
@@ -484,11 +484,11 @@ class matrix_subtraction : public matrix_expression<matrix_subtraction<M1, M2>>
assert(m_m1.dim_n() == m_m2.dim_n());
}
constexpr size_t dim_m() const { return m_m1.dim_m(); } ///< Return dimension m
constexpr size_t dim_n() const { return m_m1.dim_n(); } ///< Return dimension n
constexpr std::size_t dim_m() const { return m_m1.dim_m(); } ///< Return dimension m
constexpr std::size_t dim_n() const { return m_m1.dim_n(); } ///< Return dimension n
/** Access to the value of element [ @a i, @a j ] */
constexpr auto operator()(size_t i, size_t j) const
constexpr auto operator()(std::size_t i, std::size_t j) const
{
return m_m1(i, j) - m_m2(i, j);
}
@@ -523,17 +523,17 @@ class matrix_matrix_multiplication : public matrix_expression<matrix_matrix_mult
assert(m1.dim_m() == m2.dim_n());
}
constexpr size_t dim_m() const { return m_m1.dim_m(); } ///< Return dimension m
constexpr size_t dim_n() const { return m_m1.dim_n(); } ///< Return dimension n
constexpr std::size_t dim_m() const { return m_m1.dim_m(); } ///< Return dimension m
constexpr std::size_t dim_n() const { return m_m1.dim_n(); } ///< Return dimension n
/** Access to the value of element [ @a i, @a j ] */
constexpr auto operator()(size_t i, size_t j) const
constexpr auto operator()(std::size_t i, std::size_t j) const
{
using value_type = decltype(m_m1(0, 0));
value_type result = {};
for (size_t k = 0; k < m_m1.dim_m(); ++k)
for (std::size_t k = 0; k < m_m1.dim_m(); ++k)
result += m_m1(i, k) * m_m2(k, j);
return result;
@@ -564,11 +564,11 @@ class matrix_scalar_multiplication : public matrix_expression<matrix_scalar_mult
{
}
constexpr size_t dim_m() const { return m_m.dim_m(); } ///< Return dimension m
constexpr size_t dim_n() const { return m_m.dim_n(); } ///< Return dimension n
constexpr std::size_t dim_m() const { return m_m.dim_m(); } ///< Return dimension m
constexpr std::size_t dim_n() const { return m_m.dim_n(); } ///< Return dimension n
/** Access to the value of element [ @a i, @a j ] */
constexpr auto operator()(size_t i, size_t j) const
constexpr auto operator()(std::size_t i, std::size_t j) const
{
return m_m(i, j) * m_v;
}
@@ -655,21 +655,21 @@ class matrix_cofactors : public matrix_expression<matrix_cofactors<M>>
{
}
constexpr size_t dim_m() const { return m_m.dim_m(); } ///< Return dimension m
constexpr size_t dim_n() const { return m_m.dim_n(); } ///< Return dimension n
constexpr std::size_t dim_m() const { return m_m.dim_m(); } ///< Return dimension m
constexpr std::size_t dim_n() const { return m_m.dim_n(); } ///< Return dimension n
/** Access to the value of element [ @a i, @a j ] */
constexpr auto operator()(size_t i, size_t j) const
constexpr auto operator()(std::size_t i, std::size_t j) const
{
const size_t ixs[4][3] = {
const std::size_t ixs[4][3] = {
{ 1, 2, 3 },
{ 0, 2, 3 },
{ 0, 1, 3 },
{ 0, 1, 2 }
};
const size_t *ix = ixs[i];
const size_t *iy = ixs[j];
const std::size_t *ix = ixs[i];
const std::size_t *iy = ixs[j];
auto result =
m_m(ix[0], iy[0]) * m_m(ix[1], iy[1]) * m_m(ix[2], iy[2]) +

View File

@@ -604,7 +604,7 @@ class monomer : public residue
monomer &operator=(monomer &&rhs);
/// \brief constructor with actual values
monomer(const polymer &polymer, size_t index, int seqID, const std::string &authSeqID,
monomer(const polymer &polymer, std::size_t index, int seqID, const std::string &authSeqID,
const std::string &pdbInsCode, const std::string &compoundID);
bool is_first_in_chain() const; ///< Return if this residue is the first residue in the chain
@@ -624,8 +624,8 @@ class monomer : public residue
float omega() const; ///< Return the omega value for this residue
// torsion angles
size_t nr_of_chis() const; ///< Return how many torsion angles can be calculated
float chi(size_t i) const; ///< Return torsion angle @a i
std::size_t nr_of_chis() const; ///< Return how many torsion angles can be calculated
float chi(std::size_t i) const; ///< Return torsion angle @a i
bool is_cis() const; ///< Return true if this residue is in a cis conformation
@@ -674,7 +674,7 @@ class monomer : public residue
private:
const polymer *m_polymer;
size_t m_index;
std::size_t m_index;
};
// --------------------------------------------------------------------
@@ -756,9 +756,9 @@ class sugar : public residue
void set_link(atom link) { m_link = link; }
/// \brief Return the sugar number of the sugar linked to C1
size_t get_link_nr() const
std::size_t get_link_nr() const
{
size_t result = 0;
std::size_t result = 0;
if (m_link)
result = m_link.get_property_int("auth_seq_id");
return result;
@@ -865,10 +865,10 @@ class structure
{
public:
/// \brief Read the structure from cif::file @a p
structure(file &p, size_t modelNr = 1, StructureOpenOptions options = {});
structure(file &p, std::size_t modelNr = 1, StructureOpenOptions options = {});
/// \brief Load the structure from already parsed mmCIF data in @a db
structure(datablock &db, size_t modelNr = 1, StructureOpenOptions options = {});
structure(datablock &db, std::size_t modelNr = 1, StructureOpenOptions options = {});
/** @cond */
structure(structure &&s) = default;
@@ -881,7 +881,7 @@ class structure
~structure() = default;
/// \brief Return the model number
size_t get_model_nr() const { return m_model_nr; }
std::size_t get_model_nr() const { return m_model_nr; }
/// \brief Return a list of all the atoms in this structure
const std::vector<atom> &atoms() const { return m_atoms; }
@@ -1107,9 +1107,9 @@ class structure
void remove_sugar(sugar &sugar);
datablock &m_db;
size_t m_model_nr;
std::size_t m_model_nr;
std::vector<atom> m_atoms;
std::vector<size_t> m_atom_index;
std::vector<std::size_t> m_atom_index;
std::list<polymer> m_polymers;
std::list<branch> m_branches;
std::vector<residue> m_non_polymers;

View File

@@ -867,7 +867,7 @@ class spherical_dots
}
/// \brief The number of points
size_t size() const { return P; }
std::size_t size() const { return P; }
/// \brief Access a point by index
const point operator[](uint32_t inIx) const { return m_points[inIx]; }

View File

@@ -85,7 +85,7 @@ namespace detail
template <typename... C>
struct get_row_result
{
static constexpr size_t N = sizeof...(C);
static constexpr std::size_t N = sizeof...(C);
get_row_result(const row_handle &r, std::array<uint16_t, N> &&items)
: m_row(r)
@@ -104,7 +104,7 @@ namespace detail
return get<Ts...>(std::index_sequence_for<Ts...>{});
}
template <typename... Ts, size_t... Is>
template <typename... Ts, std::size_t... Is>
std::tuple<Ts...> get(std::index_sequence<Is...>) const
{
return std::tuple<Ts...>{ m_row[m_items[Is]].template as<Ts>()... };

View File

@@ -300,7 +300,7 @@ namespace literals
* @endcode
*
*/
inline sym_op operator""_symop(const char *text, size_t length)
inline sym_op operator""_symop(const char *text, std::size_t length)
{
return sym_op({ text, length });
}
@@ -464,7 +464,7 @@ class spacegroup : public std::vector<transformation>
private:
int m_nr;
size_t m_index;
std::size_t m_index;
};
// --------------------------------------------------------------------

View File

@@ -352,7 +352,7 @@ std::string cif_id_for_number(int number);
* a dynamic programming approach to get the most efficient filling of
* the space.
*/
std::vector<std::string> word_wrap(const std::string &text, size_t width);
std::vector<std::string> word_wrap(const std::string &text, std::size_t width);
// --------------------------------------------------------------------
/// \brief std::from_chars for floating point types.

View File

@@ -164,7 +164,7 @@ class category_index
return result;
}
size_t size() const;
std::size_t size() const;
// bool isValid() const;
private:
@@ -475,12 +475,12 @@ category_index::entry *category_index::erase(category &cat, entry *h, row *k)
return fix_up(h);
}
size_t category_index::size() const
std::size_t category_index::size() const
{
std::stack<entry *> s;
s.push(m_root);
size_t result = 0;
std::size_t result = 0;
while (not s.empty())
{
@@ -544,7 +544,7 @@ category::~category()
void category::remove_item(std::string_view item_name)
{
for (size_t ix = 0; ix < m_items.size(); ++ix)
for (std::size_t ix = 0; ix < m_items.size(); ++ix)
{
if (not iequals(item_name, m_items[ix].m_name))
continue;
@@ -563,7 +563,7 @@ void category::remove_item(std::string_view item_name)
void category::rename_item(std::string_view from_name, std::string_view to_name)
{
for (size_t ix = 0; ix < m_items.size(); ++ix)
for (std::size_t ix = 0; ix < m_items.size(); ++ix)
{
if (not iequals(from_name, m_items[ix].m_name))
continue;
@@ -832,7 +832,7 @@ bool category::validate_links() const
if (name() == "atom_site" and (parent->name() == "pdbx_poly_seq_scheme" or parent->name() == "entity_poly_seq"))
continue;
size_t missing = 0;
std::size_t missing = 0;
category first_missing_rows(name());
for (auto r : *this)
@@ -909,7 +909,7 @@ condition category::get_parents_condition(row_handle rh, const category &parentC
{
condition cond;
for (size_t ix = 0; ix < link->m_child_keys.size(); ++ix)
for (std::size_t ix = 0; ix < link->m_child_keys.size(); ++ix)
{
auto childValue = rh[link->m_child_keys[ix]];
@@ -951,7 +951,7 @@ condition category::get_children_condition(row_handle rh, const category &childC
{
condition cond;
for (size_t ix = 0; ix < link->m_parent_keys.size(); ++ix)
for (std::size_t ix = 0; ix < link->m_parent_keys.size(); ++ix)
{
auto childKey = link->m_child_keys[ix];
auto parentKey = link->m_parent_keys[ix];
@@ -1127,14 +1127,14 @@ class save_value
const T m_sv;
};
size_t category::erase(condition &&cond)
std::size_t category::erase(condition &&cond)
{
return erase(std::move(cond), {});
}
size_t category::erase(condition &&cond, std::function<void(row_handle)> &&visit)
std::size_t category::erase(condition &&cond, std::function<void(row_handle)> &&visit)
{
size_t result = 0;
std::size_t result = 0;
cond.prepare(*this);
@@ -1274,7 +1274,7 @@ std::string category::get_unique_value(std::string_view item_name)
if (result.empty())
{
// brain-dead implementation
for (size_t ix = 0; ix < size(); ++ix)
for (std::size_t ix = 0; ix < size(); ++ix)
{
// result = m_name + "-" + std::to_string(ix);
result = cif_id_for_number(ix);
@@ -1331,7 +1331,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie
condition cond;
std::string childItemName;
for (size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
for (std::size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
{
std::string pk = linked->m_parent_keys[ix];
std::string ck = linked->m_child_keys[ix];
@@ -1362,7 +1362,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie
{
condition cond_c;
for (size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
for (std::size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
{
std::string pk = linked->m_parent_keys[ix];
std::string ck = linked->m_child_keys[ix];
@@ -1380,7 +1380,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie
// oops, we need to split this child, unless a row already exists for the new value
condition check;
for (size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
for (std::size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
{
std::string pk = linked->m_parent_keys[ix];
std::string ck = linked->m_child_keys[ix];
@@ -1476,7 +1476,7 @@ void category::update_value(row *row, uint16_t item, std::string_view value, boo
condition cond;
std::string childItemName;
for (size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
for (std::size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
{
std::string pk = linked->m_parent_keys[ix];
std::string ck = linked->m_child_keys[ix];
@@ -1513,7 +1513,7 @@ void category::update_value(row *row, uint16_t item, std::string_view value, boo
condition cond_n;
for (size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
for (std::size_t ix = 0; ix < linked->m_parent_keys.size(); ++ix)
{
std::string pk = linked->m_parent_keys[ix];
std::string ck = linked->m_child_keys[ix];
@@ -1720,7 +1720,7 @@ void category::sort(std::function<int(row_handle, row_handle)> f)
m_tail = rows.back().get_row();
auto r = m_head;
for (size_t i = 1; i < rows.size(); ++i)
for (std::size_t i = 1; i < rows.size(); ++i)
r = r->m_next = rows[i].get_row();
r->m_next = nullptr;
@@ -1736,7 +1736,7 @@ void category::reorder_by_index()
namespace detail
{
size_t write_value(std::ostream &os, std::string_view value, size_t offset, size_t width, bool right_aligned)
std::size_t write_value(std::ostream &os, std::string_view value, std::size_t offset, std::size_t width, bool right_aligned)
{
if (value.find('\n') != std::string::npos or width == 0 or value.length() > 132) // write as text item
{
@@ -1897,7 +1897,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
{
os << "loop_\n";
std::vector<size_t> itemWidths(m_items.size());
std::vector<std::size_t> itemWidths(m_items.size());
for (auto cix : order)
{
@@ -1919,7 +1919,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
if (v->text().find('\n') == std::string_view::npos)
{
size_t l = v->text().length();
std::size_t l = v->text().length();
if (not sac_parser::is_unquoted_string(v->text()))
l += 2;
@@ -1935,11 +1935,11 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
for (auto r = m_head; r != nullptr; r = r->m_next) // loop over rows
{
size_t offset = 0;
std::size_t offset = 0;
for (uint16_t cix : order)
{
size_t w = itemWidths[cix];
std::size_t w = itemWidths[cix];
std::string_view s;
auto iv = r->get(cix);
@@ -1949,7 +1949,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
if (s.empty())
s = "?";
size_t l = s.length();
std::size_t l = s.length();
if (not sac_parser::is_unquoted_string(s))
l += 2;
if (l < w)
@@ -1977,7 +1977,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
else
{
// first find the indent level
size_t l = 0;
std::size_t l = 0;
for (auto &col : m_items)
{
@@ -1989,7 +1989,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
l += 3;
size_t width = 1;
std::size_t width = 1;
for (auto cix : order)
{
@@ -2004,7 +2004,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
if (s.empty())
s = "?";
size_t l2 = s.length();
std::size_t l2 = s.length();
if (not sac_parser::is_unquoted_string(s))
l2 += 2;
@@ -2030,7 +2030,7 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
if (s.empty())
s = "?";
size_t offset = l;
std::size_t offset = l;
if (s.length() + l >= kMaxLineLength)
{
os << '\n';
@@ -2070,7 +2070,7 @@ bool category::operator==(const category &rhs) const
typedef std::function<int(std::string_view, std::string_view)> compType;
std::vector<std::tuple<std::string, compType>> item_names;
std::vector<std::string> keys;
std::vector<size_t> keyIx;
std::vector<std::size_t> keyIx;
if (catValidator == nullptr)
{

View File

@@ -608,9 +608,9 @@ compound *local_compound_factory_impl::construct_compound(const datablock &rdb,
float formula_weight = 0;
int formal_charge = 0;
std::map<std::string,size_t> formula_data;
std::map<std::string,std::size_t> formula_data;
for (size_t ord = 1; const auto &[atom_id, type_symbol, type, charge, x, y, z] :
for (std::size_t ord = 1; const auto &[atom_id, type_symbol, type, charge, x, y, z] :
rdb["chem_comp_atom"].rows<std::string, std::string, std::string, int, float, float, float>(
"atom_id", "type_symbol", "type", "charge", "x", "y", "z"))
{
@@ -633,7 +633,7 @@ compound *local_compound_factory_impl::construct_compound(const datablock &rdb,
formal_charge += charge;
}
for (size_t ord = 1; const auto &[atom_id_1, atom_id_2, type, aromatic] :
for (std::size_t ord = 1; const auto &[atom_id_1, atom_id_2, type, aromatic] :
rdb["chem_comp_bond"].rows<std::string, std::string, std::string, bool>("atom_id_1", "atom_id_2", "type", "aromatic"))
{
std::string value_order("SING");

View File

@@ -76,6 +76,20 @@ namespace detail
return this;
}
condition_impl *key_equals_number_condition_impl::prepare(const category &c)
{
m_item_ix = c.get_item_ix(m_item_name);
if (c.get_cat_validator() != nullptr and
c.key_item_indices().contains(m_item_ix) and
c.key_item_indices().size() == 1)
{
m_single_hit = c[{ { m_item_name, m_value } }];
}
return this;
}
bool found_in_range(condition_impl *c, std::vector<and_condition_impl *>::iterator b, std::vector<and_condition_impl *>::iterator e)
{
bool result = true;

View File

@@ -308,17 +308,17 @@ class dictionary_parser : public parser
using key_type = std::tuple<std::string, std::string, int>;
std::map<key_type, size_t> linkIndex;
std::map<key_type, std::size_t> linkIndex;
// Each link group consists of a set of keys
std::vector<std::tuple<std::vector<std::string>, std::vector<std::string>>> linkKeys;
auto addLink = [&](size_t ix, const std::string &pk, const std::string &ck)
auto addLink = [&](std::size_t ix, const std::string &pk, const std::string &ck)
{
auto &&[pkeys, ckeys] = linkKeys.at(ix);
bool found = false;
for (size_t i = 0; i < pkeys.size(); ++i)
for (std::size_t i = 0; i < pkeys.size(); ++i)
{
if (pkeys[i] == pk and ckeys[i] == ck)
{
@@ -357,7 +357,7 @@ class dictionary_parser : public parser
linkKeys.push_back({});
}
size_t ix = linkIndex.at(key);
std::size_t ix = linkIndex.at(key);
addLink(ix, piv->m_item_name, civ->m_item_name);
}
@@ -385,7 +385,7 @@ class dictionary_parser : public parser
linkKeys.push_back({});
}
size_t ix = linkIndex.at(key);
std::size_t ix = linkIndex.at(key);
addLink(ix, piv->m_item_name, civ->m_item_name);
}
}

View File

@@ -488,7 +488,7 @@ std::ostream &operator<<(std::ostream &os, const residue &res)
// --------------------------------------------------------------------
// monomer
monomer::monomer(const polymer &polymer, size_t index, int seqID, const std::string &authSeqID, const std::string &pdbInsCode, const std::string &compoundID)
monomer::monomer(const polymer &polymer, std::size_t index, int seqID, const std::string &authSeqID, const std::string &pdbInsCode, const std::string &compoundID)
: residue(*polymer.get_structure(), compoundID, polymer.get_asym_id(), seqID, polymer.get_auth_asym_id(), authSeqID, pdbInsCode)
, m_polymer(&polymer)
, m_index(index)
@@ -693,9 +693,9 @@ const std::map<std::string, std::vector<std::string>> kChiAtomsMap = {
{"PRO", {"CG", "CD"}},
{"VAL", {"CG1"}}};
size_t monomer::nr_of_chis() const
std::size_t monomer::nr_of_chis() const
{
size_t result = 0;
std::size_t result = 0;
auto i = kChiAtomsMap.find(m_compound_id);
if (i != kChiAtomsMap.end())
@@ -704,7 +704,7 @@ size_t monomer::nr_of_chis() const
return result;
}
float monomer::chi(size_t nr) const
float monomer::chi(std::size_t nr) const
{
float result = 0;
@@ -891,7 +891,7 @@ polymer::polymer(structure &s, const std::string &entityID, const std::string &a
{
using namespace cif::literals;
std::map<size_t, size_t> ix;
std::map<std::size_t, std::size_t> ix;
auto &poly_seq_scheme = s.get_datablock()["pdbx_poly_seq_scheme"];
reserve(poly_seq_scheme.size());
@@ -906,7 +906,7 @@ polymer::polymer(structure &s, const std::string &entityID, const std::string &a
if (authSeqID.empty() and pdbSeqNum.has_value())
authSeqID = std::to_string(*pdbSeqNum);
size_t index = size();
std::size_t index = size();
// store only the first
if (not ix.count(seqID))
@@ -1090,7 +1090,7 @@ branch::branch(structure &structure, const std::string &asym_id, const std::stri
emplace_back(*this, comp_id, asym_id, num);
}
for (const auto &[num1, num2, atom1, atom2] : branch_link.find<size_t, size_t, std::string, std::string>(
for (const auto &[num1, num2, atom1, atom2] : branch_link.find<std::size_t, std::size_t, std::string, std::string>(
"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"))
@@ -1117,7 +1117,7 @@ void branch::link_atoms()
auto entity_id = front().get_entity_id();
for (const auto &[num1, num2, atom1, atom2] : branch_link.find<size_t, size_t, std::string, std::string>(
for (const auto &[num1, num2, atom1, atom2] : branch_link.find<std::size_t, std::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"))
{
// if (not iequals(atom1, "c1"))
@@ -1252,12 +1252,12 @@ float branch::weight() const
// --------------------------------------------------------------------
// structure
structure::structure(file &p, size_t modelNr, StructureOpenOptions options)
structure::structure(file &p, std::size_t modelNr, StructureOpenOptions options)
: structure(p.front(), modelNr, options)
{
}
structure::structure(datablock &db, size_t modelNr, StructureOpenOptions options)
structure::structure(datablock &db, std::size_t modelNr, StructureOpenOptions options)
: m_db(db)
, m_model_nr(modelNr)
{
@@ -1268,7 +1268,7 @@ structure::structure(datablock &db, size_t modelNr, StructureOpenOptions options
// Check to see if we should actually load another model?
if (m_atoms.empty() and m_model_nr == 1)
{
std::optional<size_t> model_nr;
std::optional<std::size_t> model_nr;
cif::tie(model_nr) = atomCat.front().get("pdbx_PDB_model_num");
if (model_nr and *model_nr != m_model_nr)
{
@@ -1532,9 +1532,9 @@ atom structure::get_atom_by_label(const std::string &atom_id, const std::string
atom structure::get_atom_by_position(point p) const
{
double dist = std::numeric_limits<double>::max();
size_t index = std::numeric_limits<size_t>::max();
std::size_t index = std::numeric_limits<std::size_t>::max();
for (size_t i = 0; i < m_atoms.size(); ++i)
for (std::size_t i = 0; i < m_atoms.size(); ++i)
{
auto &a = m_atoms.at(i);
@@ -1555,9 +1555,9 @@ atom structure::get_atom_by_position(point p) const
atom structure::get_atom_by_position_and_type(point p, std::string_view type, std::string_view res_type) const
{
double dist = std::numeric_limits<double>::max();
size_t index = std::numeric_limits<size_t>::max();
std::size_t index = std::numeric_limits<std::size_t>::max();
for (size_t i = 0; i < m_atoms.size(); ++i)
for (std::size_t i = 0; i < m_atoms.size(); ++i)
{
auto &a = m_atoms.at(i);
@@ -2131,14 +2131,14 @@ void structure::remove_sugar(sugar &s)
auto si = std::find(branch.begin(), branch.end(), s);
if (si == branch.end())
throw std::runtime_error("sugar not part of branch");
size_t six = si - branch.begin();
std::size_t six = si - branch.begin();
if (six == 0) // first sugar, means the death of this branch
remove_branch(branch);
else
{
std::set<size_t> dix;
std::stack<size_t> test;
std::set<std::size_t> dix;
std::stack<std::size_t> test;
test.push(s.num());
while (not test.empty())
@@ -2279,7 +2279,7 @@ std::string structure::create_non_poly(const std::string &entity_id, const std::
}
auto &pdbx_nonpoly_scheme = m_db["pdbx_nonpoly_scheme"];
size_t ndb_nr = pdbx_nonpoly_scheme.find("asym_id"_key == asym_id and "entity_id"_key == entity_id).size() + 1;
std::size_t ndb_nr = pdbx_nonpoly_scheme.find("asym_id"_key == asym_id and "entity_id"_key == entity_id).size() + 1;
pdbx_nonpoly_scheme.emplace({
{"asym_id", asym_id},
{"entity_id", entity_id},
@@ -2342,7 +2342,7 @@ std::string structure::create_non_poly(const std::string &entity_id, std::vector
}
auto &pdbx_nonpoly_scheme = m_db["pdbx_nonpoly_scheme"];
size_t ndb_nr = pdbx_nonpoly_scheme.find("asym_id"_key == asym_id and "entity_id"_key == entity_id).size() + 1;
std::size_t ndb_nr = pdbx_nonpoly_scheme.find("asym_id"_key == asym_id and "entity_id"_key == entity_id).size() + 1;
pdbx_nonpoly_scheme.emplace({
{"asym_id", asym_id},
{"entity_id", entity_id},
@@ -2751,7 +2751,7 @@ void structure::cleanup_empty_categories()
std::string type, id;
cif::tie(type, id) = entity.get("type", "id");
std::optional<size_t> count;
std::optional<std::size_t> count;
if (type == "polymer")
count = m_db["struct_asym"].find("entity_id"_key == id).size();
else if (type == "non-polymer" or type == "water")
@@ -2797,7 +2797,7 @@ void structure::validate_atoms() const
{
// validate order
assert(m_atoms.size() == m_atom_index.size());
for (size_t i = 0; i + i < m_atoms.size(); ++i)
for (std::size_t i = 0; i + i < m_atoms.size(); ++i)
assert(m_atoms[m_atom_index[i]].id().compare(m_atoms[m_atom_index[i + 1]].id()) < 0);
std::vector<atom> atoms = m_atoms;

View File

@@ -182,7 +182,7 @@ std::vector<std::string> MapAsymIDs2ChainIDs(const std::vector<std::string> &asy
}
// support for wrapping text using a 'continuation marker'
size_t WriteContinuedLine(std::ostream &pdbFile, std::string header, int &count, int cLen, std::string text, std::string::size_type lStart = 0)
std::size_t WriteContinuedLine(std::ostream &pdbFile, std::string header, int &count, int cLen, std::string text, std::string::size_type lStart = 0)
{
if (lStart == 0)
{
@@ -217,15 +217,15 @@ size_t WriteContinuedLine(std::ostream &pdbFile, std::string header, int &count,
return lines.size();
}
size_t WriteOneContinuedLine(std::ostream &pdbFile, std::string header, int cLen, std::string line, int lStart = 0)
std::size_t WriteOneContinuedLine(std::ostream &pdbFile, std::string header, int cLen, std::string line, int lStart = 0)
{
int count = 0;
return WriteContinuedLine(pdbFile, header, count, cLen, line, lStart);
}
size_t WriteCitation(std::ostream &pdbFile, const datablock &db, row_handle r, int reference)
std::size_t WriteCitation(std::ostream &pdbFile, const datablock &db, row_handle r, int reference)
{
size_t result = 0;
std::size_t result = 0;
std::string s1;
@@ -560,7 +560,7 @@ void WriteTitle(std::ostream &pdbFile, const datablock &db)
std::string cs = ++continuation > 1 ? std::to_string(continuation) : std::string();
pdbFile << cif::format(kRevDatFmt, revNum, cs, date, db.name(), modType);
for (size_t i = 0; i < 4; ++i)
for (std::size_t i = 0; i < 4; ++i)
pdbFile << cif::format(" %-6.6s", (i < types.size() ? types[i] : std::string()));
pdbFile << '\n';
@@ -748,7 +748,7 @@ class Fs : public FBase
virtual void out(std::ostream &os)
{
std::string s{ text() };
size_t width = os.width();
std::size_t width = os.width();
if (s.empty())
{
@@ -2368,7 +2368,7 @@ void WriteRemark280(std::ostream &pdbFile, const datablock &db)
const char *keys[] = { "pdbx_details", "ph", "method", "temp" };
for (size_t i = 0; i < (sizeof(keys) / sizeof(const char *)); ++i)
for (std::size_t i = 0; i < (sizeof(keys) / sizeof(const char *)); ++i)
{
const char *c = keys[i];
@@ -2634,7 +2634,7 @@ void WriteRemark470(std::ostream &pdbFile, const datablock &db)
{
pdbFile << cif::format("REMARK 470 %3.3s %3.3s %1.1s%4d%1.1s ", modelNr, resName, chainID, seqNr, iCode) << " ";
for (size_t i = 0; i < 6 and not a.second.empty(); ++i)
for (std::size_t i = 0; i < 6 and not a.second.empty(); ++i)
{
pdbFile << cif2pdbAtomName(a.second.front(), resName, db) << ' ';
a.second.pop_front();
@@ -3284,7 +3284,7 @@ int WriteMiscellaneousFeatures(std::ostream &pdbFile, const datablock &db)
std::string siteID = std::get<0>(s);
std::deque<std::string> &res = std::get<1>(s);
size_t numRes = res.size();
std::size_t numRes = res.size();
int nr = 1;
while (res.empty() == false)

View File

@@ -160,7 +160,7 @@ PDBRecord::~PDBRecord()
{
}
void *PDBRecord::operator new(size_t size, size_t vLen)
void *PDBRecord::operator new(std::size_t size, std::size_t vLen)
{
return malloc(size + vLen + 1);
}
@@ -170,7 +170,7 @@ void PDBRecord::operator delete(void *p)
free(p);
}
void PDBRecord::operator delete(void *p, size_t vLen)
void PDBRecord::operator delete(void *p, std::size_t vLen)
{
free(p);
}
@@ -180,7 +180,7 @@ bool PDBRecord::is(const char *name) const
return iequals(mName, name);
}
char PDBRecord::vC(size_t column)
char PDBRecord::vC(std::size_t column)
{
char result = ' ';
if (column - 7 < mVlen)
@@ -188,7 +188,7 @@ char PDBRecord::vC(size_t column)
return result;
}
std::string PDBRecord::vS(size_t columnFirst, size_t columnLast)
std::string PDBRecord::vS(std::size_t columnFirst, std::size_t columnLast)
{
std::string result;
@@ -272,7 +272,7 @@ int PDBRecord::vI(int columnFirst, int columnLast)
return result;
}
std::string PDBRecord::vF(size_t columnFirst, size_t columnLast)
std::string PDBRecord::vF(std::size_t columnFirst, std::size_t columnLast)
{
// for now... TODO: check format?
return vS(columnFirst, columnLast);
@@ -780,17 +780,17 @@ class PDBFileParser
// ----------------------------------------------------------------
char vC(size_t column) const
char vC(std::size_t column) const
{
return mRec->vC(column);
}
std::string vS(size_t columnFirst, size_t columnLast = std::numeric_limits<size_t>::max()) const
std::string vS(std::size_t columnFirst, std::size_t columnLast = std::numeric_limits<std::size_t>::max()) const
{
return mRec->vS(columnFirst, columnLast);
}
std::string vF(size_t columnFirst, size_t columnLast) const
std::string vF(std::size_t columnFirst, std::size_t columnLast) const
{
return mRec->vF(columnFirst, columnLast);
}
@@ -847,7 +847,7 @@ class PDBFileParser
void ParseRemarks();
// void ParseRemark3();
// size_t ParseRemark3(const std::string& program, const Remark3Template templ[], size_t N);
// std::size_t ParseRemark3(const std::string& program, const Remark3Template templ[], std::size_t N);
// std::string NextRemark3Line();
void ParseRemark200();
@@ -1320,7 +1320,7 @@ void PDBFileParser::PreParseInput(std::istream &is)
{
std::string siteName = value.substr(5, 3);
cif::trim_right(value);
size_t n = value.length() - 12;
std::size_t n = value.length() - 12;
value += std::string(11 - (n % 11), ' ');
while (lookahead.substr(0, 6) == type and lookahead.substr(11, 3) == siteName)
@@ -4202,7 +4202,7 @@ void PDBFileParser::ConstructEntities()
chains.push_back(std::string{ chain.mDbref.chainID });
size_t seqLen = 0, seqCanLen = 0;
std::size_t seqLen = 0, seqCanLen = 0;
for (auto &res : chain.mSeqres)
{
@@ -4265,7 +4265,7 @@ void PDBFileParser::ConstructEntities()
}
auto cat_ps = getCategory("entity_poly_seq");
for (size_t i = 0; i < chain.mSeqres.size(); ++i)
for (std::size_t i = 0; i < chain.mSeqres.size(); ++i)
{
auto &rs = chain.mSeqres[i];
@@ -4335,7 +4335,7 @@ void PDBFileParser::ConstructEntities()
std::map<std::tuple<std::string, std::string>, int> ndbSeqNum; // for nonpoly scheme
std::map<std::string, int> entityAuthSeqNum; // for nonpoly scheme too
for (size_t i = 0; i < mHets.size(); ++i)
for (std::size_t i = 0; i < mHets.size(); ++i)
{
auto &heti = mHets[i];
@@ -5712,7 +5712,7 @@ void PDBFileParser::ParseCoordinate(int modelNr)
stable_sort(atoms.begin(), atoms.end(), rLess);
// now reiterate the atoms to reorder alternates
for (size_t i = 0; i + 1 < atoms.size(); ++i)
for (std::size_t i = 0; i + 1 < atoms.size(); ++i)
{
char altLoc = std::get<3>(atoms[i])->vC(17);
@@ -6361,7 +6361,7 @@ bool PDBFileParser::PDBChain::SameSequence(const PDBChain &rhs) const
{
bool result = mSeqres.size() == rhs.mSeqres.size();
for (size_t i = 0; result and i < mSeqres.size(); ++i)
for (std::size_t i = 0; result and i < mSeqres.size(); ++i)
result = mSeqres[i].mMonID == rhs.mSeqres[i].mMonID;
return result;

View File

@@ -980,8 +980,8 @@ std::string Remark3Parser::nextLine()
while (mRec != nullptr and mRec->is("REMARK 3"))
{
size_t valueIndent = 0;
for (size_t i = 4; i < mRec->mVlen; ++i)
std::size_t valueIndent = 0;
for (std::size_t i = 4; i < mRec->mVlen; ++i)
{
if (mRec->mValue[i] == ' ')
continue;
@@ -1232,7 +1232,7 @@ void Remark3Parser::storeCapture(const char *category, std::initializer_list<con
}
// else if (iequals(category, "struct_ncs_dom"))
// {
// size_t id = cat.size() + 1;
// std::size_t id = cat.size() + 1;
//
// cat.emplace({
// { "id", id }

View File

@@ -40,24 +40,24 @@ struct PDBRecord
PDBRecord *mNext;
uint32_t mLineNr;
char mName[11];
size_t mVlen;
std::size_t mVlen;
char mValue[1];
PDBRecord(uint32_t lineNr, const std::string &name, const std::string &value);
~PDBRecord();
void *operator new(size_t);
void *operator new(size_t size, size_t vLen);
void *operator new(std::size_t);
void *operator new(std::size_t size, std::size_t vLen);
void operator delete(void *p);
void operator delete(void *p, size_t vLen);
void operator delete(void *p, std::size_t vLen);
bool is(const char *name) const;
char vC(size_t column);
std::string vS(size_t columnFirst, size_t columnLast = std::numeric_limits<size_t>::max());
char vC(std::size_t column);
std::string vS(std::size_t columnFirst, std::size_t columnLast = std::numeric_limits<std::size_t>::max());
int vI(int columnFirst, int columnLast);
std::string vF(size_t columnFirst, size_t columnLast);
std::string vF(std::size_t columnFirst, std::size_t columnLast);
};
} // namespace pdbx

View File

@@ -211,11 +211,11 @@ void createEntityIDs(datablock &db)
lastSeqID = seq_id;
}
std::map<size_t, std::string> entity_ids;
std::map<std::size_t, std::string> entity_ids;
atom_site.add_item("label_entity_id");
for (size_t i = 0; i < entities.size(); ++i)
for (std::size_t i = 0; i < entities.size(); ++i)
{
if (entity_ids.contains(i))
continue;
@@ -223,14 +223,14 @@ void createEntityIDs(datablock &db)
auto entity_id = std::to_string(i + 1);
entity_ids[i] = entity_id;
for (size_t j = i + 1; j < entities.size(); ++j)
for (std::size_t j = i + 1; j < entities.size(); ++j)
{
if (entities[i] == entities[j])
entity_ids[j] = entity_id;
}
}
for (size_t ix = 0; auto &e : entities)
for (std::size_t ix = 0; auto &e : entities)
{
auto k = e.front();
const auto &entity_id = entity_ids[ix++];
@@ -1138,7 +1138,7 @@ bool reconstruct_pdbx(file &file, std::string_view dictionary)
iv->m_type != nullptr and
iv->m_type->m_primitive_type == cif::DDL_PrimitiveType::Numb;
for (size_t ix = 0; auto row : cat)
for (std::size_t ix = 0; auto row : cat)
{
if (number)
row.assign(key, std::to_string(++ix), false, false);

View File

@@ -48,7 +48,7 @@ condition get_parents_condition(const validator &validator, row_handle rh, const
{
condition cond;
for (size_t ix = 0; ix < link->m_child_keys.size(); ++ix)
for (std::size_t ix = 0; ix < link->m_child_keys.size(); ++ix)
{
auto childValue = rh[link->m_child_keys[ix]];

View File

@@ -128,7 +128,7 @@ std::string sym_op::string() const
*r.ptr++ = '0' + m_tc;
*r.ptr = 0;
return { b, static_cast<size_t>(r.ptr - b) };
return { b, static_cast<std::size_t>(r.ptr - b) };
}
// --------------------------------------------------------------------
@@ -184,7 +184,7 @@ void transformation::try_create_quaternion()
auto ev = es.eigenvalues();
for (size_t j = 0; j < 4; ++j)
for (std::size_t j = 0; j < 4; ++j)
{
if (std::abs(ev[j].real() - 1) > 0.01)
continue;
@@ -221,7 +221,7 @@ transformation inverse(const transformation &t)
spacegroup::spacegroup(int nr)
: m_nr(nr)
{
const size_t N = kSymopNrTableSize;
const std::size_t N = kSymopNrTableSize;
int32_t L = 0, R = static_cast<int32_t>(N - 1);
while (L <= R)
{
@@ -234,7 +234,7 @@ spacegroup::spacegroup(int nr)
m_index = L;
for (size_t i = L; i < N and kSymopNrTable[i].spacegroup() == m_nr; ++i)
for (std::size_t i = L; i < N and kSymopNrTable[i].spacegroup() == m_nr; ++i)
emplace_back(kSymopNrTable[i].symop().data());
}
@@ -343,7 +343,7 @@ int get_space_group_number(std::string_view spacegroup)
int result = 0;
const size_t N = kNrOfSpaceGroups;
const std::size_t N = kNrOfSpaceGroups;
int32_t L = 0, R = static_cast<int32_t>(N - 1);
while (L <= R)
{
@@ -365,7 +365,7 @@ int get_space_group_number(std::string_view spacegroup)
// not found, see if we can find a match based on xHM name
if (result == 0)
{
for (size_t i = 0; i < kNrOfSpaceGroups; ++i)
for (std::size_t i = 0; i < kNrOfSpaceGroups; ++i)
{
auto &sp = kSpaceGroups[i];
if (sp.xHM == spacegroup)
@@ -395,7 +395,7 @@ int get_space_group_number(std::string_view spacegroup, space_group_name type)
if (type == space_group_name::full)
{
const size_t N = kNrOfSpaceGroups;
const std::size_t N = kNrOfSpaceGroups;
int32_t L = 0, R = static_cast<int32_t>(N - 1);
while (L <= R)
{
@@ -475,7 +475,7 @@ std::tuple<float,point,sym_op> crystal::closest_symmetry_copy(point a, point b)
a = orthogonal(fa, m_cell);
for (size_t i = 0; i < m_spacegroup.size(); ++i)
for (std::size_t i = 0; i < m_spacegroup.size(); ++i)
{
sym_op s(static_cast<uint8_t>(i + 1));
auto &t = m_spacegroup[i];

View File

@@ -426,7 +426,7 @@ const space_group kSpaceGroups[] =
out << R"(
};
const size_t kNrOfSpaceGroups = sizeof(kSpaceGroups) / sizeof(space_group);
const std::size_t kNrOfSpaceGroups = sizeof(kSpaceGroups) / sizeof(space_group);
const symop_datablock kSymopNrTable[] = {
)";
@@ -450,7 +450,7 @@ const symop_datablock kSymopNrTable[] = {
out << R"(};
const size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(symop_datablock);
const std::size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(symop_datablock);
} // namespace mmcif
)";

View File

@@ -361,7 +361,7 @@ const space_group kSpaceGroups[] =
};
const size_t kNrOfSpaceGroups = sizeof(kSpaceGroups) / sizeof(space_group);
const std::size_t kNrOfSpaceGroups = sizeof(kSpaceGroups) / sizeof(space_group);
const symop_datablock kSymopNrTable[] = {
// P 1
@@ -5286,6 +5286,6 @@ const symop_datablock kSymopNrTable[] = {
{ 5005, 4, { -1, 0, 0, 0, 1, 0, 0, 0,-1, 1, 2, 0, 0, 1, 2, } },
};
const size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(symop_datablock);
const std::size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(symop_datablock);
} // namespace mmcif

View File

@@ -433,10 +433,10 @@ std::string::const_iterator nextLineBreak(std::string::const_iterator text, std:
return text;
}
std::vector<std::string> wrapLine(const std::string &text, size_t width)
std::vector<std::string> wrapLine(const std::string &text, std::size_t width)
{
std::vector<std::string> result;
std::vector<size_t> offsets = { 0 };
std::vector<std::size_t> offsets = { 0 };
auto b = text.begin();
while (b != text.end())
@@ -448,18 +448,18 @@ std::vector<std::string> wrapLine(const std::string &text, size_t width)
b = e;
}
size_t count = offsets.size() - 1;
std::size_t count = offsets.size() - 1;
std::vector<size_t> minima(count + 1, 1000000);
std::vector<std::size_t> minima(count + 1, 1000000);
minima[0] = 0;
std::vector<size_t> breaks(count + 1, 0);
std::vector<std::size_t> breaks(count + 1, 0);
for (size_t i = 0; i < count; ++i)
for (std::size_t i = 0; i < count; ++i)
{
size_t j = i + 1;
std::size_t j = i + 1;
while (j <= count)
{
size_t w = offsets[j] - offsets[i];
std::size_t w = offsets[j] - offsets[i];
if (w > width)
break;
@@ -467,7 +467,7 @@ std::vector<std::string> wrapLine(const std::string &text, size_t width)
while (w > 0 and isspace(text[offsets[i] + w - 1]))
--w;
size_t cost = minima[i];
std::size_t cost = minima[i];
if (j < count) // last line may be shorter
cost += (width - w) * (width - w);
@@ -481,10 +481,10 @@ std::vector<std::string> wrapLine(const std::string &text, size_t width)
}
}
size_t j = count;
std::size_t j = count;
while (j > 0)
{
size_t i = breaks[j];
std::size_t i = breaks[j];
result.push_back(text.substr(offsets[i], offsets[j] - offsets[i]));
j = i;
}
@@ -494,7 +494,7 @@ std::vector<std::string> wrapLine(const std::string &text, size_t width)
return result;
}
std::vector<std::string> word_wrap(const std::string &text, size_t width)
std::vector<std::string> word_wrap(const std::string &text, std::size_t width)
{
std::vector<std::string> result;
for (auto p : cif::split<std::string>(text, "\n"))

View File

@@ -215,7 +215,7 @@ const char* kSpinner[] = {
".", "o", "O", "0", "@", "*", " "
};
const size_t kSpinnerCount = sizeof(kSpinner) / sizeof(char*);
const std::size_t kSpinnerCount = sizeof(kSpinner) / sizeof(char*);
const int kSpinnerTimeInterval = 100;
@@ -877,6 +877,21 @@ class resource_pool
resource_pool::resource_pool()
{
// directories are searched in reverse order
// As a last resort, try the location that might have been
// used during installation, works only when running on an
// OS with a proc file system.
std::error_code ec;
if (auto exefile = fs::read_symlink("/proc/self/exe", ec); not ec and exefile.parent_path().filename() == "bin")
{
auto install_prefix = exefile.parent_path().parent_path();
auto data_dir = install_prefix / "share" / "libcifpp";
if (fs::exists(data_dir, ec))
pushDir(data_dir);
}
#if defined(DATA_DIR)
pushDir(DATA_DIR);
#endif

View File

@@ -353,7 +353,7 @@ void validator::add_link_validator(link_validator &&v)
if (ccv == nullptr)
throw std::runtime_error("unknown child category " + v.m_child_category);
for (size_t i = 0; i < v.m_parent_keys.size(); ++i)
for (std::size_t i = 0; i < v.m_parent_keys.size(); ++i)
{
auto piv = pcv->get_validator_for_item(v.m_parent_keys[i]);

View File

@@ -32,11 +32,11 @@
// --------------------------------------------------------------------
cif::file operator""_cf(const char *text, size_t length)
cif::file operator""_cf(const char *text, std::size_t length)
{
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}

View File

@@ -32,11 +32,11 @@
// --------------------------------------------------------------------
cif::file operator""_cf(const char* text, size_t length)
cif::file operator""_cf(const char* text, std::size_t length)
{
struct membuf : public std::streambuf
{
membuf(char* text, size_t length)
membuf(char* text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -131,7 +131,7 @@ TEST_CASE("sugar_name_1")
// auto &db = s.get_datablock();
// auto &as = db["atom_site"];
// for (size_t i = 0; i < 2; ++i)
// for (std::size_t i = 0; i < 2; ++i)
// {
// for (auto r : as.find("label_asym_id"_key == "H" and "auth_seq_id"_key == i + 1))
// /*auto &ri = */ai[i].emplace_back(r);

View File

@@ -34,11 +34,11 @@
// --------------------------------------------------------------------
cif::file operator""_cf(const char *text, size_t length)
cif::file operator""_cf(const char *text, std::size_t length)
{
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -230,7 +230,7 @@ TEST_CASE("dh_q_1")
TEST_CASE("m2q_0, *utf::tolerance(0.001f)")
{
for (size_t i = 0; i < cif::kSymopNrTableSize; ++i)
for (std::size_t i = 0; i < cif::kSymopNrTableSize; ++i)
{
auto d = cif::kSymopNrTable[i].symop().data();
@@ -256,10 +256,10 @@ TEST_CASE("m2q_0, *utf::tolerance(0.001f)")
auto ev = es.eigenvalues();
size_t bestJ = 0;
std::size_t bestJ = 0;
float bestEV = -1;
for (size_t j = 0; j < 4; ++j)
for (std::size_t j = 0; j < 4; ++j)
{
if (bestEV < ev[j].real())
{
@@ -293,7 +293,7 @@ TEST_CASE("m2q_0, *utf::tolerance(0.001f)")
// "TEST_CASE(m2q_1, *utf::tolerance(0.001f)")
// {
// for (size_t i = 0; i < cif::kSymopNrTableSize; ++i)
// for (std::size_t i = 0; i < cif::kSymopNrTableSize; ++i)
// {
// auto d = cif::kSymopNrTable[i].symop().data();
@@ -317,10 +317,10 @@ TEST_CASE("m2q_0, *utf::tolerance(0.001f)")
// auto &&[ev, em] = cif::eigen(m * (1/3.0f), false);
// size_t bestJ = 0;
// std::size_t bestJ = 0;
// float bestEV = -1;
// for (size_t j = 0; j < 4; ++j)
// for (std::size_t j = 0; j < 4; ++j)
// {
// if (bestEV < ev[j])
// {

View File

@@ -34,11 +34,11 @@
// --------------------------------------------------------------------
cif::file operator""_cf(const char *text, size_t length)
cif::file operator""_cf(const char *text, std::size_t length)
{
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -240,7 +240,7 @@ TEST_CASE("r_2")
{
cif::category c("foo");
for (size_t i = 1; i < 256; ++i)
for (std::size_t i = 1; i < 256; ++i)
{
c.emplace({ { "id", i },
{ "txt", std::string(i, 'x') } });
@@ -537,7 +537,7 @@ _test.value
REQUIRE(not t.empty());
REQUIRE(t.front()["name"].as<std::string>() == "aap");
auto t2 = test.find(cif::key("value") == 1.2f);
auto t2 = test.find(cif::key("value") == 1.2);
REQUIRE(not t2.empty());
REQUIRE(t2.front()["name"].as<std::string>() == "mies");
}
@@ -572,6 +572,28 @@ _test.value
// --------------------------------------------------------------------
TEST_CASE("compare-with-float")
{
auto f = R"(data_TEST
#
loop_
_test.id
_test.value
1 1.0
2 2.0
3 3.0
4 ?
5 .
)"_cf;
auto &db = f.front();
auto &cat = db["test"];
CHECK(cat.find_first<int>(cif::key("value") == 1.0, "id") == 1);
}
// --------------------------------------------------------------------
TEST_CASE("sw_1")
{
using namespace cif::literals;
@@ -700,7 +722,7 @@ save__cat_2.desc
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -735,7 +757,7 @@ _cat_2.desc
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -853,7 +875,7 @@ save__cat_1.c
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -880,7 +902,7 @@ mies Mies
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -1015,7 +1037,7 @@ save__cat_2.desc
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -1053,7 +1075,7 @@ _cat_2.desc
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -1218,7 +1240,7 @@ save__cat_2.parent_id3
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -1266,7 +1288,7 @@ _cat_2.parent_id3
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -1439,7 +1461,7 @@ cat_2 3 cat_2:cat_1:3
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -1480,7 +1502,7 @@ _cat_2.parent_id3
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -1679,7 +1701,7 @@ cat_2 1 cat_2:cat_1:1
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -1720,7 +1742,7 @@ _cat_2.parent_id_2
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -2075,7 +2097,7 @@ cat_2 1 '_cat_2.num' '_cat_3.num' cat_3
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -2121,7 +2143,7 @@ _cat_3.num
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -2360,7 +2382,7 @@ cat_2 1 '_cat_2.num' '_cat_3.num' cat_3
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -2406,7 +2428,7 @@ _cat_3.num
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -2567,11 +2589,11 @@ _cat_3.num
// bonded.insert({atom_id_1, atom_id_2});
// }
// for (size_t i = 0; i + 1 < atoms.size(); ++i)
// for (std::size_t i = 0; i + 1 < atoms.size(); ++i)
// {
// auto label_i = atoms[i].labelAtomID();
// for (size_t j = i + 1; j < atoms.size(); ++j)
// for (std::size_t j = i + 1; j < atoms.size(); ++j)
// {
// auto label_j = atoms[j].labelAtomID();
@@ -2592,7 +2614,7 @@ _cat_3.num
// auto &poly = structure.polymers().front();
// for (size_t i = 0; i + 1 < poly.size(); ++i)
// for (std::size_t i = 0; i + 1 < poly.size(); ++i)
// {
// auto C = poly[i].atomByID("C");
// auto N = poly[i + 1].atomByID("N");
@@ -2694,7 +2716,7 @@ boo.data_.whatever
REQUIRE(test1.size() == sizeof(kS) / sizeof(T));
size_t i = 0;
std::size_t i = 0;
for (auto r : test1)
{
auto text = r.get<std::string>("text");
@@ -2750,7 +2772,7 @@ There it was!)",
REQUIRE(test1.size() == sizeof(kS) / sizeof(T));
size_t i = 0;
std::size_t i = 0;
for (auto r : test1)
{
auto text = r.get<std::string>("text");
@@ -2957,7 +2979,7 @@ save__cat_1.name
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -2984,7 +3006,7 @@ _cat_1.name
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -3152,7 +3174,7 @@ save__cat_1.name
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -3183,7 +3205,7 @@ _cat_1.name
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -3259,7 +3281,7 @@ save__cat_1.id_2
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -3288,7 +3310,7 @@ _cat_1.id_2
struct data_membuf : public std::streambuf
{
data_membuf(char *text, size_t length)
data_membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}
@@ -3472,7 +3494,7 @@ ATOM 7 CD PRO A 1 15.762 13.216 43.724 1.00 30.71 C)"
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}

View File

@@ -32,11 +32,11 @@
// --------------------------------------------------------------------
cif::file operator""_cf(const char *text, size_t length)
cif::file operator""_cf(const char *text, std::size_t length)
{
struct membuf : public std::streambuf
{
membuf(char *text, size_t length)
membuf(char *text, std::size_t length)
{
this->setg(text, text, text + length);
}