mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-11-02 15:27:19 +01:00
Update POCO library.
This commit is contained in:
32
vendor/POCO/Data/src/AbstractBinder.cpp
vendored
32
vendor/POCO/Data/src/AbstractBinder.cpp
vendored
@@ -16,6 +16,7 @@
|
||||
#include "Poco/Data/Date.h"
|
||||
#include "Poco/Data/Time.h"
|
||||
#include "Poco/Data/LOB.h"
|
||||
#include "Poco/Data/Transcoder.h"
|
||||
#include "Poco/Data/DataException.h"
|
||||
#include "Poco/DateTime.h"
|
||||
#include "Poco/Any.h"
|
||||
@@ -26,13 +27,42 @@ namespace Poco {
|
||||
namespace Data {
|
||||
|
||||
|
||||
AbstractBinder::AbstractBinder()
|
||||
AbstractBinder::AbstractBinder(Poco::TextEncoding::Ptr pFromEncoding,
|
||||
Poco::TextEncoding::Ptr pDBEncoding) :
|
||||
_pTranscoder(Transcoder::create(pFromEncoding, pDBEncoding))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AbstractBinder::~AbstractBinder()
|
||||
{
|
||||
if (_pStrings)
|
||||
{
|
||||
for (auto& s : *_pStrings)
|
||||
delete s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AbstractBinder::transcode(const std::string& from, std::string& to)
|
||||
{
|
||||
if (_pTranscoder)
|
||||
_pTranscoder->transcode(from, to);
|
||||
}
|
||||
|
||||
|
||||
void AbstractBinder::reverseTranscode(const std::string& from, std::string& to)
|
||||
{
|
||||
if (_pTranscoder)
|
||||
_pTranscoder->reverseTranscode(from, to);
|
||||
}
|
||||
|
||||
|
||||
const std::string& AbstractBinder::toString(const UUID& uuid)
|
||||
{
|
||||
if (!_pStrings) _pStrings.reset(new StringList);
|
||||
_pStrings->push_back(new std::string(uuid.toString()));
|
||||
return *_pStrings->back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
6
vendor/POCO/Data/src/AbstractBinding.cpp
vendored
6
vendor/POCO/Data/src/AbstractBinding.cpp
vendored
@@ -19,9 +19,9 @@ namespace Poco {
|
||||
namespace Data {
|
||||
|
||||
|
||||
AbstractBinding::AbstractBinding(const std::string& name,
|
||||
Direction direction,
|
||||
Poco::UInt32 bulkSize):
|
||||
AbstractBinding::AbstractBinding(const std::string& name,
|
||||
Direction direction,
|
||||
Poco::UInt32 bulkSize):
|
||||
_pBinder(0),
|
||||
_name(name),
|
||||
_direction(direction),
|
||||
|
||||
4
vendor/POCO/Data/src/AbstractExtraction.cpp
vendored
4
vendor/POCO/Data/src/AbstractExtraction.cpp
vendored
@@ -21,8 +21,8 @@ namespace Data {
|
||||
|
||||
AbstractExtraction::AbstractExtraction(Poco::UInt32 limit,
|
||||
Poco::UInt32 position,
|
||||
bool bulk):
|
||||
_pExtractor(0),
|
||||
bool bulk):
|
||||
_pExtractor(0),
|
||||
_limit(limit),
|
||||
_position(position),
|
||||
_bulk(bulk),
|
||||
|
||||
19
vendor/POCO/Data/src/AbstractExtractor.cpp
vendored
19
vendor/POCO/Data/src/AbstractExtractor.cpp
vendored
@@ -13,6 +13,7 @@
|
||||
|
||||
|
||||
#include "Poco/Data/AbstractExtractor.h"
|
||||
#include "Poco/Data/Transcoder.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
@@ -20,7 +21,9 @@ namespace Poco {
|
||||
namespace Data {
|
||||
|
||||
|
||||
AbstractExtractor::AbstractExtractor()
|
||||
AbstractExtractor::AbstractExtractor(Poco::TextEncoding::Ptr pDBEncoding,
|
||||
Poco::TextEncoding::Ptr pToEncoding):
|
||||
_pTranscoder(Transcoder::create(pDBEncoding, pToEncoding))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,6 +33,20 @@ AbstractExtractor::~AbstractExtractor()
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtractor::transcode(const std::string& from, std::string& to)
|
||||
{
|
||||
if (_pTranscoder)
|
||||
_pTranscoder->transcode(from, to);
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtractor::reverseTranscode(const std::string& from, std::string& to)
|
||||
{
|
||||
if (_pTranscoder)
|
||||
_pTranscoder->reverseTranscode(from, to);
|
||||
}
|
||||
|
||||
|
||||
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int8>& val)
|
||||
{
|
||||
throw NotImplementedException("std::vector extractor must be implemented.");
|
||||
|
||||
14
vendor/POCO/Data/src/ArchiveStrategy.cpp
vendored
14
vendor/POCO/Data/src/ArchiveStrategy.cpp
vendored
@@ -30,8 +30,8 @@ const std::string ArchiveStrategy::DEFAULT_ARCHIVE_DESTINATION = "T_POCO_LOG_ARC
|
||||
|
||||
|
||||
ArchiveStrategy::ArchiveStrategy(const std::string& connector,
|
||||
const std::string& connect,
|
||||
const std::string& source,
|
||||
const std::string& connect,
|
||||
const std::string& source,
|
||||
const std::string& destination):
|
||||
_connector(connector),
|
||||
_connect(connect),
|
||||
@@ -61,9 +61,9 @@ void ArchiveStrategy::open()
|
||||
//
|
||||
|
||||
|
||||
ArchiveByAgeStrategy::ArchiveByAgeStrategy(const std::string& connector,
|
||||
const std::string& connect,
|
||||
const std::string& sourceTable,
|
||||
ArchiveByAgeStrategy::ArchiveByAgeStrategy(const std::string& connector,
|
||||
const std::string& connect,
|
||||
const std::string& sourceTable,
|
||||
const std::string& destinationTable):
|
||||
ArchiveStrategy(connector, connect, sourceTable, destinationTable)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ void ArchiveByAgeStrategy::setThreshold(const std::string& age)
|
||||
while (it != end && Ascii::isSpace(*it)) ++it;
|
||||
std::string unit;
|
||||
while (it != end && Ascii::isAlpha(*it)) unit += *it++;
|
||||
|
||||
|
||||
Timespan::TimeDiff factor = Timespan::SECONDS;
|
||||
if (unit == "minutes")
|
||||
factor = Timespan::MINUTES;
|
||||
@@ -138,7 +138,7 @@ void ArchiveByAgeStrategy::setThreshold(const std::string& age)
|
||||
factor = 30*Timespan::DAYS;
|
||||
else if (unit != "seconds")
|
||||
throw InvalidArgumentException("setMaxAge", age);
|
||||
|
||||
|
||||
_maxAge = factor * n;
|
||||
}
|
||||
|
||||
|
||||
4
vendor/POCO/Data/src/Date.cpp
vendored
4
vendor/POCO/Data/src/Date.cpp
vendored
@@ -61,7 +61,7 @@ void Date::assign(int year, int month, int day)
|
||||
throw InvalidArgumentException("Month must be between 1 and 12");
|
||||
|
||||
if (day < 1 || day > DateTime::daysOfMonth(year, month))
|
||||
throw InvalidArgumentException("Month must be between 1 and " +
|
||||
throw InvalidArgumentException("Month must be between 1 and " +
|
||||
NumberFormatter::format(DateTime::daysOfMonth(year, month)));
|
||||
|
||||
_year = year;
|
||||
@@ -80,7 +80,7 @@ bool Date::operator < (const Date& date) const
|
||||
{
|
||||
int month = date.month();
|
||||
if (_month < month) return true;
|
||||
else
|
||||
else
|
||||
if (_month > month) return false;
|
||||
else // months equal
|
||||
if (_day < date.day()) return true;
|
||||
|
||||
189
vendor/POCO/Data/src/JSONRowFormatter.cpp
vendored
Normal file
189
vendor/POCO/Data/src/JSONRowFormatter.cpp
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
//
|
||||
// JSONRowFormatter.cpp
|
||||
//
|
||||
// Library: Data
|
||||
// Package: DataCore
|
||||
// Module: JSONRowFormatter
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Data/JSONRowFormatter.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/JSONString.h"
|
||||
#include "Poco/Format.h"
|
||||
|
||||
|
||||
using Poco::trimInPlace;
|
||||
using Poco::format;
|
||||
using Poco::toJSON;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
|
||||
|
||||
const int JSONRowFormatter::JSON_FMT_MODE_SMALL;
|
||||
const int JSONRowFormatter::JSON_FMT_MODE_ROW_COUNT;
|
||||
const int JSONRowFormatter::JSON_FMT_MODE_COLUMN_NAMES;
|
||||
const int JSONRowFormatter::JSON_FMT_MODE_FULL;
|
||||
|
||||
|
||||
JSONRowFormatter::JSONRowFormatter(int mode) : RowFormatter("{", "]}"),
|
||||
_firstTime(true)
|
||||
{
|
||||
if (mode == JSON_FMT_MODE_FULL)
|
||||
{
|
||||
mode |= JSON_FMT_MODE_ROW_COUNT;
|
||||
mode |= JSON_FMT_MODE_COLUMN_NAMES;
|
||||
}
|
||||
|
||||
setJSONMode(mode);
|
||||
}
|
||||
|
||||
|
||||
JSONRowFormatter::~JSONRowFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void JSONRowFormatter::adjustPrefix() const
|
||||
{
|
||||
if (printRowCount())
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << "{\"count\":" << getTotalRowCount() << ",";
|
||||
if (_mode & JSON_FMT_MODE_FULL)
|
||||
ostr << '[';
|
||||
setPrefix(ostr.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void JSONRowFormatter::setJSONMode(int mode)
|
||||
{
|
||||
if (mode < JSON_FMT_MODE_SMALL ||
|
||||
mode > (JSON_FMT_MODE_SMALL | JSON_FMT_MODE_ROW_COUNT | JSON_FMT_MODE_COLUMN_NAMES | JSON_FMT_MODE_FULL))
|
||||
{
|
||||
throw Poco::InvalidArgumentException(
|
||||
Poco::format("JSONRowFormatter mode must be between "
|
||||
"%d (JSON_FMT_MODE_SMALL) and %d (JSON_FMT_MODE_FULL)",
|
||||
JSON_FMT_MODE_SMALL,
|
||||
JSON_FMT_MODE_FULL));
|
||||
}
|
||||
|
||||
_mode = mode;
|
||||
if (!(_mode & JSON_FMT_MODE_SMALL) && !(_mode & JSON_FMT_MODE_FULL))
|
||||
_mode |= JSON_FMT_MODE_SMALL;
|
||||
else if (_mode & JSON_FMT_MODE_FULL)
|
||||
{
|
||||
_mode |= JSON_FMT_MODE_ROW_COUNT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string& JSONRowFormatter::formatValues(const ValueVec& vals, std::string& formattedValues)
|
||||
{
|
||||
std::ostringstream str;
|
||||
if (!_firstTime) str << ',';
|
||||
if (isSmall())
|
||||
{
|
||||
if (_firstTime)
|
||||
{
|
||||
if (printColumnNames())
|
||||
str << ",\"values\":";
|
||||
|
||||
str << '[';
|
||||
}
|
||||
|
||||
str << '[';
|
||||
ValueVec::const_iterator it = vals.begin();
|
||||
ValueVec::const_iterator end = vals.end();
|
||||
for (; it != end;)
|
||||
{
|
||||
if (!it->isEmpty())
|
||||
{
|
||||
if (it->isString() || it->isDate() || it->isTime())
|
||||
{
|
||||
std::string val = it->convert<std::string>();
|
||||
trimInPlace(val);
|
||||
str << toJSON(val);
|
||||
}
|
||||
else
|
||||
str << it->convert<std::string>();
|
||||
}
|
||||
else
|
||||
str << "null";
|
||||
|
||||
if (++it == end) break;
|
||||
|
||||
str << ',';
|
||||
}
|
||||
str << ']';
|
||||
}
|
||||
else if (isFull())
|
||||
{
|
||||
str << '{';
|
||||
ValueVec::const_iterator it = vals.begin();
|
||||
ValueVec::const_iterator end = vals.end();
|
||||
NameVec::iterator nIt = _pNames->begin();
|
||||
NameVec::iterator nEnd = _pNames->end();
|
||||
for (; it != end && nIt != nEnd; ++nIt)
|
||||
{
|
||||
if (!it->isEmpty())
|
||||
{
|
||||
if (it->isString() || it->isDate() || it->isTime())
|
||||
{
|
||||
std::string val = it->convert<std::string>();
|
||||
trimInPlace(val);
|
||||
str << '"' << *nIt << "\":" << toJSON(val);
|
||||
}
|
||||
else
|
||||
str << '"' << *nIt << "\":" << it->convert<std::string>();
|
||||
}
|
||||
else
|
||||
str << '"' << *nIt << "\":null";
|
||||
|
||||
if (++it != end) str << ',';
|
||||
}
|
||||
str << '}';
|
||||
}
|
||||
|
||||
_firstTime = false;
|
||||
return formattedValues = str.str();
|
||||
}
|
||||
|
||||
|
||||
std::string& JSONRowFormatter::formatNames(const NameVecPtr pNames, std::string& formattedNames)
|
||||
{
|
||||
//adjustPrefix();
|
||||
if (isFull())
|
||||
{
|
||||
// names are used in formatValues
|
||||
if (pNames && !_pNames) _pNames = pNames;
|
||||
return formattedNames = "";
|
||||
}
|
||||
else if (printColumnNames())
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << "\"names\":[";
|
||||
for (NameVec::const_iterator it = pNames->begin(),
|
||||
end = pNames->end();;)
|
||||
{
|
||||
ostr << '"' << *it << '"';
|
||||
if (++it == end) break;
|
||||
ostr << ',';
|
||||
}
|
||||
ostr << "]";
|
||||
return formattedNames = ostr.str();
|
||||
}
|
||||
|
||||
return formattedNames = "";
|
||||
}
|
||||
|
||||
|
||||
} }// namespace Poco::Data
|
||||
2
vendor/POCO/Data/src/MetaColumn.cpp
vendored
2
vendor/POCO/Data/src/MetaColumn.cpp
vendored
@@ -92,7 +92,7 @@ MetaColumn& MetaColumn::operator = (MetaColumn&& other) noexcept
|
||||
}
|
||||
|
||||
|
||||
void MetaColumn::swap(MetaColumn& other)
|
||||
void MetaColumn::swap(MetaColumn& other) noexcept
|
||||
{
|
||||
std::swap(_name, other._name);
|
||||
std::swap(_length, other._length);
|
||||
|
||||
1
vendor/POCO/Data/src/RecordSet.cpp
vendored
1
vendor/POCO/Data/src/RecordSet.cpp
vendored
@@ -160,6 +160,7 @@ Poco::Dynamic::Var RecordSet::value(std::size_t col, std::size_t row, bool useFi
|
||||
case MetaColumn::FDT_TIME: return value<Time>(col, row, useFilter);
|
||||
case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(col, row);
|
||||
case MetaColumn::FDT_UUID: return value<UUID>(col, row);
|
||||
case MetaColumn::FDT_JSON: return value<std::string>(col, row, useFilter);
|
||||
default:
|
||||
throw UnknownTypeException("Data type not supported.");
|
||||
}
|
||||
|
||||
22
vendor/POCO/Data/src/Row.cpp
vendored
22
vendor/POCO/Data/src/Row.cpp
vendored
@@ -29,7 +29,7 @@ std::ostream& operator << (std::ostream &os, const Row& row)
|
||||
}
|
||||
|
||||
|
||||
Row::Row():
|
||||
Row::Row():
|
||||
_pNames(0),
|
||||
_pSortMap(new SortMap),
|
||||
_pFormatter(new SimpleRowFormatter)
|
||||
@@ -63,9 +63,9 @@ void Row::init(const SortMapPtr& pSortMap, const RowFormatter::Ptr& pFormatter)
|
||||
if (sz)
|
||||
{
|
||||
_values.resize(sz);
|
||||
// Row sortability in the strict weak ordering sense is
|
||||
// Row sortability in the strict weak ordering sense is
|
||||
// an invariant, hence we must start with a zero here.
|
||||
// If null value is later retrieved from DB, the
|
||||
// If null value is later retrieved from DB, the
|
||||
// Var::empty() call should be used to empty
|
||||
// the corresponding Row value.
|
||||
_values[0] = 0;
|
||||
@@ -102,7 +102,7 @@ std::size_t Row::getPosition(const std::string& name)
|
||||
std::size_t col = 0;
|
||||
for (; it != end; ++it, ++col)
|
||||
if (0 == icompare(name, *it)) return col;
|
||||
|
||||
|
||||
throw NotFoundException(name);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ void Row::addSortField(std::size_t pos)
|
||||
SortMap::iterator end = _pSortMap->end();
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
if (it->get<0>() == pos) return;
|
||||
if (it->get<0>() == pos) return;
|
||||
}
|
||||
|
||||
ComparisonType ct;
|
||||
@@ -295,16 +295,16 @@ bool Row::operator < (const Row& other) const
|
||||
return false;
|
||||
|
||||
case COMPARE_AS_INTEGER:
|
||||
if (_values[it->get<0>()].convert<Poco::Int64>() <
|
||||
if (_values[it->get<0>()].convert<Poco::Int64>() <
|
||||
other._values[it->get<0>()].convert<Poco::Int64>())
|
||||
return true;
|
||||
else if (_values[it->get<0>()].convert<Poco::Int64>() !=
|
||||
else if (_values[it->get<0>()].convert<Poco::Int64>() !=
|
||||
other._values[it->get<0>()].convert<Poco::Int64>())
|
||||
return false;
|
||||
break;
|
||||
|
||||
case COMPARE_AS_FLOAT:
|
||||
if (_values[it->get<0>()].convert<double>() <
|
||||
if (_values[it->get<0>()].convert<double>() <
|
||||
other._values[it->get<0>()].convert<double>())
|
||||
return true;
|
||||
else if (_values[it->get<0>()].convert<double>() !=
|
||||
@@ -313,7 +313,7 @@ bool Row::operator < (const Row& other) const
|
||||
break;
|
||||
|
||||
case COMPARE_AS_STRING:
|
||||
if (_values[it->get<0>()].convert<std::string>() <
|
||||
if (_values[it->get<0>()].convert<std::string>() <
|
||||
other._values[it->get<0>()].convert<std::string>())
|
||||
return true;
|
||||
else if (_values[it->get<0>()].convert<std::string>() !=
|
||||
@@ -334,7 +334,7 @@ void Row::setFormatter(const RowFormatter::Ptr& pFormatter)
|
||||
{
|
||||
if (pFormatter.get())
|
||||
_pFormatter = pFormatter;
|
||||
else
|
||||
else
|
||||
_pFormatter = new SimpleRowFormatter;
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ void Row::setSortMap(const SortMapPtr& pSortMap)
|
||||
{
|
||||
if (pSortMap.get())
|
||||
_pSortMap = pSortMap;
|
||||
else
|
||||
else
|
||||
_pSortMap = new SortMap;
|
||||
}
|
||||
|
||||
|
||||
6
vendor/POCO/Data/src/RowFilter.cpp
vendored
6
vendor/POCO/Data/src/RowFilter.cpp
vendored
@@ -77,7 +77,7 @@ bool RowFilter::isAllowed(std::size_t row) const
|
||||
{
|
||||
Poco::Dynamic::Var retVal;
|
||||
const RecordSet& rs = recordSet();
|
||||
|
||||
|
||||
std::size_t columns = rs.columnCount();
|
||||
ComparisonMap::const_iterator it = _comparisonMap.begin();
|
||||
ComparisonMap::const_iterator end = _comparisonMap.end();
|
||||
@@ -111,7 +111,7 @@ bool RowFilter::isAllowed(std::size_t row) const
|
||||
default:
|
||||
throw IllegalStateException("Unsupported comparison criteria.");
|
||||
}
|
||||
|
||||
|
||||
doCompare(ret, val, compOp, it->second);
|
||||
if (retVal.isEmpty()) retVal = ret;
|
||||
else retVal = retVal || ret;
|
||||
@@ -212,7 +212,7 @@ RecordSet& RowFilter::recordSet() const
|
||||
_pRecordSet = pParent->_pRecordSet;
|
||||
}
|
||||
poco_check_ptr (_pRecordSet);
|
||||
return *_pRecordSet;
|
||||
return *_pRecordSet;
|
||||
}
|
||||
|
||||
|
||||
|
||||
8
vendor/POCO/Data/src/RowFormatter.cpp
vendored
8
vendor/POCO/Data/src/RowFormatter.cpp
vendored
@@ -24,7 +24,7 @@ namespace Data {
|
||||
RowFormatter::RowFormatter(const std::string& prefix,
|
||||
const std::string& postfix,
|
||||
Mode mode):
|
||||
_prefix(prefix),
|
||||
_prefix(prefix),
|
||||
_postfix(postfix),
|
||||
_mode(mode),
|
||||
_totalRowCount(0)
|
||||
@@ -77,4 +77,10 @@ void RowFormatter::reset()
|
||||
}
|
||||
|
||||
|
||||
void RowFormatter::adjustPrefix() const
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Data
|
||||
|
||||
6
vendor/POCO/Data/src/RowIterator.cpp
vendored
6
vendor/POCO/Data/src/RowIterator.cpp
vendored
@@ -26,7 +26,7 @@ namespace Data {
|
||||
const std::size_t RowIterator::POSITION_END = std::numeric_limits<std::size_t>::max();
|
||||
|
||||
|
||||
RowIterator::RowIterator(RecordSet* pRecordSet, bool positionEnd):
|
||||
RowIterator::RowIterator(RecordSet* pRecordSet, bool positionEnd):
|
||||
_pRecordSet(pRecordSet),
|
||||
_position(positionEnd ? POSITION_END : 0)
|
||||
{
|
||||
@@ -67,10 +67,10 @@ RowIterator& RowIterator::operator = (RowIterator&& other) noexcept
|
||||
}
|
||||
|
||||
|
||||
void RowIterator::swap(RowIterator& other)
|
||||
void RowIterator::swap(RowIterator& other) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
|
||||
|
||||
swap(_pRecordSet, other._pRecordSet);
|
||||
swap(_position, other._position);
|
||||
}
|
||||
|
||||
14
vendor/POCO/Data/src/SQLChannel.cpp
vendored
14
vendor/POCO/Data/src/SQLChannel.cpp
vendored
@@ -53,7 +53,7 @@ SQLChannel::SQLChannel():
|
||||
}
|
||||
|
||||
|
||||
SQLChannel::SQLChannel(const std::string& connector,
|
||||
SQLChannel::SQLChannel(const std::string& connector,
|
||||
const std::string& connect,
|
||||
const std::string& name):
|
||||
_connector(connector),
|
||||
@@ -93,7 +93,7 @@ void SQLChannel::open()
|
||||
initLogStatement();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SQLChannel::close()
|
||||
{
|
||||
wait();
|
||||
@@ -110,9 +110,9 @@ void SQLChannel::log(const Message& msg)
|
||||
void SQLChannel::logAsync(const Message& msg)
|
||||
{
|
||||
poco_check_ptr (_pLogStatement);
|
||||
if (0 == wait() && !_pLogStatement->done() && !_pLogStatement->initialized())
|
||||
if (0 == wait() && !_pLogStatement->done() && !_pLogStatement->initialized())
|
||||
{
|
||||
if (_throw)
|
||||
if (_throw)
|
||||
throw TimeoutException("Timed out waiting for previous statement completion");
|
||||
else return;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ void SQLChannel::logSync(const Message& msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SQLChannel::setProperty(const std::string& name, const std::string& value)
|
||||
{
|
||||
if (name == PROP_NAME)
|
||||
@@ -222,7 +222,7 @@ void SQLChannel::setProperty(const std::string& name, const std::string& value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string SQLChannel::getProperty(const std::string& name) const
|
||||
{
|
||||
if (name == PROP_NAME)
|
||||
@@ -288,7 +288,7 @@ void SQLChannel::initLogStatement()
|
||||
|
||||
void SQLChannel::registerChannel()
|
||||
{
|
||||
Poco::LoggingFactory::defaultFactory().registerChannelClass("SQLChannel",
|
||||
Poco::LoggingFactory::defaultFactory().registerChannelClass("SQLChannel",
|
||||
new Poco::Instantiator<SQLChannel, Poco::Channel>);
|
||||
}
|
||||
|
||||
|
||||
4
vendor/POCO/Data/src/SessionFactory.cpp
vendored
4
vendor/POCO/Data/src/SessionFactory.cpp
vendored
@@ -83,8 +83,8 @@ Session SessionFactory::create(const std::string& uri,
|
||||
}
|
||||
|
||||
|
||||
SessionFactory::SessionInfo::SessionInfo(Connector* pSI):
|
||||
cnt(1),
|
||||
SessionFactory::SessionInfo::SessionInfo(Connector* pSI):
|
||||
cnt(1),
|
||||
ptrSI(pSI)
|
||||
{
|
||||
}
|
||||
|
||||
11
vendor/POCO/Data/src/SessionPool.cpp
vendored
11
vendor/POCO/Data/src/SessionPool.cpp
vendored
@@ -22,12 +22,13 @@ namespace Poco {
|
||||
namespace Data {
|
||||
|
||||
|
||||
SessionPool::SessionPool(const std::string& connector, const std::string& connectionString, int minSessions, int maxSessions, int idleTime):
|
||||
SessionPool::SessionPool(const std::string& connector, const std::string& connectionString, int minSessions, int maxSessions, int idleTime, int connTimeout):
|
||||
_connector(connector),
|
||||
_connectionString(connectionString),
|
||||
_minSessions(minSessions),
|
||||
_maxSessions(maxSessions),
|
||||
_idleTime(idleTime),
|
||||
_connTimeout(connTimeout),
|
||||
_nSessions(0),
|
||||
_janitorTimer(1000*idleTime, 1000*idleTime/4),
|
||||
_shutdown(false)
|
||||
@@ -72,7 +73,7 @@ Session SessionPool::get()
|
||||
{
|
||||
if (_nSessions < _maxSessions)
|
||||
{
|
||||
Session newSession(SessionFactory::instance().create(_connector, _connectionString));
|
||||
Session newSession(SessionFactory::instance().create(_connector, _connectionString, static_cast<std::size_t>(_connTimeout)));
|
||||
applySettings(newSession.impl());
|
||||
customizeSession(newSession);
|
||||
|
||||
@@ -130,6 +131,12 @@ int SessionPool::idle() const
|
||||
}
|
||||
|
||||
|
||||
int SessionPool::connTimeout() const
|
||||
{
|
||||
return _connTimeout;
|
||||
}
|
||||
|
||||
|
||||
int SessionPool::dead()
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
12
vendor/POCO/Data/src/SessionPoolContainer.cpp
vendored
12
vendor/POCO/Data/src/SessionPoolContainer.cpp
vendored
@@ -51,10 +51,10 @@ void SessionPoolContainer::add(SessionPool* pPool)
|
||||
}
|
||||
|
||||
|
||||
Session SessionPoolContainer::add(const std::string& sessionKey,
|
||||
Session SessionPoolContainer::add(const std::string& sessionKey,
|
||||
const std::string& connectionString,
|
||||
int minSessions,
|
||||
int maxSessions,
|
||||
int minSessions,
|
||||
int maxSessions,
|
||||
int idleTime)
|
||||
{
|
||||
std::string name = SessionPool::name(sessionKey, connectionString);
|
||||
@@ -65,10 +65,10 @@ Session SessionPoolContainer::add(const std::string& sessionKey,
|
||||
// pool already exists, silently return a session from it
|
||||
if (it != _sessionPools.end()) return it->second->get();
|
||||
|
||||
SessionPool* pSP =
|
||||
SessionPool* pSP =
|
||||
new SessionPool(sessionKey, connectionString, minSessions, maxSessions, idleTime);
|
||||
|
||||
std::pair<SessionPoolMap::iterator, bool> ins =
|
||||
std::pair<SessionPoolMap::iterator, bool> ins =
|
||||
_sessionPools.insert(SessionPoolMap::value_type(name, pSP));
|
||||
|
||||
return ins.first->second->get();
|
||||
@@ -78,7 +78,7 @@ Session SessionPoolContainer::add(const std::string& sessionKey,
|
||||
bool SessionPoolContainer::isActive(const std::string& sessionKey,
|
||||
const std::string& connectionString) const
|
||||
{
|
||||
std::string name = connectionString.empty() ?
|
||||
std::string name = connectionString.empty() ?
|
||||
sessionKey : SessionPool::name(sessionKey, connectionString);
|
||||
|
||||
SessionPoolMap::const_iterator it = _sessionPools.find(name);
|
||||
|
||||
4
vendor/POCO/Data/src/SimpleRowFormatter.cpp
vendored
4
vendor/POCO/Data/src/SimpleRowFormatter.cpp
vendored
@@ -49,7 +49,7 @@ SimpleRowFormatter& SimpleRowFormatter::operator = (const SimpleRowFormatter& ro
|
||||
}
|
||||
|
||||
|
||||
void SimpleRowFormatter::swap(SimpleRowFormatter& other)
|
||||
void SimpleRowFormatter::swap(SimpleRowFormatter& other) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
|
||||
@@ -91,7 +91,7 @@ std::string& SimpleRowFormatter::formatValues(const ValueVec& vals, std::string&
|
||||
if (it != vals.begin()) str << space;
|
||||
if (it->isNumeric())
|
||||
{
|
||||
str << std::right
|
||||
str << std::right
|
||||
<< std::fixed
|
||||
<< std::setprecision(2);
|
||||
}
|
||||
|
||||
16
vendor/POCO/Data/src/Statement.cpp
vendored
16
vendor/POCO/Data/src/Statement.cpp
vendored
@@ -89,10 +89,10 @@ Statement& Statement::operator = (Statement&& stmt) noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Statement::swap(Statement& other)
|
||||
void Statement::swap(Statement& other) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
|
||||
|
||||
swap(_pImpl, other._pImpl);
|
||||
swap(_async, other._async);
|
||||
swap(_pAsyncExec, other._pAsyncExec);
|
||||
@@ -116,7 +116,7 @@ std::size_t Statement::execute(bool reset)
|
||||
bool isDone = done();
|
||||
if (initialized() || paused() || isDone)
|
||||
{
|
||||
if (_arguments.size())
|
||||
if (_arguments.size())
|
||||
{
|
||||
_pImpl->formatSQL(_arguments);
|
||||
_arguments.clear();
|
||||
@@ -132,7 +132,7 @@ std::size_t Statement::execute(bool reset)
|
||||
doAsyncExec();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else throw InvalidAccessException("Statement still executing.");
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ Statement& Statement::operator , (const Bulk& bulk)
|
||||
if (!_pImpl->isBulkSupported())
|
||||
throw InvalidAccessException("Bulk not supported by this session.");
|
||||
|
||||
if (0 == _pImpl->extractions().size() &&
|
||||
if (0 == _pImpl->extractions().size() &&
|
||||
0 == _pImpl->bindings().size() &&
|
||||
_pImpl->bulkExtractionAllowed() &&
|
||||
_pImpl->bulkBindingAllowed())
|
||||
@@ -293,8 +293,8 @@ Statement& Statement::operator , (const Bulk& bulk)
|
||||
Statement& Statement::operator , (BulkFnType)
|
||||
{
|
||||
const Limit& limit(_pImpl->extractionLimit());
|
||||
if (limit.isHardLimit() ||
|
||||
limit.isLowerLimit() ||
|
||||
if (limit.isHardLimit() ||
|
||||
limit.isLowerLimit() ||
|
||||
Limit::LIMIT_UNLIMITED == limit.value())
|
||||
{
|
||||
throw InvalidAccessException("Bulk is only allowed with limited extraction,"
|
||||
@@ -311,7 +311,7 @@ Statement& Statement::operator , (BulkFnType)
|
||||
|
||||
Session Statement::session()
|
||||
{
|
||||
Poco::AutoPtr<SessionImpl> ps(&impl()->session(), true);
|
||||
Poco::AutoPtr<SessionImpl> ps(&impl()->session(), true);
|
||||
return Session(ps);
|
||||
}
|
||||
|
||||
|
||||
2
vendor/POCO/Data/src/StatementCreator.cpp
vendored
2
vendor/POCO/Data/src/StatementCreator.cpp
vendored
@@ -57,7 +57,7 @@ StatementCreator& StatementCreator::operator = (StatementCreator&& other) noexce
|
||||
return *this;
|
||||
}
|
||||
|
||||
void StatementCreator::swap(StatementCreator& other)
|
||||
void StatementCreator::swap(StatementCreator& other) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap(_ptrImpl, other._ptrImpl);
|
||||
|
||||
52
vendor/POCO/Data/src/StatementImpl.cpp
vendored
52
vendor/POCO/Data/src/StatementImpl.cpp
vendored
@@ -69,34 +69,40 @@ StatementImpl::~StatementImpl()
|
||||
|
||||
std::size_t StatementImpl::execute(const bool& reset)
|
||||
{
|
||||
if (reset) resetExtraction();
|
||||
|
||||
if (!_rSession.isConnected())
|
||||
{
|
||||
_state = ST_DONE;
|
||||
throw NotConnectedException(_rSession.connectionString());
|
||||
}
|
||||
|
||||
std::size_t lim = 0;
|
||||
if (_lowerLimit > _extrLimit.value())
|
||||
throw LimitException("Illegal Statement state. Upper limit must not be smaller than the lower limit.");
|
||||
|
||||
do
|
||||
try
|
||||
{
|
||||
compile();
|
||||
if (reset) resetExtraction();
|
||||
|
||||
if (!_rSession.isConnected())
|
||||
throw NotConnectedException(_rSession.connectionString());
|
||||
|
||||
if (_lowerLimit > _extrLimit.value())
|
||||
throw LimitException("Illegal Statement state. Upper limit must not be smaller than the lower limit.");
|
||||
|
||||
do
|
||||
{
|
||||
compile();
|
||||
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
|
||||
lim += executeWithoutLimit();
|
||||
else
|
||||
lim += executeWithLimit();
|
||||
} while (canCompile());
|
||||
|
||||
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
|
||||
lim += executeWithoutLimit();
|
||||
else
|
||||
lim += executeWithLimit();
|
||||
} while (canCompile());
|
||||
_state = ST_DONE;
|
||||
|
||||
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
|
||||
if (lim < _lowerLimit)
|
||||
throw LimitException("Did not receive enough data.");
|
||||
|
||||
assignSubTotal(reset);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_state = ST_DONE;
|
||||
|
||||
if (lim < _lowerLimit)
|
||||
throw LimitException("Did not receive enough data.");
|
||||
|
||||
assignSubTotal(reset);
|
||||
throw;
|
||||
}
|
||||
|
||||
return lim;
|
||||
}
|
||||
@@ -353,6 +359,8 @@ void StatementImpl::makeExtractors(std::size_t count)
|
||||
addInternalExtract<DateTime>(mc); break;
|
||||
case MetaColumn::FDT_UUID:
|
||||
addInternalExtract<UUID>(mc); break;
|
||||
case MetaColumn::FDT_JSON:
|
||||
addInternalExtract<std::string>(mc); break;
|
||||
default:
|
||||
throw Poco::InvalidArgumentException("Data type not supported.");
|
||||
}
|
||||
|
||||
10
vendor/POCO/Data/src/Time.cpp
vendored
10
vendor/POCO/Data/src/Time.cpp
vendored
@@ -52,13 +52,13 @@ Time::~Time()
|
||||
|
||||
void Time::assign(int hour, int minute, int second)
|
||||
{
|
||||
if (hour < 0 || hour > 23)
|
||||
if (hour < 0 || hour > 23)
|
||||
throw InvalidArgumentException("Hour must be between 0 and 23.");
|
||||
|
||||
if (minute < 0 || minute > 59)
|
||||
if (minute < 0 || minute > 59)
|
||||
throw InvalidArgumentException("Minute must be between 0 and 59.");
|
||||
|
||||
if (second < 0 || second > 59)
|
||||
if (second < 0 || second > 59)
|
||||
throw InvalidArgumentException("Second must be between 0 and 59.");
|
||||
|
||||
_hour = hour;
|
||||
@@ -77,7 +77,7 @@ bool Time::operator < (const Time& time) const
|
||||
{
|
||||
int minute = time.minute();
|
||||
if (_minute < minute) return true;
|
||||
else
|
||||
else
|
||||
if (_minute > minute) return false;
|
||||
else // minutes equal
|
||||
if (_second < time.second()) return true;
|
||||
@@ -94,7 +94,7 @@ Time& Time::operator = (const Var& var)
|
||||
// TODO: determine the version able to handle it properly
|
||||
*this = var.extract<Time>();
|
||||
#else
|
||||
*this = var.operator Time();
|
||||
*this = var.operator Time();
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
14
vendor/POCO/Data/src/Transaction.cpp
vendored
14
vendor/POCO/Data/src/Transaction.cpp
vendored
@@ -35,7 +35,7 @@ Transaction::Transaction(Poco::Data::Session& rSession, bool start):
|
||||
if (start) begin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Transaction::~Transaction()
|
||||
{
|
||||
try
|
||||
@@ -44,19 +44,19 @@ Transaction::~Transaction()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_pLogger)
|
||||
if (_pLogger)
|
||||
_pLogger->debug("Rolling back transaction.");
|
||||
|
||||
_rSession.rollback();
|
||||
}
|
||||
catch (Poco::Exception& exc)
|
||||
{
|
||||
if (_pLogger)
|
||||
if (_pLogger)
|
||||
_pLogger->error("Error while rolling back database transaction: %s", exc.displayText());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (_pLogger)
|
||||
if (_pLogger)
|
||||
_pLogger->error("Error while rolling back database transaction.");
|
||||
}
|
||||
}
|
||||
@@ -105,16 +105,16 @@ void Transaction::execute(const std::vector<std::string>& sql)
|
||||
|
||||
void Transaction::commit()
|
||||
{
|
||||
if (_pLogger)
|
||||
if (_pLogger)
|
||||
_pLogger->debug("Committing transaction.");
|
||||
|
||||
_rSession.commit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Transaction::rollback()
|
||||
{
|
||||
if (_pLogger)
|
||||
if (_pLogger)
|
||||
_pLogger->debug("Rolling back transaction.");
|
||||
|
||||
_rSession.rollback();
|
||||
|
||||
76
vendor/POCO/Data/src/Transcoder.cpp
vendored
Normal file
76
vendor/POCO/Data/src/Transcoder.cpp
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// Transcoder.cpp
|
||||
//
|
||||
// Library: Data
|
||||
// Package: DataCore
|
||||
// Module: Transcoder
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Data/Transcoder.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
|
||||
|
||||
Transcoder::Transcoder(Poco::TextEncoding::Ptr pFromEncoding,
|
||||
Poco::TextEncoding::Ptr pToEncoding):
|
||||
_pFromEncoding(pFromEncoding),
|
||||
_pToEncoding(pToEncoding),
|
||||
_pConverter(new Poco::TextConverter(*_pFromEncoding, *_pToEncoding)),
|
||||
_pReverseConverter(new Poco::TextConverter(*_pToEncoding, *_pFromEncoding))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Transcoder::~Transcoder()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Transcoder::Ptr Transcoder::create(Poco::TextEncoding::Ptr pFromEncoding,
|
||||
Poco::TextEncoding::Ptr pToEncoding)
|
||||
{
|
||||
Ptr pTranscoder;
|
||||
|
||||
if (!pFromEncoding && !pToEncoding)
|
||||
return pTranscoder;
|
||||
|
||||
if (!pFromEncoding) pFromEncoding = Poco::TextEncoding::find("UTF-8");
|
||||
if (!pToEncoding) pToEncoding = Poco::TextEncoding::find("UTF-8");
|
||||
|
||||
if (pToEncoding->isA(pFromEncoding->canonicalName()))
|
||||
return pTranscoder;
|
||||
|
||||
pTranscoder.reset(new Transcoder(pFromEncoding, pToEncoding));
|
||||
return pTranscoder;
|
||||
}
|
||||
|
||||
|
||||
void Transcoder::transcode(const std::string& from, std::string& to)
|
||||
{
|
||||
if (_pConverter)
|
||||
{
|
||||
to.clear();
|
||||
_pConverter->convert(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Transcoder::reverseTranscode(const std::string& from, std::string& to)
|
||||
{
|
||||
if (_pConverter)
|
||||
{
|
||||
to.clear();
|
||||
_pReverseConverter->convert(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Data
|
||||
Reference in New Issue
Block a user