mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-23 07:24:40 +01:00
commit
238b12b899
@ -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 ()
|
||||
|
||||
|
@ -27,24 +27,11 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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 ()
|
||||
|
@ -34,54 +34,41 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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)
|
||||
|
@ -27,22 +27,9 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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)
|
||||
|
@ -27,22 +27,9 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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)
|
||||
|
@ -48,22 +48,9 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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)
|
||||
|
@ -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 )
|
||||
|
@ -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 <bool x>
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <mach/clock.h>
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#elif defined(POCO_VXWORKS)
|
||||
#include <timers.h>
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -208,6 +208,7 @@ void Timer::run()
|
||||
{
|
||||
Poco::ErrorHandler::handle();
|
||||
}
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
interval = _periodicInterval;
|
||||
}
|
||||
_nextInvocation += static_cast<Clock::ClockVal>(interval)*1000;
|
||||
|
@ -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<std::string> 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<std::string> 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();
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,10 @@
|
||||
#include "MemoryStreamTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Buffer.h"
|
||||
#include "Poco/MemoryStream.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using Poco::MemoryInputStream;
|
||||
using Poco::MemoryOutputStream;
|
||||
@ -86,6 +88,343 @@ void MemoryStreamTest::testOutput()
|
||||
assert (ostr2.fail());
|
||||
}
|
||||
|
||||
void MemoryStreamTest::testTell()
|
||||
{
|
||||
Poco::Buffer<char> 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<char> 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<char> 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<char> 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<char> 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;
|
||||
}
|
||||
|
@ -28,6 +28,11 @@ public:
|
||||
|
||||
void testInput();
|
||||
void testOutput();
|
||||
void testTell();
|
||||
void testInputSeek();
|
||||
void testInputSeekVsStringStream();
|
||||
void testOutputSeek();
|
||||
void testOutputSeekVsStringStream();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
@ -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 ()
|
||||
|
||||
|
@ -25,25 +25,12 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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 ()
|
||||
|
||||
|
@ -34,25 +34,12 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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 ()
|
||||
|
||||
|
@ -25,25 +25,12 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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 ()
|
||||
|
||||
|
@ -25,26 +25,13 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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 ()
|
||||
|
||||
|
@ -130,25 +130,12 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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 ()
|
||||
|
||||
|
@ -19,5 +19,3 @@ install(
|
||||
RUNTIME DESTINATION bin
|
||||
INCLUDES DESTINATION include
|
||||
)
|
||||
|
||||
#POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}")
|
||||
|
@ -19,5 +19,3 @@ install(
|
||||
RUNTIME DESTINATION bin
|
||||
INCLUDES DESTINATION include
|
||||
)
|
||||
|
||||
#POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}")
|
||||
|
@ -15,5 +15,3 @@ install(
|
||||
RUNTIME DESTINATION bin
|
||||
INCLUDES DESTINATION include
|
||||
)
|
||||
|
||||
#POCO_GENERATE_PACKAGE("${LIBNAME}" "${LIBNAME}Targets" "lib/cmake/${PROJECT_NAME}")
|
||||
|
@ -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.
|
||||
|
@ -66,26 +66,13 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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 ()
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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<std::string> ArgVec;
|
||||
typedef Poco::AutoPtr<Subsystem> SubsystemPtr;
|
||||
typedef std::vector<SubsystemPtr> 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 <class C> 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<Subsystem> SubsystemPtr;
|
||||
typedef std::vector<SubsystemPtr> SubsystemVec;
|
||||
typedef Poco::AutoPtr<LayeredConfiguration> 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 <class C> 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;
|
||||
}
|
||||
|
||||
|
@ -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&);
|
||||
|
@ -38,14 +38,20 @@ class Util_API WinRegistryKey
|
||||
public:
|
||||
typedef std::vector<std::string> Keys;
|
||||
typedef std::vector<std::string> 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<char>& value);
|
||||
void setBinary(const std::string& name, const std::vector<char>& 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;
|
||||
|
@ -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<wchar_t> 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<char> 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<char>
|
||||
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 ;
|
||||
|
||||
|
@ -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 ()
|
||||
|
||||
|
@ -25,25 +25,12 @@ target_include_directories( "${LIBNAME}"
|
||||
$<INSTALL_INTERFACE:include>
|
||||
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 ()
|
||||
|
||||
|
11
appveyor.yml
Normal file
11
appveyor.yml
Normal file
@ -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 .
|
@ -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 =
|
||||
|
@ -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 =
|
||||
|
@ -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 =
|
||||
|
@ -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 =
|
||||
|
@ -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 <Your Path>
|
||||
# points to the root directory of the include directory of Poco. e.g
|
||||
# If you have put poco in C:\development\Poco then <Your Path> 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 <Your Path>/poco<-version>
|
||||
# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/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} "<Your Path>/include")
|
||||
# 3) Set an environment variable called ${POCO_ROOT} that points to the root of where you have
|
||||
# installed Poco, e.g. <Your Path>. 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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user