Commit 1c02a451 by Maarten L. Hekkelman

improved has_atom_id

added couple of comparison operators to sym_op class
parent 448855a2
...@@ -35,14 +35,15 @@ include(CheckIncludeFiles) ...@@ -35,14 +35,15 @@ include(CheckIncludeFiles)
include(CheckLibraryExists) include(CheckLibraryExists)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
include(Dart)
include(GenerateExportHeader) include(GenerateExportHeader)
set(CXX_EXTENSIONS OFF) set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_CXX_VISIBILITY_PRESET hidden) # set(CMAKE_CXX_VISIBILITY_PRESET hidden)
# set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) # set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
elseif(MSVC) elseif(MSVC)
...@@ -102,11 +103,22 @@ if(MSVC) ...@@ -102,11 +103,22 @@ if(MSVC)
add_compile_options(/permissive-) add_compile_options(/permissive-)
macro(get_WIN32_WINNT version) macro(get_WIN32_WINNT version)
if(WIN32 AND CMAKE_SYSTEM_VERSION) if(CMAKE_SYSTEM_VERSION)
set(ver ${CMAKE_SYSTEM_VERSION}) set(ver ${CMAKE_SYSTEM_VERSION})
string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver})
string(REGEX MATCH "^([0-9]+)" verMajor ${ver})
# Check for Windows 10, b/c we'll need to convert to hex 'A'.
if("${verMajor}" MATCHES "10")
set(verMajor "A")
string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver})
endif()
# Remove all remaining '.' characters.
string(REPLACE "." "" ver ${ver}) string(REPLACE "." "" ver ${ver})
string(REGEX REPLACE "([0-9])" "0\\1" ver ${ver})
# Prepend each digit with a zero.
string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver})
set(${version} "0x${ver}") set(${version} "0x${ver}")
endif() endif()
endmacro() endmacro()
...@@ -157,15 +169,16 @@ if(MSVC) ...@@ -157,15 +169,16 @@ if(MSVC)
set(_ZLIB_x86 "(x86)") set(_ZLIB_x86 "(x86)")
set(_ZLIB_SEARCH_NORMAL set(_ZLIB_SEARCH_NORMAL
PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]"
"$ENV{ProgramFiles}/zlib" "$ENV{ProgramFiles}/zlib"
"$ENV{ProgramFiles${_ZLIB_x86}}/zlib") "$ENV{ProgramFiles${_ZLIB_x86}}/zlib")
unset(_ZLIB_x86) unset(_ZLIB_x86)
list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
foreach(search ${_ZLIB_SEARCHES}) foreach(search ${_ZLIB_SEARCHES})
find_library(ZLIB_LIBRARY NAMES zlibstatic NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib) find_library(ZLIB_LIBRARY NAMES zlibstatic NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib)
endforeach() endforeach()
endif() endif()
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(Eigen3 REQUIRED) find_package(Eigen3 REQUIRED)
...@@ -448,7 +461,7 @@ endif() ...@@ -448,7 +461,7 @@ endif()
if(CIFPP_INSTALL_UPDATE_SCRIPT) if(CIFPP_INSTALL_UPDATE_SCRIPT)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(CIFPP_CRON_DIR "${CIFPP_ETC_DIR}/cron.weekly") set(CIFPP_CRON_DIR "${CIFPP_ETC_DIR}/cron.weekly")
elseif(UNIX) # assume all others are like FreeBSD... elseif(UNIX) # assume all others are like FreeBSD...
set(CIFPP_CRON_DIR "${CIFPP_ETC_DIR}/periodic/weekly") set(CIFPP_CRON_DIR "${CIFPP_ETC_DIR}/periodic/weekly")
else() else()
message(FATAL_ERROR "Don't know where to install the update script") message(FATAL_ERROR "Don't know where to install the update script")
......
...@@ -216,6 +216,20 @@ struct sym_op ...@@ -216,6 +216,20 @@ struct sym_op
std::string string() const; std::string string() const;
#if defined(__cpp_impl_three_way_comparison)
constexpr auto operator<=>(const sym_op &rhs) const = default;
#else
constexpr bool operator==(const sym_op &rhs) const
{
return m_nr == rhs.m_nr and m_ta == rhs.m_ta and m_tb == rhs.m_tb and m_tc == rhs.m_tc;
}
constexpr bool operator!=(const sym_op &rhs) const
{
return not operator==(rhs);
}
#endif
uint8_t m_nr; uint8_t m_nr;
uint8_t m_ta, m_tb, m_tc; uint8_t m_ta, m_tb, m_tc;
}; };
......
...@@ -1545,15 +1545,31 @@ EntityType structure::get_entity_type_for_asym_id(const std::string asym_id) con ...@@ -1545,15 +1545,31 @@ EntityType structure::get_entity_type_for_asym_id(const std::string asym_id) con
bool structure::has_atom_id(const std::string &id) const bool structure::has_atom_id(const std::string &id) const
{ {
bool result = true; assert(m_atoms.size() == m_atom_index.size());
try
{ bool result = false;
get_atom_by_id(id);
} int L = 0, R = static_cast<int>(m_atoms.size() - 1);
catch (...) while (L <= R)
{ {
result = false; int i = (L + R) / 2;
const atom &atom = m_atoms[m_atom_index[i]];
int d = atom.id().compare(id);
if (d == 0)
{
result = true;
break;
}
if (d < 0)
L = i + 1;
else
R = i - 1;
} }
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment