Commit 4524357c by Maarten L. Hekkelman

zlib, again (use the zlib from boost in Windows)

parent 0b05b6f6
...@@ -9,4 +9,6 @@ test/rename-compound-test ...@@ -9,4 +9,6 @@ test/rename-compound-test
tools/update-dictionary-script tools/update-dictionary-script
data/ data/
CMakeSettings.json CMakeSettings.json
msvc/ msvc/
\ No newline at end of file Testing/
...@@ -182,7 +182,9 @@ if(NOT BUILD_SHARED_LIBS) ...@@ -182,7 +182,9 @@ if(NOT BUILD_SHARED_LIBS)
endif() endif()
find_package(Boost 1.70.0 REQUIRED COMPONENTS system iostreams regex date_time program_options) find_package(Boost 1.70.0 REQUIRED COMPONENTS system iostreams regex date_time program_options)
find_package(ZLIB REQUIRED) if(NOT MSVC AND Boost_USE_STATIC_LIBS)
find_package(ZLIB REQUIRED)
endif()
# Create a revision file, containing the current git version info # Create a revision file, containing the current git version info
...@@ -209,7 +211,7 @@ if(RECREATE_SYMOP_DATA) ...@@ -209,7 +211,7 @@ if(RECREATE_SYMOP_DATA)
add_executable(symop-map-generator "${CMAKE_SOURCE_DIR}/tools/symop-map-generator.cpp") add_executable(symop-map-generator "${CMAKE_SOURCE_DIR}/tools/symop-map-generator.cpp")
target_link_libraries(symop-map-generator Threads::Threads ${Boost_LIBRARIES} std::filesystem ZLIB::ZLIB) target_link_libraries(symop-map-generator Threads::Threads ${Boost_LIBRARIES} std::filesystem ${ZLIB_LIBRARIES})
if(Boost_INCLUDE_DIR) if(Boost_INCLUDE_DIR)
target_include_directories(symop-map-generator PUBLIC ${Boost_INCLUDE_DIR}) target_include_directories(symop-map-generator PUBLIC ${Boost_INCLUDE_DIR})
endif() endif()
...@@ -282,7 +284,7 @@ target_include_directories(cifpp ...@@ -282,7 +284,7 @@ target_include_directories(cifpp
${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}
) )
target_link_libraries(cifpp Threads::Threads ${Boost_LIBRARIES} std::filesystem ZLIB::ZLIB) target_link_libraries(cifpp Threads::Threads ${Boost_LIBRARIES} std::filesystem ${ZLIB_LIBRARIES})
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_link_options(cifpp PRIVATE -undefined dynamic_lookup) target_link_options(cifpp PRIVATE -undefined dynamic_lookup)
...@@ -446,7 +448,7 @@ if(CIFPP_BUILD_TESTS) ...@@ -446,7 +448,7 @@ if(CIFPP_BUILD_TESTS)
${CMAKE_CURRENT_BINARY_DIR} # for config.h ${CMAKE_CURRENT_BINARY_DIR} # for config.h
) )
target_link_libraries(${CIFPP_TEST} PRIVATE Threads::Threads cifpp ${Boost_LIBRARIES} std::filesystem ZLIB::ZLIB) target_link_libraries(${CIFPP_TEST} PRIVATE Threads::Threads cifpp ${Boost_LIBRARIES} std::filesystem ${ZLIB_LIBRARIES})
if(MSVC) if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions # Specify unwind semantics so that MSVC knowns how to handle exceptions
......
...@@ -2141,15 +2141,15 @@ class File ...@@ -2141,15 +2141,15 @@ class File
File(); File();
File(std::istream &is, bool validate = false); File(std::istream &is, bool validate = false);
File(const std::string &path, bool validate = false); File(const std::filesystem::path &path, bool validate = false);
File(File &&rhs); File(File &&rhs);
File(const File &rhs) = delete; File(const File &rhs) = delete;
File &operator=(const File &rhs) = delete; File &operator=(const File &rhs) = delete;
~File(); ~File();
void load(const std::string &p); void load(const std::filesystem::path &p);
void save(const std::string &p); void save(const std::filesystem::path &p);
void load(std::istream &is); void load(std::istream &is);
void save(std::ostream &os); void save(std::ostream &os);
......
...@@ -162,8 +162,8 @@ class CompoundFactory ...@@ -162,8 +162,8 @@ class CompoundFactory
static CompoundFactory &instance(); static CompoundFactory &instance();
static void clear(); static void clear();
void setDefaultDictionary(const std::string &inDictFile); void setDefaultDictionary(const std::filesystem::path &inDictFile);
void pushDictionary(const std::string &inDictFile); void pushDictionary(const std::filesystem::path &inDictFile);
void popDictionary(); void popDictionary();
bool isKnownPeptide(const std::string &res_name) const; bool isKnownPeptide(const std::string &res_name) const;
......
...@@ -397,7 +397,7 @@ class File : public std::enable_shared_from_this<File> ...@@ -397,7 +397,7 @@ class File : public std::enable_shared_from_this<File>
{ {
public: public:
File(); File();
File(const std::string &path); File(const std::filesystem::path &path);
File(const char *data, size_t length); // good luck trying to find out what it is... File(const char *data, size_t length); // good luck trying to find out what it is...
~File(); ~File();
...@@ -406,8 +406,8 @@ class File : public std::enable_shared_from_this<File> ...@@ -406,8 +406,8 @@ class File : public std::enable_shared_from_this<File>
cif::Datablock& createDatablock(const std::string &name); cif::Datablock& createDatablock(const std::string &name);
void load(const std::string &path); void load(const std::filesystem::path &path);
void save(const std::string &path); void save(const std::filesystem::path &path);
Structure *model(size_t nr = 1); Structure *model(size_t nr = 1);
......
...@@ -3399,7 +3399,7 @@ File::File(std::istream &is, bool validate) ...@@ -3399,7 +3399,7 @@ File::File(std::istream &is, bool validate)
load(is); load(is);
} }
File::File(const std::string &path, bool validate) File::File(const std::filesystem::path &path, bool validate)
: File() : File()
{ {
try try
...@@ -3452,7 +3452,7 @@ void File::append(Datablock *e) ...@@ -3452,7 +3452,7 @@ void File::append(Datablock *e)
} }
} }
void File::load(const std::string &p) void File::load(const std::filesystem::path &p)
{ {
fs::path path(p); fs::path path(p);
...@@ -3482,7 +3482,7 @@ void File::load(const std::string &p) ...@@ -3482,7 +3482,7 @@ void File::load(const std::string &p)
} }
} }
void File::save(const std::string &p) void File::save(const std::filesystem::path &p)
{ {
fs::path path(p); fs::path path(p);
......
...@@ -268,7 +268,7 @@ class CompoundFactoryImpl : public std::enable_shared_from_this<CompoundFactoryI ...@@ -268,7 +268,7 @@ class CompoundFactoryImpl : public std::enable_shared_from_this<CompoundFactoryI
public: public:
CompoundFactoryImpl(std::shared_ptr<CompoundFactoryImpl> next); CompoundFactoryImpl(std::shared_ptr<CompoundFactoryImpl> next);
CompoundFactoryImpl(const std::string &file, std::shared_ptr<CompoundFactoryImpl> next); CompoundFactoryImpl(const std::filesystem::path &file, std::shared_ptr<CompoundFactoryImpl> next);
virtual ~CompoundFactoryImpl() virtual ~CompoundFactoryImpl()
{ {
...@@ -362,7 +362,7 @@ CompoundFactoryImpl::CompoundFactoryImpl(std::shared_ptr<CompoundFactoryImpl> ne ...@@ -362,7 +362,7 @@ CompoundFactoryImpl::CompoundFactoryImpl(std::shared_ptr<CompoundFactoryImpl> ne
mKnownBases.insert(key); mKnownBases.insert(key);
} }
CompoundFactoryImpl::CompoundFactoryImpl(const std::string &file, std::shared_ptr<CompoundFactoryImpl> next) CompoundFactoryImpl::CompoundFactoryImpl(const std::filesystem::path &file, std::shared_ptr<CompoundFactoryImpl> next)
: mNext(next) : mNext(next)
{ {
cif::File cifFile(file); cif::File cifFile(file);
...@@ -677,10 +677,10 @@ void CompoundFactory::clear() ...@@ -677,10 +677,10 @@ void CompoundFactory::clear()
sInstance.reset(); sInstance.reset();
} }
void CompoundFactory::setDefaultDictionary(const std::string &inDictFile) void CompoundFactory::setDefaultDictionary(const std::filesystem::path &inDictFile)
{ {
if (not fs::exists(inDictFile)) if (not fs::exists(inDictFile))
throw std::runtime_error("file not found: " + inDictFile); throw std::runtime_error("file not found: " + inDictFile.string());
try try
{ {
...@@ -693,10 +693,10 @@ void CompoundFactory::setDefaultDictionary(const std::string &inDictFile) ...@@ -693,10 +693,10 @@ void CompoundFactory::setDefaultDictionary(const std::string &inDictFile)
} }
} }
void CompoundFactory::pushDictionary(const std::string &inDictFile) void CompoundFactory::pushDictionary(const std::filesystem::path &inDictFile)
{ {
if (not fs::exists(inDictFile)) if (not fs::exists(inDictFile))
throw std::runtime_error("file not found: " + inDictFile); throw std::runtime_error("file not found: " + inDictFile.string());
// ifstream file(inDictFile); // ifstream file(inDictFile);
// if (not file.is_open()) // if (not file.is_open())
......
...@@ -59,8 +59,8 @@ struct FileImpl ...@@ -59,8 +59,8 @@ struct FileImpl
void load_data(const char *data, size_t length); void load_data(const char *data, size_t length);
void load(const std::string &p); void load(const std::filesystem::path &path);
void save(const std::string &p); void save(const std::filesystem::path &path);
}; };
void FileImpl::load_data(const char *data, size_t length) void FileImpl::load_data(const char *data, size_t length)
...@@ -112,10 +112,8 @@ void FileImpl::load_data(const char *data, size_t length) ...@@ -112,10 +112,8 @@ void FileImpl::load_data(const char *data, size_t length)
std::cerr << "Invalid mmCIF file" << (cif::VERBOSE ? "." : " use --verbose option to see errors") << std::endl; std::cerr << "Invalid mmCIF file" << (cif::VERBOSE ? "." : " use --verbose option to see errors") << std::endl;
} }
void FileImpl::load(const std::string &p) void FileImpl::load(const std::filesystem::path &path)
{ {
fs::path path(p);
std::ifstream inFile(path, std::ios_base::in | std::ios_base::binary); std::ifstream inFile(path, std::ios_base::in | std::ios_base::binary);
if (not inFile.is_open()) if (not inFile.is_open())
throw std::runtime_error("No such file: " + path.string()); throw std::runtime_error("No such file: " + path.string());
...@@ -185,18 +183,13 @@ void FileImpl::load(const std::string &p) ...@@ -185,18 +183,13 @@ void FileImpl::load(const std::string &p)
std::cerr << "Invalid mmCIF file" << (cif::VERBOSE ? "." : " use --verbose option to see errors") << std::endl; std::cerr << "Invalid mmCIF file" << (cif::VERBOSE ? "." : " use --verbose option to see errors") << std::endl;
} }
void FileImpl::save(const std::string &p) void FileImpl::save(const std::filesystem::path &path)
{ {
fs::path path(p); std::ofstream outFile(path, std::ios_base::out | std::ios_base::binary);
std::ofstream outFile(p, std::ios_base::out | std::ios_base::binary);
io::filtering_stream<io::output> out; io::filtering_stream<io::output> out;
if (path.extension() == ".gz") if (path.extension() == ".gz")
{
out.push(io::gzip_compressor()); out.push(io::gzip_compressor());
path = path.stem();
}
out.push(outFile); out.push(outFile);
...@@ -1732,7 +1725,7 @@ File::File(const char *data, size_t length) ...@@ -1732,7 +1725,7 @@ File::File(const char *data, size_t length)
mImpl->load_data(data, length); mImpl->load_data(data, length);
} }
File::File(const std::string &File) File::File(const std::filesystem::path &File)
: mImpl(new FileImpl) : mImpl(new FileImpl)
{ {
load(File); load(File);
...@@ -1753,12 +1746,12 @@ cif::Datablock& File::createDatablock(const std::string &name) ...@@ -1753,12 +1746,12 @@ cif::Datablock& File::createDatablock(const std::string &name)
return *mImpl->mDb; return *mImpl->mDb;
} }
void File::load(const std::string &p) void File::load(const std::filesystem::path &p)
{ {
mImpl->load(p); mImpl->load(p);
} }
void File::save(const std::string &file) void File::save(const std::filesystem::path &file)
{ {
mImpl->save(file); mImpl->save(file);
} }
......
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