diff --git a/CppParser/CMakeLists.txt b/CppParser/CMakeLists.txt index 3423906c8..fe52d3a42 100644 --- a/CppParser/CMakeLists.txt +++ b/CppParser/CMakeLists.txt @@ -26,24 +26,10 @@ target_include_directories( "${LIBNAME}" PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) - -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(testsuite) + add_subdirectory(testsuite) endif () diff --git a/Crypto/CMakeLists.txt b/Crypto/CMakeLists.txt index 507c573e9..7f4c2621b 100644 --- a/Crypto/CMakeLists.txt +++ b/Crypto/CMakeLists.txt @@ -27,24 +27,11 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) + add_subdirectory(samples) + add_subdirectory(testsuite) endif () diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index b70c1075c..e96cf3eb5 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -34,54 +34,41 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if(ENABLE_DATA_SQLITE) -# SQlite3 is built in any case -add_subdirectory( SQLite ) + # SQlite3 is built in any case + add_subdirectory( SQLite ) endif(ENABLE_DATA_SQLITE) if(ENABLE_DATA_MYSQL) -find_package(MySQL) -if(MYSQL_FOUND) - include_directories("${MYSQL_INCLUDE_DIR}") - message(STATUS "MySQL Support Enabled") - add_subdirectory( MySQL ) -else() - message(STATUS "MySQL Support Disabled - no MySQL library") -endif(MYSQL_FOUND) + find_package(MySQL) + if(MYSQL_FOUND) + include_directories("${MYSQL_INCLUDE_DIR}") + message(STATUS "MySQL Support Enabled") + add_subdirectory( MySQL ) + else() + message(STATUS "MySQL Support Disabled - no MySQL library") + endif(MYSQL_FOUND) endif(ENABLE_DATA_MYSQL) if(ENABLE_DATA_ODBC) -find_package(ODBC) -if(WIN32 AND NOT WINCE) - set(ODBC_LIBRARIES "odbc32" "odbccp32") - message(STATUS "Windows native ODBC Support Enabled") - add_subdirectory( ODBC ) -else(WIN32 AND NOT WINCE) - if(ODBC_FOUND) - include_directories("${ODBC_INCLUDE_DIRECTORIES}") - message(STATUS "ODBC Support Enabled") + find_package(ODBC) + if(WIN32 AND NOT WINCE) + set(ODBC_LIBRARIES "odbc32" "odbccp32") + message(STATUS "Windows native ODBC Support Enabled") add_subdirectory( ODBC ) - else() - message(STATUS "ODBC Support Disabled - no ODBC runtime") - endif() -endif(WIN32 AND NOT WINCE) + else(WIN32 AND NOT WINCE) + if(ODBC_FOUND) + include_directories("${ODBC_INCLUDE_DIRECTORIES}") + message(STATUS "ODBC Support Enabled") + add_subdirectory( ODBC ) + else() + message(STATUS "ODBC Support Disabled - no ODBC runtime") + endif() + endif(WIN32 AND NOT WINCE) endif(ENABLE_DATA_ODBC) if (ENABLE_TESTS) diff --git a/Data/MySQL/CMakeLists.txt b/Data/MySQL/CMakeLists.txt index 87a572168..254135be5 100644 --- a/Data/MySQL/CMakeLists.txt +++ b/Data/MySQL/CMakeLists.txt @@ -27,22 +27,9 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) add_subdirectory(testsuite) diff --git a/Data/ODBC/CMakeLists.txt b/Data/ODBC/CMakeLists.txt index 007dc8661..eb29288a8 100644 --- a/Data/ODBC/CMakeLists.txt +++ b/Data/ODBC/CMakeLists.txt @@ -27,22 +27,9 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) add_subdirectory(testsuite) diff --git a/Data/SQLite/CMakeLists.txt b/Data/SQLite/CMakeLists.txt index 559303f24..a7a5bf574 100644 --- a/Data/SQLite/CMakeLists.txt +++ b/Data/SQLite/CMakeLists.txt @@ -48,22 +48,9 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) add_subdirectory(testsuite) diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index 8d677cc17..c1dd25ff4 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -121,22 +121,8 @@ target_include_directories( "${LIBNAME}" PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) - -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) add_subdirectory( samples ) diff --git a/Foundation/include/Poco/Bugcheck.h b/Foundation/include/Poco/Bugcheck.h index ede6f1924..d11b2bbb5 100644 --- a/Foundation/include/Poco/Bugcheck.h +++ b/Foundation/include/Poco/Bugcheck.h @@ -148,9 +148,9 @@ protected: // -#if defined(GNUC) && (GNUC > 4) && (GNUC_MINOR > 6) +#if defined(POCO_COMPILER_GCC) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) GCC_DIAG_OFF(unused-local-typedefs) // supress numerous gcc warnings -#endif // (GNUC) && (GNUC > 4) && (GNUC_MINOR > 6) +#endif // POCO_COMPILER_GCC && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) template diff --git a/Foundation/include/Poco/MemoryStream.h b/Foundation/include/Poco/MemoryStream.h index 361dbdde2..7fc612198 100644 --- a/Foundation/include/Poco/MemoryStream.h +++ b/Foundation/include/Poco/MemoryStream.h @@ -74,6 +74,66 @@ public: return char_traits::eof(); } + virtual pos_type seekoff(off_type off, std::ios_base::seekdir way, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) + { + const pos_type fail = off_type(-1); + off_type newoff = off_type(-1); + + if ((which & std::ios_base::in) != 0) + { + if (this->gptr() == 0) + return fail; + + switch (way) + { + case std::ios_base::beg: + newoff = 0; + break; + case std::ios_base::cur: + // cur is not valid if both in and out are specified (Condition 3) + if ((which & std::ios_base::out) != 0) + return fail; + newoff = this->gptr() - this->eback(); + break; + case std::ios_base::end: + newoff = this->egptr() - this->eback(); + break; + } + + if ((newoff + off) < 0 || (this->egptr() - this->eback()) < (newoff + off)) + return fail; + this->setg(this->eback(), this->eback() + newoff + off, this->egptr()); + } + + if ((which & std::ios_base::out) != 0) + { + if (this->pptr() == 0) + return fail; + + switch (way) + { + case std::ios_base::beg: + newoff = 0; + break; + case std::ios_base::cur: + // cur is not valid if both in and out are specified (Condition 3) + if ((which & std::ios_base::in) != 0) + return fail; + newoff = this->pptr() - this->pbase(); + break; + case std::ios_base::end: + newoff = this->epptr() - this->pbase(); + break; + } + + if (newoff + off < 0 || (this->epptr() - this->pbase()) < newoff + off) + return fail; + this->pbump((int)(newoff + off - (this->pptr() - this->pbase()))); + } + + return newoff; + } + virtual int sync() { return 0; diff --git a/Foundation/include/Poco/RecursiveDirectoryIterator.h b/Foundation/include/Poco/RecursiveDirectoryIterator.h index fcbb2311e..acbb74ea7 100644 --- a/Foundation/include/Poco/RecursiveDirectoryIterator.h +++ b/Foundation/include/Poco/RecursiveDirectoryIterator.h @@ -66,9 +66,8 @@ public: enum { - D_INFINITE = 0 + D_INFINITE = 0 /// Constant for infinite traverse depth. }; - /// Constant for infinite traverse depth. RecursiveDirectoryIterator() /// Creates the end iterator. @@ -76,31 +75,34 @@ public: { } - RecursiveDirectoryIterator(const std::string& path, UInt16 maxDepth = D_INFINITE); + RecursiveDirectoryIterator(const std::string& path, UInt16 maxDepth = D_INFINITE) /// Creates a recursive directory iterator for the given path. - - RecursiveDirectoryIterator(const MyType& iterator) - /// Creates a copy of another recursive directory iterator. - : _pImpl(iterator._pImpl), _path(iterator._path), _file(iterator._file) + : _pImpl(new ImplType(path, maxDepth)), _path(Path(_pImpl->get())), _file(_path) { } - RecursiveDirectoryIterator(const DirectoryIterator& iterator, UInt16 maxDepth = D_INFINITE) + RecursiveDirectoryIterator(const MyType& iterator): + /// Creates a copy of another recursive directory iterator. + _pImpl(iterator._pImpl), _path(iterator._path), _file(iterator._file) + { + } + + RecursiveDirectoryIterator(const DirectoryIterator& iterator, UInt16 maxDepth = D_INFINITE): /// Creates a recursive directory iterator for the path of /// non-recursive directory iterator. - : _pImpl(new ImplType(iterator->path(), maxDepth)), _path(Path(_pImpl->get())), _file(_path) + _pImpl(new ImplType(iterator->path(), maxDepth)), _path(Path(_pImpl->get())), _file(_path) { } - RecursiveDirectoryIterator(const File& file, UInt16 maxDepth = D_INFINITE) + RecursiveDirectoryIterator(const File& file, UInt16 maxDepth = D_INFINITE): /// Creates a recursive directory iterator for the given path. - : _pImpl(new ImplType(file.path(), maxDepth)), _path(Path(_pImpl->get())), _file(_path) + _pImpl(new ImplType(file.path(), maxDepth)), _path(Path(_pImpl->get())), _file(_path) { } - RecursiveDirectoryIterator(const Path& path, UInt16 maxDepth = D_INFINITE) + RecursiveDirectoryIterator(const Path& path, UInt16 maxDepth = D_INFINITE): /// Creates a recursive directory iterator for the given path. - : _pImpl(new ImplType(path.toString(), maxDepth)), _path(Path(_pImpl->get())), _file(_path) + _pImpl(new ImplType(path.toString(), maxDepth)), _path(Path(_pImpl->get())), _file(_path) { } diff --git a/Foundation/src/Clock.cpp b/Foundation/src/Clock.cpp index 6000ef38b..ac95bfc80 100644 --- a/Foundation/src/Clock.cpp +++ b/Foundation/src/Clock.cpp @@ -22,6 +22,7 @@ #include #elif defined(POCO_OS_FAMILY_UNIX) #include +#include #elif defined(POCO_VXWORKS) #include #elif defined(POCO_OS_FAMILY_WINDOWS) diff --git a/Foundation/src/File_WIN32.cpp b/Foundation/src/File_WIN32.cpp index 4d4ae343e..004cc800c 100644 --- a/Foundation/src/File_WIN32.cpp +++ b/Foundation/src/File_WIN32.cpp @@ -34,17 +34,17 @@ public: FileImpl::handleLastErrorImpl(path); } } - + ~FileHandle() { if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h); } - + HANDLE get() const { return _h; } - + private: HANDLE _h; }; @@ -112,7 +112,7 @@ bool FileImpl::existsImpl() const bool FileImpl::canReadImpl() const { poco_assert (!_path.empty()); - + DWORD attr = GetFileAttributes(_path.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { @@ -131,7 +131,7 @@ bool FileImpl::canReadImpl() const bool FileImpl::canWriteImpl() const { poco_assert (!_path.empty()); - + DWORD attr = GetFileAttributes(_path.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) handleLastErrorImpl(_path); @@ -201,7 +201,7 @@ Timestamp FileImpl::createdImpl() const poco_assert (!_path.empty()); WIN32_FILE_ATTRIBUTE_DATA fad; - if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0) + if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0) handleLastErrorImpl(_path); return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime); } @@ -212,7 +212,7 @@ Timestamp FileImpl::getLastModifiedImpl() const poco_assert (!_path.empty()); WIN32_FILE_ATTRIBUTE_DATA fad; - if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0) + if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0) handleLastErrorImpl(_path); return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime); } @@ -239,7 +239,7 @@ FileImpl::FileSizeImpl FileImpl::getSizeImpl() const poco_assert (!_path.empty()); WIN32_FILE_ATTRIBUTE_DATA fad; - if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0) + if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0) handleLastErrorImpl(_path); LARGE_INTEGER li; li.LowPart = fad.nFileSizeLow; @@ -257,7 +257,7 @@ void FileImpl::setSizeImpl(FileSizeImpl size) li.QuadPart = size; if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER) handleLastErrorImpl(_path); - if (SetEndOfFile(fh.get()) == 0) + if (SetEndOfFile(fh.get()) == 0) handleLastErrorImpl(_path); } @@ -288,12 +288,8 @@ void FileImpl::copyToImpl(const std::string& path) const { poco_assert (!_path.empty()); - if (CopyFileA(_path.c_str(), path.c_str(), FALSE) != 0) - { - FileImpl copy(path); - copy.setWriteableImpl(true); - } - else handleLastErrorImpl(_path); + if (CopyFileA(_path.c_str(), path.c_str(), FALSE) == 0) + handleLastErrorImpl(_path); } @@ -301,7 +297,7 @@ void FileImpl::renameToImpl(const std::string& path) { poco_assert (!_path.empty()); - if (MoveFileA(_path.c_str(), path.c_str()) == 0) + if (MoveFileA(_path.c_str(), path.c_str()) == 0) handleLastErrorImpl(_path); } @@ -312,7 +308,7 @@ void FileImpl::removeImpl() if (isDirectoryImpl()) { - if (RemoveDirectoryA(_path.c_str()) == 0) + if (RemoveDirectoryA(_path.c_str()) == 0) handleLastErrorImpl(_path); } else @@ -344,7 +340,7 @@ bool FileImpl::createFileImpl() bool FileImpl::createDirectoryImpl() { poco_assert (!_path.empty()); - + if (existsImpl() && isDirectoryImpl()) return false; if (CreateDirectoryA(_path.c_str(), 0) == 0) diff --git a/Foundation/src/File_WIN32U.cpp b/Foundation/src/File_WIN32U.cpp index 80d340305..e3572b798 100644 --- a/Foundation/src/File_WIN32U.cpp +++ b/Foundation/src/File_WIN32U.cpp @@ -35,17 +35,17 @@ public: FileImpl::handleLastErrorImpl(path); } } - + ~FileHandle() { if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h); } - + HANDLE get() const { return _h; } - + private: HANDLE _h; }; @@ -116,7 +116,7 @@ bool FileImpl::existsImpl() const bool FileImpl::canReadImpl() const { poco_assert (!_path.empty()); - + DWORD attr = GetFileAttributesW(_upath.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { @@ -135,7 +135,7 @@ bool FileImpl::canReadImpl() const bool FileImpl::canWriteImpl() const { poco_assert (!_path.empty()); - + DWORD attr = GetFileAttributesW(_upath.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) handleLastErrorImpl(_path); @@ -205,7 +205,7 @@ Timestamp FileImpl::createdImpl() const poco_assert (!_path.empty()); WIN32_FILE_ATTRIBUTE_DATA fad; - if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) + if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) handleLastErrorImpl(_path); return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime); } @@ -216,7 +216,7 @@ Timestamp FileImpl::getLastModifiedImpl() const poco_assert (!_path.empty()); WIN32_FILE_ATTRIBUTE_DATA fad; - if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) + if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) handleLastErrorImpl(_path); return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime); } @@ -243,7 +243,7 @@ FileImpl::FileSizeImpl FileImpl::getSizeImpl() const poco_assert (!_path.empty()); WIN32_FILE_ATTRIBUTE_DATA fad; - if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) + if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) handleLastErrorImpl(_path); LARGE_INTEGER li; li.LowPart = fad.nFileSizeLow; @@ -261,12 +261,12 @@ void FileImpl::setSizeImpl(FileSizeImpl size) li.QuadPart = size; if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER) handleLastErrorImpl(_path); - if (SetEndOfFile(fh.get()) == 0) + if (SetEndOfFile(fh.get()) == 0) handleLastErrorImpl(_path); } -void FileImpl::setWriteableImpl(bool flag) +void FileImpl::setWriteableImpl(bool flag) { poco_assert (!_path.empty()); @@ -294,12 +294,8 @@ void FileImpl::copyToImpl(const std::string& path) const std::wstring upath; UnicodeConverter::toUTF16(path, upath); - if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) != 0) - { - FileImpl copy(path); - copy.setWriteableImpl(true); - } - else handleLastErrorImpl(_path); + if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0) + handleLastErrorImpl(_path); } @@ -309,7 +305,7 @@ void FileImpl::renameToImpl(const std::string& path) std::wstring upath; UnicodeConverter::toUTF16(path, upath); - if (MoveFileW(_upath.c_str(), upath.c_str()) == 0) + if (MoveFileW(_upath.c_str(), upath.c_str()) == 0) handleLastErrorImpl(_path); } @@ -320,7 +316,7 @@ void FileImpl::removeImpl() if (isDirectoryImpl()) { - if (RemoveDirectoryW(_upath.c_str()) == 0) + if (RemoveDirectoryW(_upath.c_str()) == 0) handleLastErrorImpl(_path); } else @@ -352,7 +348,7 @@ bool FileImpl::createFileImpl() bool FileImpl::createDirectoryImpl() { poco_assert (!_path.empty()); - + if (existsImpl() && isDirectoryImpl()) return false; if (CreateDirectoryW(_upath.c_str(), 0) == 0) diff --git a/Foundation/src/File_WINCE.cpp b/Foundation/src/File_WINCE.cpp index 61ab5d671..c321a76ee 100644 --- a/Foundation/src/File_WINCE.cpp +++ b/Foundation/src/File_WINCE.cpp @@ -36,17 +36,17 @@ public: FileImpl::handleLastErrorImpl(path); } } - + ~FileHandle() { if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h); } - + HANDLE get() const { return _h; } - + private: HANDLE _h; }; @@ -117,7 +117,7 @@ bool FileImpl::existsImpl() const bool FileImpl::canReadImpl() const { poco_assert (!_path.empty()); - + DWORD attr = GetFileAttributesW(_upath.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { @@ -136,7 +136,7 @@ bool FileImpl::canReadImpl() const bool FileImpl::canWriteImpl() const { poco_assert (!_path.empty()); - + DWORD attr = GetFileAttributesW(_upath.c_str()); if (attr == INVALID_FILE_ATTRIBUTES) handleLastErrorImpl(_path); @@ -196,7 +196,7 @@ Timestamp FileImpl::createdImpl() const poco_assert (!_path.empty()); WIN32_FILE_ATTRIBUTE_DATA fad; - if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) + if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) handleLastErrorImpl(_path); return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime); } @@ -207,7 +207,7 @@ Timestamp FileImpl::getLastModifiedImpl() const poco_assert (!_path.empty()); WIN32_FILE_ATTRIBUTE_DATA fad; - if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) + if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) handleLastErrorImpl(_path); return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime); } @@ -234,7 +234,7 @@ FileImpl::FileSizeImpl FileImpl::getSizeImpl() const poco_assert (!_path.empty()); WIN32_FILE_ATTRIBUTE_DATA fad; - if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) + if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0) handleLastErrorImpl(_path); LARGE_INTEGER li; li.LowPart = fad.nFileSizeLow; @@ -252,12 +252,12 @@ void FileImpl::setSizeImpl(FileSizeImpl size) li.QuadPart = size; if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER) handleLastErrorImpl(_path); - if (SetEndOfFile(fh.get()) == 0) + if (SetEndOfFile(fh.get()) == 0) handleLastErrorImpl(_path); } -void FileImpl::setWriteableImpl(bool flag) +void FileImpl::setWriteableImpl(bool flag) { poco_assert (!_path.empty()); @@ -285,12 +285,8 @@ void FileImpl::copyToImpl(const std::string& path) const std::wstring upath; UnicodeConverter::toUTF16(path, upath); - if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) != 0) - { - FileImpl copy(path); - copy.setWriteableImpl(true); - } - else handleLastErrorImpl(_path); + if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0) + handleLastErrorImpl(_path); } @@ -300,7 +296,7 @@ void FileImpl::renameToImpl(const std::string& path) std::wstring upath; UnicodeConverter::toUTF16(path, upath); - if (MoveFileW(_upath.c_str(), upath.c_str()) == 0) + if (MoveFileW(_upath.c_str(), upath.c_str()) == 0) handleLastErrorImpl(_path); } @@ -311,7 +307,7 @@ void FileImpl::removeImpl() if (isDirectoryImpl()) { - if (RemoveDirectoryW(_upath.c_str()) == 0) + if (RemoveDirectoryW(_upath.c_str()) == 0) handleLastErrorImpl(_path); } else @@ -343,7 +339,7 @@ bool FileImpl::createFileImpl() bool FileImpl::createDirectoryImpl() { poco_assert (!_path.empty()); - + if (existsImpl() && isDirectoryImpl()) return false; if (CreateDirectoryW(_upath.c_str(), 0) == 0) diff --git a/Foundation/src/Timer.cpp b/Foundation/src/Timer.cpp index ff4edb725..a24818809 100644 --- a/Foundation/src/Timer.cpp +++ b/Foundation/src/Timer.cpp @@ -208,6 +208,7 @@ void Timer::run() { Poco::ErrorHandler::handle(); } + Poco::FastMutex::ScopedLock lock(_mutex); interval = _periodicInterval; } _nextInvocation += static_cast(interval)*1000; diff --git a/Foundation/testsuite/src/FileTest.cpp b/Foundation/testsuite/src/FileTest.cpp index 03b24e9a6..d5586623e 100644 --- a/Foundation/testsuite/src/FileTest.cpp +++ b/Foundation/testsuite/src/FileTest.cpp @@ -45,7 +45,7 @@ void FileTest::testFileAttributes1() { File f("testfile.dat"); assert (!f.exists()); - + try { bool flag = f.canRead(); @@ -201,7 +201,7 @@ void FileTest::testFileAttributes2() bool created = f.createFile(); Timestamp ts; assert (created); - + assert (f.exists()); assert (f.canRead()); assert (f.canWrite()); @@ -211,15 +211,15 @@ void FileTest::testFileAttributes2() Timestamp tsm = f.getLastModified(); assert (tsc - ts >= -2000000 && tsc - ts <= 2000000); assert (tsm - ts >= -2000000 && tsm - ts <= 2000000); - + f.setWriteable(false); assert (!f.canWrite()); assert (f.canRead()); - f.setReadOnly(false); + f.setReadOnly(false); assert (f.canWrite()); assert (f.canRead()); - + ts = Timestamp::fromEpochTime(1000000); f.setLastModified(ts); assert (f.getLastModified() == ts); @@ -247,7 +247,7 @@ void FileTest::testCompare() File f1("abc.txt"); File f2("def.txt"); File f3("abc.txt"); - + assert (f1 == f3); assert (!(f1 == f2)); assert (f1 != f2); @@ -261,7 +261,7 @@ void FileTest::testCompare() assert (f2 >= f1); assert (!(f1 > f2)); assert (!(f1 >= f2)); - + assert (f1 <= f3); assert (f1 >= f3); } @@ -325,7 +325,7 @@ void FileTest::testDirectory() { } TemporaryFile::registerForDeletion("testdir"); - + bool created = d.createDirectory(); assert (created); assert (d.isDirectory()); @@ -333,23 +333,23 @@ void FileTest::testDirectory() std::vector files; d.list(files); assert (files.empty()); - + File f = Path("testdir/file1", Path::PATH_UNIX); f.createFile(); f = Path("testdir/file2", Path::PATH_UNIX); f.createFile(); f = Path("testdir/file3", Path::PATH_UNIX); f.createFile(); - + d.list(files); assert (files.size() == 3); - + std::set fs; fs.insert(files.begin(), files.end()); assert (fs.find("file1") != fs.end()); assert (fs.find("file2") != fs.end()); assert (fs.find("file3") != fs.end()); - + File dd(Path("testdir/testdir2/testdir3", Path::PATH_UNIX)); dd.createDirectories(); assert (dd.exists()); @@ -359,7 +359,7 @@ void FileTest::testDirectory() ddd.createDirectories(); assert (ddd.exists()); assert (ddd.isDirectory()); - + d.remove(true); } @@ -372,9 +372,11 @@ void FileTest::testCopy() File f1("testfile.dat"); TemporaryFile f2; - f1.copyTo(f2.path()); + f1.setReadOnly().copyTo(f2.path()); assert (f2.exists()); + assert (!f2.canWrite()); assert (f1.getSize() == f2.getSize()); + f1.setWriteable().remove(); } @@ -422,9 +424,9 @@ void FileTest::testCopyDirectory() std::ofstream ostr3(pf3.toString().c_str()); ostr3 << "Hello, world!" << std::endl; ostr3.close(); - + File fd3("testdir2"); - + try { fd3.remove(true); @@ -432,19 +434,19 @@ void FileTest::testCopyDirectory() catch (...) { } - + fd1.copyTo("testdir2"); - + Path pd1t("testdir2"); File fd1t(pd1t); assert (fd1t.exists()); assert (fd1t.isDirectory()); - + Path pd2t(pd1t, "subdir"); File fd2t(pd2t); assert (fd2t.exists()); assert (fd2t.isDirectory()); - + Path pf1t(pd1t, "testfile1.dat"); File ff1t(pf1t); assert (ff1t.exists()); @@ -459,7 +461,7 @@ void FileTest::testCopyDirectory() File ff3t(pf3t); assert (ff3t.exists()); assert (ff3t.isFile()); - + fd1.remove(true); fd3.remove(true); } @@ -478,7 +480,7 @@ void FileTest::testRename() assert (f2.exists()); assert (f1.exists()); assert (f1 == f2); - + f2.remove(); } diff --git a/Foundation/testsuite/src/MemoryStreamTest.cpp b/Foundation/testsuite/src/MemoryStreamTest.cpp index 66efbce65..4daa68284 100644 --- a/Foundation/testsuite/src/MemoryStreamTest.cpp +++ b/Foundation/testsuite/src/MemoryStreamTest.cpp @@ -13,8 +13,10 @@ #include "MemoryStreamTest.h" #include "CppUnit/TestCaller.h" #include "CppUnit/TestSuite.h" +#include "Poco/Buffer.h" #include "Poco/MemoryStream.h" +#include using Poco::MemoryInputStream; using Poco::MemoryOutputStream; @@ -86,6 +88,343 @@ void MemoryStreamTest::testOutput() assert (ostr2.fail()); } +void MemoryStreamTest::testTell() +{ + Poco::Buffer buffer(1024); + Poco::MemoryOutputStream ostr(buffer.begin(), buffer.size()); + ostr << 'H' << 'e' << 'l' << 'l' << 'o' << '\0'; + std::streamoff np = ostr.tellp(); + assert (np == 6); + + Poco::MemoryInputStream istr(buffer.begin(), buffer.size()); + + char c; + istr >> c; + assert (c == 'H'); + + istr >> c; + assert (c == 'e'); + + istr >> c; + assert (c == 'l'); + + std::streamoff ng = istr.tellg(); + assert (ng == 3); +} + + +void MemoryStreamTest::testInputSeek() +{ + Poco::Buffer buffer(9); + Poco::MemoryOutputStream ostr(buffer.begin(), buffer.size()); + ostr << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9'; + + Poco::MemoryInputStream istr(buffer.begin(), buffer.size()); + char c; + + istr >> c; + assert (c == '1'); + + istr.seekg(3, std::ios_base::beg); // 3 from beginning + istr >> c; // now that makes 4 + assert (4 == istr.tellg()); + assert (c == '4'); + + istr.seekg(2, std::ios_base::cur); // now that makes 6 + istr >> c; // now that makes 7 + assert (7 == istr.tellg()); + assert (c == '7'); + + istr.seekg(-7, std::ios_base::end); // so that puts us at 9-7=2 + istr >> c; // now 3 + assert (3 == istr.tellg()); + assert (c == '3'); + + + istr.seekg(9, std::ios_base::beg); + assert (istr.good()); + assert (9 == istr.tellg()); + + { + Poco::MemoryInputStream istr2(buffer.begin(), buffer.size()); + istr2.seekg(10, std::ios_base::beg); + assert (istr2.fail()); + } + + + istr.seekg(-9, std::ios_base::end); + assert (istr.good()); + assert (0 == istr.tellg()); + + { + Poco::MemoryInputStream istr2(buffer.begin(), buffer.size()); + istr2.seekg(-10, std::ios_base::end); + assert (istr2.fail()); + } + + + istr.seekg(0, std::ios_base::beg); + assert (istr.good()); + assert (0 == istr.tellg()); + + { + Poco::MemoryInputStream istr2(buffer.begin(), buffer.size()); + istr2.seekg(-1, std::ios_base::beg); + assert (istr2.fail()); + } + + + istr.seekg(0, std::ios_base::end); + assert (istr.good()); + assert (9 == istr.tellg()); + + { + Poco::MemoryInputStream istr2(buffer.begin(), buffer.size()); + istr2.seekg(1, std::ios_base::end); + assert (istr2.fail()); + } + + + istr.seekg(3, std::ios_base::beg); + assert (istr.good()); + assert (3 == istr.tellg()); + istr.seekg(6, std::ios_base::cur); + assert (istr.good()); + assert (9 == istr.tellg()); + + { + Poco::MemoryInputStream istr2(buffer.begin(), buffer.size()); + istr2.seekg(4, std::ios_base::beg); + istr2.seekg(6, std::ios_base::cur); + assert (istr2.fail()); + } + + + istr.seekg(-4, std::ios_base::end); + assert (istr.good()); + assert (5 == istr.tellg()); + istr.seekg(4, std::ios_base::cur); + assert (istr.good()); + assert (9 == istr.tellg()); + + { + Poco::MemoryInputStream istr2(buffer.begin(), buffer.size()); + istr2.seekg(-4, std::ios_base::end); + istr2.seekg(5, std::ios_base::cur); + assert (istr2.fail()); + } + + + istr.seekg(4, std::ios_base::beg); + assert (istr.good()); + assert (4 == istr.tellg()); + istr.seekg(-4, std::ios_base::cur); + assert (istr.good()); + assert (0 == istr.tellg()); + + { + Poco::MemoryInputStream istr2(buffer.begin(), buffer.size()); + istr2.seekg(4, std::ios_base::beg); + istr2.seekg(-5, std::ios_base::cur); + assert (istr2.fail()); + } +} + + +void MemoryStreamTest::testInputSeekVsStringStream() +{ + Poco::Buffer buffer(9); + Poco::MemoryOutputStream ostr(buffer.begin(), buffer.size()); + ostr << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9'; + + std::stringstream sss; + sss << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9'; + + Poco::MemoryInputStream mis(buffer.begin(), buffer.size()); + + char x, y; + + sss >> x; + mis >> y; + assert (x == y); + + sss.seekg(3, std::ios_base::beg); + mis.seekg(3, std::ios_base::beg); + sss >> x; + mis >> y; + assert (x == y); + assert (sss.tellg() == mis.tellg()); + + sss.seekg(2, std::ios_base::cur); + mis.seekg(2, std::ios_base::cur); + sss >> x; + mis >> y; + assert (x == y); + assert (sss.tellg() == mis.tellg()); + + sss.seekg(-7, std::ios_base::end); + mis.seekg(-7, std::ios_base::end); + sss >> x; + mis >> y; + assert (x == y); + assert (sss.tellg() == mis.tellg()); +} + + +void MemoryStreamTest::testOutputSeek() +{ + Poco::Buffer buffer(9); + Poco::MemoryOutputStream ostr(buffer.begin(), buffer.size()); + ostr << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9'; + + ostr.seekp(4, std::ios_base::beg); // 4 from beginning + ostr << 'a'; // and that makes 5 (zero index 4) + assert (5 == ostr.tellp()); + assert (buffer[4] == 'a'); + + ostr.seekp(2, std::ios_base::cur); // and this makes 7 + ostr << 'b'; // and this makes 8 (zero index 7) + assert (8 == ostr.tellp()); + assert (buffer[7] == 'b'); + + ostr.seekp(-3, std::ios_base::end); // 9-3=6 from the beginning + ostr << 'c'; // and this makes 7 (zero index 6) + assert (7 == ostr.tellp()); + assert (buffer[6] == 'c'); + + + ostr.seekp(9, std::ios_base::beg); + assert (ostr.good()); + assert (9 == ostr.tellp()); + + { + Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size()); + ostr2.seekp(10, std::ios_base::beg); + assert (ostr2.fail()); + } + + + ostr.seekp(-9, std::ios_base::end); + assert (ostr.good()); + assert (0 == ostr.tellp()); + + { + Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size()); + ostr2.seekp(-10, std::ios_base::end); + assert (ostr2.fail()); + } + + + ostr.seekp(0, std::ios_base::beg); + assert (ostr.good()); + assert (0 == ostr.tellp()); + + { + Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size()); + ostr2.seekp(-1, std::ios_base::beg); + assert (ostr2.fail()); + } + + + ostr.seekp(0, std::ios_base::end); + assert (ostr.good()); + assert (9 == ostr.tellp()); + + { + Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size()); + ostr2.seekp(1, std::ios_base::end); + assert (ostr2.fail()); + } + + + ostr.seekp(3, std::ios_base::beg); + assert (ostr.good()); + assert (3 == ostr.tellp()); + ostr.seekp(6, std::ios_base::cur); + assert (ostr.good()); + assert (9 == ostr.tellp()); + + { + Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size()); + ostr2.seekp(4, std::ios_base::beg); + ostr2.seekp(6, std::ios_base::cur); + assert (ostr2.fail()); + } + + + ostr.seekp(-4, std::ios_base::end); + assert (ostr.good()); + assert (5 == ostr.tellp()); + ostr.seekp(4, std::ios_base::cur); + assert (ostr.good()); + assert (9 == ostr.tellp()); + + { + Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size()); + ostr2.seekp(-4, std::ios_base::end); + ostr2.seekp(5, std::ios_base::cur); + assert (ostr2.fail()); + } + + + ostr.seekp(4, std::ios_base::beg); + assert (ostr.good()); + assert (4 == ostr.tellp()); + ostr.seekp(-4, std::ios_base::cur); + assert (ostr.good()); + assert (0 == ostr.tellp()); + + { + Poco::MemoryOutputStream ostr2(buffer.begin(), buffer.size()); + ostr2.seekp(4, std::ios_base::beg); + ostr2.seekp(-5, std::ios_base::cur); + assert (ostr2.fail()); + } +} + + +void MemoryStreamTest::testOutputSeekVsStringStream() +{ + Poco::Buffer buffer(9); + Poco::MemoryOutputStream mos(buffer.begin(), buffer.size()); + mos << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9'; + + std::ostringstream oss; + oss << '1' << '2' << '3' << '4' << '5' << '6' << '7' << '8' << '9'; + + mos.seekp(4, std::ios_base::beg); + oss.seekp(4, std::ios_base::beg); + mos << 'a'; + oss << 'a'; + assert (oss.str()[4] == 'a'); + assert (buffer[4] == oss.str()[4]); + assert (oss.tellp() == mos.tellp()); + + mos.seekp(2, std::ios_base::cur); + oss.seekp(2, std::ios_base::cur); + mos << 'b'; + oss << 'b'; + assert (oss.str()[7] == 'b'); + assert (buffer[7] == oss.str()[7]); + assert (oss.tellp() == mos.tellp()); + + mos.seekp(-3, std::ios_base::end); + oss.seekp(-3, std::ios_base::end); + mos << 'c'; + oss << 'c'; + assert (oss.str()[6] == 'c'); + assert (buffer[6] == oss.str()[6]); + assert (oss.tellp() == mos.tellp()); + + mos.seekp(-2, std::ios_base::cur); + oss.seekp(-2, std::ios_base::cur); + mos << 'd'; + oss << 'd'; + assert (oss.str()[5] == 'd'); + assert (buffer[5] == oss.str()[5]); + assert (oss.tellp() == mos.tellp()); +} + void MemoryStreamTest::setUp() { @@ -103,6 +442,11 @@ CppUnit::Test* MemoryStreamTest::suite() CppUnit_addTest(pSuite, MemoryStreamTest, testInput); CppUnit_addTest(pSuite, MemoryStreamTest, testOutput); + CppUnit_addTest(pSuite, MemoryStreamTest, testTell); + CppUnit_addTest(pSuite, MemoryStreamTest, testInputSeek); + CppUnit_addTest(pSuite, MemoryStreamTest, testInputSeekVsStringStream); + CppUnit_addTest(pSuite, MemoryStreamTest, testOutputSeek); + CppUnit_addTest(pSuite, MemoryStreamTest, testOutputSeekVsStringStream); return pSuite; } diff --git a/Foundation/testsuite/src/MemoryStreamTest.h b/Foundation/testsuite/src/MemoryStreamTest.h index 95d1fc73a..5a37005cc 100644 --- a/Foundation/testsuite/src/MemoryStreamTest.h +++ b/Foundation/testsuite/src/MemoryStreamTest.h @@ -28,6 +28,11 @@ public: void testInput(); void testOutput(); + void testTell(); + void testInputSeek(); + void testInputSeekVsStringStream(); + void testOutputSeek(); + void testOutputSeekVsStringStream(); void setUp(); void tearDown(); diff --git a/JSON/CMakeLists.txt b/JSON/CMakeLists.txt index 7e314a0cc..e5746a628 100644 --- a/JSON/CMakeLists.txt +++ b/JSON/CMakeLists.txt @@ -26,25 +26,11 @@ target_include_directories( "${LIBNAME}" PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) - -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) + add_subdirectory(samples) + add_subdirectory(testsuite) endif () diff --git a/MongoDB/CMakeLists.txt b/MongoDB/CMakeLists.txt index 03e1fbcb9..5b95e6254 100644 --- a/MongoDB/CMakeLists.txt +++ b/MongoDB/CMakeLists.txt @@ -25,25 +25,12 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) + add_subdirectory(samples) + add_subdirectory(testsuite) endif () diff --git a/Net/CMakeLists.txt b/Net/CMakeLists.txt index 3a3969dc1..af19c0487 100644 --- a/Net/CMakeLists.txt +++ b/Net/CMakeLists.txt @@ -34,25 +34,12 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) + add_subdirectory(samples) + add_subdirectory(testsuite) endif () diff --git a/NetSSL_OpenSSL/CMakeLists.txt b/NetSSL_OpenSSL/CMakeLists.txt index 0ad6a67f1..f6a40c68d 100644 --- a/NetSSL_OpenSSL/CMakeLists.txt +++ b/NetSSL_OpenSSL/CMakeLists.txt @@ -25,25 +25,12 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) + add_subdirectory(samples) + add_subdirectory(testsuite) endif () diff --git a/NetSSL_Win/CMakeLists.txt b/NetSSL_Win/CMakeLists.txt index c5b41de63..355f49baf 100644 --- a/NetSSL_Win/CMakeLists.txt +++ b/NetSSL_Win/CMakeLists.txt @@ -25,26 +25,13 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - #TODO: Looks like the samples use crypto somehow? - #add_subdirectory(samples) - #add_subdirectory(testsuite) + #TODO: Looks like the samples use crypto somehow? + #add_subdirectory(samples) + #add_subdirectory(testsuite) endif () diff --git a/PDF/CMakeLists.txt b/PDF/CMakeLists.txt index fbca89940..46f538d77 100644 --- a/PDF/CMakeLists.txt +++ b/PDF/CMakeLists.txt @@ -130,25 +130,12 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) + add_subdirectory(samples) + add_subdirectory(testsuite) endif () diff --git a/PageCompiler/CMakeLists.txt b/PageCompiler/CMakeLists.txt index a7a60bb74..3a55c5575 100644 --- a/PageCompiler/CMakeLists.txt +++ b/PageCompiler/CMakeLists.txt @@ -19,5 +19,3 @@ install( RUNTIME DESTINATION bin INCLUDES DESTINATION include ) - -#POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") diff --git a/PageCompiler/File2Page/CMakeLists.txt b/PageCompiler/File2Page/CMakeLists.txt index 9ab634dd8..cb6d9694b 100644 --- a/PageCompiler/File2Page/CMakeLists.txt +++ b/PageCompiler/File2Page/CMakeLists.txt @@ -19,5 +19,3 @@ install( RUNTIME DESTINATION bin INCLUDES DESTINATION include ) - -#POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") diff --git a/PocoDoc/CMakeLists.txt b/PocoDoc/CMakeLists.txt index 80e49d39d..824168c08 100644 --- a/PocoDoc/CMakeLists.txt +++ b/PocoDoc/CMakeLists.txt @@ -15,5 +15,3 @@ install( RUNTIME DESTINATION bin INCLUDES DESTINATION include ) - -#POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") diff --git a/README.md b/README.md index 93c344743..eef5a0066 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ -POCO C++ Libraries [![Build Status](https://travis-ci.org/pocoproject/poco.png?branch=develop)](https://travis-ci.org/pocoproject/poco) +POCO C++ Libraries ================== +Build Status +------------ + +- Travis: [![Travis Build Status](https://travis-ci.org/pocoproject/poco.png?branch=develop)](https://travis-ci.org/pocoproject/poco) +- AppVeyor: [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/7iyrx3f233s3akae)](https://ci.appveyor.com/project/obiltschnig/poco) + + POrtable COmponents C++ Libraries are: -------------------------------------- - A collection of C++ class libraries, conceptually similar to the Java Class Library, the .NET Framework or Appleā€™s Cocoa. diff --git a/SevenZip/CMakeLists.txt b/SevenZip/CMakeLists.txt index bcc35dfd0..bf76be324 100644 --- a/SevenZip/CMakeLists.txt +++ b/SevenZip/CMakeLists.txt @@ -66,26 +66,13 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(samples) - # TODO: Add tests - #add_subdirectory(testsuite) + add_subdirectory(samples) + # TODO: Add tests + #add_subdirectory(testsuite) endif () diff --git a/Util/CMakeLists.txt b/Util/CMakeLists.txt index a8dd68661..852519227 100644 --- a/Util/CMakeLists.txt +++ b/Util/CMakeLists.txt @@ -32,22 +32,8 @@ target_include_directories( "${LIBNAME}" PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) - -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) add_subdirectory(samples) diff --git a/Util/include/Poco/Util/Application.h b/Util/include/Poco/Util/Application.h index 30b826d9b..d2843cb11 100644 --- a/Util/include/Poco/Util/Application.h +++ b/Util/include/Poco/Util/Application.h @@ -70,7 +70,7 @@ class Util_API Application: public Subsystem /// - a SystemConfiguration (priority 100) /// - the configurations loaded with loadConfiguration(). /// - /// The Application class sets a few default properties in + /// The Application class sets a few default properties in /// its configuration. These are: /// - application.path: the absolute path to application executable /// - application.name: the file name of the application executable @@ -86,6 +86,8 @@ class Util_API Application: public Subsystem { public: typedef std::vector ArgVec; + typedef Poco::AutoPtr SubsystemPtr; + typedef std::vector SubsystemVec; enum ExitCode /// Commonly used exit status codes. @@ -108,14 +110,14 @@ public: EXIT_NOPERM = 77, /// permission denied EXIT_CONFIG = 78 /// configuration error }; - + enum ConfigPriority { PRIO_APPLICATION = -100, PRIO_DEFAULT = 0, PRIO_SYSTEM = 100 }; - + Application(); /// Creates the Application. @@ -131,7 +133,7 @@ public: void init(int argc, char* argv[]); /// Processes the application's command line arguments - /// and sets the application's properties (e.g., + /// and sets the application's properties (e.g., /// "application.path", "application.name", etc.). /// /// Note that as of release 1.3.7, init() no longer @@ -140,7 +142,7 @@ public: #if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING) void init(int argc, wchar_t* argv[]); /// Processes the application's command line arguments - /// and sets the application's properties (e.g., + /// and sets the application's properties (e.g., /// "application.path", "application.name", etc.). /// /// Note that as of release 1.3.7, init() no longer @@ -152,7 +154,7 @@ public: void init(const ArgVec& args); /// Processes the application's command line arguments - /// and sets the application's properties (e.g., + /// and sets the application's properties (e.g., /// "application.path", "application.name", etc.). /// /// Note that as of release 1.3.7, init() no longer @@ -172,11 +174,11 @@ public: int loadConfiguration(int priority = PRIO_DEFAULT); /// Loads configuration information from a default location. /// - /// The configuration(s) will be added to the application's + /// The configuration(s) will be added to the application's /// LayeredConfiguration with the given priority. /// /// The configuration file(s) must be located in the same directory - /// as the executable or a parent directory of it, and must have the + /// as the executable or a parent directory of it, and must have the /// same base name as the executable, with one of the following extensions: /// .properties, .ini or .xml. /// @@ -185,9 +187,9 @@ public: /// /// If the application is built in debug mode (the _DEBUG preprocessor /// macro is defined) and the base name of the appication executable - /// ends with a 'd', a config file without the 'd' ending its base name is + /// ends with a 'd', a config file without the 'd' ending its base name is /// also found. - /// + /// /// Example: Given the application "SampleAppd.exe", built in debug mode. /// Then loadConfiguration() will automatically find a configuration file /// named "SampleApp.properties" if it exists and if "SampleAppd.properties" @@ -208,7 +210,7 @@ public: /// /// Extensions are not case sensitive. /// - /// The configuration will be added to the application's + /// The configuration will be added to the application's /// LayeredConfiguration with the given priority. template C& getSubsystem() const; @@ -218,6 +220,9 @@ public: /// Throws a NotFoundException if such a subsystem has /// not been registered. + SubsystemVec& subsystems(); + /// Returns a reference to the subsystem list + virtual int run(); /// Runs the application by performing additional (un)initializations /// and calling the main() method. @@ -237,7 +242,7 @@ public: LayeredConfiguration& config() const; /// Returns the application's configuration. - + Poco::Logger& logger() const; /// Returns the application's logger. /// @@ -245,21 +250,21 @@ public: /// application's logger is "ApplicationStartup", which is /// connected to a ConsoleChannel. /// - /// After the logging subsystem has been initialized, which + /// After the logging subsystem has been initialized, which /// usually happens as the first action in Application::initialize(), /// the application's logger is the one specified by the /// "application.logger" configuration property. If that property /// is not specified, the logger is "Application". - + const ArgVec& argv() const; - /// Returns reference to vector of the application's arguments as - /// specified on the command line. If user overrides the + /// Returns reference to vector of the application's arguments as + /// specified on the command line. If user overrides the /// Application::main(const ArgVec&) function, it will receive /// only the command line parameters that were not processed in - /// Application::processOptons(). This function returns the + /// Application::processOptons(). This function returns the /// full set of command line parameters as received in /// main(argc, argv*). - + const OptionSet& options() const; /// Returns the application's option set. @@ -273,7 +278,7 @@ public: Poco::Timespan uptime() const; /// Returns the application uptime. - + void stopOptionsProcessing(); /// If called from an option callback, stops all further /// options processing. @@ -295,11 +300,11 @@ protected: /// in which they have been registered. /// /// Overriding implementations must call the base class implementation. - + void uninitialize(); /// Uninitializes the application and all registered subsystems. /// Subsystems are always uninitialized in reverse order in which - /// they have been initialized. + /// they have been initialized. /// /// Overriding implementations must call the base class implementation. @@ -367,10 +372,8 @@ private: void processOptions(); bool findAppConfigFile(const std::string& appName, const std::string& extension, Poco::Path& path) const; - typedef Poco::AutoPtr SubsystemPtr; - typedef std::vector SubsystemVec; typedef Poco::AutoPtr ConfigPtr; - + ConfigPtr _pConfig; SubsystemVec _subsystems; bool _initialized; @@ -388,7 +391,7 @@ private: #endif static Application* _pInstance; - + friend class LoggingSubsystem; Application(const Application&); @@ -410,6 +413,11 @@ template C& Application::getSubsystem() const throw Poco::NotFoundException("The subsystem has not been registered", typeid(C).name()); } +inline Application::SubsystemVec& Application::subsystems() +{ + return _subsystems; +} + inline bool Application::initialized() const { @@ -459,7 +467,7 @@ inline Poco::Timespan Application::uptime() const { Poco::Timestamp now; Poco::Timespan uptime = now - _startTime; - + return uptime; } diff --git a/Util/include/Poco/Util/Subsystem.h b/Util/include/Poco/Util/Subsystem.h index 442e9ce5d..0f7c04880 100644 --- a/Util/include/Poco/Util/Subsystem.h +++ b/Util/include/Poco/Util/Subsystem.h @@ -44,7 +44,7 @@ class Util_API Subsystem: public Poco::RefCountedObject /// life of a running application. /// /// The degree to which dynamic reconfiguration is supported - /// is up to the actual subsystem implementation. It can + /// is up to the actual subsystem implementation. It can /// range from ignoring the reconfiguration request (not /// recommended), to changing certain settings that affect /// the performance, to a complete reinitialization. @@ -52,15 +52,15 @@ class Util_API Subsystem: public Poco::RefCountedObject public: Subsystem(); /// Creates the Subsystem. - -protected: + virtual const char* name() const = 0; /// Returns the name of the subsystem. /// Must be implemented by subclasses. +protected: virtual void initialize(Application& app) = 0; /// Initializes the subsystem. - + virtual void uninitialize() = 0; /// Uninitializes the subsystem. @@ -70,7 +70,7 @@ protected: /// The default implementation just calls /// uninitialize() followed by initialize(). /// Actual implementations might want to use a - /// less radical and possibly more performant + /// less radical and possibly more performant /// approach. virtual void defineOptions(OptionSet& options); @@ -85,9 +85,9 @@ protected: virtual ~Subsystem(); /// Destroys the Subsystem. - + friend class Application; - + private: Subsystem(const Subsystem&); Subsystem& operator = (const Subsystem&); diff --git a/Util/include/Poco/Util/WinRegistryKey.h b/Util/include/Poco/Util/WinRegistryKey.h index d8005fce9..67c3af47e 100644 --- a/Util/include/Poco/Util/WinRegistryKey.h +++ b/Util/include/Poco/Util/WinRegistryKey.h @@ -38,14 +38,20 @@ class Util_API WinRegistryKey public: typedef std::vector Keys; typedef std::vector Values; - - enum Type + + enum Type { - REGT_NONE = 0, - REGT_STRING = 1, - REGT_STRING_EXPAND = 2, + REGT_NONE = 0, + REGT_STRING = 1, + REGT_STRING_EXPAND = 2, REGT_BINARY = 3, - REGT_DWORD = 4, + REGT_DWORD = 4, + REGT_DWORD_BIG_ENDIAN = 5, + REGT_LINK = 6, + REGT_MULTI_STRING = 7, + REGT_RESOURCE_LIST = 8, + REGT_FULL_RESOURCE_DESCRIPTOR = 9, + REGT_RESOURCE_REQUIREMENTS_LIST = 10, REGT_QWORD = 11 }; @@ -78,7 +84,7 @@ public: void setString(const std::string& name, const std::string& value); /// Sets the string value (REG_SZ) with the given name. /// An empty name denotes the default value. - + std::string getString(const std::string& name); /// Returns the string value (REG_SZ) with the given name. /// An empty name denotes the default value. @@ -88,7 +94,7 @@ public: void setStringExpand(const std::string& name, const std::string& value); /// Sets the expandable string value (REG_EXPAND_SZ) with the given name. /// An empty name denotes the default value. - + std::string getStringExpand(const std::string& name); /// Returns the string value (REG_EXPAND_SZ) with the given name. /// An empty name denotes the default value. @@ -97,7 +103,7 @@ public: /// /// Throws a NotFoundException if the value does not exist. - void setBinary(const std::string& name, const std::vector& value); + void setBinary(const std::string& name, const std::vector& value); /// Sets the string value (REG_BINARY) with the given name. /// An empty name denotes the default value. @@ -110,7 +116,7 @@ public: void setInt(const std::string& name, int value); /// Sets the numeric (REG_DWORD) value with the given name. /// An empty name denotes the default value. - + int getInt(const std::string& name); /// Returns the numeric value (REG_DWORD) with the given name. /// An empty name denotes the default value. @@ -144,7 +150,7 @@ public: Type type(const std::string& name); /// Returns the type of the key value. - + bool exists(const std::string& name); /// Returns true iff the given value exists under that key. @@ -153,7 +159,7 @@ public: void values(Values& vals); /// Appends all value names to vals; - + bool isReadOnly() const; /// Returns true iff the key has been opened for read-only access only. @@ -162,6 +168,7 @@ protected: void close(); std::string key() const; std::string key(const std::string& valueName) const; + HKEY handle(); void handleSetError(const std::string& name); static HKEY handleFor(const std::string& rootKey); @@ -169,7 +176,7 @@ private: WinRegistryKey(); WinRegistryKey(const WinRegistryKey&); WinRegistryKey& operator = (const WinRegistryKey&); - + HKEY _hRootKey; std::string _subKey; HKEY _hKey; diff --git a/Util/src/WinRegistryKey.cpp b/Util/src/WinRegistryKey.cpp index 31b118220..3cafe424c 100644 --- a/Util/src/WinRegistryKey.cpp +++ b/Util/src/WinRegistryKey.cpp @@ -40,17 +40,17 @@ namespace _h(h) { } - + ~AutoHandle() { FreeLibrary(_h); } - + HMODULE handle() { return _h; } - + private: HMODULE _h; }; @@ -98,10 +98,10 @@ void WinRegistryKey::setString(const std::string& name, const std::string& value std::wstring uvalue; Poco::UnicodeConverter::toUTF16(value, uvalue); if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_SZ, (CONST BYTE*) uvalue.c_str(), (DWORD) (uvalue.size() + 1)*sizeof(wchar_t)) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #else if (RegSetValueExA(_hKey, name.c_str(), 0, REG_SZ, (CONST BYTE*) value.c_str(), (DWORD) value.size() + 1) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #endif } @@ -114,7 +114,7 @@ std::string WinRegistryKey::getString(const std::string& name) #if defined(POCO_WIN32_UTF8) std::wstring uname; Poco::UnicodeConverter::toUTF16(name, uname); - if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ) + if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_LINK)) throw NotFoundException(key(name)); if (size > 0) { @@ -128,7 +128,7 @@ std::string WinRegistryKey::getString(const std::string& name) return result; } #else - if (RegQueryValueExA(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ) + if (RegQueryValueExA(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_LINK)) throw NotFoundException(key(name)); if (size > 0) { @@ -152,10 +152,10 @@ void WinRegistryKey::setStringExpand(const std::string& name, const std::string& std::wstring uvalue; Poco::UnicodeConverter::toUTF16(value, uvalue); if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_EXPAND_SZ, (CONST BYTE*) uvalue.c_str(), (DWORD) (uvalue.size() + 1)*sizeof(wchar_t)) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #else if (RegSetValueExA(_hKey, name.c_str(), 0, REG_EXPAND_SZ, (CONST BYTE*) value.c_str(), (DWORD) value.size() + 1) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #endif } @@ -168,7 +168,7 @@ std::string WinRegistryKey::getStringExpand(const std::string& name) #if defined(POCO_WIN32_UTF8) std::wstring uname; Poco::UnicodeConverter::toUTF16(name, uname); - if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ) + if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_LINK)) throw NotFoundException(key(name)); if (size > 0) { @@ -178,7 +178,7 @@ std::string WinRegistryKey::getStringExpand(const std::string& name) buffer[len] = 0; #if !defined(_WIN32_WCE) wchar_t temp; - DWORD expSize = ExpandEnvironmentStringsW(buffer.begin(), &temp, 1); + DWORD expSize = ExpandEnvironmentStringsW(buffer.begin(), &temp, 1); Poco::Buffer expBuffer(expSize); ExpandEnvironmentStringsW(buffer.begin(), expBuffer.begin(), expSize); std::string result; @@ -190,7 +190,7 @@ std::string WinRegistryKey::getStringExpand(const std::string& name) return result; } #else - if (RegQueryValueExA(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ) + if (RegQueryValueExA(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_LINK)) throw NotFoundException(key(name)); if (size > 0) { @@ -198,7 +198,7 @@ std::string WinRegistryKey::getStringExpand(const std::string& name) RegQueryValueExA(_hKey, name.c_str(), NULL, NULL, (BYTE*) Buffer.begin(), &size); buffer[size] = 0; char temp; - DWORD expSize = ExpandEnvironmentStringsA(buffer, &temp, 1); + DWORD expSize = ExpandEnvironmentStringsA(buffer, &temp, 1); Poco::Buffer expBuffer(expSize); ExpandEnvironmentStringsA(Buffer.begin(), expBuffer.begin(), expSize); std::string result(expBuffer.begin()); @@ -217,10 +217,10 @@ void WinRegistryKey::setBinary( const std::string& name, const std::vector std::wstring uname; Poco::UnicodeConverter::toUTF16(name, uname); if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_BINARY, (CONST BYTE*) &value[0], (DWORD) value.size()) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #else if (RegSetValueExA(_hKey, name.c_str(), 0, REG_BINARY, (CONST BYTE*) &value[0], (DWORD) value.size()) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #endif } @@ -263,10 +263,10 @@ void WinRegistryKey::setInt(const std::string& name, int value) std::wstring uname; Poco::UnicodeConverter::toUTF16(name, uname); if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_DWORD, (CONST BYTE*) &data, sizeof(data)) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #else if (RegSetValueExA(_hKey, name.c_str(), 0, REG_DWORD, (CONST BYTE*) &data, sizeof(data)) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #endif } @@ -280,10 +280,10 @@ int WinRegistryKey::getInt(const std::string& name) #if defined(POCO_WIN32_UTF8) std::wstring uname; Poco::UnicodeConverter::toUTF16(name, uname); - if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || type != REG_DWORD) + if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || (type != REG_DWORD && type != REG_DWORD_BIG_ENDIAN)) throw NotFoundException(key(name)); #else - if (RegQueryValueExA(_hKey, name.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || type != REG_DWORD) + if (RegQueryValueExA(_hKey, name.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || (type != REG_DWORD && type != REG_DWORD_BIG_ENDIAN)) throw NotFoundException(key(name)); #endif return data; @@ -300,10 +300,10 @@ void WinRegistryKey::setInt64(const std::string& name, Poco::Int64 value) std::wstring uname; Poco::UnicodeConverter::toUTF16(name, uname); if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_QWORD, (CONST BYTE*) &value, sizeof(value)) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #else if (RegSetValueExA(_hKey, name.c_str(), 0, REG_QWORD, (CONST BYTE*) &value, sizeof(value)) != ERROR_SUCCESS) - handleSetError(name); + handleSetError(name); #endif } @@ -365,7 +365,7 @@ void WinRegistryKey::deleteKey() #if defined(POCO_WIN32_UTF8) std::wstring usubKey; Poco::UnicodeConverter::toUTF16(_subKey, usubKey); - + #if !defined(_WIN32_WCE) typedef LONG (WINAPI *RegDeleteKeyExWFunc)(HKEY hKey, const wchar_t* lpSubKey, REGSAM samDesired, DWORD Reserved); if (_extraSam != 0) @@ -443,8 +443,6 @@ WinRegistryKey::Type WinRegistryKey::type(const std::string& name) if (RegQueryValueExA(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS) throw NotFoundException(key(name)); #endif - if (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_DWORD && type != REG_QWORD && type != REG_BINARY) - throw NotFoundException(key(name)+": type not supported"); Type aType = (Type)type; return aType; @@ -558,6 +556,13 @@ std::string WinRegistryKey::key(const std::string& valueName) const } +HKEY WinRegistryKey::handle() +{ + open(); + return _hKey; +} + + HKEY WinRegistryKey::handleFor(const std::string& rootKey) { if (rootKey == "HKEY_CLASSES_ROOT") @@ -594,7 +599,7 @@ void WinRegistryKey::subKeys(WinRegistryKey::Keys& keys) DWORD subKeyCount = 0; DWORD valueCount = 0; - + if (RegQueryInfoKey(_hKey, NULL, NULL, NULL, &subKeyCount, NULL, NULL, &valueCount, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) return; @@ -633,7 +638,7 @@ void WinRegistryKey::values(WinRegistryKey::Values& vals) open(); DWORD valueCount = 0; - + if (RegQueryInfoKey(_hKey, NULL, NULL, NULL, NULL, NULL, NULL, &valueCount, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) return ; diff --git a/XML/CMakeLists.txt b/XML/CMakeLists.txt index 17c0a37cd..21e57f825 100644 --- a/XML/CMakeLists.txt +++ b/XML/CMakeLists.txt @@ -49,25 +49,11 @@ target_include_directories( "${LIBNAME}" PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) - -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) + add_subdirectory(samples) + add_subdirectory(testsuite) endif () diff --git a/Zip/CMakeLists.txt b/Zip/CMakeLists.txt index 1937e91e4..1263d283d 100644 --- a/Zip/CMakeLists.txt +++ b/Zip/CMakeLists.txt @@ -25,25 +25,12 @@ target_include_directories( "${LIBNAME}" $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -install( - DIRECTORY include/Poco - DESTINATION include - COMPONENT Devel - PATTERN ".svn" EXCLUDE - ) -install( - TARGETS "${LIBNAME}" EXPORT "${LIBNAME}Targets" - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}") +POCO_INSTALL("${LIBNAME}") +POCO_GENERATE_PACKAGE("${LIBNAME}") if (ENABLE_TESTS) - add_subdirectory(samples) - add_subdirectory(testsuite) + add_subdirectory(samples) + add_subdirectory(testsuite) endif () diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..71bbe23e1 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,11 @@ +version: '{build}' + +install: + - cinst cmake + +build_script: + - set PATH=C:\ProgramData\chocolatey\bin;%PATH% + - mkdir cmake-build + - cd cmake-build + - cmake .. + - cmake --build . diff --git a/build/config/Darwin-clang b/build/config/Darwin-clang index 6bdd172e6..7990d003f 100644 --- a/build/config/Darwin-clang +++ b/build/config/Darwin-clang @@ -32,7 +32,7 @@ CXX = clang++ LINK = $(CXX) -bind_at_load LIB = libtool -static -o RANLIB = ranlib -SHLIB = $(CXX) -dynamiclib -o $@ +SHLIB = $(CXX) -dynamiclib -Wl,-install_name,$(POCO_LIB_INSTALLDIR)/$(notdir \$@) -o $@ DYLIB = $(CXX) -dynamic -bundle $(RORELOCS) -Wl,-bind_at_load -o $@ SHLIBLN = $(POCO_BASE)/build/script/shlibln STRIP = diff --git a/build/config/Darwin-clang-libc++ b/build/config/Darwin-clang-libc++ index 732be9268..2f6c15d43 100644 --- a/build/config/Darwin-clang-libc++ +++ b/build/config/Darwin-clang-libc++ @@ -29,7 +29,7 @@ CXX = $(shell xcrun -find clang++) LINK = $(CXX) -bind_at_load LIB = libtool -static -o RANLIB = ranlib -SHLIB = $(CXX) -dynamiclib -o $@ +SHLIB = $(CXX) -dynamiclib -Wl,-install_name,$(POCO_LIB_INSTALLDIR)/$(notdir \$@) -o $@ DYLIB = $(CXX) -dynamic -bundle -read_only_relocs suppress -Wl,-bind_at_load -o $@ SHLIBLN = $(POCO_BASE)/build/script/shlibln STRIP = diff --git a/build/config/Darwin-gcc b/build/config/Darwin-gcc index f273ee8ae..99f295a3a 100644 --- a/build/config/Darwin-gcc +++ b/build/config/Darwin-gcc @@ -29,7 +29,7 @@ CXX = g++ LINK = $(CXX) -bind_at_load LIB = libtool -static -o RANLIB = ranlib -SHLIB = $(CXX) -dynamiclib -o $@ +SHLIB = $(CXX) -dynamiclib -Wl,-install_name,$(POCO_LIB_INSTALLDIR)/$(notdir \$@) -o $@ DYLIB = $(CXX) -dynamic -bundle -bind_at_load -o $@ SHLIBLN = $(POCO_BASE)/build/script/shlibln STRIP = diff --git a/build/rules/global b/build/rules/global index 0226ebcf6..33c593a8e 100644 --- a/build/rules/global +++ b/build/rules/global @@ -192,6 +192,11 @@ POCO_HOST_LIBDIR = lib/$(POCO_HOST_OSNAME)/$(POCO_HOST_OSARCH) POCO_TARGET_LIBDIR = $(LIBDIR) POCO_HOST_LIBPATH = $(POCO_BUILD)/$(POCO_HOST_LIBDIR) POCO_TARGET_LIBPATH = $(LIBPATH) +ifdef POCO_PREFIX +POCO_LIB_INSTALLDIR = $(POCO_PREFIX)/lib +else +POCO_LIB_INSTALLDIR = $(LIBPATH) +endif ifeq ($(POCO_BASE),$(PROJECT_BASE)) POCO_LIBRARY = diff --git a/cmake/PocoConfig.cmake b/cmake/PocoConfig.cmake deleted file mode 100644 index 0ce51e690..000000000 --- a/cmake/PocoConfig.cmake +++ /dev/null @@ -1,143 +0,0 @@ -# - Find the Poco includes and libraries. -# The following variables are set if Poco is found. If Poco is not -# found, Poco_FOUND is set to false. -# Poco_FOUND - True when the Poco include directory is found. -# Poco_INCLUDE_DIRS - the path to where the poco include files are. -# Poco_LIBRARY_DIRS - The path to where the poco library files are. -# Poco_BINARY_DIRS - The path to where the poco dlls are. - -# ---------------------------------------------------------------------------- -# If you have installed Poco in a non-standard location. -# Then you have three options. -# In the following comments, it is assumed that -# points to the root directory of the include directory of Poco. e.g -# If you have put poco in C:\development\Poco then is -# "C:/development/Poco" and in this directory there will be two -# directories called "include" and "lib". -# 1) After CMake runs, set Poco_INCLUDE_DIR to /poco<-version> -# 2) Use CMAKE_INCLUDE_PATH to set a path to /poco<-version>. This will allow FIND_PATH() -# to locate Poco_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. -# SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "/include") -# 3) Set an environment variable called ${POCO_ROOT} that points to the root of where you have -# installed Poco, e.g. . It is assumed that there is at least a subdirectory called -# Foundation/include/Poco in this path. -# -# Note: -# 1) If you are just using the poco headers, then you do not need to use -# Poco_LIBRARY_DIRS in your CMakeLists.txt file. -# 2) If Poco has not been installed, then when setting Poco_LIBRARY_DIRS -# the script will look for /lib first and, if this fails, then for /stage/lib. -# -# Usage: -# In your CMakeLists.txt file do something like this: -# ... -# # Poco -# FIND_PACKAGE(Poco) -# ... -# INCLUDE_DIRECTORIES(${Poco_INCLUDE_DIRS}) -# LINK_DIRECTORIES(${Poco_LIBRARY_DIRS}) -# -# In Windows, we make the assumption that, if the Poco files are installed, the default directory -# will be C:\poco or C:\Program Files\Poco. - -SET(POCO_INCLUDE_PATH_DESCRIPTION "top-level directory containing the poco include directories. E.g /usr/local/include/poco-1.2.1 or c:\\poco\\include\\poco-1.2.1") -SET(POCO_INCLUDE_DIR_MESSAGE "Set the Poco_INCLUDE_DIR cmake cache entry to the ${POCO_INCLUDE_PATH_DESCRIPTION}") -SET(POCO_LIBRARY_PATH_DESCRIPTION "top-level directory containing the poco libraries.") -SET(POCO_LIBRARY_DIR_MESSAGE "Set the Poco_LIBRARY_DIR cmake cache entry to the ${POCO_LIBRARY_PATH_DESCRIPTION}") - - -SET(POCO_DIR_SEARCH $ENV{POCO_ROOT}) -IF(POCO_DIR_SEARCH) - FILE(TO_CMAKE_PATH ${POCO_DIR_SEARCH} POCO_DIR_SEARCH) -ENDIF(POCO_DIR_SEARCH) - - -IF(WIN32) - SET(POCO_DIR_SEARCH - ${POCO_DIR_SEARCH} - C:/poco - D:/poco - "C:Program Files/poco" - "D:Program Files/poco" - ) -ENDIF(WIN32) - -# Add in some path suffixes. These will have to be updated whenever a new Poco version comes out. -SET(SUFFIX_FOR_INCLUDE_PATH - poco-1.2.4 - poco-1.2.3 - poco-1.2.1 -) - -SET(SUFFIX_FOR_LIBRARY_PATH - poco-1.2.4/lib - poco-1.2.4/lib/Linux/i686 - poco-1.2.3/lib - poco-1.2.3/lib/Linux/i686 - poco-1.2.1/lib - poco-1.2.1/lib/Linux/i686 - lib - lib/Linux/i686 -) - -# -# Look for an installation. -# -FIND_PATH(Poco_INCLUDE_DIR NAMES Foundation/include/Poco/AbstractCache.h PATH_SUFFIXES ${SUFFIX_FOR_INCLUDE_PATH} PATHS - - # Look in other places. - ${POCO_DIR_SEARCH} - - # Help the user find it if we cannot. - DOC "The ${POCO_INCLUDE_DIR_MESSAGE}" -) - -# Assume we didn't find it. -SET(Poco_FOUND 0) - -# Now try to get the include and library path. -IF(Poco_INCLUDE_DIR) - - IF(EXISTS "${Poco_INCLUDE_DIR}") - SET(Poco_INCLUDE_DIRS - ${Poco_INCLUDE_DIR}/CppUnit/include - ${Poco_INCLUDE_DIR}/Foundation/include - ${Poco_INCLUDE_DIR}/Net/include - ${Poco_INCLUDE_DIR}/Util/include - ${Poco_INCLUDE_DIR}/XML/include - ) - SET(Poco_FOUND 1) - ENDIF(EXISTS "${Poco_INCLUDE_DIR}") - - FIND_LIBRARY(Poco_LIBRARY_DIR NAMES PocoFoundation PocoFoundationd PATH_SUFFIXES ${SUFFIX_FOR_LIBRARY_PATH} PATHS - - # Look in other places. - ${Poco_INCLUDE_DIR} - ${POCO_DIR_SEARCH} - - # Help the user find it if we cannot. - DOC "The ${POCO_LIBRARY_PATH_DESCRIPTION}" - ) - GET_FILENAME_COMPONENT(Poco_LIBRARY_DIR ${Poco_LIBRARY_DIR} PATH) - IF(Poco_INCLUDE_DIR) - SET(Poco_LIBRARY_DIRS ${Poco_LIBRARY_DIR}) - - # Look for the poco binary path. - SET(Poco_BINARY_DIR ${Poco_INCLUDE_DIR}) - IF(Poco_BINARY_DIR AND EXISTS "${Poco_BINARY_DIR}") - SET(Poco_BINARY_DIRS ${Poco_BINARY_DIR}/bin) - ENDIF(Poco_BINARY_DIR AND EXISTS "${Poco_BINARY_DIR}") - ENDIF(Poco_INCLUDE_DIR) - -ENDIF(Poco_INCLUDE_DIR) - -IF(NOT Poco_FOUND) - IF(NOT Poco_FIND_QUIETLY) - MESSAGE(STATUS "Poco was not found. ${POCO_DIR_MESSAGE}") - ELSE(NOT Poco_FIND_QUIETLY) - IF(Poco_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Poco was not found. ${POCO_DIR_MESSAGE}") - ENDIF(Poco_FIND_REQUIRED) - ENDIF(NOT Poco_FIND_QUIETLY) -ENDIF(NOT Poco_FOUND) - diff --git a/cmake/PocoMacros.cmake b/cmake/PocoMacros.cmake index f255c502a..95e09201b 100644 --- a/cmake/PocoMacros.cmake +++ b/cmake/PocoMacros.cmake @@ -187,46 +187,67 @@ endmacro() #=============================================================================== # Macros for Package generation # -#TODO: Document this! # POCO_GENERATE_PACKAGE - Generates *Config.cmake -# Usage: POCO_SOURCES_PLAT( out name platform sources) +# Usage: POCO_GENERATE_PACKAGE(target_name) # INPUT: -# out the variable the sources are added to -# name: the name of the components -# platform: the platform this sources are for (ON = All, OFF = None, WIN32, UNIX ...) -# sources: a list of files to add to ${out} -# Example: POCO_SOURCES_PLAT( SRCS Foundation ON src/Foundation.cpp ) -macro(POCO_GENERATE_PACKAGE target_name export_name package_destination) +# target_name the name of the target. e.g. Foundation for PocoFoundation +# Example: POCO_GENERATE_PACKAGE(Foundation) +macro(POCO_GENERATE_PACKAGE target_name) include(CMakePackageConfigHelpers) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/Poco${target_name}ConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ) -export(EXPORT "${export_name}" - FILE "${CMAKE_CURRENT_BINARY_DIR}/Poco${target_name}Targets.cmake" - NAMESPACE "Poco::" +export(EXPORT "${target_name}Targets" + FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake" + NAMESPACE "${PROJECT_NAME}::" ) -configure_file(cmake/Poco${target_name}Config.cmake - "${CMAKE_CURRENT_BINARY_DIR}/Poco${target_name}Config.cmake" +configure_file("cmake/Poco${target_name}Config.cmake" + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake" @ONLY ) -set(ConfigPackageLocation "${package_destination}") +set(ConfigPackageLocation "lib/cmake/${PROJECT_NAME}") install( - EXPORT "${export_name}" - FILE "Poco${target_name}Targets.cmake" - NAMESPACE "Poco::" - DESTINATION ${package_destination} + EXPORT "${target_name}Targets" + FILE "${PROJECT_NAME}${target_name}Targets.cmake" + NAMESPACE "${PROJECT_NAME}::" + DESTINATION "lib/cmake/${PROJECT_NAME}" ) install( FILES - "${CMAKE_CURRENT_BINARY_DIR}/Poco${target_name}Config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/Poco${target_name}ConfigVersion.cmake" - DESTINATION ${package_destination} + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake" + "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}ConfigVersion.cmake" + DESTINATION "lib/cmake/${PROJECT_NAME}" COMPONENT Devel ) endmacro() + +#=============================================================================== +# Macros for simplified installation +# +# POCO_INSTALL - Install the given target +# Usage: POCO_INSTALL(target_name) +# INPUT: +# target_name the name of the target. e.g. Foundation for PocoFoundation +# Example: POCO_INSTALL(Foundation) +macro(POCO_INSTALL target_name) +install( + DIRECTORY include/Poco + DESTINATION include + COMPONENT Devel + PATTERN ".svn" EXCLUDE + ) + +install( + TARGETS "${target_name}" EXPORT "${target_name}Targets" + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + RUNTIME DESTINATION bin + INCLUDES DESTINATION include + ) +endmacro()