Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/pocoproject/poco into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
cristiantm committed Jun 5, 2014
2 parents 73b07c0 + 6512ff1 commit d67f6be
Show file tree
Hide file tree
Showing 150 changed files with 3,111 additions and 1,177 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ Release 1.5.3 (2014-05-xx)
- fixed GH #442: Use correct prefix length field of Windows IP_ADAPTER_PREFIX structure
- improved GH #328: NetworkInterface on Windows XP
- fixed GH #154 Add support for MYSQL_TYPE_NEWDECIMAL to Poco::Data::MySQL
- fixed GH #290: Unicode support
- fixed GH #318: Logger local time doesn't automatically account for DST
- fixed GH #363: DateTimeParser tryParse/parse
- added HTMLForm Content-Length calculation (Rangel Reale)
- Make TemporaryFile append a slash to tempDir
- fixed GH #319 android build with cmake
- added hasDelegates() method to AbstractEvent
- fixed GH #230: Poco::Timer problem
- fixed GH #317: Poco::Zip does not support newer Zip file versions.


Release 1.5.2 (2013-09-16)
==========================
Expand Down
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ if(CMAKE_SYSTEM MATCHES "Windows")

endif(CMAKE_SYSTEM MATCHES "Windows")

if (CMAKE_SYSTEM MATCHES "Linux")
if (CMAKE_SYSTEM MATCHES "Linux" AND NOT ANDROID )
add_definitions( -DPOCO_OS_FAMILY_UNIX )
# Standard 'must be' defines
add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64)
set(SYSLIBS pthread dl rt)
endif(CMAKE_SYSTEM MATCHES "Linux")
endif(CMAKE_SYSTEM MATCHES "Linux" AND NOT ANDROID )

if (CMAKE_SYSTEM MATCHES "SunOS")
add_definitions( -DPOCO_OS_FAMILY_UNIX )
Expand Down Expand Up @@ -149,6 +149,11 @@ if (IOS)
add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES )
endif(IOS)

#ANDROID
if (ANDROID)
add_definitions( -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY )
endif()

IF (ENABLE_TESTS)
add_subdirectory(CppUnit)
ENDIF ()
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Cristian Thiago Moecke
Sergei Nikulov
Aaron Kaluszka
Iyed Bennour
Scott Davis
Kristin Cowalcijk

--
$Id$
4 changes: 3 additions & 1 deletion Crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ install(

install(
TARGETS ${LIBNAME}
DESTINATION lib
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
RUNTIME DESTINATION bin
)

if (ENABLE_TESTS)
Expand Down
4 changes: 3 additions & 1 deletion Data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ install(

install(
TARGETS ${LIBNAME}
DESTINATION lib
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
RUNTIME DESTINATION bin
)

add_subdirectory( SQLite )
Expand Down
4 changes: 3 additions & 1 deletion Data/MySQL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ install(

install(
TARGETS ${LIBNAME}
DESTINATION lib
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
RUNTIME DESTINATION bin
)

if (ENABLE_TESTS)
Expand Down
4 changes: 3 additions & 1 deletion Data/ODBC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ install(

install(
TARGETS ${LIBNAME}
DESTINATION lib
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
RUNTIME DESTINATION bin
)

if (ENABLE_TESTS)
Expand Down
125 changes: 112 additions & 13 deletions Data/ODBC/include/Poco/Data/ODBC/Binder.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,18 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
void bind(std::size_t pos, const std::list<std::string>& val, Direction dir);
/// Binds a string list.

void bind(std::size_t pos, const UTF16String& val, Direction dir);
/// Binds a string.

void bind(std::size_t pos, const std::vector<UTF16String>& val, Direction dir);
/// Binds a string vector.

void bind(std::size_t pos, const std::deque<UTF16String>& val, Direction dir);
/// Binds a string deque.

void bind(std::size_t pos, const std::list<UTF16String>& val, Direction dir);
/// Binds a string list.

void bind(std::size_t pos, const BLOB& val, Direction dir);
/// Binds a BLOB. In-bound only.

Expand Down Expand Up @@ -341,18 +353,20 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
/// Clears the cached storage.

private:
typedef std::vector<SQLLEN*> LengthVec;
typedef std::vector<std::vector<SQLLEN> > LengthVecVec;
typedef std::vector<char*> CharPtrVec;
typedef std::vector<bool*> BoolPtrVec;
typedef std::vector<std::vector<SQL_DATE_STRUCT> > DateVec;
typedef std::vector<std::vector<SQL_TIME_STRUCT> > TimeVec;
typedef std::vector<std::vector<SQL_TIMESTAMP_STRUCT> > DateTimeVec;
typedef std::vector<std::vector<Poco::Any> > AnyVec;
typedef std::map<char*, std::string*> StringMap;
typedef std::map<SQL_DATE_STRUCT*, Date*> DateMap;
typedef std::map<SQL_TIME_STRUCT*, Time*> TimeMap;
typedef std::map<SQL_TIMESTAMP_STRUCT*, DateTime*> TimestampMap;
typedef std::vector<SQLLEN*> LengthVec;
typedef std::vector<std::vector<SQLLEN> > LengthVecVec;
typedef std::vector<char*> CharPtrVec;
typedef std::vector<UTF16Char*> UTF16CharPtrVec;
typedef std::vector<bool*> BoolPtrVec;
typedef std::vector<std::vector<SQL_DATE_STRUCT> > DateVec;
typedef std::vector<std::vector<SQL_TIME_STRUCT> > TimeVec;
typedef std::vector<std::vector<SQL_TIMESTAMP_STRUCT> > DateTimeVec;
typedef std::vector<std::vector<Poco::Any> > AnyVec;
typedef std::map<char*, std::string*> StringMap;
typedef std::map<UTF16String::value_type*, UTF16String*> UTF16StringMap;
typedef std::map<SQL_DATE_STRUCT*, Date*> DateMap;
typedef std::map<SQL_TIME_STRUCT*, Time*> TimeMap;
typedef std::map<SQL_TIMESTAMP_STRUCT*, DateTime*> TimestampMap;

void describeParameter(std::size_t pos);
/// Sets the description field for the parameter, if needed.
Expand Down Expand Up @@ -581,6 +595,71 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
}
}

template <typename C>
void bindImplContainerUTF16String(std::size_t pos, const C& val, Direction dir)
/// Utility function to bind containers of strings.
{
if (isOutBound(dir) || !isInBound(dir))
throw NotImplementedException("String container parameter type can only be inbound.");

if (PB_IMMEDIATE != _paramBinding)
throw InvalidAccessException("Containers can only be bound immediately.");

if (0 == val.size())
throw InvalidArgumentException("Empty container not allowed.");

setParamSetSize(val.size());

SQLINTEGER size = 0;
getColumnOrParameterSize(pos, size);
poco_assert(size > 0);

if (size == _maxFieldSize)
{
getMinValueSize(val, size);
// accomodate for terminating zero
if (size != _maxFieldSize) size += sizeof(UTF16Char);
}

if (_vecLengthIndicator.size() <= pos)
{
_vecLengthIndicator.resize(pos + 1);
_vecLengthIndicator[pos].resize(val.size(), SQL_NTS);
}

if (_utf16CharPtrs.size() <= pos)
_utf16CharPtrs.resize(pos + 1, 0);

_utf16CharPtrs[pos] = (UTF16Char*)std::calloc(val.size() * size, sizeof(UTF16Char));

std::size_t strSize;
std::size_t offset = 0;
typename C::const_iterator it = val.begin();
typename C::const_iterator end = val.end();
for (; it != end; ++it)
{
strSize = it->size() * sizeof(UTF16Char);
if (strSize > size)
throw LengthExceededException("SQLBindParameter(std::vector<UTF16String>)");
std::memcpy(_utf16CharPtrs[pos] + offset, it->data(), strSize);
offset += (size / sizeof(UTF16Char));
}

if (Utility::isError(SQLBindParameter(_rStmt,
(SQLUSMALLINT)pos + 1,
toODBCDirection(dir),
SQL_C_WCHAR,
SQL_WLONGVARCHAR,
(SQLUINTEGER)size - 1,
0,
_utf16CharPtrs[pos],
(SQLINTEGER)size,
&_vecLengthIndicator[pos][0])))
{
throw StatementException(_rStmt, "SQLBindParameter(std::vector<UTF16String>)");
}
}

template <typename C>
void bindImplContainerLOB(std::size_t pos, const C& val, Direction dir)
{
Expand Down Expand Up @@ -859,7 +938,7 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
typename T::const_iterator end = val.end();
for (; it != end; ++it)
{
std::size_t sz = it->size();
std::size_t sz = it->size() * sizeof(T);
if (sz > _maxFieldSize)
throw LengthExceededException();

Expand Down Expand Up @@ -888,11 +967,13 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
TimeMap _times;
TimestampMap _timestamps;
StringMap _strings;
UTF16StringMap _utf16Strings;

DateVec _dateVec;
TimeVec _timeVec;
DateTimeVec _dateTimeVec;
CharPtrVec _charPtrs;
UTF16CharPtrVec _utf16CharPtrs;
BoolPtrVec _boolPtrs;
const TypeInfo* _pTypeInfo;
SQLINTEGER _paramSetSize;
Expand Down Expand Up @@ -1241,6 +1322,24 @@ inline void Binder::bind(std::size_t pos, const std::list<std::string>& val, Dir
bindImplContainerString(pos, val, dir);
}


inline void Binder::bind(std::size_t pos, const std::vector<UTF16String>& val, Direction dir)
{
bindImplContainerUTF16String(pos, val, dir);
}


inline void Binder::bind(std::size_t pos, const std::deque<UTF16String>& val, Direction dir)
{
bindImplContainerUTF16String(pos, val, dir);
}


inline void Binder::bind(std::size_t pos, const std::list<UTF16String>& val, Direction dir)
{
bindImplContainerUTF16String(pos, val, dir);
}

inline void Binder::bind(std::size_t pos, const BLOB& val, Direction dir)
{
bindImplLOB<BLOB>(pos, val, dir);
Expand Down
54 changes: 52 additions & 2 deletions Data/ODBC/include/Poco/Data/ODBC/Extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "Poco/Any.h"
#include "Poco/Dynamic/Var.h"
#include "Poco/Nullable.h"
#include "Poco/UTFString.h"
#include "Poco/Exception.h"
#include <map>
#ifdef POCO_OS_FAMILY_WINDOWS
Expand Down Expand Up @@ -232,6 +233,19 @@ class ODBC_API Extractor: public Poco::Data::AbstractExtractor

bool extract(std::size_t pos, std::list<std::string>& val);
/// Extracts a string list.
/// Extracts a single character list.

bool extract(std::size_t pos, UTF16String& val);
/// Extracts a string.

bool extract(std::size_t pos, std::vector<UTF16String>& val);
/// Extracts a string vector.

bool extract(std::size_t pos, std::deque<UTF16String>& val);
/// Extracts a string deque.

bool extract(std::size_t pos, std::list<UTF16String>& val);
/// Extracts a string list.

bool extract(std::size_t pos, Poco::Data::BLOB& val);
/// Extracts a BLOB.
Expand Down Expand Up @@ -372,7 +386,10 @@ class ODBC_API Extractor: public Poco::Data::AbstractExtractor

bool extractBoundImplContainer(std::size_t pos, std::vector<std::string>& values);
bool extractBoundImplContainer(std::size_t pos, std::deque<std::string>& values);
bool extractBoundImplContainer(std::size_t pos, std::list<std::string>& values);
bool extractBoundImplContainer(std::size_t pos, std::list<std::string>& values);
bool extractBoundImplContainer(std::size_t pos, std::vector<Poco::UTF16String>& values);
bool extractBoundImplContainer(std::size_t pos, std::deque<Poco::UTF16String>& values);
bool extractBoundImplContainer(std::size_t pos, std::list<Poco::UTF16String>& values);
bool extractBoundImplContainer(std::size_t pos, std::vector<Poco::Data::CLOB>& values);
bool extractBoundImplContainer(std::size_t pos, std::deque<Poco::Data::CLOB>& values);
bool extractBoundImplContainer(std::size_t pos, std::list<Poco::Data::CLOB>& values);
Expand All @@ -394,7 +411,19 @@ class ODBC_API Extractor: public Poco::Data::AbstractExtractor
ItType it = values.begin();
ItType end = values.end();
for (int row = 0; it != end; ++it, ++row)
it->assign(*pc + row * colWidth, _pPreparator->actualDataSize(pos, row));
{
it->assign(*pc + row * colWidth / sizeof(CharType), _pPreparator->actualDataSize(pos, row));
// clean up superfluous null chars returned by some drivers
typename StringType::size_type trimLen = 0;
typename StringType::reverse_iterator sIt = it->rbegin();
typename StringType::reverse_iterator sEnd = it->rend();
for (; sIt != sEnd; ++sIt)
{
if (*sIt == '\0') ++trimLen;
else break;
}
if (trimLen) it->assign(it->begin(), it->begin() + it->length() - trimLen);
}

return true;
}
Expand Down Expand Up @@ -522,6 +551,9 @@ class ODBC_API Extractor: public Poco::Data::AbstractExtractor
case MetaColumn::FDT_STRING:
{ return extAny<T, std::string>(pos, val); }

case MetaColumn::FDT_WSTRING:
{ return extAny<T, Poco::UTF16String>(pos, val); }

case MetaColumn::FDT_BLOB:
{ return extAny<T, Poco::Data::BLOB>(pos, val); }

Expand Down Expand Up @@ -592,6 +624,24 @@ inline bool Extractor::extractBoundImplContainer(std::size_t pos, std::list<std:
}


inline bool Extractor::extractBoundImplContainer(std::size_t pos, std::vector<Poco::UTF16String>& values)
{
return extractBoundImplContainerString(pos, values);
}


inline bool Extractor::extractBoundImplContainer(std::size_t pos, std::deque<Poco::UTF16String>& values)
{
return extractBoundImplContainerString(pos, values);
}


inline bool Extractor::extractBoundImplContainer(std::size_t pos, std::list<Poco::UTF16String>& values)
{
return extractBoundImplContainerString(pos, values);
}


inline bool Extractor::extractBoundImplContainer(std::size_t pos,
std::vector<Poco::Data::CLOB>& values)
{
Expand Down
Loading

0 comments on commit d67f6be

Please sign in to comment.