mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-19 20:32:15 +01:00
Merge branch 'develop' of https://github.com/pocoproject/poco into develop
This commit is contained in:
commit
dc2e299bef
5
.gitignore
vendored
5
.gitignore
vendored
@ -103,6 +103,7 @@ lib/*
|
||||
lib64/*
|
||||
pocomsg.h
|
||||
*/testsuite/bin/*
|
||||
Util/testsuite/TestConfiguration/
|
||||
|
||||
# Eclipse generated files #
|
||||
######################
|
||||
@ -117,10 +118,12 @@ cmake-build/
|
||||
CodeGeneration
|
||||
RemotingNG
|
||||
XSD
|
||||
stage/
|
||||
releases/
|
||||
|
||||
|
||||
# openssl binaries #
|
||||
####################
|
||||
|
||||
!openssl/win32/bin/debug/*.dll
|
||||
!openssl/win32/bin/debug/*.lib
|
||||
!openssl/win32/bin/release/*.dll
|
||||
|
50
.travis.yml
50
.travis.yml
@ -5,51 +5,68 @@ cache:
|
||||
|
||||
before_install:
|
||||
# we need a recent version of CMake
|
||||
- sudo add-apt-repository -y ppa:andykimpe/cmake3
|
||||
# - sudo add-apt-repository -y ppa:andykimpe/cmake3
|
||||
# linux prereqisite packages
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then wget --no-check-certificate https://www.cmake.org/files/v3.2/cmake-3.2.3-Linux-x86_64.tar.gz; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then tar -xzvf cmake-3.2.3-Linux-x86_64.tar.gz; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export PATH=$PWD/cmake-3.2.3-Linux-x86_64/bin:$PATH; fi
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq -y unixodbc-dev libmysqlclient-dev g++-arm-linux-gnueabi g++-arm-linux-gnueabihf clang-3.5 sloccount cppcheck
|
||||
- sudo apt-get install -qq -y unixodbc-dev libmysqlclient-dev libsqlite3-dev
|
||||
- sudo apt-get install -qq -y g++-arm-linux-gnueabi g++-arm-linux-gnueabihf clang-3.5
|
||||
- sudo apt-get install -qq -y sloccount cppcheck
|
||||
|
||||
services:
|
||||
- mongodb
|
||||
|
||||
- redis-server
|
||||
|
||||
notifications:
|
||||
slack: pocoproject:ItIUZvs8aJGyPdaKxIKMnS1t
|
||||
slack:
|
||||
rooms:
|
||||
- pocoproject:ItIUZvs8aJGyPdaKxIKMnS1t
|
||||
- kampbell:v4ARuptk0ETzwUsKDdV6Gspb#travis
|
||||
|
||||
env:
|
||||
global: TEST_NAME=""
|
||||
|
||||
before_script:
|
||||
- echo ${TEST_NAME}
|
||||
- sqlite3 -version
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- env: TEST_NAME="gcc (make)"
|
||||
- env: TEST_NAME="gcc (make) bundled"
|
||||
compiler: gcc
|
||||
script:
|
||||
- ./configure --everything && make -s -j2
|
||||
- ./travis/runtests.sh
|
||||
- travis_wait 30 ./travis/runtests.sh
|
||||
|
||||
- env: TEST_NAME="gcc (make) unbundled"
|
||||
compiler: gcc
|
||||
script:
|
||||
- sudo apt-get install -qq -y libpcre3-dev libssl-dev libexpat1-dev
|
||||
- ./configure --everything --unbundled && make -s -j2
|
||||
- travis_wait 30 ./travis/runtests.sh
|
||||
|
||||
- env: TEST_NAME="clang (make)"
|
||||
compiler: clang
|
||||
script:
|
||||
- ./configure --everything --config=Linux-clang && make -s -j2
|
||||
- ./travis/runtests.sh
|
||||
- travis_wait 30 ./travis/runtests.sh
|
||||
|
||||
- env: TEST_NAME="arm-linux-gnueabi- (make)"
|
||||
script:
|
||||
- ./configure --omit=Data/ODBC,Data/MySQL,Crypto,NetSSL,PageCompiler && make -s -j2 CROSS_COMPILE=arm-linux-gnueabi- POCO_TARGET_OSARCH=armv7l
|
||||
#FIXME the -m64 option bring by the Linux config is not supported by arm-linux-gnueabi-g++ which makes this test failing
|
||||
#FIXME - env: TEST_NAME="arm-linux-gnueabi- (make)"
|
||||
#FIXME script:
|
||||
#FIXME - ./configure --omit=Data/ODBC,Data/MySQL,Crypto,NetSSL,PageCompiler && make -s -j2 CROSS_COMPILE=arm-linux-gnueabi- POCO_TARGET_OSARCH=armv7l
|
||||
|
||||
- env: TEST_NAME="gcc (CMake)"
|
||||
compiler: gcc
|
||||
script:
|
||||
- sudo apt-get install -qq -y cmake3
|
||||
# disable tests, gcc-4.6 gets an internal compiler error
|
||||
- mkdir cmake-build && cd cmake-build && cmake -DENABLE_TESTS=OFF .. && make -j2 && cd ..
|
||||
|
||||
- env: TEST_NAME="gcc-4.8 (CMake)"
|
||||
compiler: gcc
|
||||
script:
|
||||
- sudo apt-get install -qq -y cmake3
|
||||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq -y g++-4.8
|
||||
@ -60,19 +77,16 @@ matrix:
|
||||
- env: TEST_NAME="clang (CMake)"
|
||||
compiler: clang
|
||||
script:
|
||||
- sudo apt-get install -qq -y cmake3
|
||||
- mkdir cmake-build && cd cmake-build && cmake -DENABLE_TESTS=ON .. && make -j2 && cd ..
|
||||
|
||||
- env: TEST_NAME="arm-linux-gnueabi-g++ (CMake)"
|
||||
script:
|
||||
- sudo apt-get install -qq -y cmake3
|
||||
- export CC="arm-linux-gnueabi-gcc"
|
||||
- export CXX="arm-linux-gnueabi-g++"
|
||||
- mkdir cmake-build && cd cmake-build && cmake -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=ON .. && make -j2 && cd ..
|
||||
|
||||
- env: TEST_NAME="arm-linux-gnueabihf-g++ (CMake)"
|
||||
script:
|
||||
- sudo apt-get install -qq -y cmake3
|
||||
- export CC="arm-linux-gnueabihf-gcc"
|
||||
- export CXX="arm-linux-gnueabihf-g++"
|
||||
- mkdir cmake-build && cd cmake-build && cmake -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_TESTS=ON .. && make -j2 && cd ..
|
||||
@ -88,6 +102,12 @@ matrix:
|
||||
# - sudo -E build/script/runtests.sh
|
||||
|
||||
# QA jobs for code analytics and metrics
|
||||
# build documentation and release
|
||||
- env: TEST_NAME="documentation & release"
|
||||
compiler: gcc
|
||||
script:
|
||||
- . env.sh && mkdoc all && mkrel all
|
||||
|
||||
# static code analysis with cppcheck (we can add --enable=all later)
|
||||
- env: TEST_NAME="cppcheck"
|
||||
script: cppcheck --force --quiet --inline-suppr -j2 -iData/SQLite/src/sqlite3.c .
|
||||
|
@ -77,6 +77,7 @@ option(ENABLE_CPPPARSER "Enable C++ parser" OFF)
|
||||
option(ENABLE_POCODOC "Enable Poco Documentation Generator" OFF)
|
||||
option(ENABLE_PAGECOMPILER "Enable PageCompiler" ON)
|
||||
option(ENABLE_PAGECOMPILER_FILE2PAGE "Enable File2Page" ON)
|
||||
option(ENABLE_REDIS "Enable Redis" ON)
|
||||
|
||||
option(FORCE_OPENSSL "Force usage of OpenSSL even under windows" OFF)
|
||||
|
||||
@ -192,6 +193,10 @@ if(ENABLE_ZIP)
|
||||
add_subdirectory(Zip)
|
||||
list(APPEND Poco_COMPONENTS "Zip")
|
||||
endif()
|
||||
if(ENABLE_REDIS)
|
||||
add_subdirectory(Redis)
|
||||
list(APPEND Poco_COMPONENTS "Redis")
|
||||
endif()
|
||||
|
||||
find_package(APR)
|
||||
find_package(Apache2)
|
||||
|
@ -23,8 +23,12 @@ endif
|
||||
ifeq ($(LINKMODE),STATIC)
|
||||
LIBLINKEXT = .a
|
||||
else
|
||||
ifeq ($(OSNAME), Cygwin)
|
||||
LIBLINKEXT = $(IMPLIBLINKEXT)
|
||||
else
|
||||
LIBLINKEXT = $(SHAREDLIBLINKEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
INCLUDE += -I$(POCO_ODBC_INCLUDE)
|
||||
SYSLIBS += -L$(POCO_ODBC_LIB)
|
||||
|
@ -3569,6 +3569,9 @@ CppUnit::Test* SQLiteTest::suite()
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testTransactor);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testFTS3);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testJSONRowFormatter);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testIncrementVacuum);
|
||||
//
|
||||
// To be fixed by dimanikulin
|
||||
// CppUnit_addTest(pSuite, SQLiteTest, testIncrementVacuum);
|
||||
//
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -162,17 +162,17 @@ class BasicMemoryBinaryReader : public BinaryReader
|
||||
/// A convenient wrapper for using Buffer and MemoryStream with BinaryReader.
|
||||
{
|
||||
public:
|
||||
BasicMemoryBinaryReader(const Buffer<T>& data, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER):
|
||||
BinaryReader(_istr, byteOrder),
|
||||
_data(data),
|
||||
_istr(data.begin(), data.capacity())
|
||||
BasicMemoryBinaryReader(const Buffer<T>& dataBuffer, StreamByteOrder order = NATIVE_BYTE_ORDER):
|
||||
BinaryReader(_istr, order),
|
||||
_data(dataBuffer),
|
||||
_istr(dataBuffer.begin(), dataBuffer.capacity())
|
||||
{
|
||||
}
|
||||
|
||||
BasicMemoryBinaryReader(const Buffer<T>& data, TextEncoding& encoding, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER):
|
||||
BinaryReader(_istr, encoding, byteOrder),
|
||||
_data(data),
|
||||
_istr(data.begin(), data.capacity())
|
||||
BasicMemoryBinaryReader(const Buffer<T>& dataBuffer, TextEncoding& encoding, StreamByteOrder order = NATIVE_BYTE_ORDER):
|
||||
BinaryReader(_istr, encoding, order),
|
||||
_data(dataBuffer),
|
||||
_istr(dataBuffer.begin(), dataBuffer.capacity())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -57,10 +57,10 @@ public:
|
||||
LITTLE_ENDIAN_BYTE_ORDER = 3 /// little-endian byte-order
|
||||
};
|
||||
|
||||
BinaryWriter(std::ostream& ostr, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
||||
BinaryWriter(std::ostream& ostr, StreamByteOrder order = NATIVE_BYTE_ORDER);
|
||||
/// Creates the BinaryWriter.
|
||||
|
||||
BinaryWriter(std::ostream& ostr, TextEncoding& encoding, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
||||
BinaryWriter(std::ostream& ostr, TextEncoding& encoding, StreamByteOrder order = NATIVE_BYTE_ORDER);
|
||||
/// Creates the BinaryWriter using the given TextEncoding.
|
||||
///
|
||||
/// Strings will be converted from the currently set global encoding
|
||||
@ -171,17 +171,17 @@ class BasicMemoryBinaryWriter: public BinaryWriter
|
||||
/// A convenient wrapper for using Buffer and MemoryStream with BinarWriter.
|
||||
{
|
||||
public:
|
||||
BasicMemoryBinaryWriter(Buffer<T>& data, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER):
|
||||
BinaryWriter(_ostr, byteOrder),
|
||||
_data(data),
|
||||
_ostr(data.begin(), data.capacity())
|
||||
BasicMemoryBinaryWriter(Buffer<T>& dataBuffer, StreamByteOrder order = NATIVE_BYTE_ORDER):
|
||||
BinaryWriter(_ostr, order),
|
||||
_data(dataBuffer),
|
||||
_ostr(dataBuffer.begin(), dataBuffer.capacity())
|
||||
{
|
||||
}
|
||||
|
||||
BasicMemoryBinaryWriter(Buffer<T>& data, TextEncoding& encoding, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER):
|
||||
BinaryWriter(_ostr, encoding, byteOrder),
|
||||
_data(data),
|
||||
_ostr(data.begin(), data.capacity())
|
||||
BasicMemoryBinaryWriter(Buffer<T>& dataBuffer, TextEncoding& encoding, StreamByteOrder order = NATIVE_BYTE_ORDER):
|
||||
BinaryWriter(_ostr, encoding, order),
|
||||
_data(dataBuffer),
|
||||
_ostr(dataBuffer.begin(), dataBuffer.capacity())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -38,16 +38,16 @@ class Buffer
|
||||
/// is needed.
|
||||
{
|
||||
public:
|
||||
Buffer(std::size_t capacity):
|
||||
_capacity(capacity),
|
||||
_used(capacity),
|
||||
Buffer(std::size_t length):
|
||||
_capacity(length),
|
||||
_used(length),
|
||||
_ptr(0),
|
||||
_ownMem(true)
|
||||
/// Creates and allocates the Buffer.
|
||||
{
|
||||
if (capacity > 0)
|
||||
if (length > 0)
|
||||
{
|
||||
_ptr = new T[capacity];
|
||||
_ptr = new T[length];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,8 @@ public:
|
||||
typedef typename std::map<K, T>::const_iterator MapConstIterator;
|
||||
|
||||
MapConstIterator it = val.begin();
|
||||
MapConstIterator end = val.end();
|
||||
for (; it != end; ++it) _data.insert(ValueType(it->first, Var(it->second)));
|
||||
MapConstIterator itEnd = val.end();
|
||||
for (; it != itEnd; ++it) _data.insert(ValueType(it->first, Var(it->second)));
|
||||
}
|
||||
|
||||
virtual ~Struct()
|
||||
|
@ -160,16 +160,16 @@ inline int Exception::code() const
|
||||
POCO_DECLARE_EXCEPTION_CODE(API, CLS, BASE, 0)
|
||||
|
||||
#define POCO_IMPLEMENT_EXCEPTION(CLS, BASE, NAME) \
|
||||
CLS::CLS(int code): BASE(code) \
|
||||
CLS::CLS(int otherCode): BASE(otherCode) \
|
||||
{ \
|
||||
} \
|
||||
CLS::CLS(const std::string& msg, int code): BASE(msg, code) \
|
||||
CLS::CLS(const std::string& msg, int otherCode): BASE(msg, otherCode) \
|
||||
{ \
|
||||
} \
|
||||
CLS::CLS(const std::string& msg, const std::string& arg, int code): BASE(msg, arg, code) \
|
||||
CLS::CLS(const std::string& msg, const std::string& arg, int otherCode): BASE(msg, arg, otherCode) \
|
||||
{ \
|
||||
} \
|
||||
CLS::CLS(const std::string& msg, const Poco::Exception& exc, int code): BASE(msg, exc, code) \
|
||||
CLS::CLS(const std::string& msg, const Poco::Exception& exc, int otherCode): BASE(msg, exc, otherCode) \
|
||||
{ \
|
||||
} \
|
||||
CLS::CLS(const CLS& exc): BASE(exc) \
|
||||
|
@ -77,33 +77,33 @@ public:
|
||||
/// Readable event observers are notified, with true value
|
||||
/// as the argument
|
||||
|
||||
BasicFIFOBuffer(std::size_t size, bool notify = false):
|
||||
_buffer(size),
|
||||
BasicFIFOBuffer(std::size_t bufferSize, bool bufferNotify = false):
|
||||
_buffer(bufferSize),
|
||||
_begin(0),
|
||||
_used(0),
|
||||
_notify(notify),
|
||||
_notify(bufferNotify),
|
||||
_eof(false),
|
||||
_error(false)
|
||||
/// Creates the FIFOBuffer.
|
||||
{
|
||||
}
|
||||
|
||||
BasicFIFOBuffer(T* pBuffer, std::size_t size, bool notify = false):
|
||||
_buffer(pBuffer, size),
|
||||
BasicFIFOBuffer(T* pBuffer, std::size_t bufferSize, bool bufferNotify = false):
|
||||
_buffer(pBuffer, bufferSize),
|
||||
_begin(0),
|
||||
_used(0),
|
||||
_notify(notify),
|
||||
_notify(bufferNotify),
|
||||
_eof(false),
|
||||
_error(false)
|
||||
/// Creates the FIFOBuffer.
|
||||
{
|
||||
}
|
||||
|
||||
BasicFIFOBuffer(const T* pBuffer, std::size_t size, bool notify = false):
|
||||
_buffer(pBuffer, size),
|
||||
BasicFIFOBuffer(const T* pBuffer, std::size_t bufferSize, bool bufferNotify = false):
|
||||
_buffer(pBuffer, bufferSize),
|
||||
_begin(0),
|
||||
_used(size),
|
||||
_notify(notify),
|
||||
_used(bufferSize),
|
||||
_notify(bufferNotify),
|
||||
_eof(false),
|
||||
_error(false)
|
||||
/// Creates the FIFOBuffer.
|
||||
@ -154,7 +154,7 @@ public:
|
||||
return length;
|
||||
}
|
||||
|
||||
std::size_t peek(Poco::Buffer<T>& buffer, std::size_t length = 0) const
|
||||
std::size_t peek(Poco::Buffer<T>& rBuffer, std::size_t length = 0) const
|
||||
/// Peeks into the data currently in the FIFO
|
||||
/// without actually extracting it.
|
||||
/// Resizes the supplied buffer to the size of
|
||||
@ -169,8 +169,8 @@ public:
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (!isReadable()) return 0;
|
||||
if (0 == length || length > _used) length = _used;
|
||||
buffer.resize(length);
|
||||
return peek(buffer.begin(), length);
|
||||
rBuffer.resize(length);
|
||||
return peek(rBuffer.begin(), length);
|
||||
}
|
||||
|
||||
std::size_t read(T* pBuffer, std::size_t length)
|
||||
@ -196,7 +196,7 @@ public:
|
||||
return readLen;
|
||||
}
|
||||
|
||||
std::size_t read(Poco::Buffer<T>& buffer, std::size_t length = 0)
|
||||
std::size_t read(Poco::Buffer<T>& rBuffer, std::size_t length = 0)
|
||||
/// Copies the data currently in the FIFO
|
||||
/// into the supplied buffer.
|
||||
/// Resizes the supplied buffer to the size of
|
||||
@ -207,7 +207,7 @@ public:
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (!isReadable()) return 0;
|
||||
std::size_t usedBefore = _used;
|
||||
std::size_t readLen = peek(buffer, length);
|
||||
std::size_t readLen = peek(rBuffer, length);
|
||||
poco_assert (_used >= readLen);
|
||||
_used -= readLen;
|
||||
if (0 == _used) _begin = 0;
|
||||
@ -242,8 +242,8 @@ public:
|
||||
}
|
||||
|
||||
std::size_t usedBefore = _used;
|
||||
std::size_t available = _buffer.size() - _used - _begin;
|
||||
std::size_t len = length > available ? available : length;
|
||||
std::size_t availableBefore = _buffer.size() - _used - _begin;
|
||||
std::size_t len = length > availableBefore ? availableBefore : length;
|
||||
std::memcpy(begin() + _used, pBuffer, len * sizeof(T));
|
||||
_used += len;
|
||||
poco_assert (_used <= _buffer.size());
|
||||
@ -252,7 +252,7 @@ public:
|
||||
return len;
|
||||
}
|
||||
|
||||
std::size_t write(const Buffer<T>& buffer, std::size_t length = 0)
|
||||
std::size_t write(const Buffer<T>& rBuffer, std::size_t length = 0)
|
||||
/// Writes data from supplied buffer to the FIFO buffer.
|
||||
/// If there is no sufficient space for the whole
|
||||
/// buffer to be written, data up to available
|
||||
@ -263,10 +263,10 @@ public:
|
||||
///
|
||||
/// Returns the length of data written.
|
||||
{
|
||||
if (length == 0 || length > buffer.size())
|
||||
length = buffer.size();
|
||||
if (length == 0 || length > rBuffer.size())
|
||||
length = rBuffer.size();
|
||||
|
||||
return write(buffer.begin(), length);
|
||||
return write(rBuffer.begin(), length);
|
||||
}
|
||||
|
||||
std::size_t size() const
|
||||
@ -499,10 +499,10 @@ public:
|
||||
return !isFull() && isValid() && !_eof;
|
||||
}
|
||||
|
||||
void setNotify(bool notify = true)
|
||||
void setNotify(bool bufferNotify = true)
|
||||
/// Enables/disables notifications.
|
||||
{
|
||||
_notify = notify;
|
||||
_notify = bufferNotify;
|
||||
}
|
||||
|
||||
bool getNotify() const
|
||||
|
@ -118,12 +118,12 @@ public:
|
||||
clear();
|
||||
}
|
||||
|
||||
Iterator find(const std::string& className) const
|
||||
Iterator find(const std::string& rClassName) const
|
||||
/// Returns an iterator pointing to the MetaObject
|
||||
/// for the given class. If the MetaObject cannot
|
||||
/// be found, the iterator points to end().
|
||||
{
|
||||
return Iterator(_metaMap.find(className));
|
||||
return Iterator(_metaMap.find(rClassName));
|
||||
}
|
||||
|
||||
Iterator begin() const
|
||||
|
@ -40,7 +40,7 @@ class AbstractMetaObject
|
||||
/// factory for its class.
|
||||
{
|
||||
public:
|
||||
AbstractMetaObject(const char* name): _name(name)
|
||||
AbstractMetaObject(const char* pName): _name(pName)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -28,17 +28,19 @@
|
||||
#include <map>
|
||||
|
||||
|
||||
#ifdef POCO_UNBUNDLED
|
||||
#include <pcre.h>
|
||||
#else
|
||||
//
|
||||
// Copy these definitions from pcre.h
|
||||
// to avoid pulling in the entire header file
|
||||
//
|
||||
extern "C"
|
||||
{
|
||||
struct real_pcre8_or_16; /* declaration; the definition is private */
|
||||
typedef struct real_pcre8_or_16 pcre;
|
||||
struct pcre_extra;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
@ -126,9 +126,9 @@ class TaskCustomNotification: public TaskNotification
|
||||
/// mechanism between the task and its observer(s).
|
||||
{
|
||||
public:
|
||||
TaskCustomNotification(Task* pTask, const C& custom):
|
||||
TaskCustomNotification(Task* pTask, const C& rCustom):
|
||||
TaskNotification(pTask),
|
||||
_custom(custom)
|
||||
_custom(rCustom)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -136,9 +136,9 @@ AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter)
|
||||
}
|
||||
|
||||
|
||||
AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value)
|
||||
AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType valueType)
|
||||
{
|
||||
__sync_lock_test_and_set(&_counter, value);
|
||||
__sync_lock_test_and_set(&_counter, valueType);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -24,26 +24,26 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
BinaryReader::BinaryReader(std::istream& istr, StreamByteOrder byteOrder):
|
||||
BinaryReader::BinaryReader(std::istream& istr, StreamByteOrder order):
|
||||
_istr(istr),
|
||||
_pTextConverter(0)
|
||||
{
|
||||
#if defined(POCO_ARCH_BIG_ENDIAN)
|
||||
_flipBytes = (byteOrder == LITTLE_ENDIAN_BYTE_ORDER);
|
||||
_flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
|
||||
#else
|
||||
_flipBytes = (byteOrder == BIG_ENDIAN_BYTE_ORDER);
|
||||
_flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
BinaryReader::BinaryReader(std::istream& istr, TextEncoding& encoding, StreamByteOrder byteOrder):
|
||||
BinaryReader::BinaryReader(std::istream& istr, TextEncoding& encoding, StreamByteOrder order):
|
||||
_istr(istr),
|
||||
_pTextConverter(new TextConverter(encoding, Poco::TextEncoding::global()))
|
||||
{
|
||||
#if defined(POCO_ARCH_BIG_ENDIAN)
|
||||
_flipBytes = (byteOrder == LITTLE_ENDIAN_BYTE_ORDER);
|
||||
_flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
|
||||
#else
|
||||
_flipBytes = (byteOrder == BIG_ENDIAN_BYTE_ORDER);
|
||||
_flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -24,26 +24,26 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
BinaryWriter::BinaryWriter(std::ostream& ostr, StreamByteOrder byteOrder):
|
||||
BinaryWriter::BinaryWriter(std::ostream& ostr, StreamByteOrder order):
|
||||
_ostr(ostr),
|
||||
_pTextConverter(0)
|
||||
{
|
||||
#if defined(POCO_ARCH_BIG_ENDIAN)
|
||||
_flipBytes = (byteOrder == LITTLE_ENDIAN_BYTE_ORDER);
|
||||
_flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
|
||||
#else
|
||||
_flipBytes = (byteOrder == BIG_ENDIAN_BYTE_ORDER);
|
||||
_flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
BinaryWriter::BinaryWriter(std::ostream& ostr, TextEncoding& encoding, StreamByteOrder byteOrder):
|
||||
BinaryWriter::BinaryWriter(std::ostream& ostr, TextEncoding& encoding, StreamByteOrder order):
|
||||
_ostr(ostr),
|
||||
_pTextConverter(new TextConverter(Poco::TextEncoding::global(), encoding))
|
||||
{
|
||||
#if defined(POCO_ARCH_BIG_ENDIAN)
|
||||
_flipBytes = (byteOrder == LITTLE_ENDIAN_BYTE_ORDER);
|
||||
_flipBytes = (order == LITTLE_ENDIAN_BYTE_ORDER);
|
||||
#else
|
||||
_flipBytes = (byteOrder == BIG_ENDIAN_BYTE_ORDER);
|
||||
_flipBytes = (order == BIG_ENDIAN_BYTE_ORDER);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -96,21 +96,21 @@ void CountingStreamBuf::setCurrentLineNumber(int line)
|
||||
}
|
||||
|
||||
|
||||
void CountingStreamBuf::addChars(int chars)
|
||||
void CountingStreamBuf::addChars(int charsToAdd)
|
||||
{
|
||||
_chars += chars;
|
||||
_chars += charsToAdd;
|
||||
}
|
||||
|
||||
|
||||
void CountingStreamBuf::addLines(int lines)
|
||||
void CountingStreamBuf::addLines(int linesToAdd)
|
||||
{
|
||||
_lines += lines;
|
||||
_lines += linesToAdd;
|
||||
}
|
||||
|
||||
|
||||
void CountingStreamBuf::addPos(int pos)
|
||||
void CountingStreamBuf::addPos(int posToAdd)
|
||||
{
|
||||
_pos += pos;
|
||||
_pos += posToAdd;
|
||||
}
|
||||
|
||||
|
||||
@ -149,21 +149,21 @@ void CountingIOS::setCurrentLineNumber(int line)
|
||||
}
|
||||
|
||||
|
||||
void CountingIOS::addChars(int chars)
|
||||
void CountingIOS::addChars(int charsToAdd)
|
||||
{
|
||||
_buf.addChars(chars);
|
||||
_buf.addChars(charsToAdd);
|
||||
}
|
||||
|
||||
|
||||
void CountingIOS::addLines(int lines)
|
||||
void CountingIOS::addLines(int linesToAdd)
|
||||
{
|
||||
_buf.addLines(lines);
|
||||
_buf.addLines(linesToAdd);
|
||||
}
|
||||
|
||||
|
||||
void CountingIOS::addPos(int pos)
|
||||
void CountingIOS::addPos(int posToAdd)
|
||||
{
|
||||
_buf.addPos(pos);
|
||||
_buf.addPos(posToAdd);
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,46 +45,46 @@ DateTime::DateTime()
|
||||
}
|
||||
|
||||
|
||||
DateTime::DateTime(const Timestamp& timestamp):
|
||||
_utcTime(timestamp.utcTime())
|
||||
DateTime::DateTime(const Timestamp& rTimestamp):
|
||||
_utcTime(rTimestamp.utcTime())
|
||||
{
|
||||
computeGregorian(julianDay());
|
||||
computeDaytime();
|
||||
}
|
||||
|
||||
|
||||
DateTime::DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond):
|
||||
_year(year),
|
||||
_month(month),
|
||||
_day(day),
|
||||
_hour(hour),
|
||||
_minute(minute),
|
||||
_second(second),
|
||||
_millisecond(millisecond),
|
||||
_microsecond(microsecond)
|
||||
DateTime::DateTime(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
|
||||
_year(otherYear),
|
||||
_month(otherMonth),
|
||||
_day(otherDay),
|
||||
_hour(otherHour),
|
||||
_minute(otherMinute),
|
||||
_second(otherSecond),
|
||||
_millisecond(otherMillisecond),
|
||||
_microsecond(otherMicrosecond)
|
||||
{
|
||||
poco_assert (year >= 0 && year <= 9999);
|
||||
poco_assert (month >= 1 && month <= 12);
|
||||
poco_assert (day >= 1 && day <= daysOfMonth(year, month));
|
||||
poco_assert (hour >= 0 && hour <= 23);
|
||||
poco_assert (minute >= 0 && minute <= 59);
|
||||
poco_assert (second >= 0 && second <= 59);
|
||||
poco_assert (millisecond >= 0 && millisecond <= 999);
|
||||
poco_assert (microsecond >= 0 && microsecond <= 999);
|
||||
poco_assert (_year >= 0 && _year <= 9999);
|
||||
poco_assert (_month >= 1 && _month <= 12);
|
||||
poco_assert (_day >= 1 && _day <= daysOfMonth(_year, _month));
|
||||
poco_assert (_hour >= 0 && _hour <= 23);
|
||||
poco_assert (_minute >= 0 && _minute <= 59);
|
||||
poco_assert (_second >= 0 && _second <= 59);
|
||||
poco_assert (_millisecond >= 0 && _millisecond <= 999);
|
||||
poco_assert (_microsecond >= 0 && _microsecond <= 999);
|
||||
|
||||
_utcTime = toUtcTime(toJulianDay(year, month, day)) + 10*(hour*Timespan::HOURS + minute*Timespan::MINUTES + second*Timespan::SECONDS + millisecond*Timespan::MILLISECONDS + microsecond);
|
||||
_utcTime = toUtcTime(toJulianDay(_year, _month, _day)) + 10*(_hour*Timespan::HOURS + _minute*Timespan::MINUTES + _second*Timespan::SECONDS + _millisecond*Timespan::MILLISECONDS + _microsecond);
|
||||
}
|
||||
|
||||
|
||||
DateTime::DateTime(double julianDay):
|
||||
_utcTime(toUtcTime(julianDay))
|
||||
DateTime::DateTime(double otherJulianDay):
|
||||
_utcTime(toUtcTime(otherJulianDay))
|
||||
{
|
||||
computeGregorian(julianDay);
|
||||
computeGregorian(otherJulianDay);
|
||||
}
|
||||
|
||||
|
||||
DateTime::DateTime(Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff):
|
||||
_utcTime(utcTime + diff*10)
|
||||
DateTime::DateTime(Timestamp::UtcTimeVal otherUtcTime, Timestamp::TimeDiff diff):
|
||||
_utcTime(otherUtcTime + diff*10)
|
||||
{
|
||||
computeGregorian(julianDay());
|
||||
computeDaytime();
|
||||
@ -128,43 +128,43 @@ DateTime& DateTime::operator = (const DateTime& dateTime)
|
||||
}
|
||||
|
||||
|
||||
DateTime& DateTime::operator = (const Timestamp& timestamp)
|
||||
DateTime& DateTime::operator = (const Timestamp& otherTimestamp)
|
||||
{
|
||||
_utcTime = timestamp.utcTime();
|
||||
_utcTime = otherTimestamp.utcTime();
|
||||
computeGregorian(julianDay());
|
||||
computeDaytime();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DateTime& DateTime::operator = (double julianDay)
|
||||
DateTime& DateTime::operator = (double otherJulianDay)
|
||||
{
|
||||
_utcTime = toUtcTime(julianDay);
|
||||
computeGregorian(julianDay);
|
||||
_utcTime = toUtcTime(otherJulianDay);
|
||||
computeGregorian(otherJulianDay);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DateTime& DateTime::assign(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond)
|
||||
DateTime& DateTime::assign(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond)
|
||||
{
|
||||
poco_assert (year >= 0 && year <= 9999);
|
||||
poco_assert (month >= 1 && month <= 12);
|
||||
poco_assert (day >= 1 && day <= daysOfMonth(year, month));
|
||||
poco_assert (hour >= 0 && hour <= 23);
|
||||
poco_assert (minute >= 0 && minute <= 59);
|
||||
poco_assert (second >= 0 && second <= 59);
|
||||
poco_assert (millisecond >= 0 && millisecond <= 999);
|
||||
poco_assert (microsecond >= 0 && microsecond <= 999);
|
||||
poco_assert (otherYear >= 0 && otherYear <= 9999);
|
||||
poco_assert (otherMonth >= 1 && otherMonth <= 12);
|
||||
poco_assert (otherDay >= 1 && otherDay <= daysOfMonth(otherYear, otherMonth));
|
||||
poco_assert (otherHour >= 0 && otherHour <= 23);
|
||||
poco_assert (otherMinute >= 0 && otherMinute <= 59);
|
||||
poco_assert (otherSecond >= 0 && otherSecond <= 59);
|
||||
poco_assert (otherMillisecond >= 0 && otherMillisecond <= 999);
|
||||
poco_assert (otherMicrosecond >= 0 && otherMicrosecond <= 999);
|
||||
|
||||
_utcTime = toUtcTime(toJulianDay(year, month, day)) + 10*(hour*Timespan::HOURS + minute*Timespan::MINUTES + second*Timespan::SECONDS + millisecond*Timespan::MILLISECONDS + microsecond);
|
||||
_year = year;
|
||||
_month = month;
|
||||
_day = day;
|
||||
_hour = hour;
|
||||
_minute = minute;
|
||||
_second = second;
|
||||
_millisecond = millisecond;
|
||||
_microsecond = microsecond;
|
||||
_utcTime = toUtcTime(toJulianDay(otherYear, otherMonth, otherDay)) + 10*(otherHour*Timespan::HOURS + otherMinute*Timespan::MINUTES + otherSecond*Timespan::SECONDS + otherMillisecond*Timespan::MILLISECONDS + otherMicrosecond);
|
||||
_year = otherYear;
|
||||
_month = otherMonth;
|
||||
_day = otherDay;
|
||||
_hour = otherHour;
|
||||
_minute = otherMinute;
|
||||
_second = otherSecond;
|
||||
_millisecond = otherMillisecond;
|
||||
_microsecond = otherMicrosecond;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -193,8 +193,8 @@ int DateTime::dayOfWeek() const
|
||||
int DateTime::dayOfYear() const
|
||||
{
|
||||
int doy = 0;
|
||||
for (int month = 1; month < _month; ++month)
|
||||
doy += daysOfMonth(_year, month);
|
||||
for (int currentMonth = 1; currentMonth < _month; ++currentMonth)
|
||||
doy += daysOfMonth(_year, currentMonth);
|
||||
doy += _day;
|
||||
return doy;
|
||||
}
|
||||
@ -345,10 +345,10 @@ void DateTime::normalize()
|
||||
}
|
||||
|
||||
|
||||
void DateTime::computeGregorian(double julianDay)
|
||||
void DateTime::computeGregorian(double otherJulianDay)
|
||||
{
|
||||
double z = std::floor(julianDay - 1721118.5);
|
||||
double r = julianDay - 1721118.5 - z;
|
||||
double z = std::floor(otherJulianDay - 1721118.5);
|
||||
double r = otherJulianDay - 1721118.5 - z;
|
||||
double g = z - 0.25;
|
||||
double a = std::floor(g / 36524.25);
|
||||
double b = a - std::floor(a/4);
|
||||
@ -392,10 +392,10 @@ void DateTime::computeGregorian(double julianDay)
|
||||
void DateTime::computeDaytime()
|
||||
{
|
||||
Timespan span(_utcTime/10);
|
||||
int hour = span.hours();
|
||||
int spanHour = span.hours();
|
||||
// Due to double rounding issues, the previous call to computeGregorian()
|
||||
// may have crossed into the next or previous day. We need to correct that.
|
||||
if (hour == 23 && _hour == 0)
|
||||
if (spanHour == 23 && _hour == 0)
|
||||
{
|
||||
_day--;
|
||||
if (_day == 0)
|
||||
@ -409,7 +409,7 @@ void DateTime::computeDaytime()
|
||||
_day = daysOfMonth(_year, _month);
|
||||
}
|
||||
}
|
||||
else if (hour == 0 && _hour == 23)
|
||||
else if (spanHour == 0 && _hour == 23)
|
||||
{
|
||||
_day++;
|
||||
if (_day > daysOfMonth(_year, _month))
|
||||
@ -423,7 +423,7 @@ void DateTime::computeDaytime()
|
||||
_day = 1;
|
||||
}
|
||||
}
|
||||
_hour = hour;
|
||||
_hour = spanHour;
|
||||
_minute = span.minutes();
|
||||
_second = span.seconds();
|
||||
_millisecond = span.milliseconds();
|
||||
|
@ -36,7 +36,7 @@ DirectoryIterator::DirectoryIterator(): _pImpl(0)
|
||||
}
|
||||
|
||||
|
||||
DirectoryIterator::DirectoryIterator(const std::string& path): _path(path), _pImpl(new DirectoryIteratorImpl(path))
|
||||
DirectoryIterator::DirectoryIterator(const std::string& pathString): _path(pathString), _pImpl(new DirectoryIteratorImpl(pathString))
|
||||
{
|
||||
_path.makeDirectory();
|
||||
_path.setFileName(_pImpl->get());
|
||||
@ -62,7 +62,7 @@ DirectoryIterator::DirectoryIterator(const File& file): _path(file.path()), _pIm
|
||||
}
|
||||
|
||||
|
||||
DirectoryIterator::DirectoryIterator(const Path& path): _path(path), _pImpl(new DirectoryIteratorImpl(path.toString()))
|
||||
DirectoryIterator::DirectoryIterator(const Path& otherPath): _path(otherPath), _pImpl(new DirectoryIteratorImpl(otherPath.toString()))
|
||||
{
|
||||
_path.makeDirectory();
|
||||
_path.setFileName(_pImpl->get());
|
||||
@ -101,11 +101,11 @@ DirectoryIterator& DirectoryIterator::operator = (const File& file)
|
||||
}
|
||||
|
||||
|
||||
DirectoryIterator& DirectoryIterator::operator = (const Path& path)
|
||||
DirectoryIterator& DirectoryIterator::operator = (const Path& otherPath)
|
||||
{
|
||||
if (_pImpl) _pImpl->release();
|
||||
_pImpl = new DirectoryIteratorImpl(path.toString());
|
||||
_path = path;
|
||||
_pImpl = new DirectoryIteratorImpl(otherPath.toString());
|
||||
_path = otherPath;
|
||||
_path.makeDirectory();
|
||||
_path.setFileName(_pImpl->get());
|
||||
_file = _path;
|
||||
@ -113,11 +113,11 @@ DirectoryIterator& DirectoryIterator::operator = (const Path& path)
|
||||
}
|
||||
|
||||
|
||||
DirectoryIterator& DirectoryIterator::operator = (const std::string& path)
|
||||
DirectoryIterator& DirectoryIterator::operator = (const std::string& pathString)
|
||||
{
|
||||
if (_pImpl) _pImpl->release();
|
||||
_pImpl = new DirectoryIteratorImpl(path);
|
||||
_path.parseDirectory(path);
|
||||
_pImpl = new DirectoryIteratorImpl(pathString);
|
||||
_path.parseDirectory(pathString);
|
||||
_path.setFileName(_pImpl->get());
|
||||
_file = _path;
|
||||
return *this;
|
||||
|
@ -53,8 +53,8 @@ namespace Poco {
|
||||
class DirectoryWatcherStrategy
|
||||
{
|
||||
public:
|
||||
DirectoryWatcherStrategy(DirectoryWatcher& owner):
|
||||
_owner(owner)
|
||||
DirectoryWatcherStrategy(DirectoryWatcher& ownerWatcher):
|
||||
_owner(ownerWatcher)
|
||||
{
|
||||
}
|
||||
|
||||
@ -263,8 +263,8 @@ private:
|
||||
class LinuxDirectoryWatcherStrategy: public DirectoryWatcherStrategy
|
||||
{
|
||||
public:
|
||||
LinuxDirectoryWatcherStrategy(DirectoryWatcher& owner):
|
||||
DirectoryWatcherStrategy(owner),
|
||||
LinuxDirectoryWatcherStrategy(DirectoryWatcher& ownerWatcher):
|
||||
DirectoryWatcherStrategy(ownerWatcher),
|
||||
_fd(-1),
|
||||
_stopped(false)
|
||||
{
|
||||
@ -474,8 +474,8 @@ private:
|
||||
class PollingDirectoryWatcherStrategy: public DirectoryWatcherStrategy
|
||||
{
|
||||
public:
|
||||
PollingDirectoryWatcherStrategy(DirectoryWatcher& owner):
|
||||
DirectoryWatcherStrategy(owner)
|
||||
PollingDirectoryWatcherStrategy(DirectoryWatcher& ownerWatcher):
|
||||
DirectoryWatcherStrategy(ownerWatcher)
|
||||
{
|
||||
}
|
||||
|
||||
@ -519,22 +519,22 @@ private:
|
||||
|
||||
|
||||
|
||||
DirectoryWatcher::DirectoryWatcher(const std::string& path, int eventMask, int scanInterval,
|
||||
DirectoryWatcher::DirectoryWatcher(const std::string& path, int otherEventMask, int otherScanInterval,
|
||||
bool forceScan) :
|
||||
_directory(path),
|
||||
_eventMask(eventMask),
|
||||
_scanInterval(scanInterval),
|
||||
_eventMask(otherEventMask),
|
||||
_scanInterval(otherScanInterval),
|
||||
_forceScan(forceScan)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
DirectoryWatcher::DirectoryWatcher(const Poco::File& directory, int eventMask, int scanInterval,
|
||||
DirectoryWatcher::DirectoryWatcher(const Poco::File& otherDirectory, int otherEventMask, int otherScanInterval,
|
||||
bool forceScan) :
|
||||
_directory(directory),
|
||||
_eventMask(eventMask),
|
||||
_scanInterval(scanInterval),
|
||||
_directory(otherDirectory),
|
||||
_eventMask(otherEventMask),
|
||||
_scanInterval(otherScanInterval),
|
||||
_forceScan(forceScan)
|
||||
{
|
||||
init();
|
||||
|
@ -21,17 +21,17 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
Exception::Exception(int code): _pNested(0), _code(code)
|
||||
Exception::Exception(int otherCode): _pNested(0), _code(otherCode)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Exception::Exception(const std::string& msg, int code): _msg(msg), _pNested(0), _code(code)
|
||||
Exception::Exception(const std::string& msg, int otherCode): _msg(msg), _pNested(0), _code(otherCode)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Exception::Exception(const std::string& msg, const std::string& arg, int code): _msg(msg), _pNested(0), _code(code)
|
||||
Exception::Exception(const std::string& msg, const std::string& arg, int otherCode): _msg(msg), _pNested(0), _code(otherCode)
|
||||
{
|
||||
if (!arg.empty())
|
||||
{
|
||||
@ -41,7 +41,7 @@ Exception::Exception(const std::string& msg, const std::string& arg, int code):
|
||||
}
|
||||
|
||||
|
||||
Exception::Exception(const std::string& msg, const Exception& nested, int code): _msg(msg), _pNested(nested.clone()), _code(code)
|
||||
Exception::Exception(const std::string& msg, const Exception& nestedException, int otherCode): _msg(msg), _pNested(nestedException.clone()), _code(otherCode)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,12 @@ FIFOBufferStreamBuf::FIFOBufferStreamBuf():
|
||||
}
|
||||
|
||||
|
||||
FIFOBufferStreamBuf::FIFOBufferStreamBuf(FIFOBuffer& fifoBuffer):
|
||||
BufferedBidirectionalStreamBuf(fifoBuffer.size() + 4, std::ios::in | std::ios::out),
|
||||
FIFOBufferStreamBuf::FIFOBufferStreamBuf(FIFOBuffer& rFifoBuffer):
|
||||
BufferedBidirectionalStreamBuf(rFifoBuffer.size() + 4, std::ios::in | std::ios::out),
|
||||
_pFIFOBuffer(0),
|
||||
_fifoBuffer(fifoBuffer)
|
||||
_fifoBuffer(rFifoBuffer)
|
||||
{
|
||||
fifoBuffer.setNotify(true);
|
||||
rFifoBuffer.setNotify(true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,17 +44,17 @@ File::File()
|
||||
}
|
||||
|
||||
|
||||
File::File(const std::string& path): FileImpl(path)
|
||||
File::File(const std::string& rPath): FileImpl(rPath)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
File::File(const char* path): FileImpl(std::string(path))
|
||||
File::File(const char* pPath): FileImpl(std::string(pPath))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
File::File(const Path& path): FileImpl(path.toString())
|
||||
File::File(const Path& rPath): FileImpl(rPath.toString())
|
||||
{
|
||||
}
|
||||
|
||||
@ -76,24 +76,24 @@ File& File::operator = (const File& file)
|
||||
}
|
||||
|
||||
|
||||
File& File::operator = (const std::string& path)
|
||||
File& File::operator = (const std::string& rPath)
|
||||
{
|
||||
setPathImpl(path);
|
||||
setPathImpl(rPath);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
File& File::operator = (const char* path)
|
||||
File& File::operator = (const char* pPath)
|
||||
{
|
||||
poco_check_ptr (path);
|
||||
setPathImpl(path);
|
||||
poco_check_ptr (pPath);
|
||||
setPathImpl(pPath);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
File& File::operator = (const Path& path)
|
||||
File& File::operator = (const Path& rPath)
|
||||
{
|
||||
setPathImpl(path.toString());
|
||||
setPathImpl(rPath.toString());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -211,11 +211,11 @@ File& File::setExecutable(bool flag)
|
||||
}
|
||||
|
||||
|
||||
void File::copyTo(const std::string& path) const
|
||||
void File::copyTo(const std::string& rPath) const
|
||||
{
|
||||
Path src(getPathImpl());
|
||||
Path dest(path);
|
||||
File destFile(path);
|
||||
Path dest(rPath);
|
||||
File destFile(rPath);
|
||||
if ((destFile.exists() && destFile.isDirectory()) || dest.isDirectory())
|
||||
{
|
||||
dest.makeDirectory();
|
||||
@ -228,9 +228,9 @@ void File::copyTo(const std::string& path) const
|
||||
}
|
||||
|
||||
|
||||
void File::copyDirectory(const std::string& path) const
|
||||
void File::copyDirectory(const std::string& rPath) const
|
||||
{
|
||||
File target(path);
|
||||
File target(rPath);
|
||||
target.createDirectories();
|
||||
|
||||
Path src(getPathImpl());
|
||||
@ -239,23 +239,23 @@ void File::copyDirectory(const std::string& path) const
|
||||
DirectoryIterator end;
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
it->copyTo(path);
|
||||
it->copyTo(rPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void File::moveTo(const std::string& path)
|
||||
void File::moveTo(const std::string& rPath)
|
||||
{
|
||||
copyTo(path);
|
||||
copyTo(rPath);
|
||||
remove(true);
|
||||
setPathImpl(path);
|
||||
setPathImpl(rPath);
|
||||
}
|
||||
|
||||
|
||||
void File::renameTo(const std::string& path)
|
||||
void File::renameTo(const std::string& rPath)
|
||||
{
|
||||
renameToImpl(path);
|
||||
setPathImpl(path);
|
||||
renameToImpl(rPath);
|
||||
setPathImpl(rPath);
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,8 +54,8 @@ FileChannel::FileChannel():
|
||||
}
|
||||
|
||||
|
||||
FileChannel::FileChannel(const std::string& path):
|
||||
_path(path),
|
||||
FileChannel::FileChannel(const std::string& rPath):
|
||||
_path(rPath),
|
||||
_times("utc"),
|
||||
_compress(false),
|
||||
_flush(true),
|
||||
|
@ -34,30 +34,30 @@ LocalDateTime::LocalDateTime()
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime::LocalDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond):
|
||||
_dateTime(year, month, day, hour, minute, second, millisecond, microsecond)
|
||||
LocalDateTime::LocalDateTime(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
|
||||
_dateTime(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicrosecond)
|
||||
{
|
||||
determineTzd();
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime::LocalDateTime(int tzd, int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond):
|
||||
_dateTime(year, month, day, hour, minute, second, millisecond, microsecond),
|
||||
_tzd(tzd)
|
||||
LocalDateTime::LocalDateTime(int otherTzd, int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicrosecond):
|
||||
_dateTime(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicrosecond),
|
||||
_tzd(otherTzd)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime::LocalDateTime(double julianDay):
|
||||
_dateTime(julianDay)
|
||||
LocalDateTime::LocalDateTime(double otherJulianDay):
|
||||
_dateTime(otherJulianDay)
|
||||
{
|
||||
determineTzd(true);
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime::LocalDateTime(int tzd, double julianDay):
|
||||
_dateTime(julianDay),
|
||||
_tzd(tzd)
|
||||
LocalDateTime::LocalDateTime(int otherTzd, double otherJulianDay):
|
||||
_dateTime(otherJulianDay),
|
||||
_tzd(otherTzd)
|
||||
{
|
||||
adjustForTzd();
|
||||
}
|
||||
@ -70,17 +70,17 @@ LocalDateTime::LocalDateTime(const DateTime& dateTime):
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime::LocalDateTime(int tzd, const DateTime& dateTime):
|
||||
_dateTime(dateTime),
|
||||
_tzd(tzd)
|
||||
LocalDateTime::LocalDateTime(int otherTzd, const DateTime& otherDateTime):
|
||||
_dateTime(otherDateTime),
|
||||
_tzd(otherTzd)
|
||||
{
|
||||
adjustForTzd();
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime::LocalDateTime(int tzd, const DateTime& dateTime, bool adjust):
|
||||
_dateTime(dateTime),
|
||||
_tzd(tzd)
|
||||
LocalDateTime::LocalDateTime(int otherTzd, const DateTime& otherDateTime, bool adjust):
|
||||
_dateTime(otherDateTime),
|
||||
_tzd(otherTzd)
|
||||
{
|
||||
if (adjust)
|
||||
adjustForTzd();
|
||||
@ -94,9 +94,9 @@ LocalDateTime::LocalDateTime(const LocalDateTime& dateTime):
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime::LocalDateTime(Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff, int tzd):
|
||||
_dateTime(utcTime, diff),
|
||||
_tzd(tzd)
|
||||
LocalDateTime::LocalDateTime(Timestamp::UtcTimeVal utcTimeVal, Timestamp::TimeDiff diff, int otherTzd):
|
||||
_dateTime(utcTimeVal, diff),
|
||||
_tzd(otherTzd)
|
||||
{
|
||||
adjustForTzd();
|
||||
}
|
||||
@ -118,45 +118,45 @@ LocalDateTime& LocalDateTime::operator = (const LocalDateTime& dateTime)
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime& LocalDateTime::operator = (const Timestamp& timestamp)
|
||||
LocalDateTime& LocalDateTime::operator = (const Timestamp& otherTimestamp)
|
||||
{
|
||||
if (timestamp != this->timestamp())
|
||||
if (otherTimestamp != timestamp())
|
||||
{
|
||||
_dateTime = timestamp;
|
||||
_dateTime = otherTimestamp;
|
||||
determineTzd(true);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime& LocalDateTime::operator = (double julianDay)
|
||||
LocalDateTime& LocalDateTime::operator = (double otherJulianDay)
|
||||
{
|
||||
_dateTime = julianDay;
|
||||
_dateTime = otherJulianDay;
|
||||
determineTzd(true);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime& LocalDateTime::assign(int year, int month, int day, int hour, int minute, int second, int millisecond, int microseconds)
|
||||
LocalDateTime& LocalDateTime::assign(int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicroseconds)
|
||||
{
|
||||
_dateTime.assign(year, month, day, hour, minute, second, millisecond, microseconds);
|
||||
_dateTime.assign(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicroseconds);
|
||||
determineTzd(false);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime& LocalDateTime::assign(int tzd, int year, int month, int day, int hour, int minute, int second, int millisecond, int microseconds)
|
||||
LocalDateTime& LocalDateTime::assign(int otherTzd, int otherYear, int otherMonth, int otherDay, int otherHour, int otherMinute, int otherSecond, int otherMillisecond, int otherMicroseconds)
|
||||
{
|
||||
_dateTime.assign(year, month, day, hour, minute, second, millisecond, microseconds);
|
||||
_tzd = tzd;
|
||||
_dateTime.assign(otherYear, otherMonth, otherDay, otherHour, otherMinute, otherSecond, otherMillisecond, otherMicroseconds);
|
||||
_tzd = otherTzd;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime& LocalDateTime::assign(int tzd, double julianDay)
|
||||
LocalDateTime& LocalDateTime::assign(int otherTzd, double otherJulianDay)
|
||||
{
|
||||
_tzd = tzd;
|
||||
_dateTime = julianDay;
|
||||
_tzd = otherTzd;
|
||||
_dateTime = otherJulianDay;
|
||||
adjustForTzd();
|
||||
return *this;
|
||||
}
|
||||
@ -292,7 +292,7 @@ void LocalDateTime::determineTzd(bool adjust)
|
||||
}
|
||||
|
||||
|
||||
std::time_t LocalDateTime::dstOffset(int& dstOffset) const
|
||||
std::time_t LocalDateTime::dstOffset(int& rDstOffset) const
|
||||
{
|
||||
std::time_t local;
|
||||
std::tm broken;
|
||||
@ -310,7 +310,7 @@ std::time_t LocalDateTime::dstOffset(int& dstOffset) const
|
||||
local = std::mktime(&broken);
|
||||
#endif
|
||||
|
||||
dstOffset = (broken.tm_isdst == 1) ? 3600 : 0;
|
||||
rDstOffset = (broken.tm_isdst == 1) ? 3600 : 0;
|
||||
return local;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
LogFile::LogFile(const std::string& path): LogFileImpl(path)
|
||||
LogFile::LogFile(const std::string& rPath): LogFileImpl(rPath)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace Poco {
|
||||
//
|
||||
|
||||
|
||||
LogStreamBuf::LogStreamBuf(Logger& logger, Message::Priority priority):
|
||||
_logger(logger),
|
||||
LogStreamBuf::LogStreamBuf(Logger& rLogger, Message::Priority priority):
|
||||
_logger(rLogger),
|
||||
_priority(priority)
|
||||
{
|
||||
}
|
||||
@ -87,15 +87,15 @@ LogStreamBuf* LogIOS::rdbuf()
|
||||
//
|
||||
|
||||
|
||||
LogStream::LogStream(Logger& logger, Message::Priority priority):
|
||||
LogIOS(logger, priority),
|
||||
LogStream::LogStream(Logger& logger, Message::Priority messagePriority):
|
||||
LogIOS(logger, messagePriority),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LogStream::LogStream(const std::string& loggerName, Message::Priority priority):
|
||||
LogIOS(Logger::get(loggerName), priority),
|
||||
LogStream::LogStream(const std::string& loggerName, Message::Priority messagePriority):
|
||||
LogIOS(Logger::get(loggerName), messagePriority),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
}
|
||||
@ -210,9 +210,9 @@ LogStream& LogStream::trace(const std::string& message)
|
||||
}
|
||||
|
||||
|
||||
LogStream& LogStream::priority(Message::Priority priority)
|
||||
LogStream& LogStream::priority(Message::Priority messagePriority)
|
||||
{
|
||||
_buf.setPriority(priority);
|
||||
_buf.setPriority(messagePriority);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ Mutex Logger::_mapMtx;
|
||||
const std::string Logger::ROOT;
|
||||
|
||||
|
||||
Logger::Logger(const std::string& name, Channel* pChannel, int level): _name(name), _pChannel(pChannel), _level(level)
|
||||
Logger::Logger(const std::string& rName, Channel* pChannel, int level): _name(rName), _pChannel(pChannel), _level(level)
|
||||
{
|
||||
if (pChannel) pChannel->duplicate();
|
||||
}
|
||||
@ -69,14 +69,14 @@ void Logger::setLevel(const std::string& level)
|
||||
}
|
||||
|
||||
|
||||
void Logger::setProperty(const std::string& name, const std::string& value)
|
||||
void Logger::setProperty(const std::string& rName, const std::string& rValue)
|
||||
{
|
||||
if (name == "channel")
|
||||
setChannel(LoggingRegistry::defaultRegistry().channelForName(value));
|
||||
else if (name == "level")
|
||||
setLevel(value);
|
||||
if (rName == "channel")
|
||||
setChannel(LoggingRegistry::defaultRegistry().channelForName(rValue));
|
||||
else if (rName == "level")
|
||||
setLevel(rValue);
|
||||
else
|
||||
Channel::setProperty(name, value);
|
||||
Channel::setProperty(rName, rValue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,11 +129,11 @@ const DigestEngine::Digest& MD4Engine::digest()
|
||||
/* Append length (before padding) */
|
||||
update(bits, 8);
|
||||
|
||||
/* Store state in digest */
|
||||
unsigned char digest[16];
|
||||
encode(digest, _context.state, 16);
|
||||
/* Store state in digestArray */
|
||||
unsigned char digestArray[16];
|
||||
encode(digestArray, _context.state, 16);
|
||||
_digest.clear();
|
||||
_digest.insert(_digest.begin(), digest, digest + sizeof(digest));
|
||||
_digest.insert(_digest.begin(), digestArray, digestArray + sizeof(digestArray));
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
std::memset(&_context, 0, sizeof (_context));
|
||||
|
@ -129,11 +129,11 @@ const DigestEngine::Digest& MD5Engine::digest()
|
||||
/* Append length (before padding) */
|
||||
update(bits, 8);
|
||||
|
||||
/* Store state in digest */
|
||||
unsigned char digest[16];
|
||||
encode(digest, _context.state, 16);
|
||||
/* Store state in digestArray */
|
||||
unsigned char digestArray[16];
|
||||
encode(digestArray, _context.state, 16);
|
||||
_digest.clear();
|
||||
_digest.insert(_digest.begin(), digest, digest + sizeof(digest));
|
||||
_digest.insert(_digest.begin(), digestArray, digestArray + sizeof(digestArray));
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
std::memset(&_context, 0, sizeof (_context));
|
||||
|
@ -21,8 +21,8 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
MemoryPool::MemoryPool(std::size_t blockSize, int preAlloc, int maxAlloc):
|
||||
_blockSize(blockSize),
|
||||
MemoryPool::MemoryPool(std::size_t blockLength, int preAlloc, int maxAlloc):
|
||||
_blockSize(blockLength),
|
||||
_maxAlloc(maxAlloc),
|
||||
_allocated(preAlloc)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ Path::Path(): _absolute(false)
|
||||
}
|
||||
|
||||
|
||||
Path::Path(bool absolute): _absolute(absolute)
|
||||
Path::Path(bool absolutePath): _absolute(absolutePath)
|
||||
{
|
||||
}
|
||||
|
||||
@ -90,39 +90,39 @@ Path::Path(const Path& path):
|
||||
}
|
||||
|
||||
|
||||
Path::Path(const Path& parent, const std::string& fileName):
|
||||
_node(parent._node),
|
||||
_device(parent._device),
|
||||
_name(parent._name),
|
||||
_version(parent._version),
|
||||
_dirs(parent._dirs),
|
||||
_absolute(parent._absolute)
|
||||
Path::Path(const Path& rParent, const std::string& fileName):
|
||||
_node(rParent._node),
|
||||
_device(rParent._device),
|
||||
_name(rParent._name),
|
||||
_version(rParent._version),
|
||||
_dirs(rParent._dirs),
|
||||
_absolute(rParent._absolute)
|
||||
{
|
||||
makeDirectory();
|
||||
_name = fileName;
|
||||
}
|
||||
|
||||
|
||||
Path::Path(const Path& parent, const char* fileName):
|
||||
_node(parent._node),
|
||||
_device(parent._device),
|
||||
_name(parent._name),
|
||||
_version(parent._version),
|
||||
_dirs(parent._dirs),
|
||||
_absolute(parent._absolute)
|
||||
Path::Path(const Path& rParent, const char* fileName):
|
||||
_node(rParent._node),
|
||||
_device(rParent._device),
|
||||
_name(rParent._name),
|
||||
_version(rParent._version),
|
||||
_dirs(rParent._dirs),
|
||||
_absolute(rParent._absolute)
|
||||
{
|
||||
makeDirectory();
|
||||
_name = fileName;
|
||||
}
|
||||
|
||||
|
||||
Path::Path(const Path& parent, const Path& relative):
|
||||
_node(parent._node),
|
||||
_device(parent._device),
|
||||
_name(parent._name),
|
||||
_version(parent._version),
|
||||
_dirs(parent._dirs),
|
||||
_absolute(parent._absolute)
|
||||
Path::Path(const Path& rParent, const Path& relative):
|
||||
_node(rParent._node),
|
||||
_device(rParent._device),
|
||||
_name(rParent._name),
|
||||
_version(rParent._version),
|
||||
_dirs(rParent._dirs),
|
||||
_absolute(rParent._absolute)
|
||||
{
|
||||
resolve(relative);
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ PatternFormatter::PatternFormatter():
|
||||
}
|
||||
|
||||
|
||||
PatternFormatter::PatternFormatter(const std::string& format):
|
||||
PatternFormatter::PatternFormatter(const std::string& rFormat):
|
||||
_localTime(false),
|
||||
_pattern(format)
|
||||
_pattern(rFormat)
|
||||
{
|
||||
parsePriorityNames();
|
||||
parsePattern();
|
||||
|
@ -207,9 +207,9 @@ ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command,
|
||||
if (outPipe) outPipe->close(Pipe::CLOSE_BOTH);
|
||||
if (errPipe) errPipe->close(Pipe::CLOSE_BOTH);
|
||||
// close all open file descriptors other than stdin, stdout, stderr
|
||||
for (int i = 3; i < sysconf(_SC_OPEN_MAX); ++i)
|
||||
for (int fd = 3; i < sysconf(_SC_OPEN_MAX); ++fd)
|
||||
{
|
||||
close(i);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
execvp(argv[0], &argv[0]);
|
||||
|
@ -40,9 +40,9 @@ SimpleFileChannel::SimpleFileChannel():
|
||||
}
|
||||
|
||||
|
||||
SimpleFileChannel::SimpleFileChannel(const std::string& path):
|
||||
_path(path),
|
||||
_secondaryPath(path + ".0"),
|
||||
SimpleFileChannel::SimpleFileChannel(const std::string& rPath):
|
||||
_path(rPath),
|
||||
_secondaryPath(rPath + ".0"),
|
||||
_limit(0),
|
||||
_flush(true),
|
||||
_pFile(0)
|
||||
@ -73,12 +73,12 @@ void SimpleFileChannel::open()
|
||||
File secondary(_secondaryPath);
|
||||
Timestamp pt = primary.exists() ? primary.getLastModified() : 0;
|
||||
Timestamp st = secondary.exists() ? secondary.getLastModified() : 0;
|
||||
std::string path;
|
||||
std::string pathString;
|
||||
if (pt >= st)
|
||||
path = _path;
|
||||
pathString = _path;
|
||||
else
|
||||
path = _secondaryPath;
|
||||
_pFile = new LogFile(path);
|
||||
pathString = _secondaryPath;
|
||||
_pFile = new LogFile(pathString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ SortedDirectoryIterator::SortedDirectoryIterator()
|
||||
}
|
||||
|
||||
|
||||
SortedDirectoryIterator::SortedDirectoryIterator(const std::string& path)
|
||||
: DirectoryIterator(path), _is_finished(false)
|
||||
SortedDirectoryIterator::SortedDirectoryIterator(const std::string& rPath)
|
||||
: DirectoryIterator(rPath), _is_finished(false)
|
||||
{
|
||||
scan();
|
||||
next();
|
||||
@ -50,8 +50,8 @@ SortedDirectoryIterator::SortedDirectoryIterator(const File& file)
|
||||
}
|
||||
|
||||
|
||||
SortedDirectoryIterator::SortedDirectoryIterator(const Path& path)
|
||||
: DirectoryIterator(path), _is_finished(false)
|
||||
SortedDirectoryIterator::SortedDirectoryIterator(const Path& rPath)
|
||||
: DirectoryIterator(rPath), _is_finished(false)
|
||||
{
|
||||
scan();
|
||||
next();
|
||||
|
@ -113,10 +113,10 @@ int StreamConverterBuf::writeToDevice(char c)
|
||||
++_errors;
|
||||
return -1;
|
||||
}
|
||||
int n = _outEncoding.convert(uc, _buffer, sizeof(_buffer));
|
||||
if (n == 0) n = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer));
|
||||
poco_assert_dbg (n <= sizeof(_buffer));
|
||||
_pOstr->write((char*) _buffer, n);
|
||||
int number = _outEncoding.convert(uc, _buffer, sizeof(_buffer));
|
||||
if (number == 0) number = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer));
|
||||
poco_assert_dbg (number <= sizeof(_buffer));
|
||||
_pOstr->write((char*) _buffer, number);
|
||||
_sequenceLength = 0;
|
||||
_pos = 0;
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ namespace Poco {
|
||||
StringTokenizer::StringTokenizer(const std::string& str, const std::string& separators, int options)
|
||||
{
|
||||
std::string::const_iterator it = str.begin();
|
||||
std::string::const_iterator end = str.end();
|
||||
std::string::const_iterator itEnd = str.end();
|
||||
std::string token;
|
||||
bool doTrim = ((options & TOK_TRIM) != 0);
|
||||
bool ignoreEmpty = ((options & TOK_IGNORE_EMPTY) != 0);
|
||||
bool lastToken = false;
|
||||
|
||||
for (;it != end; ++it)
|
||||
for (;it != itEnd; ++it)
|
||||
{
|
||||
if (separators.find(*it) != std::string::npos)
|
||||
{
|
||||
|
@ -22,8 +22,8 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
Task::Task(const std::string& name):
|
||||
_name(name),
|
||||
Task::Task(const std::string& rName):
|
||||
_name(rName),
|
||||
_pOwner(0),
|
||||
_progress(0),
|
||||
_state(TASK_IDLE),
|
||||
@ -91,11 +91,11 @@ bool Task::sleep(long milliseconds)
|
||||
}
|
||||
|
||||
|
||||
void Task::setProgress(float progress)
|
||||
void Task::setProgress(float taskProgress)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
_progress = progress;
|
||||
_progress = taskProgress;
|
||||
if (_pOwner)
|
||||
_pOwner->taskProgress(this, _progress);
|
||||
}
|
||||
@ -109,9 +109,9 @@ void Task::setOwner(TaskManager* pOwner)
|
||||
}
|
||||
|
||||
|
||||
void Task::setState(TaskState state)
|
||||
void Task::setState(TaskState taskState)
|
||||
{
|
||||
_state = state;
|
||||
_state = taskState;
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,9 +79,9 @@ TaskFailedNotification::~TaskFailedNotification()
|
||||
}
|
||||
|
||||
|
||||
TaskProgressNotification::TaskProgressNotification(Task* pTask, float progress):
|
||||
TaskProgressNotification::TaskProgressNotification(Task* pTask, float taskProgress):
|
||||
TaskNotification(pTask),
|
||||
_progress(progress)
|
||||
_progress(taskProgress)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -47,18 +47,18 @@ TextBufferIterator::TextBufferIterator(const char* begin, std::size_t size, cons
|
||||
}
|
||||
|
||||
|
||||
TextBufferIterator::TextBufferIterator(const char* begin, const char* end, const TextEncoding& encoding):
|
||||
TextBufferIterator::TextBufferIterator(const char* begin, const char* pEnd, const TextEncoding& encoding):
|
||||
_pEncoding(&encoding),
|
||||
_it(begin),
|
||||
_end(end)
|
||||
_end(pEnd)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TextBufferIterator::TextBufferIterator(const char* end):
|
||||
TextBufferIterator::TextBufferIterator(const char* pEnd):
|
||||
_pEncoding(0),
|
||||
_it(end),
|
||||
_end(end)
|
||||
_it(pEnd),
|
||||
_end(pEnd)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -36,10 +36,10 @@ TextIterator::TextIterator(const std::string& str, const TextEncoding& encoding)
|
||||
}
|
||||
|
||||
|
||||
TextIterator::TextIterator(const std::string::const_iterator& begin, const std::string::const_iterator& end, const TextEncoding& encoding):
|
||||
TextIterator::TextIterator(const std::string::const_iterator& begin, const std::string::const_iterator& rEnd, const TextEncoding& encoding):
|
||||
_pEncoding(&encoding),
|
||||
_it(begin),
|
||||
_end(end)
|
||||
_end(rEnd)
|
||||
{
|
||||
}
|
||||
|
||||
@ -52,10 +52,10 @@ TextIterator::TextIterator(const std::string& str):
|
||||
}
|
||||
|
||||
|
||||
TextIterator::TextIterator(const std::string::const_iterator& end):
|
||||
TextIterator::TextIterator(const std::string::const_iterator& rEnd):
|
||||
_pEncoding(0),
|
||||
_it(end),
|
||||
_end(end)
|
||||
_it(rEnd),
|
||||
_end(rEnd)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -98,9 +98,9 @@ Thread::Thread():
|
||||
}
|
||||
|
||||
|
||||
Thread::Thread(const std::string& name):
|
||||
Thread::Thread(const std::string& rName):
|
||||
_id(uniqueId()),
|
||||
_name(name),
|
||||
_name(rName),
|
||||
_pTLS(0),
|
||||
_event()
|
||||
{
|
||||
@ -190,9 +190,9 @@ void Thread::clearTLS()
|
||||
|
||||
std::string Thread::makeName()
|
||||
{
|
||||
std::ostringstream name;
|
||||
name << '#' << _id;
|
||||
return name.str();
|
||||
std::ostringstream threadName;
|
||||
threadName << '#' << _id;
|
||||
return threadName.str();
|
||||
}
|
||||
|
||||
|
||||
@ -203,11 +203,11 @@ int Thread::uniqueId()
|
||||
}
|
||||
|
||||
|
||||
void Thread::setName(const std::string& name)
|
||||
void Thread::setName(const std::string& rName)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
_name = name;
|
||||
_name = rName;
|
||||
}
|
||||
|
||||
|
||||
|
@ -282,13 +282,13 @@ ThreadPool::ThreadPool(int minCapacity,
|
||||
}
|
||||
|
||||
|
||||
ThreadPool::ThreadPool(const std::string& name,
|
||||
ThreadPool::ThreadPool(const std::string& rName,
|
||||
int minCapacity,
|
||||
int maxCapacity,
|
||||
int idleTime,
|
||||
int stackSize,
|
||||
ThreadAffinityPolicy affinityPolicy):
|
||||
_name(name),
|
||||
_name(rName),
|
||||
_minCapacity(minCapacity),
|
||||
_maxCapacity(maxCapacity),
|
||||
_idleTime(idleTime),
|
||||
@ -414,9 +414,9 @@ void ThreadPool::start(Runnable& target, int cpu)
|
||||
}
|
||||
|
||||
|
||||
void ThreadPool::start(Runnable& target, const std::string& name, int cpu)
|
||||
void ThreadPool::start(Runnable& target, const std::string& rName, int cpu)
|
||||
{
|
||||
getThread()->start(Thread::PRIO_NORMAL, target, name, affinity(cpu));
|
||||
getThread()->start(Thread::PRIO_NORMAL, target, rName, affinity(cpu));
|
||||
}
|
||||
|
||||
|
||||
@ -426,9 +426,9 @@ void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target,
|
||||
}
|
||||
|
||||
|
||||
void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target, const std::string& name, int cpu)
|
||||
void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target, const std::string& rName, int cpu)
|
||||
{
|
||||
getThread()->start(priority, target, name, affinity(cpu));
|
||||
getThread()->start(priority, target, rName, affinity(cpu));
|
||||
}
|
||||
|
||||
|
||||
@ -542,9 +542,9 @@ PooledThread* ThreadPool::getThread()
|
||||
|
||||
PooledThread* ThreadPool::createThread()
|
||||
{
|
||||
std::ostringstream name;
|
||||
name << _name << "[#" << ++_serial << "]";
|
||||
return new PooledThread(name.str(), _stackSize);
|
||||
std::ostringstream threadName;
|
||||
threadName << _name << "[#" << ++_serial << "]";
|
||||
return new PooledThread(threadName.str(), _stackSize);
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,14 +40,14 @@ Timespan::Timespan(TimeDiff microSeconds):
|
||||
}
|
||||
|
||||
|
||||
Timespan::Timespan(long seconds, long microSeconds):
|
||||
_span(TimeDiff(seconds)*SECONDS + microSeconds)
|
||||
Timespan::Timespan(long otherSeconds, long otherMicroSeconds):
|
||||
_span(TimeDiff(otherSeconds)*SECONDS + otherMicroSeconds)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Timespan::Timespan(int days, int hours, int minutes, int seconds, int microSeconds):
|
||||
_span(TimeDiff(microSeconds) + TimeDiff(seconds)*SECONDS + TimeDiff(minutes)*MINUTES + TimeDiff(hours)*HOURS + TimeDiff(days)*DAYS)
|
||||
Timespan::Timespan(int otherDays, int otherHours, int otherMinutes, int otherSeconds, int otherMicroSeconds):
|
||||
_span(TimeDiff(otherMicroSeconds) + TimeDiff(otherSeconds)*SECONDS + TimeDiff(otherMinutes)*MINUTES + TimeDiff(otherHours)*HOURS + TimeDiff(otherDays)*DAYS)
|
||||
{
|
||||
}
|
||||
|
||||
@ -77,16 +77,16 @@ Timespan& Timespan::operator = (TimeDiff microSeconds)
|
||||
}
|
||||
|
||||
|
||||
Timespan& Timespan::assign(int days, int hours, int minutes, int seconds, int microSeconds)
|
||||
Timespan& Timespan::assign(int otherDays, int otherHours, int otherMinutes, int otherSeconds, int otherMicroSeconds)
|
||||
{
|
||||
_span = TimeDiff(microSeconds) + TimeDiff(seconds)*SECONDS + TimeDiff(minutes)*MINUTES + TimeDiff(hours)*HOURS + TimeDiff(days)*DAYS;
|
||||
_span = TimeDiff(otherMicroSeconds) + TimeDiff(otherSeconds)*SECONDS + TimeDiff(otherMinutes)*MINUTES + TimeDiff(otherHours)*HOURS + TimeDiff(otherDays)*DAYS;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Timespan& Timespan::assign(long seconds, long microSeconds)
|
||||
Timespan& Timespan::assign(long otherSeconds, long otherMicroSeconds)
|
||||
{
|
||||
_span = TimeDiff(seconds)*SECONDS + TimeDiff(microSeconds);
|
||||
_span = TimeDiff(otherSeconds)*SECONDS + TimeDiff(otherMicroSeconds);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ URIStreamFactory::~URIStreamFactory()
|
||||
}
|
||||
|
||||
|
||||
URIRedirection::URIRedirection(const std::string& uri):
|
||||
_uri(uri)
|
||||
URIRedirection::URIRedirection(const std::string& rUri):
|
||||
_uri(rUri)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ UUID::UUID(UInt32 timeLow, UInt32 timeMid, UInt32 timeHiAndVersion, UInt16 clock
|
||||
}
|
||||
|
||||
|
||||
UUID::UUID(const char* bytes, Version version)
|
||||
UUID::UUID(const char* bytes, Version uuidVersion)
|
||||
{
|
||||
UInt32 i32;
|
||||
UInt16 i16;
|
||||
@ -86,7 +86,7 @@ UUID::UUID(const char* bytes, Version version)
|
||||
std::memcpy(_node, bytes, sizeof(_node));
|
||||
|
||||
_timeHiAndVersion &= 0x0FFF;
|
||||
_timeHiAndVersion |= (version << 12);
|
||||
_timeHiAndVersion |= (uuidVersion << 12);
|
||||
_clockSeq &= 0x3FFF;
|
||||
_clockSeq |= 0x8000;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class DiyFp {
|
||||
static const int kSignificandSize = 64;
|
||||
|
||||
DiyFp() : f_(0), e_(0) {}
|
||||
DiyFp(uint64_t f, int e) : f_(f), e_(e) {}
|
||||
DiyFp(uint64_t significant, int exponent) : f_(significant), e_(exponent) {}
|
||||
|
||||
// this = this - other.
|
||||
// The exponents of both numbers must be the same and the significand of this
|
||||
@ -76,22 +76,22 @@ class DiyFp {
|
||||
|
||||
void Normalize() {
|
||||
ASSERT(f_ != 0);
|
||||
uint64_t f = f_;
|
||||
int e = e_;
|
||||
uint64_t significant = f_;
|
||||
int exponent = e_;
|
||||
|
||||
// This method is mainly called for normalizing boundaries. In general
|
||||
// boundaries need to be shifted by 10 bits. We thus optimize for this case.
|
||||
const uint64_t k10MSBits = UINT64_2PART_C(0xFFC00000, 00000000);
|
||||
while ((f & k10MSBits) == 0) {
|
||||
f <<= 10;
|
||||
e -= 10;
|
||||
while ((significant & k10MSBits) == 0) {
|
||||
significant <<= 10;
|
||||
exponent -= 10;
|
||||
}
|
||||
while ((f & kUint64MSB) == 0) {
|
||||
f <<= 1;
|
||||
e--;
|
||||
while ((significant & kUint64MSB) == 0) {
|
||||
significant <<= 1;
|
||||
exponent--;
|
||||
}
|
||||
f_ = f;
|
||||
e_ = e;
|
||||
f_ = significant;
|
||||
e_ = exponent;
|
||||
}
|
||||
|
||||
static DiyFp Normalize(const DiyFp& a) {
|
||||
|
@ -801,9 +801,9 @@ double StringToDoubleConverter::StringToIeee(
|
||||
return junk_string_value_;
|
||||
}
|
||||
}
|
||||
char sign = '+';
|
||||
char currentSign = '+';
|
||||
if (*current == '+' || *current == '-') {
|
||||
sign = static_cast<char>(*current);
|
||||
currentSign = static_cast<char>(*current);
|
||||
++current;
|
||||
if (current == end) {
|
||||
if (allow_trailing_junk) {
|
||||
@ -837,7 +837,7 @@ double StringToDoubleConverter::StringToIeee(
|
||||
++current;
|
||||
} while (current != end && *current >= '0' && *current <= '9');
|
||||
|
||||
exponent += (sign == '-' ? -num : num);
|
||||
exponent += (currentSign == '-' ? -num : num);
|
||||
}
|
||||
|
||||
if (!(allow_trailing_spaces || allow_trailing_junk) && (current != end)) {
|
||||
|
@ -158,8 +158,8 @@ template <typename T>
|
||||
class Vector {
|
||||
public:
|
||||
Vector() : start_(NULL), length_(0) {}
|
||||
Vector(T* data, int length) : start_(data), length_(length) {
|
||||
ASSERT(length == 0 || (length > 0 && data != NULL));
|
||||
Vector(T* data, int size) : start_(data), length_(size) {
|
||||
ASSERT(size == 0 || (size > 0 && data != NULL));
|
||||
}
|
||||
|
||||
// Returns a vector using the same backing storage as this one,
|
||||
@ -201,8 +201,8 @@ class Vector {
|
||||
// buffer bounds on all operations in debug mode.
|
||||
class StringBuilder {
|
||||
public:
|
||||
StringBuilder(char* buffer, int size)
|
||||
: buffer_(buffer, size), position_(0) { }
|
||||
StringBuilder(char* buffer, int length)
|
||||
: buffer_(buffer, length), position_(0) { }
|
||||
|
||||
~StringBuilder() { if (!is_finalized()) Finalize(); }
|
||||
|
||||
|
74
Makefile
74
Makefile
@ -20,7 +20,48 @@ ifndef POCO_BUILD
|
||||
export POCO_BUILD=$(POCO_BASE)
|
||||
endif
|
||||
|
||||
LIBPREFIX ?= lib
|
||||
#
|
||||
# Determine OS
|
||||
#
|
||||
POCO_HOST_OSNAME = $(shell uname)
|
||||
ifeq ($(findstring CYGWIN,$(POCO_HOST_OSNAME)),CYGWIN)
|
||||
POCO_HOST_OSNAME = Cygwin
|
||||
endif
|
||||
|
||||
ifeq ($(findstring MINGW,$(POCO_HOST_OSNAME)),MINGW)
|
||||
POCO_HOST_OSNAME = MinGW
|
||||
endif
|
||||
POCO_HOST_OSARCH ?= $(subst /,-,$(shell uname -m | tr ' ' _))
|
||||
|
||||
#
|
||||
# If POCO_CONFIG is not set, use the OS name as configuration name
|
||||
#
|
||||
ifndef POCO_CONFIG
|
||||
POCO_CONFIG = $(POCO_HOST_OSNAME)
|
||||
endif
|
||||
#$(info POCO_CONFIG = $(POCO_CONFIG))
|
||||
|
||||
#
|
||||
# Include System Specific Settings
|
||||
#
|
||||
include $(POCO_BASE)/build/config/$(POCO_CONFIG)
|
||||
|
||||
#
|
||||
# Determine operating system
|
||||
#
|
||||
ifndef POCO_TARGET_OSNAME
|
||||
OSNAME := $(POCO_HOST_OSNAME)
|
||||
else
|
||||
OSNAME := $(POCO_TARGET_OSNAME)
|
||||
endif
|
||||
#$(info OSNAME = $(OSNAME))
|
||||
|
||||
ifndef POCO_TARGET_OSARCH
|
||||
OSARCH := $(POCO_HOST_OSARCH)
|
||||
else
|
||||
OSARCH := $(POCO_TARGET_OSARCH)
|
||||
endif
|
||||
#$(info OSARCH = $(OSARCH))
|
||||
|
||||
.PHONY: poco all libexecs cppunit tests samples cleans clean distclean install
|
||||
|
||||
@ -29,7 +70,7 @@ poco: libexecs $(if $(TESTS),tests) $(if $(SAMPLES),samples)
|
||||
all: libexecs tests samples
|
||||
|
||||
INSTALLDIR = $(DESTDIR)$(POCO_PREFIX)
|
||||
COMPONENTS = Foundation XML JSON Util Net Crypto NetSSL_OpenSSL Data Data/SQLite Data/ODBC Data/MySQL MongoDB Zip PageCompiler PageCompiler/File2Page CppParser PDF
|
||||
COMPONENTS = Foundation XML JSON Util Net Crypto NetSSL_OpenSSL Data Data/SQLite Data/ODBC Data/MySQL MongoDB Redis Zip PageCompiler PageCompiler/File2Page CppParser PDF
|
||||
|
||||
cppunit:
|
||||
$(MAKE) -C $(POCO_BASE)/CppUnit
|
||||
@ -49,13 +90,17 @@ install: libexecs
|
||||
find $(POCO_BUILD)/$$comp/bin -perm -700 -type f -exec cp -f {} $(INSTALLDIR)/bin \; ; \
|
||||
fi ; \
|
||||
done
|
||||
find $(POCO_BUILD)/lib/$(POCO_TARGET_OSNAME)/$(POCO_TARGET_OSARCH) -name "$(LIBPREFIX)Poco*" -type f -exec cp -f {} $(INSTALLDIR)/lib \;
|
||||
find $(POCO_BUILD)/lib/$(POCO_TARGET_OSNAME)/$(POCO_TARGET_OSARCH) -name "$(LIBPREFIX)Poco*" -type l -exec cp -Rf {} $(INSTALLDIR)/lib \;
|
||||
ifeq ($(OSNAME), Cygwin)
|
||||
find $(POCO_BUILD)/lib/$(OSNAME)/$(OSARCH) -name "cygPoco*" -type f -exec cp -f {} $(INSTALLDIR)/bin \;
|
||||
find $(POCO_BUILD)/lib/$(OSNAME)/$(OSARCH) -name "cygPoco*" -type l -exec cp -Rf {} $(INSTALLDIR)/bin \;
|
||||
endif
|
||||
find $(POCO_BUILD)/lib/$(OSNAME)/$(OSARCH) -name "libPoco*" -type f -exec cp -f {} $(INSTALLDIR)/lib \;
|
||||
find $(POCO_BUILD)/lib/$(OSNAME)/$(OSARCH) -name "libPoco*" -type l -exec cp -Rf {} $(INSTALLDIR)/lib \;
|
||||
|
||||
libexecs = Foundation-libexec XML-libexec JSON-libexec Util-libexec Net-libexec Crypto-libexec NetSSL_OpenSSL-libexec Data-libexec Data/SQLite-libexec Data/ODBC-libexec Data/MySQL-libexec MongoDB-libexec Zip-libexec PageCompiler-libexec PageCompiler/File2Page-libexec CppParser-libexec PDF-libexec
|
||||
tests = Foundation-tests XML-tests JSON-tests Util-tests Net-tests Crypto-tests NetSSL_OpenSSL-tests Data-tests Data/SQLite-tests Data/ODBC-tests Data/MySQL-tests MongoDB-tests Zip-tests CppParser-tests PDF-tests
|
||||
libexecs = Foundation-libexec XML-libexec JSON-libexec Util-libexec Net-libexec Crypto-libexec NetSSL_OpenSSL-libexec Data-libexec Data/SQLite-libexec Data/ODBC-libexec Data/MySQL-libexec MongoDB-libexec Redis-libexec Zip-libexec PageCompiler-libexec PageCompiler/File2Page-libexec CppParser-libexec PDF-libexec
|
||||
tests = Foundation-tests XML-tests JSON-tests Util-tests Net-tests Crypto-tests NetSSL_OpenSSL-tests Data-tests Data/SQLite-tests Data/ODBC-tests Data/MySQL-tests MongoDB-tests Redis-tests Zip-tests CppParser-tests PDF-tests
|
||||
samples = Foundation-samples XML-samples JSON-samples Util-samples Net-samples Crypto-samples NetSSL_OpenSSL-samples Data-samples MongoDB-samples Zip-samples PageCompiler-samples PDF-samples
|
||||
cleans = Foundation-clean XML-clean JSON-clean Util-clean Net-clean Crypto-clean NetSSL_OpenSSL-clean Data-clean Data/SQLite-clean Data/ODBC-clean Data/MySQL-clean MongoDB-clean Zip-clean PageCompiler-clean PageCompiler/File2Page-clean CppParser-clean PDF-clean
|
||||
cleans = Foundation-clean XML-clean JSON-clean Util-clean Net-clean Crypto-clean NetSSL_OpenSSL-clean Data-clean Data/SQLite-clean Data/ODBC-clean Data/MySQL-clean MongoDB-clean Redis-clean Zip-clean PageCompiler-clean PageCompiler/File2Page-clean CppParser-clean PDF-clean
|
||||
|
||||
.PHONY: $(libexecs)
|
||||
.PHONY: $(tests)
|
||||
@ -223,6 +268,21 @@ MongoDB-clean:
|
||||
$(MAKE) -C $(POCO_BASE)/MongoDB/testsuite clean
|
||||
$(MAKE) -C $(POCO_BASE)/MongoDB/samples clean
|
||||
|
||||
Redis-libexec: Foundation-libexec Net-libexec
|
||||
$(MAKE) -C $(POCO_BASE)/Redis
|
||||
|
||||
Redis-tests: Redis-libexec cppunit
|
||||
$(MAKE) -C $(POCO_BASE)/Redis/testsuite
|
||||
|
||||
#No samples yet ... uncomment this when added, and add Redis-samples to samples above
|
||||
#Redis-samples: Redis-libexec
|
||||
# $(MAKE) -C $(POCO_BASE)/Redis/samples
|
||||
|
||||
Redis-clean:
|
||||
$(MAKE) -C $(POCO_BASE)/Redis clean
|
||||
$(MAKE) -C $(POCO_BASE)/Redis/testsuite clean
|
||||
# $(MAKE) -C $(POCO_BASE)/Redis/samples clean
|
||||
|
||||
Zip-libexec: Foundation-libexec Net-libexec Util-libexec XML-libexec
|
||||
$(MAKE) -C $(POCO_BASE)/Zip
|
||||
|
||||
|
@ -8,8 +8,13 @@
|
||||
|
||||
include $(POCO_BASE)/build/rules/global
|
||||
|
||||
# Cygwin Poco*.dll should be on PATH
|
||||
ifeq ($(OSNAME), CYGWIN)
|
||||
PATH :=$(LIBPATH):$(PATH)
|
||||
endif
|
||||
|
||||
# Where to find the PageCompiler executable
|
||||
PAGECOMPILER = $(POCO_BASE)/PageCompiler/bin/$(POCO_HOST_OSNAME)/$(POCO_HOST_OSARCH)/cpspc
|
||||
PAGECOMPILER = $(POCO_BUILD)/PageCompiler/bin/$(OSNAME)/$(OSARCH)/cpspc
|
||||
|
||||
objects = HTTPTimeServerApp TimeHandler
|
||||
|
||||
@ -20,7 +25,7 @@ target_libs = PocoUtil PocoJSON PocoNet PocoXML PocoFoundation
|
||||
include $(POCO_BASE)/build/rules/exec
|
||||
|
||||
ifdef POCO_UNBUNDLED
|
||||
SYSLIBS += -lz -lpcre -lexpat
|
||||
SYSLIBS += -lz -lpcre -lexpat
|
||||
endif
|
||||
|
||||
# Rule for runnning PageCompiler
|
||||
|
@ -13,6 +13,7 @@
|
||||
expat*.h,
|
||||
zconf.h,
|
||||
zlib.h,
|
||||
XMLStreamParser.h
|
||||
</exclude>
|
||||
</files>
|
||||
<pages>
|
||||
@ -32,6 +33,7 @@
|
||||
<options>
|
||||
${Includes},
|
||||
-I/usr/local/mysql/include,
|
||||
-I/usr/include/mysql,
|
||||
-D_DEBUG,
|
||||
-E,
|
||||
-C,
|
||||
|
@ -13,6 +13,7 @@
|
||||
expat*.h,
|
||||
zconf.h,
|
||||
zlib.h,
|
||||
XMLStreamParser.h
|
||||
${PocoBuild}/Util/include/Poco/Util/Units.h
|
||||
</exclude>
|
||||
</files>
|
||||
@ -33,6 +34,7 @@
|
||||
<options>
|
||||
${Includes},
|
||||
-I/usr/local/mysql/include,
|
||||
-I/usr/include/mysql,
|
||||
-D_DEBUG,
|
||||
-E,
|
||||
-C,
|
||||
|
37
Redis/CMakeLists.txt
Normal file
37
Redis/CMakeLists.txt
Normal file
@ -0,0 +1,37 @@
|
||||
set(LIBNAME "Redis")
|
||||
set(POCO_LIBNAME "Poco${LIBNAME}")
|
||||
|
||||
# Sources
|
||||
file(GLOB SRCS_G "src/*.cpp")
|
||||
POCO_SOURCES_AUTO( SRCS ${SRCS_G})
|
||||
|
||||
# Headers
|
||||
file(GLOB_RECURSE HDRS_G "include/*.h" )
|
||||
POCO_HEADERS_AUTO( SRCS ${HDRS_G})
|
||||
|
||||
add_library( "${LIBNAME}" ${LIB_MODE} ${SRCS} )
|
||||
add_library( "${POCO_LIBNAME}" ALIAS "${LIBNAME}")
|
||||
set_target_properties( "${LIBNAME}"
|
||||
PROPERTIES
|
||||
VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION}
|
||||
OUTPUT_NAME ${POCO_LIBNAME}
|
||||
DEFINE_SYMBOL Redis_EXPORTS
|
||||
)
|
||||
|
||||
target_link_libraries( "${LIBNAME}" Net Foundation)
|
||||
target_include_directories( "${LIBNAME}"
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS})
|
||||
|
||||
POCO_INSTALL("${LIBNAME}")
|
||||
POCO_GENERATE_PACKAGE("${LIBNAME}")
|
||||
|
||||
if (ENABLE_TESTS)
|
||||
# add_subdirectory(samples)
|
||||
add_subdirectory(testsuite)
|
||||
endif ()
|
||||
|
19
Redis/Makefile
Normal file
19
Redis/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# Makefile for Poco Redis
|
||||
#
|
||||
|
||||
include $(POCO_BASE)/build/rules/global
|
||||
|
||||
INCLUDE += -I $(POCO_BASE)/Redis/include/Poco/Redis
|
||||
|
||||
objects = AsyncReader Array Client Command Error Exception RedisStream RedisEventArgs Type
|
||||
|
||||
target = PocoRedis
|
||||
target_version = $(LIBVERSION)
|
||||
target_libs = PocoFoundation PocoNet
|
||||
|
||||
include $(POCO_BASE)/build/rules/lib
|
16
Redis/Redis.progen
Normal file
16
Redis/Redis.progen
Normal file
@ -0,0 +1,16 @@
|
||||
vc.project.guid = ${vc.project.guidFromName}
|
||||
vc.project.name = Redis
|
||||
vc.project.target = Poco${vc.project.name}
|
||||
vc.project.type = library
|
||||
vc.project.pocobase = ..
|
||||
vc.project.outdir = ${vc.project.pocobase}
|
||||
vc.project.platforms = Win32, x64
|
||||
vc.project.configurations = debug_shared, release_shared, debug_static_mt, release_static_mt, debug_static_md, release_static_md
|
||||
vc.project.prototype = ${vc.project.name}_vs90.vcproj
|
||||
vc.project.compiler.include = ..\\Foundation\\include;..\\Net\\include
|
||||
vc.project.compiler.defines =
|
||||
vc.project.compiler.defines.shared = ${vc.project.name}_EXPORTS
|
||||
vc.project.compiler.defines.debug_shared = ${vc.project.compiler.defines.shared}
|
||||
vc.project.compiler.defines.release_shared = ${vc.project.compiler.defines.shared}
|
||||
vc.solution.create = true
|
||||
vc.solution.include = testsuite\\TestSuite
|
60
Redis/Redis_x64_vs90.sln
Normal file
60
Redis/Redis_x64_vs90.sln
Normal file
@ -0,0 +1,60 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Redis", "Redis_x64_vs90.vcproj", "{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_x64_vs90.vcproj", "{96CF3103-E49E-3F5E-A11D-6DBCDA043053}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199} = {4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
debug_shared|x64 = debug_shared|x64
|
||||
release_shared|x64 = release_shared|x64
|
||||
debug_static_mt|x64 = debug_static_mt|x64
|
||||
release_static_mt|x64 = release_static_mt|x64
|
||||
debug_static_md|x64 = debug_static_md|x64
|
||||
release_static_md|x64 = release_static_md|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.debug_shared|x64.ActiveCfg = debug_shared|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.debug_shared|x64.Build.0 = debug_shared|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.debug_shared|x64.Deploy.0 = debug_shared|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.release_shared|x64.ActiveCfg = release_shared|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.release_shared|x64.Build.0 = release_shared|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.release_shared|x64.Deploy.0 = release_shared|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.debug_static_mt|x64.ActiveCfg = debug_static_mt|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.debug_static_mt|x64.Build.0 = debug_static_mt|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.debug_static_mt|x64.Deploy.0 = debug_static_mt|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.release_static_mt|x64.ActiveCfg = release_static_mt|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.release_static_mt|x64.Build.0 = release_static_mt|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.release_static_mt|x64.Deploy.0 = release_static_mt|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.debug_static_md|x64.ActiveCfg = debug_static_md|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.debug_static_md|x64.Build.0 = debug_static_md|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.debug_static_md|x64.Deploy.0 = debug_static_md|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.release_static_md|x64.ActiveCfg = release_static_md|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.release_static_md|x64.Build.0 = release_static_md|x64
|
||||
{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}.release_static_md|x64.Deploy.0 = release_static_md|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.debug_shared|x64.ActiveCfg = debug_shared|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.debug_shared|x64.Build.0 = debug_shared|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.debug_shared|x64.Deploy.0 = debug_shared|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.release_shared|x64.ActiveCfg = release_shared|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.release_shared|x64.Build.0 = release_shared|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.release_shared|x64.Deploy.0 = release_shared|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.debug_static_mt|x64.ActiveCfg = debug_static_mt|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.debug_static_mt|x64.Build.0 = debug_static_mt|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.debug_static_mt|x64.Deploy.0 = debug_static_mt|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.release_static_mt|x64.ActiveCfg = release_static_mt|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.release_static_mt|x64.Build.0 = release_static_mt|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.release_static_mt|x64.Deploy.0 = release_static_mt|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.debug_static_md|x64.ActiveCfg = debug_static_md|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.debug_static_md|x64.Build.0 = debug_static_md|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.debug_static_md|x64.Deploy.0 = debug_static_md|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.release_static_md|x64.ActiveCfg = release_static_md|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.release_static_md|x64.Build.0 = release_static_md|x64
|
||||
{96CF3103-E49E-3F5E-A11D-6DBCDA043053}.release_static_md|x64.Deploy.0 = release_static_md|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
588
Redis/Redis_x64_vs90.vcproj
Normal file
588
Redis/Redis_x64_vs90.vcproj
Normal file
@ -0,0 +1,588 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="Redis"
|
||||
ProjectGUID="{4FF2F34B-7F37-3ACD-AFBC-F21D6D426199}"
|
||||
RootNamespace="Redis"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="0"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="debug_shared|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions=""
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;Redis_EXPORTS"
|
||||
StringPooling="true"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
BufferSecurityCheck="true"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions=""
|
||||
AdditionalDependencies=""
|
||||
OutputFile="..\bin64\PocoRedis64d.dll"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\lib64"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="..\bin64\PocoRedis64d.pdb"
|
||||
SubSystem="1"
|
||||
ImportLibrary="..\lib64\PocoRedisd.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="release_shared|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions=""
|
||||
Optimization="4"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;Redis_EXPORTS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="false"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions=""
|
||||
AdditionalDependencies=""
|
||||
OutputFile="..\bin64\PocoRedis64.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\lib64"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
OptimizeForWindows98="0"
|
||||
ImportLibrary="..\lib64\PocoRedis.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="debug_static_mt|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions=""
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;"
|
||||
StringPooling="true"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
BufferSecurityCheck="true"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
ProgramDataBaseFileName="..\lib64\PocoRedismtd.pdb"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="..\lib64\PocoRedismtd.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="release_static_mt|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions=""
|
||||
Optimization="4"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="false"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="..\lib64\PocoRedismt.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="debug_static_md|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions=""
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;"
|
||||
StringPooling="true"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
BufferSecurityCheck="true"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
ProgramDataBaseFileName="..\lib64\PocoRedismdd.pdb"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="..\lib64\PocoRedismdd.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="release_static_md|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions=""
|
||||
Optimization="4"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="false"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="..\lib64\PocoRedismd.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\Array.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\AsyncReader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Client.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Command.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Error.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Exception.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\RedisEventArgs.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\RedisStream.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Type.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\Array.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\AsyncReader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\Client.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\Command.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\Error.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\Exception.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\PoolableConnectionFactory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\Redis.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\RedisEventArgs.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\RedisStream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Redis\Type.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
4
Redis/cmake/PocoRedisConfig.cmake
Normal file
4
Redis/cmake/PocoRedisConfig.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(PocoFoundation)
|
||||
find_dependency(PocoNet)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/PocoRedisTargets.cmake")
|
2
Redis/dependencies
Normal file
2
Redis/dependencies
Normal file
@ -0,0 +1,2 @@
|
||||
Foundation
|
||||
Net
|
296
Redis/include/Poco/Redis/Array.h
Normal file
296
Redis/include/Poco/Redis/Array.h
Normal file
@ -0,0 +1,296 @@
|
||||
//
|
||||
// Array.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Array
|
||||
//
|
||||
// Definition of the Array class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#ifndef Redis_Array_INCLUDED
|
||||
#define Redis_Array_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include "Poco/Redis/Redis.h"
|
||||
#include "Poco/Redis/Type.h"
|
||||
#include "Poco/Redis/Exception.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
class Redis_API Array
|
||||
/// Represents a Redis Array. An Array can contain Integers, Strings,
|
||||
/// Bulk Strings, Errors and other arrays. It can also contain a Null
|
||||
/// value.
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::vector<RedisType::Ptr>::const_iterator const_iterator;
|
||||
|
||||
Array();
|
||||
/// Default constructor. As long as there are no elements added,
|
||||
/// the array will contain a Null value.
|
||||
|
||||
Array(const Array& copy);
|
||||
/// Copy constructor.
|
||||
|
||||
virtual ~Array();
|
||||
/// Destructor.
|
||||
|
||||
template<typename T>
|
||||
Array& operator<<(const T& arg)
|
||||
/// Adds the argument to the array.
|
||||
/// Note: a std::string will be added as a BulkString because this
|
||||
/// is commonly used for representing strings in Redis. If you
|
||||
/// really need a simple string, use addSimpleString.
|
||||
{
|
||||
return add(arg);
|
||||
}
|
||||
|
||||
Array& operator<<(const char* s);
|
||||
/// Special implementation for const char*
|
||||
/// Note: the specialization creates a BulkString. If you need
|
||||
/// a simple string, call addSimpleString.
|
||||
|
||||
Array& operator<<(const std::vector<std::string>& strings);
|
||||
/// Special implementation for a vector with strings
|
||||
/// All strings will be added as a BulkString.
|
||||
|
||||
Array& add();
|
||||
/// Adds an Null BulkString
|
||||
|
||||
template<typename T>
|
||||
Array& add(const T& arg)
|
||||
/// Adds an element to the array.
|
||||
/// Note: the specialization for std::string will add a BulkString!
|
||||
/// If you really need a simple string, call addSimpleString.
|
||||
{
|
||||
addRedisType(new Type<T>(arg));
|
||||
return *this;
|
||||
}
|
||||
|
||||
Array& add(const char* s);
|
||||
/// Special implementation for const char*
|
||||
/// Note: the specialization creates a BulkString. If you need
|
||||
/// a simple string, call addSimpleString.
|
||||
|
||||
Array& add(const std::vector<std::string>& strings);
|
||||
/// Special implementation for a vector with strings
|
||||
/// All strings will be added as a BulkString.
|
||||
|
||||
Array& addRedisType(RedisType::Ptr value);
|
||||
/// Adds a Redis element.
|
||||
|
||||
Array& addSimpleString(const std::string& value);
|
||||
/// Adds a simple string (can't contain newline characters!)
|
||||
|
||||
const_iterator begin() const;
|
||||
/// Returns an iterator to the start of the array. Note:
|
||||
/// this can throw a NullValueException when this is a Null array.
|
||||
|
||||
void clear();
|
||||
/// Removes all elements from the array.
|
||||
|
||||
const_iterator end() const;
|
||||
/// Returns an iterator to the end of the array. Note:
|
||||
/// this can throw a NullValueException when this is a Null array.
|
||||
|
||||
template<typename T>
|
||||
T get(size_t pos) const
|
||||
/// Returns the element on the given position and tries to convert
|
||||
/// to the template type. A BadCastException will be thrown when the
|
||||
/// the conversion fails. An InvalidArgumentException will be thrown
|
||||
/// when the index is out of range. When the array is a Null array
|
||||
/// a NullValueException is thrown.
|
||||
{
|
||||
if ( _elements.isNull() ) throw NullValueException();
|
||||
|
||||
if ( pos >= _elements.value().size() ) throw InvalidArgumentException();
|
||||
|
||||
RedisType::Ptr element = _elements.value().at(pos);
|
||||
if ( RedisTypeTraits<T>::TypeId == element->type() )
|
||||
{
|
||||
Type<T>* concrete = dynamic_cast<Type<T>* >(element.get());
|
||||
if ( concrete != NULL ) return concrete->value();
|
||||
}
|
||||
throw BadCastException();
|
||||
}
|
||||
|
||||
int getType(size_t pos) const;
|
||||
/// Returns the type of the element. This can throw a NullValueException
|
||||
/// when this array is a Null array. An InvalidArgumentException will
|
||||
/// be thrown when the index is out of range.
|
||||
|
||||
bool isNull() const;
|
||||
/// Returns true when this is a Null array.
|
||||
|
||||
void makeNull();
|
||||
/// Turns the array into a Null array. When the array already has some
|
||||
/// elements, the array will be cleared.
|
||||
|
||||
std::string toString() const;
|
||||
/// Returns the String representation as specified in the
|
||||
/// Redis Protocol specification.
|
||||
|
||||
size_t size() const;
|
||||
/// Returns the size of the array. Note:
|
||||
/// this can throw a NullValueException when this is a Null array.
|
||||
|
||||
private:
|
||||
|
||||
Nullable<std::vector<RedisType::Ptr> > _elements;
|
||||
|
||||
void checkNull();
|
||||
/// Checks for null array and sets a new vector if true.
|
||||
};
|
||||
|
||||
inline Array& Array::operator<<(const char* s)
|
||||
{
|
||||
BulkString value(s);
|
||||
return add(value);
|
||||
}
|
||||
|
||||
inline Array& Array::operator<<(const std::vector<std::string>& strings)
|
||||
{
|
||||
return add(strings);
|
||||
}
|
||||
|
||||
inline Array& Array::add()
|
||||
{
|
||||
BulkString value;
|
||||
return add(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Array& Array::add(const std::string& arg)
|
||||
{
|
||||
BulkString value(arg);
|
||||
return add(value);
|
||||
}
|
||||
|
||||
inline Array& Array::add(const char* s)
|
||||
{
|
||||
BulkString value(s);
|
||||
return add(value);
|
||||
}
|
||||
|
||||
inline Array& Array::add(const std::vector<std::string>& strings)
|
||||
{
|
||||
for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); ++it)
|
||||
{
|
||||
add(*it);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Array& Array::addSimpleString(const std::string& value)
|
||||
{
|
||||
return addRedisType(new Type<std::string>(value));
|
||||
}
|
||||
|
||||
inline Array::const_iterator Array::begin() const
|
||||
{
|
||||
return _elements.value().begin();
|
||||
}
|
||||
|
||||
inline void Array::checkNull()
|
||||
{
|
||||
std::vector<RedisType::Ptr> v;
|
||||
if ( _elements.isNull() ) _elements.assign(v);
|
||||
}
|
||||
|
||||
inline void Array::clear()
|
||||
{
|
||||
if ( !_elements.isNull() )
|
||||
{
|
||||
_elements.value().clear();
|
||||
}
|
||||
}
|
||||
|
||||
inline Array::const_iterator Array::end() const
|
||||
{
|
||||
return _elements.value().end();
|
||||
}
|
||||
|
||||
inline bool Array::isNull() const
|
||||
{
|
||||
return _elements.isNull();
|
||||
}
|
||||
|
||||
inline void Array::makeNull()
|
||||
{
|
||||
if ( !_elements.isNull() ) _elements.value().clear();
|
||||
|
||||
_elements.clear();
|
||||
}
|
||||
|
||||
inline size_t Array::size() const
|
||||
{
|
||||
return _elements.value().size();
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
struct RedisTypeTraits<Array>
|
||||
{
|
||||
enum { TypeId = RedisType::REDIS_ARRAY };
|
||||
|
||||
static const char marker = '*';
|
||||
|
||||
static std::string toString(const Array& value)
|
||||
{
|
||||
std::stringstream result;
|
||||
result << marker;
|
||||
if ( value.isNull() )
|
||||
{
|
||||
result << "-1" << LineEnding::NEWLINE_CRLF;
|
||||
}
|
||||
else
|
||||
{
|
||||
result << value.size() << LineEnding::NEWLINE_CRLF;
|
||||
for(std::vector<RedisType::Ptr>::const_iterator it = value.begin();
|
||||
it != value.end(); ++it)
|
||||
{
|
||||
result << (*it)->toString();
|
||||
}
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
static void read(RedisInputStream& input, Array& value)
|
||||
{
|
||||
value.clear();
|
||||
|
||||
Int64 length = NumberParser::parse64(input.getline());
|
||||
|
||||
if ( length != -1 )
|
||||
{
|
||||
for(int i = 0; i < length; ++i)
|
||||
{
|
||||
char marker = input.get();
|
||||
RedisType::Ptr element = RedisType::createRedisType(marker);
|
||||
|
||||
if ( element.isNull() )
|
||||
throw RedisException("Wrong answer received from Redis server");
|
||||
|
||||
element->read(input);
|
||||
value.addRedisType(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}}
|
||||
|
||||
#endif // Redis_Array_INCLUDED
|
95
Redis/include/Poco/Redis/AsyncReader.h
Normal file
95
Redis/include/Poco/Redis/AsyncReader.h
Normal file
@ -0,0 +1,95 @@
|
||||
//
|
||||
// AsyncReader.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: AsyncReader
|
||||
//
|
||||
// Definition of the AsyncReader class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Redis_AsyncReader_INCLUDED
|
||||
#define Redis_AsyncReader_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Redis/Redis.h"
|
||||
#include "Poco/Redis/Client.h"
|
||||
#include "Poco/Redis/RedisEventArgs.h"
|
||||
#include "Poco/Activity.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
|
||||
class Redis_API AsyncReader
|
||||
/// Wrapper around a Redis client to read messages asynchronously. Use this
|
||||
/// for publish/subscribe. The redisResponse event is used to notify that
|
||||
/// a message is received. When a reader is started for a Redis server,
|
||||
/// you should use execute<void>, because this class is responsible for
|
||||
/// reading all replies.
|
||||
{
|
||||
public:
|
||||
|
||||
BasicEvent<RedisEventArgs> redisResponse;
|
||||
/// Event that is called when a message is received
|
||||
BasicEvent<RedisEventArgs> redisException;
|
||||
/// Event that is called when an error occurred.
|
||||
|
||||
AsyncReader(Client& client);
|
||||
/// Constructor.
|
||||
|
||||
virtual ~AsyncReader();
|
||||
/// Destructor
|
||||
|
||||
bool isStopped();
|
||||
/// Returns true if the activity is not running, false when it is.
|
||||
|
||||
void start();
|
||||
/// Starts the activity to read replies from the Redis server.
|
||||
|
||||
void stop();
|
||||
/// Stops the read activity.
|
||||
|
||||
protected:
|
||||
|
||||
void runActivity();
|
||||
|
||||
private:
|
||||
|
||||
AsyncReader(const AsyncReader&);
|
||||
AsyncReader& operator = (const AsyncReader&);
|
||||
|
||||
|
||||
Activity<AsyncReader> _activity;
|
||||
|
||||
Client& _client;
|
||||
};
|
||||
|
||||
|
||||
inline bool AsyncReader::isStopped()
|
||||
{
|
||||
return _activity.isStopped();
|
||||
}
|
||||
|
||||
inline void AsyncReader::start()
|
||||
{
|
||||
_activity.start();
|
||||
}
|
||||
|
||||
inline void AsyncReader::stop()
|
||||
{
|
||||
_activity.stop();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Redis
|
||||
|
||||
#endif //Redis_AsyncReader_INCLUDED
|
232
Redis/include/Poco/Redis/Client.h
Normal file
232
Redis/include/Poco/Redis/Client.h
Normal file
@ -0,0 +1,232 @@
|
||||
//
|
||||
// Client.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Client
|
||||
//
|
||||
// Definition of the Client class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Redis_Client_INCLUDED
|
||||
#define Redis_Client_INCLUDED
|
||||
|
||||
#include "Poco/Net/SocketAddress.h"
|
||||
#include "Poco/Timespan.h"
|
||||
|
||||
#include "Poco/Redis/Redis.h"
|
||||
#include "Poco/Redis/Array.h"
|
||||
#include "Poco/Redis/Error.h"
|
||||
#include "Poco/Redis/RedisStream.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
|
||||
class Redis_API Client
|
||||
/// Represents a connection to a Redis server.
|
||||
///
|
||||
/// A command is always made from an Array and a reply can be a signed 64
|
||||
/// bit integer, a simple string, a bulk string, an array or an error. The
|
||||
/// first element of the command array is the Redis command. A simple string
|
||||
/// is a string that cannot contain a CR or LF character. A bulk string is
|
||||
/// implemented as a typedef for Poco::Nullable<std::string>. This is
|
||||
/// because a bulk string can represent a Null value.
|
||||
///
|
||||
/// BulkString bs = client.execute<BulkString>(...);
|
||||
/// if ( bs.isNull() )
|
||||
/// {
|
||||
/// // We have a Null value
|
||||
/// }
|
||||
/// else
|
||||
/// {
|
||||
/// // We have a string value
|
||||
/// }
|
||||
///
|
||||
/// To create Redis commands, the factory methods of the Command class can
|
||||
/// be used or the Array class can be used directly.
|
||||
///
|
||||
/// Command llen = Command::llen("list");
|
||||
///
|
||||
/// is the same as
|
||||
///
|
||||
/// Array command;
|
||||
/// command.add("LLEN").add("list");
|
||||
///
|
||||
/// or
|
||||
///
|
||||
/// Array command;
|
||||
/// command << "LLEN" << "list";
|
||||
///
|
||||
/// or even
|
||||
///
|
||||
/// Command command("LLEN");
|
||||
/// command << "list";
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SharedPtr<Client> Ptr;
|
||||
|
||||
Client();
|
||||
/// Default constructor. Use this when you want to
|
||||
/// connect later on.
|
||||
|
||||
Client(const std::string& hostAndPort);
|
||||
/// Constructor which connects to the given Redis host/port.
|
||||
/// The host and port must be separated with a colon.
|
||||
|
||||
Client(const std::string& host, int port);
|
||||
/// Constructor which connects to the given Redis host/port.
|
||||
|
||||
Client(const Net::SocketAddress& addrs);
|
||||
/// Constructor which connects to the given Redis host/port.
|
||||
|
||||
virtual ~Client();
|
||||
/// Destructor.
|
||||
|
||||
Net::SocketAddress address() const;
|
||||
/// Returns the address of the Redis connection.
|
||||
|
||||
void connect(const std::string& hostAndPort);
|
||||
/// Connects to the given Redis server. The host and port must be
|
||||
/// separated with a colon.
|
||||
|
||||
void connect(const std::string& host, int port);
|
||||
/// Connects to the given Redis server.
|
||||
|
||||
void connect(const Net::SocketAddress& addrs);
|
||||
/// Connects to the given Redis server.
|
||||
|
||||
void connect(const std::string& hostAndPort, const Timespan& timeout);
|
||||
/// Connects to the given Redis server. The host and port must be
|
||||
/// separated with a colon.
|
||||
|
||||
void connect(const std::string& host, int port, const Timespan& timeout);
|
||||
/// Connects to the given Redis server.
|
||||
|
||||
void connect(const Net::SocketAddress& addrs, const Timespan& timeout);
|
||||
/// Connects to the given Redis server.
|
||||
|
||||
void disconnect();
|
||||
/// Disconnects from the Redis server.
|
||||
|
||||
template<typename T>
|
||||
T execute(const Array& command)
|
||||
/// Sends the Redis Command to the server. It gets the reply
|
||||
/// and tries to convert it to the given template type.
|
||||
///
|
||||
/// A specialization exists for type void, which doesn't read
|
||||
/// the reply. If the server sends a reply, it is your
|
||||
/// responsibility to read it ... (Use this for pipelining)
|
||||
///
|
||||
/// A BadCastException will be thrown when the reply couldn't be
|
||||
/// converted. Supported types are Int64, std::string, BulkString,
|
||||
/// Array and void. When the reply is an Error, it will throw
|
||||
/// a RedisException.
|
||||
{
|
||||
T result;
|
||||
writeCommand(command, true);
|
||||
readReply(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void flush();
|
||||
/// Flush the output buffer to Redis. Use this when commands
|
||||
/// are stored in the buffer to send them all at once to Redis.
|
||||
|
||||
RedisType::Ptr sendCommand(const Array& command);
|
||||
/// Sends a Redis command to the server and returns the reply.
|
||||
/// Use this when the type of the reply isn't known.
|
||||
|
||||
RedisType::Ptr readReply();
|
||||
/// Read a reply from the Redis server.
|
||||
|
||||
template<typename T>
|
||||
void readReply(T& result)
|
||||
/// Read a reply from the Redis server and tries to convert that reply
|
||||
/// to the template type. When the reply is a Redis error, it will
|
||||
/// throw a RedisException. A BadCastException will be thrown, when
|
||||
/// the reply is not of the given type.
|
||||
{
|
||||
RedisType::Ptr redisResult = readReply();
|
||||
if (redisResult->type() == RedisTypeTraits<Error>::TypeId)
|
||||
{
|
||||
Type<Error>* error = dynamic_cast<Type<Error>*>(redisResult.get());
|
||||
throw RedisException(error->value().getMessage());
|
||||
}
|
||||
|
||||
if (redisResult->type() == RedisTypeTraits<T>::TypeId)
|
||||
{
|
||||
Type<T>* type = dynamic_cast<Type<T>*>(redisResult.get());
|
||||
if (type != NULL) result = type->value();
|
||||
}
|
||||
else throw BadCastException();
|
||||
}
|
||||
|
||||
Array sendCommands(const std::vector<Array>& commands);
|
||||
/// Sends all commands (pipelining) to the Redis server before
|
||||
/// getting all replies.
|
||||
|
||||
void setReceiveTimeout(const Timespan& timeout);
|
||||
/// Sets a receive timeout.
|
||||
|
||||
private:
|
||||
|
||||
Client(const Client&);
|
||||
Client& operator = (const Client&);
|
||||
|
||||
Net::SocketAddress _address;
|
||||
Net::StreamSocket _socket;
|
||||
|
||||
void connect();
|
||||
/// Connects to the Redis server
|
||||
|
||||
void connect(const Timespan& timeout);
|
||||
/// Connects to the Redis server and sets a timeout.
|
||||
|
||||
void writeCommand(const Array& command, bool flush);
|
||||
/// Sends a request to the Redis server. Use readReply to get the
|
||||
/// answer. Can also be used for pipelining commands. Make sure you
|
||||
/// call readReply as many times as you called writeCommand, even when
|
||||
/// an error occurred on a command.
|
||||
|
||||
RedisInputStream* _input;
|
||||
RedisOutputStream* _output;
|
||||
};
|
||||
|
||||
|
||||
inline Net::SocketAddress Client::address() const
|
||||
{
|
||||
return _address;
|
||||
}
|
||||
|
||||
template<> inline
|
||||
void Client::execute<void>(const Array& command)
|
||||
{
|
||||
writeCommand(command, false);
|
||||
}
|
||||
|
||||
inline void Client::flush()
|
||||
{
|
||||
poco_assert(_output);
|
||||
_output->flush();
|
||||
}
|
||||
|
||||
inline void Client::setReceiveTimeout(const Timespan& timeout)
|
||||
{
|
||||
_socket.setReceiveTimeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Redis
|
||||
|
||||
|
||||
#endif //Redis_Client_INCLUDED
|
256
Redis/include/Poco/Redis/Command.h
Normal file
256
Redis/include/Poco/Redis/Command.h
Normal file
@ -0,0 +1,256 @@
|
||||
//
|
||||
// Command.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Command
|
||||
//
|
||||
// Definition of the Command class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#ifndef Redis_Command_INCLUDED
|
||||
#define Redis_Command_INCLUDED
|
||||
|
||||
#include "Poco/Redis/Redis.h"
|
||||
#include "Poco/Redis/Array.h"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
class Redis_API Command : public Array
|
||||
/// Helper class for creating commands. This class contains
|
||||
/// factory methods for commonly used Redis commands.
|
||||
/// There are two ways of building commands:
|
||||
/// 1. Use this class and the factory methods
|
||||
/// 2. Use the Array or Command class and build the command using the add
|
||||
/// method or << operator.
|
||||
/// For example:
|
||||
///
|
||||
/// Command cmd = Command::set("mykey", "Hello");
|
||||
///
|
||||
/// is the same as:
|
||||
///
|
||||
/// Array cmd;
|
||||
/// cmd << "SET" << "mykey" << "Hello";
|
||||
///
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::vector<std::string> StringVec;
|
||||
|
||||
Command(const std::string& command);
|
||||
/// Constructor
|
||||
|
||||
Command(const Command& copy);
|
||||
/// Copy constructor
|
||||
|
||||
virtual ~Command();
|
||||
/// Destructor
|
||||
|
||||
static Command append(const std::string& key, const std::string& value);
|
||||
/// Returns an APPEND command
|
||||
|
||||
static Command blpop(const StringVec& lists, Int64 timeout = 0);
|
||||
/// Returns a BLPOP command
|
||||
|
||||
static Command brpop(const StringVec& lists, Int64 timeout = 0);
|
||||
/// Returns a BRPOP command
|
||||
|
||||
static Command brpoplpush(const std::string& sourceList, const std::string& destinationList, Int64 timeout = 0);
|
||||
/// Returns a BRPOPLPUSH command
|
||||
|
||||
static Command decr(const std::string& key, Int64 by = 0);
|
||||
/// Returns an DECR or DECRBY command. Calls DECR when by is omitted or zero.
|
||||
|
||||
static Command del(const std::string& key);
|
||||
/// Returns an DEL command
|
||||
|
||||
static Command del(const StringVec& keys);
|
||||
/// Returns an DEL command
|
||||
|
||||
static Command get(const std::string& key);
|
||||
/// Returns an GET command
|
||||
|
||||
static Command hdel(const std::string& hash, const std::string& field);
|
||||
/// Returns an HDEL command
|
||||
|
||||
static Command hdel(const std::string& hash, const StringVec& fields);
|
||||
/// Returns an HDEL command
|
||||
|
||||
static Command hexists(const std::string& hash, const std::string& field);
|
||||
/// Returns an HEXISTS command
|
||||
|
||||
static Command hget(const std::string& hash, const std::string& field);
|
||||
/// Returns an HGET command
|
||||
|
||||
static Command hgetall(const std::string& hash);
|
||||
/// Returns an HGETALL command
|
||||
|
||||
static Command hincrby(const std::string& hash, const std::string& field, Int64 by = 1);
|
||||
/// Returns an HINCRBY command
|
||||
|
||||
static Command hkeys(const std::string& hash);
|
||||
/// Returns an HKEYS command
|
||||
|
||||
static Command hlen(const std::string& hash);
|
||||
/// Returns an HLEN command
|
||||
|
||||
static Command hmget(const std::string& hash, const StringVec& fields);
|
||||
/// Returns an HMGET command
|
||||
|
||||
static Command hmset(const std::string& hash, std::map<std::string, std::string>& fields);
|
||||
/// Returns a HMSET command
|
||||
|
||||
static Command hset(const std::string& hash, const std::string& field, const std::string& value, bool create = true);
|
||||
/// Returns an HSET or HSETNX (when create is false) command
|
||||
|
||||
static Command hset(const std::string& hash, const std::string& field, Int64 value, bool create = true);
|
||||
/// Returns an HSET or HSETNX (when create is false) command
|
||||
|
||||
static Command hstrlen(const std::string& hash, const std::string& field);
|
||||
/// Returns an HSTRLEN command (Available for Redis 3.2)
|
||||
|
||||
static Command hvals(const std::string& hash);
|
||||
/// Returns an HVALS command
|
||||
|
||||
static Command incr(const std::string& key, Int64 by = 0);
|
||||
/// Returns an INCR or INCRBY command. Calls INCR when by is omitted or zero.
|
||||
|
||||
static Command lindex(const std::string& list, Int64 index = 0);
|
||||
/// Returns a LINDEX command
|
||||
|
||||
static Command linsert(const std::string& list, bool before, const std::string& reference, const std::string& value);
|
||||
/// Returns a LINSERT command
|
||||
|
||||
static Command llen(const std::string& list);
|
||||
/// Returns a LLEN command
|
||||
|
||||
static Command lpop(const std::string& list);
|
||||
/// Returns a LPOP command
|
||||
|
||||
static Command lpush(const std::string& list, const std::string& value, bool create = true);
|
||||
/// Returns a LPUSH or LPUSHX (when create is false) command
|
||||
|
||||
static Command lpush(const std::string& list, const StringVec& value, bool create = true);
|
||||
/// Returns a LPUSH or LPUSHX (when create is false) command
|
||||
|
||||
static Command lrange(const std::string& list, Int64 start = 0, Int64 stop = -1);
|
||||
/// Returns a LRANGE command. When start and stop is omitted an LRANGE
|
||||
/// command will returned that returns all items of the list.
|
||||
|
||||
static Command lrem(const std::string& list, Int64 count, const std::string& value);
|
||||
/// Returns a LREM command
|
||||
|
||||
static Command lset(const std::string& list, Int64 index, const std::string& value);
|
||||
/// Returns a LSET command
|
||||
|
||||
static Command ltrim(const std::string& list, Int64 start = 0, Int64 stop = -1);
|
||||
/// Returns a LTRIM command
|
||||
|
||||
static Command mget(const StringVec& keys);
|
||||
/// Returns a MGET command
|
||||
|
||||
static Command mset(const std::map<std::string, std::string>& keyvalues, bool create = true);
|
||||
/// Returns a MSET or MSETNX (when create is false) command
|
||||
|
||||
static Command sadd(const std::string& set, const std::string& value);
|
||||
/// Returns a SADD command
|
||||
|
||||
static Command sadd(const std::string& set, const StringVec& values);
|
||||
/// Returns a SADD command
|
||||
|
||||
static Command scard(const std::string& set);
|
||||
/// Returns a SCARD command
|
||||
|
||||
static Command sdiff(const std::string& set1, const std::string& set2);
|
||||
/// Returns a SDIFF command
|
||||
|
||||
static Command sdiff(const std::string& set, const StringVec& sets);
|
||||
/// Returns a SDIFF command
|
||||
|
||||
static Command sdiffstore(const std::string& set, const std::string& set1, const std::string& set2);
|
||||
/// Returns a SDIFFSTORE command
|
||||
|
||||
static Command sdiffstore(const std::string& set, const StringVec& sets);
|
||||
/// Returns a SDIFFSTORE command
|
||||
|
||||
static Command set(const std::string& key, const std::string& value, bool overwrite = true, const Poco::Timespan& expireTime = 0, bool create = true);
|
||||
/// Returns a SET command to set the key with a value
|
||||
|
||||
static Command set(const std::string& key, Int64 value, bool overwrite = true, const Poco::Timespan& expireTime = 0, bool create = true);
|
||||
/// Returns a SET command to set the key with a value
|
||||
|
||||
static Command sinter(const std::string& set1, const std::string& set2);
|
||||
/// Returns a SINTER command
|
||||
|
||||
static Command sinter(const std::string& set, const StringVec& sets);
|
||||
/// Returns a SINTER command
|
||||
|
||||
static Command sinterstore(const std::string& set, const std::string& set1, const std::string& set2);
|
||||
/// Returns a SINTERSTORE command
|
||||
|
||||
static Command sinterstore(const std::string& set, const StringVec& sets);
|
||||
/// Returns a SINTERSTORE command
|
||||
|
||||
static Command sismember(const std::string& set, const std::string& member);
|
||||
/// Returns a SISMEMBER command
|
||||
|
||||
static Command smembers(const std::string& set);
|
||||
/// Returns a SMEMBERS command
|
||||
|
||||
static Command smove(const std::string& source, const std::string& destination, const std::string& member);
|
||||
/// Returns a SMOVE command
|
||||
|
||||
static Command spop(const std::string& set, Int64 count = 0);
|
||||
/// Returns a SPOP command
|
||||
|
||||
static Command srandmember(const std::string& set, Int64 count = 0);
|
||||
/// Returns a SRANDMEMBER command
|
||||
|
||||
static Command srem(const std::string& set, const std::string& member);
|
||||
/// Returns a SREM command
|
||||
|
||||
static Command srem(const std::string& set, const StringVec& members);
|
||||
/// Returns a SREM command
|
||||
|
||||
static Command sunion(const std::string& set1, const std::string& set2);
|
||||
/// Returns a SUNION command
|
||||
|
||||
static Command sunion(const std::string& set, const StringVec& sets);
|
||||
/// Returns a SUNION command
|
||||
|
||||
static Command sunionstore(const std::string& set, const std::string& set1, const std::string& set2);
|
||||
/// Returns a SUNIONSTORE command
|
||||
|
||||
static Command sunionstore(const std::string& set, const StringVec& sets);
|
||||
/// Returns a SUNIONSTORE command
|
||||
|
||||
static Command rename(const std::string& key, const std::string& newName, bool overwrite = true);
|
||||
/// Returns a RENAME or RENAMENX when overwrite is false
|
||||
|
||||
static Command rpop(const std::string& list);
|
||||
/// Returns a RPOP command
|
||||
|
||||
static Command rpoplpush(const std::string& sourceList, const std::string& destinationList);
|
||||
/// Returns a RPOPLPUSH command
|
||||
|
||||
static Command rpush(const std::string& list, const std::string& value, bool create = true);
|
||||
/// Returns a RPUSH or RPUSHX (when create is false) command
|
||||
|
||||
static Command rpush(const std::string& list, const StringVec& value, bool create = true);
|
||||
/// Returns a RPUSH or RPUSHX (when create is false) command
|
||||
};
|
||||
|
||||
}} // namespace Poco::Redis
|
||||
|
||||
#endif // Redis_Command_INCLUDED
|
81
Redis/include/Poco/Redis/Error.h
Normal file
81
Redis/include/Poco/Redis/Error.h
Normal file
@ -0,0 +1,81 @@
|
||||
//
|
||||
// Error.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Error
|
||||
//
|
||||
// Definition of the Error class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#ifndef Redis_Error_INCLUDED
|
||||
#define Redis_Error_INCLUDED
|
||||
|
||||
#include "Poco/Redis/Type.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
class Redis_API Error
|
||||
/// Represent a Redis error
|
||||
{
|
||||
public:
|
||||
|
||||
Error();
|
||||
/// Constructor
|
||||
|
||||
Error(const std::string& message);
|
||||
/// Constructor
|
||||
|
||||
virtual ~Error();
|
||||
/// Destructor
|
||||
|
||||
std::string getMessage() const;
|
||||
/// Returns the error message
|
||||
|
||||
void setMessage(const std::string& message);
|
||||
/// Sets the error message
|
||||
|
||||
private:
|
||||
|
||||
std::string _message;
|
||||
};
|
||||
|
||||
inline std::string Error::getMessage() const
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
inline void Error::setMessage(const std::string& message)
|
||||
{
|
||||
_message = message;
|
||||
}
|
||||
|
||||
template<>
|
||||
struct RedisTypeTraits<Error>
|
||||
{
|
||||
enum { TypeId = RedisType::REDIS_ERROR };
|
||||
|
||||
static const char marker = '-';
|
||||
|
||||
static std::string toString(const Error& value)
|
||||
{
|
||||
return marker + value.getMessage() + LineEnding::NEWLINE_CRLF;
|
||||
}
|
||||
|
||||
static void read(RedisInputStream& input, Error& value)
|
||||
{
|
||||
value.setMessage(input.getline());
|
||||
}
|
||||
};
|
||||
|
||||
}} // Namespace Poco::Redis
|
||||
|
||||
#endif // Redis_Error_INCLUDED
|
32
Redis/include/Poco/Redis/Exception.h
Normal file
32
Redis/include/Poco/Redis/Exception.h
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// Exception.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Exception
|
||||
//
|
||||
// Definition of the Exception class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#ifndef Redis_Exception_INCLUDED
|
||||
#define Redis_Exception_INCLUDED
|
||||
|
||||
#include "Poco/Redis/Redis.h"
|
||||
#include <typeinfo>
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
POCO_DECLARE_EXCEPTION(Redis_API, RedisException, Exception)
|
||||
|
||||
}}
|
||||
|
||||
#endif // Redis_Exception_INCLUDED
|
111
Redis/include/Poco/Redis/PoolableConnectionFactory.h
Normal file
111
Redis/include/Poco/Redis/PoolableConnectionFactory.h
Normal file
@ -0,0 +1,111 @@
|
||||
//
|
||||
// PoolableConnectionFactory.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: PoolableConnectionFactory
|
||||
//
|
||||
// Definition of the PoolableConnectionFactory class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Redis_PoolableConnectionFactory_INCLUDED
|
||||
#define Redis_PoolableConnectionFactory_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Redis/Client.h"
|
||||
#include "Poco/ObjectPool.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template<>
|
||||
class PoolableObjectFactory<Redis::Client, Redis::Client::Ptr>
|
||||
/// PoolableObjectFactory specialisation for Client. New connections
|
||||
/// are created with the given address.
|
||||
{
|
||||
public:
|
||||
PoolableObjectFactory(Net::SocketAddress& address)
|
||||
: _address(address)
|
||||
{
|
||||
}
|
||||
|
||||
PoolableObjectFactory(const std::string& address)
|
||||
: _address(address)
|
||||
{
|
||||
}
|
||||
|
||||
Redis::Client::Ptr createObject()
|
||||
{
|
||||
return new Redis::Client(_address);
|
||||
}
|
||||
|
||||
bool validateObject(Redis::Client::Ptr pObject)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void activateObject(Redis::Client::Ptr pObject)
|
||||
{
|
||||
}
|
||||
|
||||
void deactivateObject(Redis::Client::Ptr pObject)
|
||||
{
|
||||
}
|
||||
|
||||
void destroyObject(Redis::Client::Ptr pObject)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
Net::SocketAddress _address;
|
||||
};
|
||||
|
||||
|
||||
namespace Redis {
|
||||
|
||||
|
||||
class Redis_API PooledConnection
|
||||
/// Helper class for borrowing and returning a connection automatically from a pool.
|
||||
{
|
||||
public:
|
||||
PooledConnection(ObjectPool<Client, Client::Ptr>& pool, long timeoutMilliseconds = 0) : _pool(pool)
|
||||
{
|
||||
_client = _pool.borrowObject(timeoutMilliseconds);
|
||||
}
|
||||
|
||||
virtual ~PooledConnection()
|
||||
{
|
||||
try
|
||||
{
|
||||
_pool.returnObject(_client);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
poco_unexpected();
|
||||
}
|
||||
}
|
||||
|
||||
operator Client::Ptr ()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectPool<Client, Client::Ptr>& _pool;
|
||||
Client::Ptr _client;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Redis
|
||||
} // namespace Poco
|
||||
|
||||
#endif // Redis_PoolableConnectionFactory_INCLUDED
|
66
Redis/include/Poco/Redis/Redis.h
Normal file
66
Redis/include/Poco/Redis/Redis.h
Normal file
@ -0,0 +1,66 @@
|
||||
//
|
||||
// Redis.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Redis
|
||||
//
|
||||
// Basic definitions for the Poco Redis library.
|
||||
// This file must be the first file included by every other Redis
|
||||
// header file.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef RedisRedis_INCLUDED
|
||||
#define RedisRedis_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
//
|
||||
// The following block is the standard way of creating macros which make exporting
|
||||
// from a DLL simpler. All files within this DLL are compiled with the Redis_EXPORTS
|
||||
// symbol defined on the command line. this symbol should not be defined on any project
|
||||
// that uses this DLL. This way any other project whose source files include this file see
|
||||
// Redis_API functions as being imported from a DLL, wheras this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
|
||||
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
#if defined(Redis_EXPORTS)
|
||||
#define Redis_API __declspec(dllexport)
|
||||
#else
|
||||
#define Redis_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(Redis_API)
|
||||
#if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4)
|
||||
#define Redis_API __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define Redis_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Automatically link Redis library.
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(Redis_EXPORTS)
|
||||
#pragma comment(lib, "PocoRedis" POCO_LIB_SUFFIX)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif // RedisRedis_INCLUDED
|
85
Redis/include/Poco/Redis/RedisEventArgs.h
Normal file
85
Redis/include/Poco/Redis/RedisEventArgs.h
Normal file
@ -0,0 +1,85 @@
|
||||
//
|
||||
// RedisEventArgs.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: RedisEventArgs
|
||||
//
|
||||
// Definition of the RedisEventArgs class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#ifndef Redis_RedisEventArgs_INCLUDED
|
||||
#define Redis_RedisEventArgs_INCLUDED
|
||||
|
||||
#include "Poco/Redis/Type.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
class Redis_API RedisEventArgs
|
||||
{
|
||||
public:
|
||||
RedisEventArgs(RedisType::Ptr message);
|
||||
/// Constructor
|
||||
|
||||
RedisEventArgs(Exception* e);
|
||||
/// Constructor
|
||||
|
||||
~RedisEventArgs();
|
||||
/// Destructor
|
||||
|
||||
RedisType::Ptr message() const;
|
||||
/// Returns the message retrieved from the Redis server.
|
||||
/// This can be a NULL pointer when this event is about an exception.
|
||||
|
||||
const Exception* exception() const;
|
||||
/// Returns the exception if any, otherwise it returns null pointer
|
||||
|
||||
void stop();
|
||||
/// When called, the AsyncReader will stop.
|
||||
/// Note: The AsyncReader will always stop when this is an exception
|
||||
/// event. Use this for example for pub/sub when there are no
|
||||
/// subcribers anymore ...
|
||||
|
||||
bool isStopped() const;
|
||||
/// Returns true when the AsyncReader will stop
|
||||
|
||||
private:
|
||||
RedisType::Ptr _message;
|
||||
|
||||
Exception* _exception;
|
||||
|
||||
bool _stop;
|
||||
};
|
||||
|
||||
inline RedisType::Ptr RedisEventArgs::message() const
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
inline const Exception* RedisEventArgs::exception() const
|
||||
{
|
||||
return _exception;
|
||||
}
|
||||
|
||||
inline bool RedisEventArgs::isStopped() const
|
||||
{
|
||||
return _stop;
|
||||
}
|
||||
|
||||
inline void RedisEventArgs::stop()
|
||||
{
|
||||
_stop = true;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace Poco::Redis
|
||||
|
||||
#endif // Redis_RedisEventArgs_INCLUDED
|
112
Redis/include/Poco/Redis/RedisStream.h
Normal file
112
Redis/include/Poco/Redis/RedisStream.h
Normal file
@ -0,0 +1,112 @@
|
||||
//
|
||||
// RedisStream.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: RedisStream
|
||||
//
|
||||
// Definition of the RedisStream class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#ifndef Redis_RedisStream_INCLUDED
|
||||
#define Redis_RedisStream_INCLUDED
|
||||
|
||||
#include "Poco/BufferedStreamBuf.h"
|
||||
#include "Poco/Net/StreamSocket.h"
|
||||
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
class RedisStreamBuf : public BufferedStreamBuf
|
||||
/// BufferedStreamBuf for Redis
|
||||
{
|
||||
public:
|
||||
RedisStreamBuf(Net::StreamSocket& redis);
|
||||
/// Constructor
|
||||
|
||||
~RedisStreamBuf();
|
||||
/// Destructor
|
||||
|
||||
std::string readLine();
|
||||
/// Reads a line from Redis (until \r\n is encountered).
|
||||
|
||||
protected:
|
||||
int readFromDevice(char* buffer, std::streamsize length);
|
||||
|
||||
int writeToDevice(const char* buffer, std::streamsize length);
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
STREAM_BUFFER_SIZE = 1024
|
||||
};
|
||||
|
||||
Net::StreamSocket& _redis;
|
||||
};
|
||||
|
||||
class RedisIOS: public virtual std::ios
|
||||
{
|
||||
public:
|
||||
RedisIOS(Net::StreamSocket& redis);
|
||||
/// Creates the RedisIOS with the given socket.
|
||||
|
||||
~RedisIOS();
|
||||
/// Destroys the RedisIOS.
|
||||
///
|
||||
/// Flushes the buffer, but does not close the socket.
|
||||
|
||||
RedisStreamBuf* rdbuf();
|
||||
/// Returns a pointer to the internal RedisStreamBuf.
|
||||
|
||||
void close();
|
||||
/// Flushes the stream.
|
||||
|
||||
protected:
|
||||
RedisStreamBuf _buf;
|
||||
};
|
||||
|
||||
|
||||
class RedisOutputStream: public RedisIOS, public std::ostream
|
||||
/// An output stream for writing to a Redis server.
|
||||
{
|
||||
public:
|
||||
RedisOutputStream(Net::StreamSocket& redis);
|
||||
/// Creates the RedisOutputStream with the given socket.
|
||||
|
||||
~RedisOutputStream();
|
||||
/// Destroys the RedisOutputStream.
|
||||
///
|
||||
/// Flushes the buffer.
|
||||
};
|
||||
|
||||
|
||||
class RedisInputStream: public RedisIOS, public std::istream
|
||||
/// An input stream for reading from a Redis server.
|
||||
{
|
||||
public:
|
||||
RedisInputStream(Net::StreamSocket& redis);
|
||||
/// Creates the RedisInputStream with the given socket.
|
||||
|
||||
~RedisInputStream();
|
||||
/// Destroys the RedisInputStream.
|
||||
|
||||
std::string getline();
|
||||
/// Redis uses /r/n as delimiter. This getline version removes
|
||||
/// the /r from the result.
|
||||
};
|
||||
|
||||
|
||||
}} // Poco::Redis
|
||||
|
||||
#endif // Redis_RedisStream_INCLUDED
|
276
Redis/include/Poco/Redis/Type.h
Normal file
276
Redis/include/Poco/Redis/Type.h
Normal file
@ -0,0 +1,276 @@
|
||||
//
|
||||
// Type.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Type
|
||||
//
|
||||
// Definition of the Type class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#ifndef Redis_Type_INCLUDED
|
||||
#define Redis_Type_INCLUDED
|
||||
|
||||
#include "Poco/LineEndingConverter.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "Poco/Nullable.h"
|
||||
|
||||
#include "Poco/Redis/Redis.h"
|
||||
#include "Poco/Redis/RedisStream.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
|
||||
class Redis_API RedisType
|
||||
/// Base class for all Redis types. This class makes it possible to store
|
||||
/// element with different types in Array.
|
||||
{
|
||||
public:
|
||||
|
||||
enum Types {
|
||||
REDIS_INTEGER, // Redis Integer
|
||||
REDIS_SIMPLE_STRING, // Redis Simple String
|
||||
REDIS_BULK_STRING, // Redis Bulkstring
|
||||
REDIS_ARRAY, // Redis Array
|
||||
REDIS_ERROR // Redis Error
|
||||
};
|
||||
|
||||
typedef SharedPtr<RedisType> Ptr;
|
||||
|
||||
RedisType();
|
||||
/// Constructor
|
||||
|
||||
virtual ~RedisType();
|
||||
/// Destructor
|
||||
|
||||
bool isArray() const;
|
||||
/// Returns true when the value is a Redis array.
|
||||
|
||||
bool isBulkString() const;
|
||||
/// Returns true when the value is a Redis bulkstring.
|
||||
|
||||
bool isError() const;
|
||||
/// Returns true when the value is a Redis error.
|
||||
|
||||
bool isInteger() const;
|
||||
/// Returns true when the value is a Redis integer (64 bit integer)
|
||||
|
||||
bool isSimpleString() const;
|
||||
/// Returns true when the value is a simple string.
|
||||
|
||||
virtual int type() const = 0;
|
||||
/// Returns the type of the value.
|
||||
|
||||
virtual void read(RedisInputStream& input) = 0;
|
||||
/// Reads the value from the stream.
|
||||
|
||||
virtual std::string toString() const = 0;
|
||||
/// Converts the value to a RESP (REdis Serialization Protocol) string.
|
||||
|
||||
static RedisType::Ptr createRedisType(char marker);
|
||||
/// Create a Redis type based on the marker :
|
||||
/// + : a simple string (std::string)
|
||||
/// - : an error (Error)
|
||||
/// $ : a bulk string (BulkString)
|
||||
/// * : an array (Array)
|
||||
/// : : a signed 64 bit integer (Int64)
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
inline bool RedisType::isArray() const
|
||||
{
|
||||
return type() == REDIS_ARRAY;
|
||||
}
|
||||
|
||||
inline bool RedisType::isBulkString() const
|
||||
{
|
||||
return type() == REDIS_BULK_STRING;
|
||||
}
|
||||
|
||||
inline bool RedisType::isError() const
|
||||
{
|
||||
return type() == REDIS_ERROR;
|
||||
}
|
||||
|
||||
inline bool RedisType::isInteger() const
|
||||
{
|
||||
return type() == REDIS_INTEGER;
|
||||
}
|
||||
|
||||
inline bool RedisType::isSimpleString() const
|
||||
{
|
||||
return type() == REDIS_SIMPLE_STRING;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct RedisTypeTraits
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct RedisTypeTraits<Int64>
|
||||
{
|
||||
enum { TypeId = RedisType::REDIS_INTEGER };
|
||||
|
||||
static const char marker = ':';
|
||||
|
||||
static std::string toString(const Int64& value)
|
||||
{
|
||||
return marker + NumberFormatter::format(value) + "\r\n";
|
||||
}
|
||||
|
||||
static void read(RedisInputStream& input, Int64& value)
|
||||
{
|
||||
std::string number = input.getline();
|
||||
value = NumberParser::parse64(number);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct RedisTypeTraits<std::string>
|
||||
{
|
||||
enum { TypeId = RedisType::REDIS_SIMPLE_STRING };
|
||||
|
||||
static const char marker = '+';
|
||||
|
||||
static std::string toString(const std::string& value)
|
||||
{
|
||||
return marker + value + LineEnding::NEWLINE_CRLF;
|
||||
}
|
||||
|
||||
static void read(RedisInputStream& input, std::string& value)
|
||||
{
|
||||
value = input.getline();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef Nullable<std::string> BulkString;
|
||||
/// A bulk string is a string that can contain a NULL value.
|
||||
/// So, BulkString is a typedef for Nullable<std::string>.
|
||||
|
||||
|
||||
template<>
|
||||
struct RedisTypeTraits<BulkString>
|
||||
{
|
||||
enum { TypeId = RedisType::REDIS_BULK_STRING };
|
||||
|
||||
static const char marker = '$';
|
||||
|
||||
static std::string toString(const BulkString& value)
|
||||
{
|
||||
if ( value.isNull() )
|
||||
{
|
||||
return marker + std::string("-1") + LineEnding::NEWLINE_CRLF;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string s = value.value();
|
||||
return marker
|
||||
+ NumberFormatter::format(s.length())
|
||||
+ LineEnding::NEWLINE_CRLF
|
||||
+ s
|
||||
+ LineEnding::NEWLINE_CRLF;
|
||||
}
|
||||
}
|
||||
|
||||
static void read(RedisInputStream& input, BulkString& value)
|
||||
{
|
||||
value.clear();
|
||||
|
||||
std::string line = input.getline();
|
||||
int length = NumberParser::parse(line);
|
||||
|
||||
if ( length >= 0 )
|
||||
{
|
||||
std::string s;
|
||||
s.resize(length, ' ');
|
||||
input.read(&*s.begin(), length);
|
||||
value.assign(s);
|
||||
|
||||
input.getline(); // Read and ignore /r/n
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
class Type : public RedisType
|
||||
/// Template class for all Redis types. This class will use
|
||||
/// RedisTypeTraits structure for calling the type specific code.
|
||||
{
|
||||
public:
|
||||
|
||||
Type()
|
||||
/// Constructor
|
||||
{
|
||||
}
|
||||
|
||||
Type(const T& t) : _value(t)
|
||||
/// Constructor
|
||||
{
|
||||
}
|
||||
|
||||
Type(const Type& copy) : _value(copy._value)
|
||||
/// Copy Constructor
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~Type()
|
||||
/// Destructor
|
||||
{
|
||||
}
|
||||
|
||||
int type() const
|
||||
/// Returns the type of the value
|
||||
{
|
||||
return RedisTypeTraits<T>::TypeId;
|
||||
}
|
||||
|
||||
void read(RedisInputStream& socket)
|
||||
/// Reads the value from the stream (RESP).
|
||||
{
|
||||
RedisTypeTraits<T>::read(socket, _value);
|
||||
}
|
||||
|
||||
std::string toString() const
|
||||
/// Converts the value to a string based on the RESP protocol.
|
||||
{
|
||||
return RedisTypeTraits<T>::toString(_value);
|
||||
}
|
||||
|
||||
T& value()
|
||||
/// Returns the value
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
const T& value() const
|
||||
/// Returns a const value
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T _value;
|
||||
};
|
||||
|
||||
}} // Namespace Poco/Redis
|
||||
|
||||
#endif // Redis_Type_INCLUDED
|
65
Redis/src/Array.cpp
Normal file
65
Redis/src/Array.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
//
|
||||
// Array.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Array
|
||||
//
|
||||
// Implementation of the Array class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#include "Poco/Redis/Array.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
|
||||
Array::Array()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Array::Array(const Array& copy) : _elements(copy._elements)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Array::~Array()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Array& Array::addRedisType(RedisType::Ptr value)
|
||||
{
|
||||
checkNull();
|
||||
|
||||
_elements.value().push_back(value);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
int Array::getType(size_t pos) const
|
||||
{
|
||||
if ( _elements.isNull() ) throw NullValueException();
|
||||
|
||||
if ( pos >= _elements.value().size() ) throw InvalidArgumentException();
|
||||
|
||||
RedisType::Ptr element = _elements.value().at(pos);
|
||||
return element->type();
|
||||
}
|
||||
|
||||
|
||||
std::string Array::toString() const
|
||||
{
|
||||
return RedisTypeTraits<Array>::toString(*this);
|
||||
}
|
||||
|
||||
} }
|
60
Redis/src/AsyncReader.cpp
Normal file
60
Redis/src/AsyncReader.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
//
|
||||
// AsyncReader.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: AsyncReader
|
||||
//
|
||||
// Implementation of the AsyncReader class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#include "Poco/Redis/AsyncReader.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
|
||||
AsyncReader::AsyncReader(Client& client) : _client(client),
|
||||
_activity(this, &AsyncReader::runActivity)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AsyncReader::~AsyncReader()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
void AsyncReader::runActivity()
|
||||
{
|
||||
while(!_activity.isStopped())
|
||||
{
|
||||
try
|
||||
{
|
||||
RedisType::Ptr reply = _client.readReply();
|
||||
|
||||
RedisEventArgs args(reply);
|
||||
redisResponse.notify(this, args);
|
||||
|
||||
if ( args.isStopped() ) stop();
|
||||
}
|
||||
catch(Exception& e)
|
||||
{
|
||||
RedisEventArgs args(&e);
|
||||
redisException.notify(this, args);
|
||||
stop();
|
||||
}
|
||||
if (!_activity.isStopped()) Thread::trySleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} } // Poco::Redis
|
176
Redis/src/Client.cpp
Normal file
176
Redis/src/Client.cpp
Normal file
@ -0,0 +1,176 @@
|
||||
//
|
||||
// Client.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Client
|
||||
//
|
||||
// Implementation of the Client class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#include "Poco/Redis/Client.h"
|
||||
#include "Poco/Redis/Exception.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
|
||||
Client::Client() : _address(), _socket(), _input(0), _output(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Client::Client(const std::string& hostAndPort) : _address(hostAndPort), _socket(), _input(0), _output(0)
|
||||
{
|
||||
connect();
|
||||
}
|
||||
|
||||
|
||||
Client::Client(const std::string& host, int port) : _address(host, port), _socket(), _input(0), _output(0)
|
||||
{
|
||||
connect();
|
||||
}
|
||||
|
||||
|
||||
Client::Client(const Net::SocketAddress& addrs) : _address(addrs), _socket(), _input(0), _output(0)
|
||||
{
|
||||
connect();
|
||||
}
|
||||
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
delete _input;
|
||||
delete _output;
|
||||
}
|
||||
|
||||
|
||||
void Client::connect()
|
||||
{
|
||||
poco_assert(! _input);
|
||||
poco_assert(! _output);
|
||||
|
||||
_socket.connect(_address);
|
||||
_input = new RedisInputStream(_socket);
|
||||
_output = new RedisOutputStream(_socket);
|
||||
}
|
||||
|
||||
void Client::connect(const std::string& hostAndPort)
|
||||
{
|
||||
_address = Net::SocketAddress(hostAndPort);
|
||||
connect();
|
||||
}
|
||||
|
||||
|
||||
void Client::connect(const std::string& host, int port)
|
||||
{
|
||||
_address = Net::SocketAddress(host, port);
|
||||
connect();
|
||||
}
|
||||
|
||||
|
||||
void Client::connect(const Net::SocketAddress& addrs)
|
||||
{
|
||||
_address = addrs;
|
||||
connect();
|
||||
}
|
||||
|
||||
void Client::connect(const Timespan& timeout)
|
||||
{
|
||||
poco_assert(! _input);
|
||||
poco_assert(! _output);
|
||||
|
||||
_socket.connect(_address, timeout);
|
||||
_input = new RedisInputStream(_socket);
|
||||
_output = new RedisOutputStream(_socket);
|
||||
}
|
||||
|
||||
void Client::connect(const std::string& hostAndPort, const Timespan& timeout)
|
||||
{
|
||||
_address = Net::SocketAddress(hostAndPort);
|
||||
connect(timeout);
|
||||
}
|
||||
|
||||
|
||||
void Client::connect(const std::string& host, int port, const Timespan& timeout)
|
||||
{
|
||||
_address = Net::SocketAddress(host, port);
|
||||
connect(timeout);
|
||||
}
|
||||
|
||||
|
||||
void Client::connect(const Net::SocketAddress& addrs, const Timespan& timeout)
|
||||
{
|
||||
_address = addrs;
|
||||
connect(timeout);
|
||||
}
|
||||
|
||||
void Client::disconnect()
|
||||
{
|
||||
delete _input;
|
||||
_input = 0;
|
||||
|
||||
delete _output;
|
||||
_output = 0;
|
||||
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
void Client::writeCommand(const Array& command, bool flush)
|
||||
{
|
||||
poco_assert(_output);
|
||||
|
||||
std::string commandStr = command.toString();
|
||||
|
||||
_output->write(commandStr.c_str(), commandStr.length());
|
||||
if ( flush ) _output->flush();
|
||||
}
|
||||
|
||||
RedisType::Ptr Client::readReply()
|
||||
{
|
||||
poco_assert(_input);
|
||||
|
||||
int c = _input->get();
|
||||
RedisType::Ptr result = RedisType::createRedisType(c);
|
||||
if ( result.isNull() )
|
||||
{
|
||||
throw RedisException("Invalid Redis type returned");
|
||||
}
|
||||
|
||||
result->read(*_input);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
RedisType::Ptr Client::sendCommand(const Array& command)
|
||||
{
|
||||
writeCommand(command, true);
|
||||
return readReply();
|
||||
}
|
||||
|
||||
Array Client::sendCommands(const std::vector<Array>& commands)
|
||||
{
|
||||
Array results;
|
||||
|
||||
for(std::vector<Array>::const_iterator it = commands.begin(); it != commands.end(); ++it)
|
||||
{
|
||||
writeCommand(*it, false);
|
||||
}
|
||||
_output->flush();
|
||||
|
||||
for(int i = 0; i < commands.size(); ++i)
|
||||
{
|
||||
results.addRedisType(readReply());
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
} } // Poco::Redis
|
620
Redis/src/Command.cpp
Normal file
620
Redis/src/Command.cpp
Normal file
@ -0,0 +1,620 @@
|
||||
//
|
||||
// Command.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Command
|
||||
//
|
||||
// Implementation of the Command class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#include "Poco/Redis/Command.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
Command::Command(const std::string& command) : Array()
|
||||
{
|
||||
add(command);
|
||||
}
|
||||
|
||||
Command::Command(const Command& copy) : Array(copy)
|
||||
{
|
||||
}
|
||||
|
||||
Command::~Command()
|
||||
{
|
||||
}
|
||||
|
||||
Command Command::append(const std::string& key, const std::string& value)
|
||||
{
|
||||
Command cmd("APPEND");
|
||||
|
||||
cmd << key << value;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::blpop(const StringVec& lists, Int64 timeout)
|
||||
{
|
||||
Command cmd("BLPOP");
|
||||
|
||||
cmd << lists << NumberFormatter::format(timeout);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::brpop(const StringVec& lists, Int64 timeout)
|
||||
{
|
||||
Command cmd("BRPOP");
|
||||
|
||||
cmd << lists << NumberFormatter::format(timeout);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::brpoplpush(const std::string& sourceList, const std::string& destinationList, Int64 timeout)
|
||||
{
|
||||
Command cmd("BRPOPLPUSH");
|
||||
|
||||
cmd << sourceList << destinationList << NumberFormatter::format(timeout);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::decr(const std::string& key, Int64 by)
|
||||
{
|
||||
Command cmd(by == 0 ? "DECR" : "DECRBY");
|
||||
|
||||
cmd << key;
|
||||
if ( by > 0 ) cmd << NumberFormatter::format(by);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::del(const std::string& key)
|
||||
{
|
||||
Command cmd("DEL");
|
||||
|
||||
cmd << key;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::del(const StringVec& keys)
|
||||
{
|
||||
Command cmd("DEL");
|
||||
|
||||
cmd << keys;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::get(const std::string& key)
|
||||
{
|
||||
Command cmd("GET");
|
||||
|
||||
cmd << key;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hdel(const std::string& hash, const std::string& field)
|
||||
{
|
||||
Command cmd("HDEL");
|
||||
|
||||
cmd << hash << field;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hdel(const std::string& hash, const StringVec& fields)
|
||||
{
|
||||
Command cmd("HDEL");
|
||||
|
||||
cmd << hash << fields;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hexists(const std::string& hash, const std::string& field)
|
||||
{
|
||||
Command cmd("HEXISTS");
|
||||
|
||||
cmd << hash << field;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hget(const std::string& hash, const std::string& field)
|
||||
{
|
||||
Command cmd("HGET");
|
||||
|
||||
cmd << hash << field;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hgetall(const std::string& hash)
|
||||
{
|
||||
Command cmd("HGETALL");
|
||||
|
||||
cmd << hash;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hincrby(const std::string& hash, const std::string& field, Int64 by)
|
||||
{
|
||||
Command cmd("HINCRBY");
|
||||
|
||||
cmd << hash << field << NumberFormatter::format(by);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hkeys(const std::string& hash)
|
||||
{
|
||||
Command cmd("HKEYS");
|
||||
|
||||
cmd << hash;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hlen(const std::string& hash)
|
||||
{
|
||||
Command cmd("HLEN");
|
||||
|
||||
cmd << hash;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hmget(const std::string& hash, const StringVec& fields)
|
||||
{
|
||||
Command cmd("HMGET");
|
||||
|
||||
cmd << hash << fields;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hmset(const std::string& hash, std::map<std::string, std::string>& fields)
|
||||
{
|
||||
Command cmd("HMSET");
|
||||
|
||||
cmd << hash;
|
||||
for(std::map<std::string, std::string>::const_iterator it = fields.begin(); it != fields.end(); ++it)
|
||||
{
|
||||
cmd << it->first << it->second;
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hset(const std::string& hash, const std::string& field, const std::string& value, bool create)
|
||||
{
|
||||
Command cmd(create ? "HSET" : "HSETNX");
|
||||
|
||||
cmd << hash << field << value;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hset(const std::string& hash, const std::string& field, Int64 value, bool create)
|
||||
{
|
||||
return hset(hash, field, NumberFormatter::format(value), create);
|
||||
}
|
||||
|
||||
Command Command::hstrlen(const std::string& hash, const std::string& field)
|
||||
{
|
||||
Command cmd("HSTRLEN");
|
||||
|
||||
cmd << hash << field;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::hvals(const std::string& hash)
|
||||
{
|
||||
Command cmd("HVALS");
|
||||
|
||||
cmd << hash;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::incr(const std::string& key, Int64 by)
|
||||
{
|
||||
Command cmd(by == 0 ? "INCR" : "INCRBY");
|
||||
|
||||
cmd << key;
|
||||
if ( by > 0 ) cmd << NumberFormatter::format(by);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::lindex(const std::string& list, Int64 index)
|
||||
{
|
||||
Command cmd("LINDEX");
|
||||
|
||||
cmd << list << NumberFormatter::format(index);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::linsert(const std::string& list, bool before, const std::string& reference, const std::string& value)
|
||||
{
|
||||
Command cmd("LINSERT");
|
||||
|
||||
cmd << list << (before ? "BEFORE" : "AFTER") << reference << value;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::llen(const std::string& list)
|
||||
{
|
||||
Command cmd("LLEN");
|
||||
|
||||
cmd << list;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::lpop(const std::string& list)
|
||||
{
|
||||
Command cmd("LPOP");
|
||||
|
||||
cmd << list;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::lpush(const std::string& list, const std::string& value, bool create)
|
||||
{
|
||||
Command cmd(create ? "LPUSH" : "LPUSHX");
|
||||
|
||||
cmd << list << value;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::lpush(const std::string& list, const StringVec& values, bool create)
|
||||
{
|
||||
Command cmd(create ? "LPUSH" : "LPUSHX");
|
||||
|
||||
cmd << list << values;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::lrange(const std::string& list, Int64 start, Int64 stop)
|
||||
{
|
||||
Command cmd("LRANGE");
|
||||
|
||||
cmd << list << NumberFormatter::format(start) << NumberFormatter::format(stop);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::lrem(const std::string& list, Int64 count, const std::string& value)
|
||||
{
|
||||
Command cmd("LREM");
|
||||
|
||||
cmd << list << NumberFormatter::format(count) << value;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::lset(const std::string& list, Int64 index, const std::string& value)
|
||||
{
|
||||
Command cmd("LSET");
|
||||
|
||||
cmd << list << NumberFormatter::format(index) << value;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::ltrim(const std::string& list, Int64 start, Int64 stop)
|
||||
{
|
||||
Command cmd("LTRIM");
|
||||
|
||||
cmd << list << NumberFormatter::format(start) << NumberFormatter::format(stop);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::mget(const StringVec& keys)
|
||||
{
|
||||
Command cmd("MGET");
|
||||
|
||||
cmd << keys;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::mset(const std::map<std::string, std::string>& keyvalues, bool create)
|
||||
{
|
||||
Command cmd(create ? "MSET" : "MSETNX");
|
||||
|
||||
for(std::map<std::string, std::string>::const_iterator it = keyvalues.begin(); it != keyvalues.end(); ++it)
|
||||
{
|
||||
cmd << it->first << it->second;
|
||||
}
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sadd(const std::string& set, const std::string& value)
|
||||
{
|
||||
Command cmd("SADD");
|
||||
|
||||
cmd << set << value;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sadd(const std::string& set, const StringVec& values)
|
||||
{
|
||||
Command cmd("SADD");
|
||||
|
||||
cmd << set << values;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::scard(const std::string& set)
|
||||
{
|
||||
Command cmd("SCARD");
|
||||
|
||||
cmd << set;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sdiff(const std::string& set1, const std::string& set2)
|
||||
{
|
||||
Command cmd("SDIFF");
|
||||
|
||||
cmd << set1 << set2;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sdiff(const std::string& set, const StringVec& sets)
|
||||
{
|
||||
Command cmd("SDIFF");
|
||||
|
||||
cmd << set << sets;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sdiffstore(const std::string& set, const std::string& set1, const std::string& set2)
|
||||
{
|
||||
Command cmd("SDIFFSTORE");
|
||||
|
||||
cmd << set << set1 << set2;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sdiffstore(const std::string& set, const StringVec& sets)
|
||||
{
|
||||
Command cmd("SDIFFSTORE");
|
||||
|
||||
cmd << set << sets;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::set(const std::string& key, const std::string& value, bool overwrite, const Poco::Timespan& expireTime, bool create)
|
||||
{
|
||||
Command cmd("SET");
|
||||
|
||||
cmd << key << value;
|
||||
if (! overwrite) cmd << "NX";
|
||||
if (! create) cmd << "XX";
|
||||
if (expireTime.totalMicroseconds() > 0) cmd << "PX" << expireTime.totalMilliseconds();
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::set(const std::string& key, Int64 value, bool overwrite, const Poco::Timespan& expireTime, bool create)
|
||||
{
|
||||
return set(key, NumberFormatter::format(value), overwrite, expireTime, create);
|
||||
}
|
||||
|
||||
Command Command::sinter(const std::string& set1, const std::string& set2)
|
||||
{
|
||||
Command cmd("SINTER");
|
||||
|
||||
cmd << set1 << set2;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sinter(const std::string& set, const StringVec& sets)
|
||||
{
|
||||
Command cmd("SINTER");
|
||||
|
||||
cmd << set << sets;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sinterstore(const std::string& set, const std::string& set1, const std::string& set2)
|
||||
{
|
||||
Command cmd("SINTERSTORE");
|
||||
|
||||
cmd << set << set1 << set2;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sinterstore(const std::string& set, const StringVec& sets)
|
||||
{
|
||||
Command cmd("SINTERSTORE");
|
||||
|
||||
cmd << set << sets;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sismember(const std::string& set, const std::string& member)
|
||||
{
|
||||
Command cmd("SISMEMBER");
|
||||
|
||||
cmd << set << member;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::smembers(const std::string& set)
|
||||
{
|
||||
Command cmd("SMEMBERS");
|
||||
|
||||
cmd << set;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::smove(const std::string& source, const std::string& destination, const std::string& member)
|
||||
{
|
||||
Command cmd("SMOVE");
|
||||
|
||||
cmd << source << destination << member;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::spop(const std::string& set, Int64 count)
|
||||
{
|
||||
Command cmd("SPOP");
|
||||
|
||||
cmd << set;
|
||||
if( count != 0 ) cmd << NumberFormatter::format(count);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::srandmember(const std::string& set, Int64 count)
|
||||
{
|
||||
Command cmd("SRANDMEMBER");
|
||||
|
||||
cmd << set;
|
||||
if( count != 0 ) cmd << NumberFormatter::format(count);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::srem(const std::string& set1, const std::string& member)
|
||||
{
|
||||
Command cmd("SREM");
|
||||
|
||||
cmd << set1 << member;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::srem(const std::string& set, const StringVec& members)
|
||||
{
|
||||
Command cmd("SREM");
|
||||
|
||||
cmd << set << members;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sunion(const std::string& set1, const std::string& set2)
|
||||
{
|
||||
Command cmd("SUNION");
|
||||
|
||||
cmd << set1 << set2;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sunion(const std::string& set, const StringVec& sets)
|
||||
{
|
||||
Command cmd("SUNION");
|
||||
|
||||
cmd << set << sets;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sunionstore(const std::string& set, const std::string& set1, const std::string& set2)
|
||||
{
|
||||
Command cmd("SUNIONSTORE");
|
||||
|
||||
cmd << set << set1 << set2;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::sunionstore(const std::string& set, const StringVec& sets)
|
||||
{
|
||||
Command cmd("SUNIONSTORE");
|
||||
|
||||
cmd << set << sets;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::rename(const std::string& key, const std::string& newName, bool overwrite)
|
||||
{
|
||||
Command cmd(overwrite ? "RENAME" : "RENAMENX");
|
||||
|
||||
cmd << key << newName;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
Command Command::rpop(const std::string& list)
|
||||
{
|
||||
Command cmd("RPOP");
|
||||
|
||||
cmd << list;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::rpoplpush(const std::string& sourceList, const std::string& destinationList)
|
||||
{
|
||||
Command cmd("RPOPLPUSH");
|
||||
|
||||
cmd << sourceList << destinationList;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::rpush(const std::string& list, const std::string& value, bool create)
|
||||
{
|
||||
Command cmd(create ? "RPUSH" : "RPUSHX");
|
||||
|
||||
cmd << list << value;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Command Command::rpush(const std::string& list, const StringVec& values, bool create)
|
||||
{
|
||||
Command cmd(create ? "RPUSH" : "RPUSHX");
|
||||
|
||||
cmd << list << values;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
}} // Poco::Redis
|
35
Redis/src/Error.cpp
Normal file
35
Redis/src/Error.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// Error.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Error
|
||||
//
|
||||
// Implementation of the Error class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#include "Poco/Redis/Error.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
Error::Error()
|
||||
{
|
||||
}
|
||||
|
||||
Error::Error(const std::string& message) : _message(message)
|
||||
{
|
||||
}
|
||||
|
||||
Error::~Error()
|
||||
{
|
||||
}
|
||||
|
||||
} }
|
25
Redis/src/Exception.cpp
Normal file
25
Redis/src/Exception.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// Exception.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Exception
|
||||
//
|
||||
// Implementation of the Exception class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#include "Poco/Redis/Exception.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
POCO_IMPLEMENT_EXCEPTION(RedisException, Exception, "Redis Exception")
|
||||
|
||||
}}
|
43
Redis/src/RedisEventArgs.cpp
Normal file
43
Redis/src/RedisEventArgs.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
//
|
||||
// RedisEventArgs.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: RedisEventArgs
|
||||
//
|
||||
// Implementation of the RedisEventArgs class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#include "Poco/Redis/RedisEventArgs.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
RedisEventArgs::RedisEventArgs(RedisType::Ptr message) :
|
||||
_message(message),
|
||||
_exception(0),
|
||||
_stop(false)
|
||||
{
|
||||
}
|
||||
|
||||
RedisEventArgs::RedisEventArgs(Exception* exception) :
|
||||
_message(),
|
||||
_exception(exception ? exception->clone() : 0),
|
||||
_stop(false)
|
||||
{
|
||||
}
|
||||
|
||||
RedisEventArgs::~RedisEventArgs()
|
||||
{
|
||||
delete _exception;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace Poco::Redis
|
108
Redis/src/RedisStream.cpp
Normal file
108
Redis/src/RedisStream.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
//
|
||||
// RedisStream.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: RedisStream
|
||||
//
|
||||
// Implementation of the RedisStream class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
#include <iostream>
|
||||
#include "Poco/Redis/RedisStream.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
|
||||
RedisStreamBuf::RedisStreamBuf(Net::StreamSocket& redis):
|
||||
BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in | std::ios::out),
|
||||
_redis(redis)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RedisStreamBuf::~RedisStreamBuf()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int RedisStreamBuf::readFromDevice(char* buffer, std::streamsize len)
|
||||
{
|
||||
return _redis.receiveBytes(buffer, len);
|
||||
}
|
||||
|
||||
|
||||
int RedisStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
|
||||
{
|
||||
return _redis.sendBytes(buffer, length);
|
||||
}
|
||||
|
||||
RedisIOS::RedisIOS(Net::StreamSocket& redis):
|
||||
_buf(redis)
|
||||
{
|
||||
poco_ios_init(&_buf);
|
||||
}
|
||||
|
||||
|
||||
RedisIOS::~RedisIOS()
|
||||
{
|
||||
try
|
||||
{
|
||||
_buf.sync();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RedisStreamBuf* RedisIOS::rdbuf()
|
||||
{
|
||||
return &_buf;
|
||||
}
|
||||
|
||||
|
||||
void RedisIOS::close()
|
||||
{
|
||||
_buf.sync();
|
||||
}
|
||||
|
||||
RedisOutputStream::RedisOutputStream(Net::StreamSocket& redis):
|
||||
RedisIOS(redis),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RedisOutputStream::~RedisOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
RedisInputStream::RedisInputStream(Net::StreamSocket& redis):
|
||||
RedisIOS(redis),
|
||||
std::istream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RedisInputStream::~RedisInputStream()
|
||||
{
|
||||
}
|
||||
|
||||
std::string RedisInputStream::getline()
|
||||
{
|
||||
std::string line;
|
||||
std::getline(*this, line);
|
||||
if ( line.size() > 0 ) line.erase(line.end() - 1);
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
}}
|
61
Redis/src/Type.cpp
Normal file
61
Redis/src/Type.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// Type.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Library: Redis
|
||||
// Package: Redis
|
||||
// Module: Type
|
||||
//
|
||||
// Implementation of the Type class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
#include "Poco/Redis/Type.h"
|
||||
#include "Poco/Redis/Error.h"
|
||||
#include "Poco/Redis/Array.h"
|
||||
|
||||
namespace Poco {
|
||||
namespace Redis {
|
||||
|
||||
|
||||
RedisType::RedisType()
|
||||
{
|
||||
}
|
||||
|
||||
RedisType::~RedisType()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RedisType::Ptr RedisType::createRedisType(char marker)
|
||||
{
|
||||
RedisType::Ptr result;
|
||||
|
||||
switch(marker)
|
||||
{
|
||||
case RedisTypeTraits<Int64>::marker :
|
||||
result = new Type<Int64>();
|
||||
break;
|
||||
case RedisTypeTraits<std::string>::marker :
|
||||
result = new Type<std::string>();
|
||||
break;
|
||||
case RedisTypeTraits<BulkString>::marker :
|
||||
result = new Type<BulkString>();
|
||||
break;
|
||||
case RedisTypeTraits<Array>::marker :
|
||||
result = new Type<Array>();
|
||||
break;
|
||||
case RedisTypeTraits<Error>::marker :
|
||||
result = new Type<Error>();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}}
|
23
Redis/testsuite/CMakeLists.txt
Normal file
23
Redis/testsuite/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
||||
set(TESTUNIT "${LIBNAME}-testrunner")
|
||||
|
||||
# Sources
|
||||
file(GLOB SRCS_G "src/*.cpp")
|
||||
POCO_SOURCES_AUTO( TEST_SRCS ${SRCS_G})
|
||||
|
||||
# Headers
|
||||
file(GLOB_RECURSE HDRS_G "src/*.h" )
|
||||
POCO_HEADERS_AUTO( TEST_SRCS ${HDRS_G})
|
||||
|
||||
POCO_SOURCES_AUTO_PLAT( TEST_SRCS OFF
|
||||
src/WinDriver.cpp
|
||||
)
|
||||
|
||||
POCO_SOURCES_AUTO_PLAT( TEST_SRCS WINCE
|
||||
src/WinCEDriver.cpp
|
||||
)
|
||||
|
||||
set(TESTUNIT "${LIBNAME}-testrunner")
|
||||
|
||||
add_executable( ${TESTUNIT} ${TEST_SRCS} )
|
||||
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
|
||||
target_link_libraries( ${TESTUNIT} PocoRedis PocoFoundation CppUnit )
|
17
Redis/testsuite/Makefile
Normal file
17
Redis/testsuite/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# Makefile for Poco Redis testsuite
|
||||
#
|
||||
|
||||
include $(POCO_BASE)/build/rules/global
|
||||
|
||||
objects = Driver RedisTest RedisTestSuite
|
||||
|
||||
target = testrunner
|
||||
target_version = 1
|
||||
target_libs = PocoRedis PocoFoundation PocoNet CppUnit
|
||||
|
||||
include $(POCO_BASE)/build/rules/exec
|
9
Redis/testsuite/TestSuite.progen
Normal file
9
Redis/testsuite/TestSuite.progen
Normal file
@ -0,0 +1,9 @@
|
||||
vc.project.guid = ${vc.project.guidFromName}
|
||||
vc.project.name = TestSuite
|
||||
vc.project.target = TestSuite
|
||||
vc.project.type = testsuite
|
||||
vc.project.pocobase = ..\\..
|
||||
vc.project.platforms = Win32, x64
|
||||
vc.project.configurations = debug_shared, release_shared, debug_static_mt, release_static_mt, debug_static_md, release_static_md
|
||||
vc.project.prototype = TestSuite_vs90.vcproj
|
||||
vc.project.compiler.include = ..\\..\\Foundation\\include;..\\..\\Net\\include
|
464
Redis/testsuite/TestSuite_x64_vs90.vcproj
Normal file
464
Redis/testsuite/TestSuite_x64_vs90.vcproj
Normal file
@ -0,0 +1,464 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
Name="TestSuite"
|
||||
Version="9.00"
|
||||
ProjectType="Visual C++"
|
||||
ProjectGUID="{96CF3103-E49E-3F5E-A11D-6DBCDA043053}"
|
||||
RootNamespace="TestSuite"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="x64"/>
|
||||
</Platforms>
|
||||
<ToolFiles/>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="debug_shared|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;WINVER=0x0501;"
|
||||
StringPooling="true"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
BufferSecurityCheck="true"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib "
|
||||
OutputFile="bin64\TestSuited.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="..\..\lib64"
|
||||
SuppressStartupBanner="true"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="bin64\TestSuited.pdb"
|
||||
SubSystem="2"
|
||||
TargetMachine="17"
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCALinkTool"/>
|
||||
<Tool
|
||||
Name="VCManifestTool"/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="release_shared|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="4"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;WINVER=0x0501;"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="false"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="CppUnit.lib WinTestRunner.lib "
|
||||
OutputFile="bin64\TestSuite.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\lib64"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="17"
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCALinkTool"/>
|
||||
<Tool
|
||||
Name="VCManifestTool"/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="debug_static_mt|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="4"
|
||||
AdditionalIncludeDirectories="..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;WINVER=0x0501;POCO_STATIC;"
|
||||
StringPooling="true"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
BufferSecurityCheck="true"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="CppUnitmtd.lib WinTestRunnermtd.lib iphlpapi.lib winmm.lib nafxcwd.lib libcmtd.lib WinTestRunner.res "
|
||||
OutputFile="bin64\static_mt\TestSuited.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="..\..\lib64"
|
||||
IgnoreDefaultLibraryNames="nafxcwd.lib;libcmtd.lib"
|
||||
SuppressStartupBanner="true"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="bin64\static_mt\TestSuited.pdb"
|
||||
SubSystem="2"
|
||||
TargetMachine="17"
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCALinkTool"/>
|
||||
<Tool
|
||||
Name="VCManifestTool"/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="release_static_mt|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="4"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;WINVER=0x0501;POCO_STATIC;"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="false"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="CppUnitmt.lib WinTestRunnermt.lib iphlpapi.lib winmm.lib nafxcw.lib libcmt.lib WinTestRunner.res "
|
||||
OutputFile="bin64\static_mt\TestSuite.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\lib64"
|
||||
IgnoreDefaultLibraryNames="nafxcw.lib;libcmt.lib"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="17"
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCALinkTool"/>
|
||||
<Tool
|
||||
Name="VCManifestTool"/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="debug_static_md|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="4"
|
||||
AdditionalIncludeDirectories="..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;WINVER=0x0501;POCO_STATIC;"
|
||||
StringPooling="true"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
BufferSecurityCheck="true"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="CppUnitmdd.lib WinTestRunnermdd.lib iphlpapi.lib winmm.lib WinTestRunner.res "
|
||||
OutputFile="bin64\static_md\TestSuited.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="..\..\lib64"
|
||||
SuppressStartupBanner="true"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="bin64\static_md\TestSuited.pdb"
|
||||
SubSystem="2"
|
||||
TargetMachine="17"
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCALinkTool"/>
|
||||
<Tool
|
||||
Name="VCManifestTool"/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="release_static_md|x64"
|
||||
OutputDirectory="obj64\$(ConfigurationName)"
|
||||
IntermediateDirectory="obj64\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="4"
|
||||
InlineFunctionExpansion="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include;..\..\Foundation\include;..\..\Net\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;WINVER=0x0501;POCO_STATIC;"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="false"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
ForceConformanceInForLoopScope="true"
|
||||
RuntimeTypeInfo="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="0"
|
||||
DisableSpecificWarnings=""
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="CppUnitmd.lib WinTestRunnermd.lib iphlpapi.lib winmm.lib WinTestRunner.res "
|
||||
OutputFile="bin64\static_md\TestSuite.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\lib64"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="17"
|
||||
AdditionalOptions=""/>
|
||||
<Tool
|
||||
Name="VCALinkTool"/>
|
||||
<Tool
|
||||
Name="VCManifestTool"/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References/>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files">
|
||||
<File
|
||||
RelativePath=".\src\RedisTest.cpp"/>
|
||||
<File
|
||||
RelativePath=".\src\RedisTestSuite.cpp"/>
|
||||
<File
|
||||
RelativePath=".\src\WinDriver.cpp"/>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files">
|
||||
<File
|
||||
RelativePath=".\src\RedisTest.h"/>
|
||||
<File
|
||||
RelativePath=".\src\RedisTestSuite.h"/>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals/>
|
||||
</VisualStudioProject>
|
19
Redis/testsuite/src/Driver.cpp
Normal file
19
Redis/testsuite/src/Driver.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// Driver.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Console-based test driver for Poco MongoDB.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include "RedisTestSuite.h"
|
||||
|
||||
|
||||
CppUnitMain(RedisTestSuite)
|
2958
Redis/testsuite/src/RedisTest.cpp
Normal file
2958
Redis/testsuite/src/RedisTest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
106
Redis/testsuite/src/RedisTest.h
Normal file
106
Redis/testsuite/src/RedisTest.h
Normal file
@ -0,0 +1,106 @@
|
||||
//
|
||||
// RedisTest.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Definition of the RedisTest class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef RedisTest_INCLUDED
|
||||
#define RedisTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Redis/Redis.h"
|
||||
#include "Poco/Redis/Client.h"
|
||||
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class RedisTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
RedisTest(const std::string& name);
|
||||
|
||||
|
||||
virtual ~RedisTest();
|
||||
|
||||
void testAPPEND();
|
||||
void testBLPOP();
|
||||
void testBRPOP();
|
||||
void testDECR();
|
||||
void testECHO();
|
||||
void testError();
|
||||
void testEVAL();
|
||||
void testHDEL();
|
||||
void testHEXISTS();
|
||||
void testHGETALL();
|
||||
void testHINCRBY();
|
||||
void testHKEYS();
|
||||
void testHMGET();
|
||||
void testHMSET();
|
||||
void testHSET();
|
||||
void testHSTRLEN();
|
||||
void testHVALS();
|
||||
void testINCR();
|
||||
void testINCRBY();
|
||||
void testLINDEX();
|
||||
void testLINSERT();
|
||||
void testLPOP();
|
||||
void testLREM();
|
||||
void testLSET();
|
||||
void testLTRIM();
|
||||
void testMULTI();
|
||||
void testMSET();
|
||||
void testMSETWithMap();
|
||||
void testPING();
|
||||
void testPipeliningWithSendCommands();
|
||||
void testPipeliningWithWriteCommand();
|
||||
void testPubSub();
|
||||
void testSADD();
|
||||
void testSCARD();
|
||||
void testSDIFF();
|
||||
void testSDIFFSTORE();
|
||||
void testSET();
|
||||
void testSINTER();
|
||||
void testSINTERSTORE();
|
||||
void testSISMEMBER();
|
||||
void testSMEMBERS();
|
||||
void testSMOVE();
|
||||
void testSPOP();
|
||||
void testSRANDMEMBER();
|
||||
void testSREM();
|
||||
void testSUNION();
|
||||
void testSUNIONSTORE();
|
||||
void testSTRLEN();
|
||||
void testRENAME();
|
||||
void testRENAMENX();
|
||||
void testRPOP();
|
||||
void testRPOPLPUSH();
|
||||
void testRPUSH();
|
||||
|
||||
void testPool();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
|
||||
void delKey(const std::string& key);
|
||||
|
||||
std::string _host;
|
||||
unsigned _port;
|
||||
static bool _connected;
|
||||
static Poco::Redis::Client _redis;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // RedisTest_INCLUDED
|
24
Redis/testsuite/src/RedisTestSuite.cpp
Normal file
24
Redis/testsuite/src/RedisTestSuite.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
//
|
||||
// RedisTestSuite.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "RedisTestSuite.h"
|
||||
#include "RedisTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* RedisTestSuite::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("RedisTestSuite");
|
||||
|
||||
pSuite->addTest(RedisTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
29
Redis/testsuite/src/RedisTestSuite.h
Normal file
29
Redis/testsuite/src/RedisTestSuite.h
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// RedisTestSuite.h
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Definition of the RedisTestSuite class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef RedisTestSuite_INCLUDED
|
||||
#define RedisTestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
|
||||
class RedisTestSuite
|
||||
{
|
||||
public:
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // RedisTestSuite_INCLUDED
|
32
Redis/testsuite/src/WinCEDriver.cpp
Normal file
32
Redis/testsuite/src/WinCEDriver.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// WinCEDriver.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Console-based test driver for Windows CE.
|
||||
//
|
||||
// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include "RedisTestSuite.h"
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
int _tmain(int argc, wchar_t* argv[])
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
char buffer[1024];
|
||||
std::wcstombs(buffer, argv[i], sizeof(buffer));
|
||||
args.push_back(std::string(buffer));
|
||||
}
|
||||
CppUnit::TestRunner runner;
|
||||
runner.addTest("RedisTestSuite", RedisTestSuite::suite());
|
||||
return runner.run(args) ? 0 : 1;
|
||||
}
|
30
Redis/testsuite/src/WinDriver.cpp
Normal file
30
Redis/testsuite/src/WinDriver.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// WinDriver.cpp
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Windows test driver for Poco MongoDB.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "WinTestRunner/WinTestRunner.h"
|
||||
#include "RedisTestSuite.h"
|
||||
|
||||
|
||||
class TestDriver: public CppUnit::WinTestRunnerApp
|
||||
{
|
||||
void TestMain()
|
||||
{
|
||||
CppUnit::WinTestRunner runner;
|
||||
runner.addTest(RedisTestSuite::suite());
|
||||
runner.run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TestDriver theDriver;
|
@ -19,6 +19,7 @@
|
||||
#include "Poco/FileStream.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#undef min
|
||||
#include <algorithm>
|
||||
@ -40,7 +41,7 @@ CompressTest::~CompressTest()
|
||||
void CompressTest::testSingleFile()
|
||||
{
|
||||
std::ofstream out("appinf.zip", std::ios::binary);
|
||||
Poco::Path theFile(ZipTest::getTestFile("test.zip"));
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
ZipArchive a(c.close());
|
||||
@ -75,14 +76,14 @@ void CompressTest::testManipulator()
|
||||
{
|
||||
{
|
||||
std::ofstream out("appinf.zip", std::ios::binary);
|
||||
Poco::Path theFile(ZipTest::getTestFile("test.zip"));
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
ZipArchive a(c.close());
|
||||
}
|
||||
ZipManipulator zm("appinf.zip", true);
|
||||
zm.renameFile("test.zip", "renamedtest.zip");
|
||||
zm.addFile("doc/othertest.zip", ZipTest::getTestFile("test.zip"));
|
||||
zm.addFile("doc/othertest.zip", ZipTest::getTestFile("data", "test.zip"));
|
||||
ZipArchive archive=zm.commit();
|
||||
assert (archive.findHeader("doc/othertest.zip") != archive.headerEnd());
|
||||
}
|
||||
@ -92,14 +93,14 @@ void CompressTest::testManipulatorDel()
|
||||
{
|
||||
{
|
||||
std::ofstream out("appinf.zip", std::ios::binary);
|
||||
Poco::Path theFile(ZipTest::getTestFile("test.zip"));
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
ZipArchive a(c.close());
|
||||
}
|
||||
ZipManipulator zm("appinf.zip", true);
|
||||
zm.deleteFile("test.zip");
|
||||
zm.addFile("doc/data.zip", ZipTest::getTestFile("data.zip"));
|
||||
zm.addFile("doc/data.zip", ZipTest::getTestFile("data", "data.zip"));
|
||||
ZipArchive archive=zm.commit();
|
||||
assert (archive.findHeader("test.zip") == archive.headerEnd());
|
||||
assert (archive.findHeader("doc/data.zip") != archive.headerEnd());
|
||||
@ -110,13 +111,13 @@ void CompressTest::testManipulatorReplace()
|
||||
{
|
||||
{
|
||||
std::ofstream out("appinf.zip", std::ios::binary);
|
||||
Poco::Path theFile(ZipTest::getTestFile("test.zip"));
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
ZipArchive a(c.close());
|
||||
}
|
||||
ZipManipulator zm("appinf.zip", true);
|
||||
zm.replaceFile("test.zip", ZipTest::getTestFile("doc.zip"));
|
||||
zm.replaceFile("test.zip", ZipTest::getTestFile("data", "doc.zip"));
|
||||
|
||||
ZipArchive archive=zm.commit();
|
||||
assert (archive.findHeader("test.zip") != archive.headerEnd());
|
||||
@ -128,7 +129,7 @@ void CompressTest::testSetZipComment()
|
||||
{
|
||||
std::string comment("Testing...123...");
|
||||
std::ofstream out("comment.zip", std::ios::binary);
|
||||
Poco::Path theFile(ZipTest::getTestFile("test.zip"));
|
||||
Poco::Path theFile(ZipTest::getTestFile("data", "test.zip"));
|
||||
Compress c(out, true);
|
||||
c.addFile(theFile, theFile.getFileName());
|
||||
c.setZipComment(comment);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#undef min
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
@ -46,7 +47,7 @@ ZipTest::~ZipTest()
|
||||
|
||||
void ZipTest::testSkipSingleFile()
|
||||
{
|
||||
std::string testFile = getTestFile("test.zip");
|
||||
std::string testFile = getTestFile("data", "test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
assert (inp.good());
|
||||
SkipCallback skip;
|
||||
@ -68,7 +69,7 @@ void ZipTest::testSkipSingleFile()
|
||||
|
||||
void ZipTest::testDecompressSingleFile()
|
||||
{
|
||||
std::string testFile = getTestFile("test.zip");
|
||||
std::string testFile = getTestFile("data", "test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
assert (inp.good());
|
||||
ZipArchive arch(inp);
|
||||
@ -83,7 +84,7 @@ void ZipTest::testDecompressSingleFile()
|
||||
|
||||
void ZipTest::testDecompressSingleFileInDir()
|
||||
{
|
||||
std::string testFile = getTestFile("test.zip");
|
||||
std::string testFile = getTestFile("data","test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
assert (inp.good());
|
||||
ZipArchive arch(inp);
|
||||
@ -98,7 +99,7 @@ void ZipTest::testDecompressSingleFileInDir()
|
||||
|
||||
void ZipTest::testCrcAndSizeAfterData()
|
||||
{
|
||||
std::string testFile = getTestFile("data.zip");
|
||||
std::string testFile = getTestFile("data", "data.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
assert (inp.good());
|
||||
Decompress dec(inp, Poco::Path());
|
||||
@ -112,7 +113,7 @@ void ZipTest::testCrcAndSizeAfterData()
|
||||
|
||||
void ZipTest::testCrcAndSizeAfterDataWithArchive()
|
||||
{
|
||||
std::string testFile = getTestFile("data.zip");
|
||||
std::string testFile = getTestFile("data", "data.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
assert (inp.good());
|
||||
Poco::Zip::ZipArchive zip(inp);
|
||||
@ -132,30 +133,34 @@ void ZipTest::testCrcAndSizeAfterDataWithArchive()
|
||||
}
|
||||
|
||||
|
||||
std::string ZipTest::getTestFile(const std::string& testFile)
|
||||
std::string ZipTest::getTestFile(const std::string& directory, const std::string& file)
|
||||
{
|
||||
Poco::Path root;
|
||||
root.makeAbsolute();
|
||||
Poco::Path result;
|
||||
while (!Poco::Path::find(root.toString(), "data", result))
|
||||
std::ostringstream ostr;
|
||||
ostr << directory << '/' << file;
|
||||
std::string validDir(ostr.str());
|
||||
Poco::Path pathPattern(validDir);
|
||||
if (Poco::File(pathPattern).exists())
|
||||
{
|
||||
root.makeParent();
|
||||
if (root.toString().empty() || root.toString() == "/")
|
||||
throw Poco::FileNotFoundException("Didn't find data subdir");
|
||||
return validDir;
|
||||
}
|
||||
result.makeDirectory();
|
||||
result.setFileName(testFile);
|
||||
Poco::File aFile(result.toString());
|
||||
if (!aFile.exists() || (aFile.exists() && !aFile.isFile()))
|
||||
throw Poco::FileNotFoundException("Didn't find " + testFile);
|
||||
|
||||
return result.toString();
|
||||
|
||||
ostr.str("");
|
||||
ostr << "/Zip/testsuite/" << directory << '/' << file;
|
||||
validDir = Poco::Environment::get("POCO_BASE") + ostr.str();
|
||||
pathPattern = validDir;
|
||||
|
||||
if (!Poco::File(pathPattern).exists())
|
||||
{
|
||||
std::cout << "Can't find " << validDir << std::endl;
|
||||
throw Poco::NotFoundException("cannot locate directory containing valid Zip test files");
|
||||
}
|
||||
return validDir;
|
||||
}
|
||||
|
||||
|
||||
void ZipTest::testDecompress()
|
||||
{
|
||||
std::string testFile = getTestFile("test.zip");
|
||||
std::string testFile = getTestFile("data", "test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
assert (inp.good());
|
||||
Decompress dec(inp, Poco::Path());
|
||||
@ -169,7 +174,7 @@ void ZipTest::testDecompress()
|
||||
|
||||
void ZipTest::testDecompressFlat()
|
||||
{
|
||||
std::string testFile = getTestFile("test.zip");
|
||||
std::string testFile = getTestFile("data", "test.zip");
|
||||
std::ifstream inp(testFile.c_str(), std::ios::binary);
|
||||
assert (inp.good());
|
||||
Decompress dec(inp, Poco::Path(), true);
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
static std::string getTestFile(const std::string& testFile);
|
||||
static std::string getTestFile(const std::string& directory, const std::string& type);
|
||||
|
||||
private:
|
||||
void onDecompressError(const void* pSender, std::pair<const Poco::Zip::ZipLocalFileHeader, const std::string>& info);
|
||||
|
@ -20,7 +20,7 @@ CXX = g++
|
||||
LINK = $(CXX)
|
||||
LIB = ar -cr
|
||||
RANLIB = ranlib
|
||||
SHLIB = $(CXX) -shared -o $@ -Wl,--out-implib=$(dir $@)$(subst cyg,lib,$(notdir $@)).a -Wl,--export-all-symbols -Wl,--enable-auto-import
|
||||
SHLIB = $(CXX) -shared -o $@
|
||||
SHLIBLN = $(POCO_BASE)/build/script/shlibln
|
||||
STRIP =
|
||||
DEP = $(POCO_BASE)/build/script/makedepend.gcc
|
||||
@ -33,18 +33,25 @@ MKDIR = mkdir -p
|
||||
# Extension for Shared Libraries
|
||||
#
|
||||
LIBPREFIX = cyg
|
||||
SHAREDLIBEXT = .$(target_version).dll
|
||||
SHAREDLIBEXT = -$(target_version).dll
|
||||
SHAREDLIBLINKEXT = .dll
|
||||
|
||||
IMPPREFIX = lib
|
||||
IMPLIBEXT = -$(target_version).dll.a
|
||||
IMPLIBLINKEXT = .dll.a
|
||||
|
||||
#
|
||||
# Compiler and Linker Flags
|
||||
#
|
||||
CFLAGS =
|
||||
CFLAGS32 =
|
||||
CFLAGS64 =
|
||||
CXXFLAGS = -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -Wa,-mbig-obj
|
||||
CXXFLAGS32 =
|
||||
CXXFLAGS64 =
|
||||
CXXFLAGS = -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING
|
||||
CXXFLAGS32 = -Wa,-mbig-obj
|
||||
CXXFLAGS64 = -Wa,-mbig-obj
|
||||
SHLIBFLAGS = -Wl,--out-implib=$(dir $@)$(subst cyg,lib,$(notdir $@)).a -Wl,--export-all-symbols -Wl,--enable-auto-import
|
||||
SHLIBFLAGS32 =
|
||||
SHLIBFLAGS64 =
|
||||
LINKFLAGS =
|
||||
LINKFLAGS32 =
|
||||
LINKFLAGS64 =
|
||||
|
@ -44,6 +44,12 @@ CFLAGS64 = -m64
|
||||
CXXFLAGS = -Wall -Wno-sign-compare
|
||||
CXXFLAGS32 = -m32
|
||||
CXXFLAGS64 = -m64
|
||||
SHLIBFLAGS =
|
||||
SHLIBFLAGS32 = -m32
|
||||
SHLIBFLAGS64 = -m64
|
||||
LIBFLAGS =
|
||||
LIBFLAGS32 =
|
||||
LIBFLAGS64 =
|
||||
LINKFLAGS =
|
||||
LINKFLAGS32 = -m32
|
||||
LINKFLAGS64 = -m64
|
||||
|
@ -22,13 +22,13 @@ DYLIB = $(SHLIB)
|
||||
DYLIBFLAGS = $(SHLIBFLAGS)
|
||||
endif
|
||||
|
||||
DYLIB_DEBUG = $(BINPATH)/$(target)d$(OSARCH_POSTFIX)$(SHL_EXT)
|
||||
DYLIB_RELEASE = $(BINPATH)/$(target)$(OSARCH_POSTFIX)$(SHL_EXT)
|
||||
DYLIB_S_DEBUG = $(BINPATH)/static/$(target)d$(OSARCH_POSTFIX)$(SHL_EXT)
|
||||
DYLIB_S_RELEASE = $(BINPATH)/static/$(target)$(OSARCH_POSTFIX)$(SHL_EXT)
|
||||
DYLIB_DEBUG = $(BINPATH)/$(target)d$(SHL_EXT)
|
||||
DYLIB_RELEASE = $(BINPATH)/$(target)$(SHL_EXT)
|
||||
DYLIB_S_DEBUG = $(BINPATH)/static/$(target)d$(SHL_EXT)
|
||||
DYLIB_S_RELEASE = $(BINPATH)/static/$(target)$(SHL_EXT)
|
||||
|
||||
TARGET_LIBS_DEBUG = $(foreach l,$(target_libs),-l$(l)d$(OSARCH_POSTFIX))
|
||||
TARGET_LIBS_RELEASE = $(foreach l,$(target_libs),-l$(l)$(OSARCH_POSTFIX))
|
||||
TARGET_LIBS_DEBUG = $(foreach l,$(target_libs),-l$(l)d)
|
||||
TARGET_LIBS_RELEASE = $(foreach l,$(target_libs),-l$(l))
|
||||
|
||||
#
|
||||
# Include the compile rules
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user