1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-22 18:17:11 +02:00

Major plugin refactor and cleanup.

Switched to POCO library for unified platform/library interface.
Deprecated the external module API. It was creating more problems than solving.
Removed most built-in libraries in favor of system libraries for easier maintenance.
Cleaned and secured code with help from static analyzers.
This commit is contained in:
Sandu Liviu Catalin
2021-01-30 08:51:39 +02:00
parent e0e34b4030
commit 4a6bfc086c
6219 changed files with 1209835 additions and 454916 deletions

523
vendor/POCO/Data/src/AbstractBinder.cpp vendored Normal file
View File

@ -0,0 +1,523 @@
//
// AbstractBinder.cpp
//
// Library: Data
// Package: DataCore
// Module: AbstractBinder
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/AbstractBinder.h"
#include "Poco/Data/Date.h"
#include "Poco/Data/Time.h"
#include "Poco/Data/LOB.h"
#include "Poco/Data/DataException.h"
#include "Poco/DateTime.h"
#include "Poco/Any.h"
#include "Poco/Dynamic/Var.h"
namespace Poco {
namespace Data {
AbstractBinder::AbstractBinder()
{
}
AbstractBinder::~AbstractBinder()
{
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::Int8>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::Int8>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Poco::Int8>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::UInt8>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::UInt8>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Poco::UInt8>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::Int16>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::Int16>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Poco::Int16>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::UInt16>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::UInt16>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Poco::UInt16>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::Int32>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::Int32>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Poco::Int32>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::UInt32>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::UInt32>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Poco::UInt32>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::Int64>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::Int64>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Poco::Int64>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Poco::UInt64>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Poco::UInt64>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Poco::UInt64>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
#ifndef POCO_INT64_IS_LONG
void AbstractBinder::bind(std::size_t pos, const std::vector<long>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<long>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<long>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
#endif
void AbstractBinder::bind(std::size_t pos, const std::vector<bool>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<bool>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<bool>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<float>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<float>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<float>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<double>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<double>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<double>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<char>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<char>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<char>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<std::string>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<std::string>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<std::string>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const UTF16String& val, Direction dir)
{
throw NotImplementedException("UTF16String binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<UTF16String>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<UTF16String>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<UTF16String>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<BLOB>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<BLOB>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<BLOB>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<CLOB>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<CLOB>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<CLOB>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<DateTime>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<DateTime>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<DateTime>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Date>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Date>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Date>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<Time>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<Time>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<Time>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::vector<NullData>& val, Direction dir)
{
throw NotImplementedException("std::vector binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::deque<NullData>& val, Direction dir)
{
throw NotImplementedException("std::deque binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const std::list<NullData>& val, Direction dir)
{
throw NotImplementedException("std::list binder must be implemented.");
}
void AbstractBinder::bind(std::size_t pos, const Any& val, Direction dir)
{
const std::type_info& type = val.type();
if (type == typeid(Int32))
bind(pos, RefAnyCast<Int32>(val), dir);
else if (type == typeid(std::string))
bind(pos, RefAnyCast<std::string>(val), dir);
else if (type == typeid(Poco::UTF16String))
bind(pos, RefAnyCast<Poco::UTF16String>(val), dir);
else if (type == typeid(bool))
bind(pos, RefAnyCast<bool>(val), dir);
else if (type == typeid(char))
bind(pos, RefAnyCast<char>(val), dir);
else if (type == typeid(Int8))
bind(pos, RefAnyCast<Int8>(val), dir);
else if (type == typeid(UInt8))
bind(pos, RefAnyCast<UInt8>(val), dir);
else if (type == typeid(Int16))
bind(pos, RefAnyCast<Int16>(val), dir);
else if (type == typeid(UInt16))
bind(pos, RefAnyCast<UInt16>(val), dir);
else if (type == typeid(UInt32))
bind(pos, RefAnyCast<UInt32>(val), dir);
else if (type == typeid(Int64))
bind(pos, RefAnyCast<Int64>(val), dir);
else if (type == typeid(UInt64))
bind(pos, RefAnyCast<UInt64>(val), dir);
else if (type == typeid(float))
bind(pos, RefAnyCast<float>(val), dir);
else if (type == typeid(double))
bind(pos, RefAnyCast<double>(val), dir);
else if (type == typeid(DateTime))
bind(pos, RefAnyCast<DateTime>(val), dir);
else if (type == typeid(Date))
bind(pos, RefAnyCast<Date>(val), dir);
else if (type == typeid(Time))
bind(pos, RefAnyCast<Time>(val), dir);
else if (type == typeid(BLOB))
bind(pos, RefAnyCast<BLOB>(val), dir);
else if (type == typeid(void))
bind(pos, Keywords::null, dir);
else if(type == typeid(long))
bind(pos, RefAnyCast<long>(val), dir);
else
throw UnknownTypeException(std::string(val.type().name()));
}
void AbstractBinder::bind(std::size_t pos, const Poco::Dynamic::Var& val, Direction dir)
{
const std::type_info& type = val.type();
if (type == typeid(Int32))
bind(pos, val.extract<Int32>(), dir);
else if (type == typeid(std::string))
bind(pos, val.extract<std::string>(), dir);
else if (type == typeid(Poco::UTF16String))
bind(pos, val.extract<Poco::UTF16String>(), dir);
else if (type == typeid(bool))
bind(pos, val.extract<bool>(), dir);
else if (type == typeid(char))
bind(pos, val.extract<char>(), dir);
else if (type == typeid(Int8))
bind(pos, val.extract<Int8>(), dir);
else if (type == typeid(UInt8))
bind(pos, val.extract<UInt8>(), dir);
else if (type == typeid(Int16))
bind(pos, val.extract<Int16>(), dir);
else if (type == typeid(UInt16))
bind(pos, val.extract<UInt16>(), dir);
else if (type == typeid(UInt32))
bind(pos, val.extract<UInt32>(), dir);
else if (type == typeid(Int64))
bind(pos, val.extract<Int64>(), dir);
else if (type == typeid(UInt64))
bind(pos, val.extract<UInt64>(), dir);
else if (type == typeid(float))
bind(pos, val.extract<float>(), dir);
else if (type == typeid(double))
bind(pos, val.extract<double>(), dir);
else if (type == typeid(DateTime))
bind(pos, val.extract<DateTime>(), dir);
else if (type == typeid(Date))
bind(pos, val.extract<Date>(), dir);
else if (type == typeid(Time))
bind(pos, val.extract<Time>(), dir);
else if (type == typeid(BLOB))
bind(pos, val.extract<BLOB>(), dir);
else if (type == typeid(void))
bind(pos, Keywords::null, dir);
else if (type == typeid(long))
bind(pos, val.extract<long>(), dir);
else
throw UnknownTypeException(std::string(val.type().name()));
}
} } // namespace Poco::Data

View File

@ -0,0 +1,45 @@
//
// AbstractBinding.cpp
//
// Library: Data
// Package: DataCore
// Module: AbstractBinding
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/AbstractBinding.h"
namespace Poco {
namespace Data {
AbstractBinding::AbstractBinding(const std::string& name,
Direction direction,
Poco::UInt32 bulkSize):
_pBinder(0),
_name(name),
_direction(direction),
_bulkSize(bulkSize)
{
}
AbstractBinding::~AbstractBinding()
{
}
void AbstractBinding::setBinder(BinderPtr pBinder)
{
poco_check_ptr (pBinder);
_pBinder = pBinder;
}
} } // namespace Poco::Data

View File

@ -0,0 +1,40 @@
//
// AbstractExtraction.cpp
//
// Library: Data
// Package: DataCore
// Module: AbstractExtraction
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/AbstractExtraction.h"
namespace Poco {
namespace Data {
AbstractExtraction::AbstractExtraction(Poco::UInt32 limit,
Poco::UInt32 position,
bool bulk):
_pExtractor(0),
_limit(limit),
_position(position),
_bulk(bulk),
_emptyStringIsNull(false),
_forceEmptyString(false)
{
}
AbstractExtraction::~AbstractExtraction()
{
}
} } // namespace Poco::Data

View File

@ -0,0 +1,437 @@
//
// AbstractExtractor.cpp
//
// Library: Data
// Package: DataCore
// Module: AbstractExtractor
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/AbstractExtractor.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
AbstractExtractor::AbstractExtractor()
{
}
AbstractExtractor::~AbstractExtractor()
{
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int8>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int8>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int8>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt8>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt8>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt8>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int16>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int16>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int16>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt16>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt16>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt16>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int32>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int32>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int32>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt32>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt32>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt32>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int64>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int64>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int64>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt64>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt64>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt64>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
#ifndef POCO_INT64_IS_LONG
bool AbstractExtractor::extract(std::size_t pos, std::vector<long>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<long>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<long>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
#endif
bool AbstractExtractor::extract(std::size_t pos, std::vector<bool>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<bool>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<bool>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<float>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<float>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<float>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<double>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<double>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<double>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<char>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<char>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<char>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<std::string>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<std::string>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<std::string>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, UTF16String& val)
{
throw NotImplementedException("UTF16String extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<UTF16String>& val)
{
throw NotImplementedException("std::vector<UTF16String> extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<UTF16String>& val)
{
throw NotImplementedException("std::deque<UTF16String> extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<UTF16String>& val)
{
throw NotImplementedException("std::list<UTF16String> extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<BLOB>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<BLOB>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<BLOB>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<CLOB>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<CLOB>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<CLOB>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<DateTime>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<DateTime>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<DateTime>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Date>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Date>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Date>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Time>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Time>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Time>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Any>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Any>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Any>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
} } // namespace Poco::Data

View File

@ -0,0 +1,34 @@
//
// AbstractPreparation.cpp
//
// Library: Data
// Package: DataCore
// Module: AbstractPreparation
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/AbstractPreparation.h"
namespace Poco {
namespace Data {
AbstractPreparation::AbstractPreparation(PreparatorPtr pPreparator):
_pPreparator(pPreparator)
{
poco_assert_dbg (_pPreparator);
}
AbstractPreparation::~AbstractPreparation()
{
}
} } // namespace Poco::Data

View File

@ -0,0 +1,438 @@
//
// AbstractPreparator.cpp
//
// Library: Data
// Package: DataCore
// Module: AbstractPreparator
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/AbstractPreparator.h"
namespace Poco {
namespace Data {
AbstractPreparator::AbstractPreparator(Poco::UInt32 length):
_length(length),
_bulk(false)
{
}
AbstractPreparator::~AbstractPreparator()
{
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int8>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int8>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int8>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt8>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt8>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt8>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int16>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int16>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int16>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt16>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt16>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt16>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int32>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int32>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int32>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt32>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt32>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt32>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int64>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int64>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int64>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt64>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt64>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt64>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
#ifndef POCO_INT64_IS_LONG
void AbstractPreparator::prepare(std::size_t pos, const std::vector<long>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<long>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<long>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
#endif
void AbstractPreparator::prepare(std::size_t pos, const std::vector<bool>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<bool>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<bool>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<float>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<float>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<float>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<double>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<double>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<double>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<char>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<char>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<char>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<std::string>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<std::string>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<std::string>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const UTF16String& val)
{
throw NotImplementedException("UTF16String preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<UTF16String>& val)
{
throw NotImplementedException("std::vector<UTF16String> preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<UTF16String>& val)
{
throw NotImplementedException("std::deque<UTF16String> preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<UTF16String>& val)
{
throw NotImplementedException("std::list<UTF16String> preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<BLOB>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<BLOB>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<BLOB>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<CLOB>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<CLOB>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<CLOB>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<DateTime>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<DateTime>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<DateTime>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Date>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Date>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Date>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Time>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Time>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Time>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Any>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Any>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Any>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
} } // namespace Poco::Data

146
vendor/POCO/Data/src/ArchiveStrategy.cpp vendored Normal file
View File

@ -0,0 +1,146 @@
//
// ArchiveStrategy.cpp
//
// Library: Data
// Package: Logging
// Module: ArchiveStrategy
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/ArchiveStrategy.h"
#include "Poco/Ascii.h"
namespace Poco {
namespace Data {
using namespace Keywords;
//
// ArchiveStrategy
//
const std::string ArchiveStrategy::DEFAULT_ARCHIVE_DESTINATION = "T_POCO_LOG_ARCHIVE";
ArchiveStrategy::ArchiveStrategy(const std::string& connector,
const std::string& connect,
const std::string& source,
const std::string& destination):
_connector(connector),
_connect(connect),
_source(source),
_destination(destination)
{
open();
}
ArchiveStrategy::~ArchiveStrategy()
{
}
void ArchiveStrategy::open()
{
if (_connector.empty() || _connect.empty())
throw IllegalStateException("Connector and connect string must be non-empty.");
_pSession = new Session(_connector, _connect);
}
//
// ArchiveByAgeStrategy
//
ArchiveByAgeStrategy::ArchiveByAgeStrategy(const std::string& connector,
const std::string& connect,
const std::string& sourceTable,
const std::string& destinationTable):
ArchiveStrategy(connector, connect, sourceTable, destinationTable)
{
initStatements();
}
ArchiveByAgeStrategy::~ArchiveByAgeStrategy()
{
}
void ArchiveByAgeStrategy::archive()
{
if (!session().isConnected()) open();
DateTime now;
_archiveDateTime = now - _maxAge;
getCountStatement().execute();
if (_archiveCount > 0)
{
getCopyStatement().execute();
getDeleteStatement().execute();
}
}
void ArchiveByAgeStrategy::initStatements()
{
std::string src = getSource();
std::string dest = getDestination();
setCountStatement();
_archiveCount = 0;
std::string sql;
Poco::format(sql, "SELECT COUNT(*) FROM %s WHERE DateTime < ?", src);
getCountStatement() << sql, into(_archiveCount), use(_archiveDateTime);
setCopyStatement();
sql.clear();
Poco::format(sql, "INSERT INTO %s SELECT * FROM %s WHERE DateTime < ?", dest, src);
getCopyStatement() << sql, use(_archiveDateTime);
setDeleteStatement();
sql.clear();
Poco::format(sql, "DELETE FROM %s WHERE DateTime < ?", src);
getDeleteStatement() << sql, use(_archiveDateTime);
}
void ArchiveByAgeStrategy::setThreshold(const std::string& age)
{
std::string::const_iterator it = age.begin();
std::string::const_iterator end = age.end();
int n = 0;
while (it != end && Ascii::isSpace(*it)) ++it;
while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
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;
else if (unit == "hours")
factor = Timespan::HOURS;
else if (unit == "days")
factor = Timespan::DAYS;
else if (unit == "weeks")
factor = 7*Timespan::DAYS;
else if (unit == "months")
factor = 30*Timespan::DAYS;
else if (unit != "seconds")
throw InvalidArgumentException("setMaxAge", age);
_maxAge = factor * n;
}
} } // namespace Poco::Data

37
vendor/POCO/Data/src/Bulk.cpp vendored Normal file
View File

@ -0,0 +1,37 @@
//
// Bulk.cpp
//
// Library: Data
// Package: DataCore
// Module: Bulk
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Bulk.h"
namespace Poco {
namespace Data {
Bulk::Bulk(const Limit& limit): _limit(limit.value(), false, false)
{
}
Bulk::Bulk(Poco::UInt32 value): _limit(value, false, false)
{
}
Bulk::~Bulk()
{
}
} } // namespace Poco::Data

32
vendor/POCO/Data/src/Connector.cpp vendored Normal file
View File

@ -0,0 +1,32 @@
//
// Connector.cpp
//
// Library: Data
// Package: DataCore
// Module: Connector
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Connector.h"
namespace Poco {
namespace Data {
Connector::Connector()
{
}
Connector::~Connector()
{
}
} } // namespace Poco::Data

41
vendor/POCO/Data/src/DataException.cpp vendored Normal file
View File

@ -0,0 +1,41 @@
//
// DataException.cpp
//
// Library: Data
// Package: DataCore
// Module: DataException
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/DataException.h"
#include <typeinfo>
namespace Poco {
namespace Data {
POCO_IMPLEMENT_EXCEPTION(DataException, Poco::IOException, "Database Exception")
POCO_IMPLEMENT_EXCEPTION(RowDataMissingException, DataException, "Data for row missing")
POCO_IMPLEMENT_EXCEPTION(UnknownDataBaseException, DataException, "Type of data base unknown")
POCO_IMPLEMENT_EXCEPTION(UnknownTypeException, DataException, "Type of data unknown")
POCO_IMPLEMENT_EXCEPTION(ExecutionException, DataException, "Execution error")
POCO_IMPLEMENT_EXCEPTION(BindingException, DataException, "Binding error")
POCO_IMPLEMENT_EXCEPTION(ExtractException, DataException, "Extraction error")
POCO_IMPLEMENT_EXCEPTION(LimitException, DataException, "Limit error")
POCO_IMPLEMENT_EXCEPTION(NotSupportedException, DataException, "Feature or property not supported")
POCO_IMPLEMENT_EXCEPTION(SessionUnavailableException, DataException, "Session is unavailable")
POCO_IMPLEMENT_EXCEPTION(SessionPoolExhaustedException, DataException, "No more sessions available from the session pool")
POCO_IMPLEMENT_EXCEPTION(SessionPoolExistsException, DataException, "Session already exists in the pool")
POCO_IMPLEMENT_EXCEPTION(NoDataException, DataException, "No data found")
POCO_IMPLEMENT_EXCEPTION(LengthExceededException, DataException, "Data too long")
POCO_IMPLEMENT_EXCEPTION(ConnectionFailedException, DataException, "Connection attempt failed")
POCO_IMPLEMENT_EXCEPTION(NotConnectedException, DataException, "Not connected to data source")
} } // namespace Poco::Data

142
vendor/POCO/Data/src/Date.cpp vendored Normal file
View File

@ -0,0 +1,142 @@
//
// Date.cpp
//
// Library: Data
// Package: DataCore
// Module: Date
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Date.h"
#include "Poco/DateTime.h"
#include "Poco/NumberFormatter.h"
#include "Poco/Data/DynamicDateTime.h"
#include "Poco/Dynamic/Var.h"
using Poco::DateTime;
using Poco::Dynamic::Var;
using Poco::NumberFormatter;
namespace Poco {
namespace Data {
Date::Date()
{
DateTime dt;
assign(dt.year(), dt.month(), dt.day());
}
Date::Date(int year, int month, int day)
{
assign(year, month, day);
}
Date::Date(const DateTime& dt)
{
assign(dt.year(), dt.month(), dt.day());
}
Date::~Date()
{
}
void Date::assign(int year, int month, int day)
{
if (year < 0 || year > 9999)
throw InvalidArgumentException("Year must be between 0 and 9999");
if (month < 1 || month > 12)
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 " +
NumberFormatter::format(DateTime::daysOfMonth(year, month)));
_year = year;
_month = month;
_day = day;
}
bool Date::operator < (const Date& date) const
{
int year = date.year();
if (_year < year) return true;
else if (_year > year) return false;
else // years equal
{
int month = date.month();
if (_month < month) return true;
else
if (_month > month) return false;
else // months equal
if (_day < date.day()) return true;
}
return false;
}
Date& Date::operator = (const Var& var)
{
#ifndef __GNUC__
// g++ used to choke on this, newer versions seem to digest it fine
// TODO: determine the version able to handle it properly
*this = var.extract<Date>();
#else
*this = var.operator Date();
#endif
return *this;
}
} } // namespace Poco::Data
#ifdef __GNUC__
// only needed for g++ (see comment in Date::operator = above)
namespace Poco {
namespace Dynamic {
using Poco::Data::Date;
using Poco::DateTime;
template <>
Var::operator Date () const
{
VarHolder* pHolder = content();
if (!pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(Date) == pHolder->type())
return extract<Date>();
else
{
Poco::DateTime result;
pHolder->convert(result);
return Date(result);
}
}
} } // namespace Poco::Dynamic
#endif // __GNUC__

74
vendor/POCO/Data/src/DynamicLOB.cpp vendored Normal file
View File

@ -0,0 +1,74 @@
//
// DynamicLOB.cpp
//
// Library: Data
// Package: DataCore
// Module: DynamicLOB
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifdef __GNUC__
// TODO: determine g++ version able to do the right thing without these specializations
#include "Poco/Data/DynamicLOB.h"
#include "Poco/Data/LOB.h"
#include "Poco/Dynamic/Var.h"
namespace Poco {
namespace Dynamic {
using Poco::Data::CLOB;
using Poco::Data::BLOB;
template <>
Var::operator CLOB () const
{
VarHolder* pHolder = content();
if (!pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(CLOB) == pHolder->type())
return extract<CLOB>();
else
{
std::string result;
pHolder->convert(result);
return CLOB(result);
}
}
template <>
Var::operator BLOB () const
{
VarHolder* pHolder = content();
if (!pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(BLOB) == pHolder->type())
return extract<BLOB>();
else
{
std::string result;
pHolder->convert(result);
return BLOB(reinterpret_cast<const unsigned char*>(result.data()),
result.size());
}
}
} } // namespace Poco::Data
#endif // __GNUC__

35
vendor/POCO/Data/src/Limit.cpp vendored Normal file
View File

@ -0,0 +1,35 @@
//
// Limit.cpp
//
// Library: Data
// Package: DataCore
// Module: Limit
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Limit.h"
namespace Poco {
namespace Data {
Limit::Limit(SizeT value, bool hardLimit, bool isLowerLimit) :
_value(value),
_hardLimit(hardLimit),
_isLowerLimit(isLowerLimit)
{
}
Limit::~Limit()
{
}
} } // namespace Poco::Data

106
vendor/POCO/Data/src/MetaColumn.cpp vendored Normal file
View File

@ -0,0 +1,106 @@
//
// MetaColumn.cpp
//
// Library: Data
// Package: DataCore
// Module: MetaColumn
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/MetaColumn.h"
namespace Poco {
namespace Data {
MetaColumn::MetaColumn():
_length(),
_precision(),
_position(),
_type(),
_nullable()
{
}
MetaColumn::MetaColumn(std::size_t position,
const std::string& name,
ColumnDataType type,
std::size_t length,
std::size_t precision,
bool nullable):
_name(name),
_length(length),
_precision(precision),
_position(position),
_type(type),
_nullable(nullable)
{
}
MetaColumn::MetaColumn(const MetaColumn& other):
_name(other._name),
_length(other._length),
_precision(other._precision),
_position(other._position),
_type(other._type),
_nullable(other._nullable)
{
}
MetaColumn::MetaColumn(MetaColumn&& other) noexcept:
_name(std::move(other._name)),
_length(other._length),
_precision(other._precision),
_position(other._position),
_type(other._type),
_nullable(other._nullable)
{
}
MetaColumn::~MetaColumn()
{
}
MetaColumn& MetaColumn::operator = (const MetaColumn& other)
{
MetaColumn tmp(other);
swap(tmp);
return *this;
}
MetaColumn& MetaColumn::operator = (MetaColumn&& other) noexcept
{
_name = std::move(other._name);
_length = other._length;
_precision = other._precision;
_position = other._position;
_type = other._type;
_nullable = other._nullable;
return *this;
}
void MetaColumn::swap(MetaColumn& other)
{
std::swap(_name, other._name);
std::swap(_length, other._length);
std::swap(_precision, other._precision);
std::swap(_position, other._position);
std::swap(_type, other._type);
std::swap(_nullable, other._nullable);
}
} } // namespace Poco::Data

View File

@ -0,0 +1,34 @@
//
// PooledSessionHolder.cpp
//
// Library: Data
// Package: SessionPooling
// Module: PooledSessionHolder
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/PooledSessionHolder.h"
namespace Poco {
namespace Data {
PooledSessionHolder::PooledSessionHolder(SessionPool& owner, SessionImpl* pSessionImpl):
_owner(owner),
_pImpl(pSessionImpl, true)
{
}
PooledSessionHolder::~PooledSessionHolder()
{
}
} } // namespace Poco::Data

View File

@ -0,0 +1,204 @@
//
// PooledSessionImpl.cpp
//
// Library: Data
// Package: SessionPooling
// Module: PooledSessionImpl
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/PooledSessionImpl.h"
#include "Poco/Data/DataException.h"
#include "Poco/Data/SessionPool.h"
namespace Poco {
namespace Data {
PooledSessionImpl::PooledSessionImpl(PooledSessionHolder* pHolder):
SessionImpl(pHolder->session()->connectionString(),
pHolder->session()->getLoginTimeout()),
_pHolder(pHolder, true)
{
}
PooledSessionImpl::~PooledSessionImpl()
{
try
{
close();
}
catch (...)
{
poco_unexpected();
}
}
StatementImpl::Ptr PooledSessionImpl::createStatementImpl()
{
return access()->createStatementImpl();
}
void PooledSessionImpl::begin()
{
return access()->begin();
}
void PooledSessionImpl::commit()
{
return access()->commit();
}
bool PooledSessionImpl::isConnected() const
{
return access()->isConnected();
}
bool PooledSessionImpl::isGood() const
{
return access()->isGood();
}
void PooledSessionImpl::setConnectionTimeout(std::size_t timeout)
{
return access()->setConnectionTimeout(timeout);
}
std::size_t PooledSessionImpl::getConnectionTimeout() const
{
return access()->getConnectionTimeout();
}
bool PooledSessionImpl::canTransact() const
{
return access()->canTransact();
}
bool PooledSessionImpl::isTransaction() const
{
return access()->isTransaction();
}
void PooledSessionImpl::setTransactionIsolation(Poco::UInt32 ti)
{
access()->setTransactionIsolation(ti);
}
Poco::UInt32 PooledSessionImpl::getTransactionIsolation() const
{
return access()->getTransactionIsolation();
}
bool PooledSessionImpl::hasTransactionIsolation(Poco::UInt32 ti) const
{
return access()->hasTransactionIsolation(ti);
}
bool PooledSessionImpl::isTransactionIsolation(Poco::UInt32 ti) const
{
return access()->isTransactionIsolation(ti);
}
void PooledSessionImpl::rollback()
{
return access()->rollback();
}
void PooledSessionImpl::open(const std::string& connect)
{
access()->open(connect);
}
void PooledSessionImpl::close()
{
if (_pHolder)
{
if (isTransaction())
{
try
{
rollback();
}
catch (...)
{
// Something's wrong with the session. Get rid of it.
access()->close();
}
}
_pHolder->owner().putBack(_pHolder);
_pHolder = 0;
}
}
void PooledSessionImpl::reset()
{
access()->reset();
}
const std::string& PooledSessionImpl::connectorName() const
{
return access()->connectorName();
}
void PooledSessionImpl::setFeature(const std::string& name, bool state)
{
access()->setFeature(name, state);
}
bool PooledSessionImpl::getFeature(const std::string& name)
{
return access()->getFeature(name);
}
void PooledSessionImpl::setProperty(const std::string& name, const Poco::Any& value)
{
access()->setProperty(name, value);
}
Poco::Any PooledSessionImpl::getProperty(const std::string& name)
{
return access()->getProperty(name);
}
SessionImpl* PooledSessionImpl::access() const
{
if (_pHolder)
{
_pHolder->access();
return impl();
}
else throw SessionUnavailableException();
}
} } // namespace Poco::Data

32
vendor/POCO/Data/src/Position.cpp vendored Normal file
View File

@ -0,0 +1,32 @@
//
// Position.cpp
//
// Library: Data
// Package: DataCore
// Module: Position
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Position.h"
namespace Poco {
namespace Data {
Position::Position(Poco::UInt32 value): _value(value)
{
}
Position::~Position()
{
}
} } // namespace Poco::Data

40
vendor/POCO/Data/src/Range.cpp vendored Normal file
View File

@ -0,0 +1,40 @@
//
// Range.cpp
//
// Library: Data
// Package: DataCore
// Module: Range
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Range.h"
#include "Poco/Data/DataException.h"
namespace Poco {
namespace Data {
using namespace Keywords;
Range::Range(Limit::SizeT lowValue, Limit::SizeT upValue, bool hardLimit) :
_lower(lowerLimit(lowValue)),
_upper(upperLimit(upValue, hardLimit))
{
if (lowValue > upValue)
throw LimitException("lowerLimit > upperLimit!");
}
Range::~Range()
{
}
} } // namespace Poco::Data

416
vendor/POCO/Data/src/RecordSet.cpp vendored Normal file
View File

@ -0,0 +1,416 @@
//
// RecordSet.cpp
//
// Library: Data
// Package: DataCore
// Module: RecordSet
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/RecordSet.h"
#include "Poco/Data/RowFilter.h"
#include "Poco/Data/Date.h"
#include "Poco/Data/Time.h"
#include "Poco/Data/DataException.h"
#include "Poco/DateTime.h"
#include "Poco/UTFString.h"
using namespace Poco::Data::Keywords;
using Poco::DateTime;
using Poco::UTF16String;
namespace Poco {
namespace Data {
const std::size_t RecordSet::UNKNOWN_TOTAL_ROW_COUNT = std::numeric_limits<std::size_t>::max();
RecordSet::RecordSet(const Statement& rStatement,
RowFormatter::Ptr pRowFormatter):
Statement(rStatement),
_currentRow(0),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_totalRowCount(UNKNOWN_TOTAL_ROW_COUNT)
{
if (pRowFormatter) setRowFormatter(pRowFormatter);
}
RecordSet::RecordSet(Session& rSession,
const std::string& query,
RowFormatter::Ptr pRowFormatter):
Statement((rSession << query, now)),
_currentRow(0),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_totalRowCount(UNKNOWN_TOTAL_ROW_COUNT)
{
if (pRowFormatter) setRowFormatter(pRowFormatter);
}
RecordSet::RecordSet(const RecordSet& other):
Statement(other.impl()),
_currentRow(other._currentRow),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(other._pFilter),
_totalRowCount(other._totalRowCount)
{
}
RecordSet::RecordSet(RecordSet&& other) noexcept:
Statement(std::move(other)),
_currentRow(std::move(other._currentRow)),
_pBegin(std::move(other._pBegin)),
_pEnd(std::move(other._pEnd)),
_pFilter(std::move(other._pFilter)),
_totalRowCount(std::move(other._totalRowCount))
{
}
RecordSet::~RecordSet()
{
try
{
delete _pBegin;
delete _pEnd;
RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end();
for (; it != end; ++it) delete it->second;
}
catch (...)
{
poco_unexpected();
}
}
RecordSet& RecordSet::operator = (RecordSet&& other) noexcept
{
Statement::operator = (std::move(other));
_currentRow = std::move(other._currentRow);
_pBegin = std::move(other._pBegin);
_pEnd = std::move(other._pEnd);
_pFilter = std::move(other._pFilter);
_totalRowCount = std::move(other._totalRowCount);
return *this;
}
void RecordSet::reset(const Statement& stmt)
{
delete _pBegin;
_pBegin = 0;
delete _pEnd;
_pEnd = 0;
_currentRow = 0;
_totalRowCount = UNKNOWN_TOTAL_ROW_COUNT;
RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end();
for (; it != end; ++it) delete it->second;
_rowMap.clear();
Statement::operator = (stmt);
_pBegin = new RowIterator(this, 0 == rowsExtracted());
_pEnd = new RowIterator(this, true);
}
Poco::Dynamic::Var RecordSet::value(std::size_t col, std::size_t row, bool useFilter) const
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
if (isNull(col, row)) return Poco::Dynamic::Var();
switch (columnType(col))
{
case MetaColumn::FDT_BOOL: return value<bool>(col, row, useFilter);
case MetaColumn::FDT_INT8: return value<Int8>(col, row, useFilter);
case MetaColumn::FDT_UINT8: return value<UInt8>(col, row, useFilter);
case MetaColumn::FDT_INT16: return value<Int16>(col, row, useFilter);
case MetaColumn::FDT_UINT16: return value<UInt16>(col, row, useFilter);
case MetaColumn::FDT_INT32: return value<Int32>(col, row, useFilter);
case MetaColumn::FDT_UINT32: return value<UInt32>(col, row, useFilter);
case MetaColumn::FDT_INT64: return value<Int64>(col, row, useFilter);
case MetaColumn::FDT_UINT64: return value<UInt64>(col, row, useFilter);
case MetaColumn::FDT_FLOAT: return value<float>(col, row, useFilter);
case MetaColumn::FDT_DOUBLE: return value<double>(col, row, useFilter);
case MetaColumn::FDT_STRING: return value<std::string>(col, row, useFilter);
case MetaColumn::FDT_WSTRING: return value<UTF16String>(col, row, useFilter);
case MetaColumn::FDT_BLOB: return value<BLOB>(col, row, useFilter);
case MetaColumn::FDT_CLOB: return value<CLOB>(col, row, useFilter);
case MetaColumn::FDT_DATE: return value<Date>(col, row, useFilter);
case MetaColumn::FDT_TIME: return value<Time>(col, row, useFilter);
case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(col, row);
default:
throw UnknownTypeException("Data type not supported.");
}
}
Poco::Dynamic::Var RecordSet::value(const std::string& name, std::size_t row, bool useFilter) const
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
if (isNull(metaColumn(name).position(), row)) return Poco::Dynamic::Var();
switch (columnType(name))
{
case MetaColumn::FDT_BOOL: return value<bool>(name, row, useFilter);
case MetaColumn::FDT_INT8: return value<Int8>(name, row, useFilter);
case MetaColumn::FDT_UINT8: return value<UInt8>(name, row, useFilter);
case MetaColumn::FDT_INT16: return value<Int16>(name, row, useFilter);
case MetaColumn::FDT_UINT16: return value<UInt16>(name, row, useFilter);
case MetaColumn::FDT_INT32: return value<Int32>(name, row, useFilter);
case MetaColumn::FDT_UINT32: return value<UInt32>(name, row, useFilter);
case MetaColumn::FDT_INT64: return value<Int64>(name, row, useFilter);
case MetaColumn::FDT_UINT64: return value<UInt64>(name, row, useFilter);
case MetaColumn::FDT_FLOAT: return value<float>(name, row, useFilter);
case MetaColumn::FDT_DOUBLE: return value<double>(name, row, useFilter);
case MetaColumn::FDT_STRING: return value<std::string>(name, row, useFilter);
case MetaColumn::FDT_WSTRING: return value<UTF16String>(name, row, useFilter);
case MetaColumn::FDT_BLOB: return value<BLOB>(name, row, useFilter);
case MetaColumn::FDT_DATE: return value<Date>(name, row, useFilter);
case MetaColumn::FDT_TIME: return value<Time>(name, row, useFilter);
case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(name, row, useFilter);
default:
throw UnknownTypeException("Data type not supported.");
}
}
Row& RecordSet::row(std::size_t pos)
{
std::size_t rowCnt = rowCount();
if (0 == rowCnt || pos > rowCnt - 1)
throw RangeException("Invalid recordset row requested.");
RowMap::const_iterator it = _rowMap.find(pos);
Row* pRow = 0;
std::size_t columns = columnCount();
if (it == _rowMap.end())
{
if (_rowMap.size())
{
//reuse first row column names and sorting fields to save some memory
pRow = new Row(_rowMap.begin()->second->names(),
_rowMap.begin()->second->getSortMap(),
getRowFormatter());
for (std::size_t col = 0; col < columns; ++col)
pRow->set(col, value(col, pos));
}
else
{
pRow = new Row;
pRow->setFormatter(getRowFormatter());
for (std::size_t col = 0; col < columns; ++col)
pRow->append(metaColumn(static_cast<UInt32>(col)).name(), value(col, pos));
}
_rowMap.insert(RowMap::value_type(pos, pRow));
}
else
{
pRow = it->second;
poco_check_ptr (pRow);
}
return *pRow;
}
std::size_t RecordSet::rowCount() const
{
poco_assert (extractions().size());
std::size_t rc = subTotalRowCount();
if (!isFiltered()) return rc;
std::size_t counter = 0;
for (int row = 0; row < rc; ++row)
{
if (isAllowed(row)) ++counter;
}
return counter;
}
bool RecordSet::isAllowed(std::size_t row) const
{
if (!isFiltered()) return true;
return _pFilter->isAllowed(row);
}
bool RecordSet::moveFirst()
{
if (subTotalRowCount() > 0)
{
if (!isFiltered())
{
_currentRow = 0;
return true;
}
std::size_t currentRow = 0;
while (!isAllowed(currentRow))
{
if (currentRow >= subTotalRowCount() - 1) return false;
++currentRow;
}
_currentRow = currentRow;
return true;
}
else return false;
}
bool RecordSet::moveNext()
{
std::size_t currentRow = _currentRow;
do
{
if (currentRow >= subTotalRowCount() - 1) return false;
++currentRow;
} while (isFiltered() && !isAllowed(currentRow));
_currentRow = currentRow;
return true;
}
bool RecordSet::movePrevious()
{
std::size_t currentRow = _currentRow;
do
{
if (currentRow <= 0) return false;
--currentRow;
} while (isFiltered() && !isAllowed(currentRow));
_currentRow = currentRow;
return true;
}
bool RecordSet::moveLast()
{
if (subTotalRowCount() > 0)
{
std::size_t currentRow = subTotalRowCount() - 1;
if (!isFiltered())
{
_currentRow = currentRow;
return true;
}
while (!isAllowed(currentRow))
{
if (currentRow <= 0) return false;
--currentRow;
}
_currentRow = currentRow;
return true;
}
else return false;
}
void RecordSet::setRowFormatter(RowFormatter::Ptr pRowFormatter)
{
pRowFormatter->setTotalRowCount(static_cast<int>(getTotalRowCount()));
Statement::setRowFormatter(pRowFormatter);
RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end();
for (; it != end; ++it) it->second->setFormatter(getRowFormatter());
}
std::ostream& RecordSet::copyNames(std::ostream& os) const
{
std::string names = (*_pBegin)->namesToString();
if (!names.empty()) os << names;
return os;
}
std::ostream& RecordSet::copyValues(std::ostream& os, std::size_t offset, std::size_t length) const
{
RowIterator it = *_pBegin + offset;
RowIterator end = (RowIterator::POSITION_END != length) ? it + length : *_pEnd;
std::copy(it, end, std::ostream_iterator<Row>(os));
return os;
}
void RecordSet::formatValues(std::size_t offset, std::size_t length) const
{
RowIterator it = *_pBegin + offset;
RowIterator end = (RowIterator::POSITION_END != length) ? it + length : *_pEnd;
std::string val;
for (; it != end; ++it) it->formatValues();
}
std::ostream& RecordSet::copy(std::ostream& os, std::size_t offset, std::size_t length) const
{
RowFormatter& rf = const_cast<RowFormatter&>((*_pBegin)->getFormatter());
rf.setTotalRowCount(static_cast<int>(getTotalRowCount()));
if (RowFormatter::FORMAT_PROGRESSIVE == rf.getMode())
{
os << rf.prefix();
copyNames(os);
copyValues(os, offset, length);
os << rf.postfix();
}
else
{
formatNames();
formatValues(offset, length);
os << rf.toString();
}
return os;
}
void RecordSet::filter(const Poco::AutoPtr<RowFilter>& pFilter)
{
_pFilter = pFilter;
}
bool RecordSet::isFiltered() const
{
return _pFilter && !_pFilter->isEmpty();
}
void RecordSet::setTotalRowCount(const std::string& sql)
{
session() << sql, into(_totalRowCount), now;
}
} } // namespace Poco::Data

369
vendor/POCO/Data/src/Row.cpp vendored Normal file
View File

@ -0,0 +1,369 @@
//
// Row.cpp
//
// Library: Data
// Package: DataCore
// Module: Row
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Row.h"
#include "Poco/Data/SimpleRowFormatter.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
std::ostream& operator << (std::ostream &os, const Row& row)
{
os << row.valuesToString();
return os;
}
Row::Row():
_pNames(0),
_pSortMap(new SortMap),
_pFormatter(new SimpleRowFormatter)
{
}
Row::Row(NameVecPtr pNames,
const RowFormatter::Ptr& pFormatter): _pNames(pNames)
{
if (!_pNames) throw NullPointerException();
init(0, pFormatter);
}
Row::Row(NameVecPtr pNames,
const SortMapPtr& pSortMap,
const RowFormatter::Ptr& pFormatter): _pNames(pNames)
{
if (!_pNames) throw NullPointerException();
init(pSortMap, pFormatter);
}
void Row::init(const SortMapPtr& pSortMap, const RowFormatter::Ptr& pFormatter)
{
setFormatter(pFormatter);
setSortMap(pSortMap);
NameVec::size_type sz = _pNames->size();
if (sz)
{
_values.resize(sz);
// 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
// Var::empty() call should be used to empty
// the corresponding Row value.
_values[0] = 0;
addSortField(0);
}
}
Row::~Row()
{
}
Poco::Dynamic::Var& Row::get(std::size_t col)
{
try
{
return _values.at(col);
}
catch (std::out_of_range& re)
{
throw RangeException(re.what());
}
}
std::size_t Row::getPosition(const std::string& name)
{
if (!_pNames)
throw NullPointerException();
NameVec::const_iterator it = _pNames->begin();
NameVec::const_iterator end = _pNames->end();
std::size_t col = 0;
for (; it != end; ++it, ++col)
if (0 == icompare(name, *it)) return col;
throw NotFoundException(name);
}
void Row::addSortField(std::size_t pos)
{
poco_assert (pos <= _values.size());
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
for (; it != end; ++it)
{
if (it->get<0>() == pos) return;
}
ComparisonType ct;
if (_values[pos].isEmpty())
{
ct = COMPARE_AS_EMPTY;
}
else if ((_values[pos].type() == typeid(Poco::Int8)) ||
(_values[pos].type() == typeid(Poco::UInt8)) ||
(_values[pos].type() == typeid(Poco::Int16)) ||
(_values[pos].type() == typeid(Poco::UInt16)) ||
(_values[pos].type() == typeid(Poco::Int32)) ||
(_values[pos].type() == typeid(Poco::UInt32)) ||
(_values[pos].type() == typeid(Poco::Int64)) ||
(_values[pos].type() == typeid(Poco::UInt64)) ||
(_values[pos].type() == typeid(bool)))
{
ct = COMPARE_AS_INTEGER;
}
else if ((_values[pos].type() == typeid(float)) ||
(_values[pos].type() == typeid(double)))
{
ct = COMPARE_AS_FLOAT;
}
else
{
ct = COMPARE_AS_STRING;
}
_pSortMap->push_back(SortTuple(pos, ct));
}
void Row::addSortField(const std::string& name)
{
addSortField(getPosition(name));
}
void Row::removeSortField(std::size_t pos)
{
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
for (; it != end; ++it)
{
if (it->get<0>() == pos)
{
_pSortMap->erase(it);
return;
}
}
}
void Row::removeSortField(const std::string& name)
{
removeSortField(getPosition(name));
}
void Row::replaceSortField(std::size_t oldPos, std::size_t newPos)
{
poco_assert (oldPos <= _values.size());
poco_assert (newPos <= _values.size());
ComparisonType ct;
if (_values[newPos].isEmpty())
{
ct = COMPARE_AS_EMPTY;
}
else if ((_values[newPos].type() == typeid(Poco::Int8)) ||
(_values[newPos].type() == typeid(Poco::UInt8)) ||
(_values[newPos].type() == typeid(Poco::Int16)) ||
(_values[newPos].type() == typeid(Poco::UInt16)) ||
(_values[newPos].type() == typeid(Poco::Int32)) ||
(_values[newPos].type() == typeid(Poco::UInt32)) ||
(_values[newPos].type() == typeid(Poco::Int64)) ||
(_values[newPos].type() == typeid(Poco::UInt64)) ||
(_values[newPos].type() == typeid(bool)))
{
ct = COMPARE_AS_INTEGER;
}
else if ((_values[newPos].type() == typeid(float)) ||
(_values[newPos].type() == typeid(double)))
{
ct = COMPARE_AS_FLOAT;
}
else
{
ct = COMPARE_AS_STRING;
}
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
for (; it != end; ++it)
{
if (it->get<0>() == oldPos)
{
*it = SortTuple(newPos, ct);
return;
}
}
throw NotFoundException("Field not found");
}
void Row::replaceSortField(const std::string& oldName, const std::string& newName)
{
replaceSortField(getPosition(oldName), getPosition(newName));
}
void Row::resetSort()
{
_pSortMap->clear();
if (_values.size()) addSortField(0);
}
bool Row::isEqualSize(const Row& other) const
{
return (other._values.size() == _values.size());
}
bool Row::isEqualType(const Row& other) const
{
std::vector<Poco::Dynamic::Var>::const_iterator it = _values.begin();
std::vector<Poco::Dynamic::Var>::const_iterator end = _values.end();
for (int i = 0; it != end; ++it, ++i)
{
if (it->type() != other._values[i].type())
return false;
}
return true;
}
bool Row::operator == (const Row& other) const
{
if (!isEqualSize(other)) return false;
if (!isEqualType(other)) return false;
std::vector<Poco::Dynamic::Var>::const_iterator it = _values.begin();
std::vector<Poco::Dynamic::Var>::const_iterator end = _values.end();
for (int i = 0; it != end; ++it, ++i)
{
if ((*it).convert<std::string>() != other._values[i].convert<std::string>())
return false;
}
return true;
}
bool Row::operator != (const Row& other) const
{
return !(*this == other);
}
bool Row::operator < (const Row& other) const
{
if (*_pSortMap != *other._pSortMap)
throw InvalidAccessException("Rows compared have different sorting criteria.");
SortMap::const_iterator it = _pSortMap->begin();
SortMap::const_iterator end = _pSortMap->end();
for (; it != end; ++it)
{
switch (it->get<1>())
{
case COMPARE_AS_EMPTY:
return false;
case COMPARE_AS_INTEGER:
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>() !=
other._values[it->get<0>()].convert<Poco::Int64>())
return false;
break;
case COMPARE_AS_FLOAT:
if (_values[it->get<0>()].convert<double>() <
other._values[it->get<0>()].convert<double>())
return true;
else if (_values[it->get<0>()].convert<double>() !=
other._values[it->get<0>()].convert<double>())
return false;
break;
case COMPARE_AS_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>() !=
other._values[it->get<0>()].convert<std::string>())
return false;
break;
default:
throw IllegalStateException("Unknown comparison criteria.");
}
}
return false;
}
void Row::setFormatter(const RowFormatter::Ptr& pFormatter)
{
if (pFormatter.get())
_pFormatter = pFormatter;
else
_pFormatter = new SimpleRowFormatter;
}
void Row::setSortMap(const SortMapPtr& pSortMap)
{
if (pSortMap.get())
_pSortMap = pSortMap;
else
_pSortMap = new SortMap;
}
const std::string& Row::namesToString() const
{
if (!_pNames)
throw NullPointerException();
return _pFormatter->formatNames(names(), _nameStr);
}
void Row::formatNames() const
{
if (!_pNames)
throw NullPointerException();
return _pFormatter->formatNames(names());
}
} } // namespace Poco::Data

225
vendor/POCO/Data/src/RowFilter.cpp vendored Normal file
View File

@ -0,0 +1,225 @@
//
// RowFilter.cpp
//
// Library: Data
// Package: DataCore
// Module: RowFilter
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/RowFilter.h"
#include "Poco/Data/RecordSet.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
#include <functional>
namespace Poco {
namespace Data {
RowFilter::RowFilter(RecordSet* pRecordSet): _pRecordSet(pRecordSet), _not(false)
{
poco_check_ptr(pRecordSet);
init();
duplicate();
_pRecordSet->filter(this);
}
RowFilter::RowFilter(Ptr pParent, LogicOperator op): _pRecordSet(0),
_pParent(pParent),
_not(false)
{
poco_check_ptr(_pParent.get());
init();
duplicate();
_pParent->addFilter(this, op);
}
void RowFilter::init()
{
_comparisons.insert(Comparisons::value_type("<", VALUE_LESS_THAN));
_comparisons.insert(Comparisons::value_type("<=", VALUE_LESS_THAN_OR_EQUAL));
_comparisons.insert(Comparisons::value_type("=", VALUE_EQUAL));
_comparisons.insert(Comparisons::value_type("==", VALUE_EQUAL));
_comparisons.insert(Comparisons::value_type(">", VALUE_GREATER_THAN));
_comparisons.insert(Comparisons::value_type(">=", VALUE_GREATER_THAN_OR_EQUAL));
_comparisons.insert(Comparisons::value_type("<>", VALUE_NOT_EQUAL));
_comparisons.insert(Comparisons::value_type("!=", VALUE_NOT_EQUAL));
_comparisons.insert(Comparisons::value_type("IS NULL", VALUE_IS_NULL));
}
RowFilter::~RowFilter()
{
try
{
if (_pRecordSet) _pRecordSet->filter(0);
if (_pParent && _pParent->has(this))
_pParent->removeFilter(this);
release();
}
catch (...)
{
poco_unexpected();
}
}
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();
for (; it != end; ++it)
{
for (std::size_t col = 0; col < columns; ++col)
{
const std::string name = toUpper(rs.metaColumn(static_cast<UInt32>(col)).name());
if (_comparisonMap.find(name) == _comparisonMap.end()) continue;
Poco::Dynamic::Var ret;
CompT compOp = 0;
Poco::Dynamic::Var val = rs.value(col, row, false);
switch (it->second.get<1>())
{
case VALUE_LESS_THAN:
compOp = less; break;
case VALUE_LESS_THAN_OR_EQUAL:
compOp = lessOrEqual; break;
case VALUE_EQUAL:
compOp = equal; break;
case VALUE_GREATER_THAN:
compOp = greater; break;
case VALUE_GREATER_THAN_OR_EQUAL:
compOp = greaterOrEqual; break;
case VALUE_NOT_EQUAL:
compOp = notEqual; break;
case VALUE_IS_NULL:
compOp = isNull; break;
default:
throw IllegalStateException("Unsupported comparison criteria.");
}
doCompare(ret, val, compOp, it->second);
if (retVal.isEmpty()) retVal = ret;
else retVal = retVal || ret;
}
}
// iterate through children
FilterMap::const_iterator fIt = _filterMap.begin();
FilterMap::const_iterator fEnd = _filterMap.end();
for (; fIt != fEnd; ++fIt)
{
if (OP_OR == fIt->second)
{
if (retVal.isEmpty())
retVal = fIt->first->isAllowed(row);
else
retVal = retVal || fIt->first->isAllowed(row);
}
else if (OP_AND == fIt->second)
{
if (retVal.isEmpty())
retVal = fIt->first->isAllowed(row);
else
retVal = retVal && fIt->first->isAllowed(row);
}
else
throw IllegalStateException("Unknown logical operation.");
}
if (retVal.isEmpty()) retVal = true; // no filtering found
return (!_not) && retVal.extract<bool>();
}
int RowFilter::remove(const std::string& name)
{
poco_check_ptr (_pRecordSet);
_pRecordSet->moveFirst();
return static_cast<int>(_comparisonMap.erase(toUpper(name)));
}
RowFilter::Comparison RowFilter::getComparison(const std::string& comp) const
{
Comparisons::const_iterator it = _comparisons.find(toUpper(comp));
if (it == _comparisons.end())
throw NotFoundException("Comparison not found", comp);
return it->second;
}
void RowFilter::addFilter(Ptr pFilter, LogicOperator comparison)
{
poco_check_ptr (_pRecordSet);
pFilter->_pRecordSet = _pRecordSet;
_pRecordSet->moveFirst();
_filterMap.insert(FilterMap::value_type(pFilter, comparison));
}
void RowFilter::removeFilter(Ptr pFilter)
{
poco_check_ptr (_pRecordSet);
_pRecordSet->moveFirst();
_filterMap.erase(pFilter);
pFilter->_pRecordSet = 0;
pFilter->_pParent = 0;
}
void RowFilter::doCompare(Poco::Dynamic::Var& ret,
Poco::Dynamic::Var& val,
CompT comp,
const ComparisonEntry& ce)
{
if (ret.isEmpty()) ret = comp(val, ce.get<0>());
else
{
if (ce.get<2>() == OP_OR)
ret = ret || comp(val, ce.get<0>());
else if (ce.get<2>() == OP_AND)
ret = ret && comp(val, ce.get<0>());
else
throw IllegalStateException("Unknown logical operation.");
}
}
RecordSet& RowFilter::recordSet() const
{
if (!_pRecordSet)
{
Ptr pParent = _pParent;
while (pParent && !_pRecordSet)
_pRecordSet = pParent->_pRecordSet;
}
poco_check_ptr (_pRecordSet);
return *_pRecordSet;
}
void RowFilter::rewindRecordSet()
{
if (_pRecordSet) _pRecordSet->moveFirst();
}
} } // namespace Poco::Data

80
vendor/POCO/Data/src/RowFormatter.cpp vendored Normal file
View File

@ -0,0 +1,80 @@
//
// RowFormatter.cpp
//
// Library: Data
// Package: DataCore
// Module: RowFormatter
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/RowFormatter.h"
#include "Poco/Exception.h"
#include <iomanip>
namespace Poco {
namespace Data {
RowFormatter::RowFormatter(const std::string& prefix,
const std::string& postfix,
Mode mode):
_prefix(prefix),
_postfix(postfix),
_mode(mode),
_totalRowCount(0)
{
}
RowFormatter::~RowFormatter()
{
}
std::string& RowFormatter::formatNames(const NameVecPtr pNames, std::string& formattedNames)
{
formattedNames.clear();
return formattedNames;
}
void RowFormatter::formatNames(const NameVecPtr pNames)
{
return;
}
std::string& RowFormatter::formatValues(const ValueVec& vals, std::string& formattedValues)
{
formattedValues.clear();
return formattedValues;
}
void RowFormatter::formatValues(const ValueVec& vals)
{
return;
}
const std::string& RowFormatter::toString()
{
throw NotImplementedException("RowFormatter::toString()");
}
void RowFormatter::reset()
{
_prefix = "";
_postfix = "";
_totalRowCount = INVALID_ROW_COUNT;
}
} } // namespace Poco::Data

221
vendor/POCO/Data/src/RowIterator.cpp vendored Normal file
View File

@ -0,0 +1,221 @@
//
// RowIterator.cpp
//
// Library: Data
// Package: DataCore
// Module: RowIterator
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/RowIterator.h"
#include "Poco/Data/RecordSet.h"
#undef min
#undef max
#include <limits>
namespace Poco {
namespace Data {
const std::size_t RowIterator::POSITION_END = std::numeric_limits<std::size_t>::max();
RowIterator::RowIterator(RecordSet* pRecordSet, bool positionEnd):
_pRecordSet(pRecordSet),
_position(positionEnd ? POSITION_END : 0)
{
}
RowIterator::RowIterator(const RowIterator& other):
_pRecordSet(other._pRecordSet),
_position(other._position)
{
}
RowIterator::RowIterator(RowIterator&& other) noexcept:
_pRecordSet(std::move(other._pRecordSet)),
_position(std::move(other._position))
{
}
RowIterator::~RowIterator()
{
}
RowIterator& RowIterator::operator = (const RowIterator& other)
{
RowIterator tmp(other);
swap(tmp);
return *this;
}
RowIterator& RowIterator::operator = (RowIterator&& other) noexcept
{
_pRecordSet = std::move(other._pRecordSet);
_position = std::move(other._position);
return *this;
}
void RowIterator::swap(RowIterator& other)
{
using std::swap;
swap(_pRecordSet, other._pRecordSet);
swap(_position, other._position);
}
void RowIterator::increment() const
{
if (POSITION_END == _position)
throw RangeException("End of iterator reached.");
if (_position < _pRecordSet->subTotalRowCount() - 1)
++_position;
else
_position = POSITION_END;
if (_pRecordSet->getFilter() && POSITION_END != _position)
{
while (!_pRecordSet->isAllowed(_position))
{
increment();
if (POSITION_END == _position) break;
}
}
}
void RowIterator::decrement() const
{
if (0 == _position)
throw RangeException("Beginning of iterator reached.");
else if (POSITION_END == _position)
_position = _pRecordSet->subTotalRowCount() - 1;
else
--_position;
if (_pRecordSet->getFilter() && 0 != _position)
{
while (!_pRecordSet->isAllowed(_position))
{
decrement();
if (0 == _position) break;
}
}
}
void RowIterator::setPosition(std::size_t pos) const
{
if (_position == pos) return;
if (_pRecordSet->getFilter())
{
std::size_t start = _position;
if (_position > pos)
{
std::size_t end = _position - pos;
for (; start > end; --start)
{
if (pos) --pos;
else throw RangeException("Invalid position argument.");
}
}
else
{
std::size_t end = pos - _position;
for (; start < end; ++start)
{
if (_pRecordSet->subTotalRowCount() != pos) ++pos;
else throw RangeException("Invalid position argument.");
}
}
}
if (pos < _pRecordSet->subTotalRowCount())
_position = pos;
else if (pos == _pRecordSet->subTotalRowCount())
_position = POSITION_END;
else
throw RangeException("Invalid position argument.");
}
Row& RowIterator::operator * () const
{
if (POSITION_END == _position)
throw InvalidAccessException("End of iterator reached.");
return _pRecordSet->row(_position);
}
Row* RowIterator::operator -> () const
{
if (POSITION_END == _position)
throw InvalidAccessException("End of iterator reached.");
return &_pRecordSet->row(_position);
}
const RowIterator& RowIterator::operator ++ () const
{
increment();
return *this;
}
RowIterator RowIterator::operator ++ (int) const
{
RowIterator old(*this);
increment();
return old;
}
const RowIterator& RowIterator::operator -- () const
{
decrement();
return *this;
}
RowIterator RowIterator::operator -- (int) const
{
RowIterator old(*this);
decrement();
return old;
}
RowIterator RowIterator::operator + (std::size_t diff) const
{
RowIterator ri(*this);
ri.setPosition(_position + diff);
return ri;
}
RowIterator RowIterator::operator - (std::size_t diff) const
{
if (diff > _position) throw RangeException("Invalid position argument.");
RowIterator ri(*this);
ri.setPosition(_position - diff);
return ri;
}
} } // namespace Poco::Data

296
vendor/POCO/Data/src/SQLChannel.cpp vendored Normal file
View File

@ -0,0 +1,296 @@
//
// SQLChannel.cpp
//
// Library: Data
// Package: Logging
// Module: SQLChannel
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/SQLChannel.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/DateTime.h"
#include "Poco/LoggingFactory.h"
#include "Poco/Instantiator.h"
#include "Poco/NumberParser.h"
#include "Poco/NumberFormatter.h"
#include "Poco/Format.h"
namespace Poco {
namespace Data {
using namespace Keywords;
const std::string SQLChannel::PROP_CONNECTOR("connector");
const std::string SQLChannel::PROP_CONNECT("connect");
const std::string SQLChannel::PROP_NAME("name");
const std::string SQLChannel::PROP_TABLE("table");
const std::string SQLChannel::PROP_ARCHIVE_TABLE("archive");
const std::string SQLChannel::PROP_MAX_AGE("keep");
const std::string SQLChannel::PROP_ASYNC("async");
const std::string SQLChannel::PROP_TIMEOUT("timeout");
const std::string SQLChannel::PROP_THROW("throw");
SQLChannel::SQLChannel():
_name("-"),
_table("T_POCO_LOG"),
_timeout(1000),
_throw(true),
_async(true),
_pid(),
_tid(),
_priority()
{
}
SQLChannel::SQLChannel(const std::string& connector,
const std::string& connect,
const std::string& name):
_connector(connector),
_connect(connect),
_name(name),
_table("T_POCO_LOG"),
_timeout(1000),
_throw(true),
_async(true),
_pid(),
_tid(),
_priority()
{
open();
}
SQLChannel::~SQLChannel()
{
try
{
close();
}
catch (...)
{
poco_unexpected();
}
}
void SQLChannel::open()
{
if (_connector.empty() || _connect.empty())
throw IllegalStateException("Connector and connect string must be non-empty.");
_pSession = new Session(_connector, _connect);
initLogStatement();
}
void SQLChannel::close()
{
wait();
}
void SQLChannel::log(const Message& msg)
{
if (_async) logAsync(msg);
else logSync(msg);
}
void SQLChannel::logAsync(const Message& msg)
{
poco_check_ptr (_pLogStatement);
if (0 == wait() && !_pLogStatement->done() && !_pLogStatement->initialized())
{
if (_throw)
throw TimeoutException("Timed out waiting for previous statement completion");
else return;
}
if (!_pSession || !_pSession->isConnected()) open();
logSync(msg);
}
void SQLChannel::logSync(const Message& msg)
{
if (_pArchiveStrategy) _pArchiveStrategy->archive();
_source = msg.getSource();
_pid = msg.getPid();
_thread = msg.getThread();
_tid = msg.getTid();
_priority = msg.getPriority();
_text = msg.getText();
_dateTime = msg.getTime();
if (_source.empty()) _source = _name;
try
{
_pLogStatement->execute();
}
catch (Exception&)
{
if (_throw) throw;
}
}
void SQLChannel::setProperty(const std::string& name, const std::string& value)
{
if (name == PROP_NAME)
{
_name = value;
if (_name.empty()) _name = "-";
}
else if (name == PROP_CONNECTOR)
{
_connector = value;
close(); open();
}
else if (name == PROP_CONNECT)
{
_connect = value;
close(); open();
}
else if (name == PROP_TABLE)
{
_table = value;
initLogStatement();
}
else if (name == PROP_ARCHIVE_TABLE)
{
if (value.empty())
{
_pArchiveStrategy = 0;
}
else if (_pArchiveStrategy)
{
_pArchiveStrategy->setDestination(value);
}
else
{
_pArchiveStrategy = new ArchiveByAgeStrategy(_connector, _connect, _table, value);
}
}
else if (name == PROP_MAX_AGE)
{
if (value.empty() || "forever" == value)
{
_pArchiveStrategy = 0;
}
else if (_pArchiveStrategy)
{
_pArchiveStrategy->setThreshold(value);
}
else
{
ArchiveByAgeStrategy* p = new ArchiveByAgeStrategy(_connector, _connect, _table);
p->setThreshold(value);
_pArchiveStrategy = p;
}
}
else if (name == PROP_ASYNC)
{
_async = isTrue(value);
initLogStatement();
}
else if (name == PROP_TIMEOUT)
{
if (value.empty() || '0' == value[0])
_timeout = Statement::WAIT_FOREVER;
else
_timeout = NumberParser::parse(value);
}
else if (name == PROP_THROW)
{
_throw = isTrue(value);
}
else
{
Channel::setProperty(name, value);
}
}
std::string SQLChannel::getProperty(const std::string& name) const
{
if (name == PROP_NAME)
{
if (_name != "-") return _name;
else return "";
}
else if (name == PROP_CONNECTOR)
{
return _connector;
}
else if (name == PROP_CONNECT)
{
return _connect;
}
else if (name == PROP_TABLE)
{
return _table;
}
else if (name == PROP_ARCHIVE_TABLE)
{
return _pArchiveStrategy ? _pArchiveStrategy->getDestination() : "";
}
else if (name == PROP_MAX_AGE)
{
return _pArchiveStrategy ? _pArchiveStrategy->getThreshold() : "forever";
}
else if (name == PROP_TIMEOUT)
{
return NumberFormatter::format(_timeout);
}
else if (name == PROP_THROW)
{
if (_throw) return "true";
else return "false";
}
else
{
return Channel::getProperty(name);
}
}
void SQLChannel::initLogStatement()
{
_pLogStatement = new Statement(*_pSession);
std::string sql;
Poco::format(sql, "INSERT INTO %s VALUES (?,?,?,?,?,?,?,?)", _table);
*_pLogStatement << sql,
use(_source),
use(_name),
use(_pid),
use(_thread),
use(_tid),
use(_priority),
use(_text),
use(_dateTime);
if (_async) _pLogStatement->setAsync();
}
void SQLChannel::registerChannel()
{
Poco::LoggingFactory::defaultFactory().registerChannelClass("SQLChannel",
new Poco::Instantiator<SQLChannel, Poco::Channel>);
}
} } // namespace Poco::Data

93
vendor/POCO/Data/src/Session.cpp vendored Normal file
View File

@ -0,0 +1,93 @@
//
// Session.cpp
//
// Library: Data
// Package: DataCore
// Module: Session
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Session.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/String.h"
#include "Poco/URI.h"
#include <algorithm>
namespace Poco {
namespace Data {
Session::Session(Poco::AutoPtr<SessionImpl> pImpl):
_pImpl(pImpl),
_statementCreator(pImpl)
{
poco_check_ptr (pImpl.get());
}
Session::Session(const std::string& connector,
const std::string& connectionString,
std::size_t timeout)
{
Session newSession(SessionFactory::instance().create(connector, connectionString, timeout));
swap(newSession);
}
Session::Session(const std::string& connection,
std::size_t timeout)
{
Session newSession(SessionFactory::instance().create(connection, timeout));
swap(newSession);
}
Session::Session(const Session& other):
_pImpl(other._pImpl),
_statementCreator(other._statementCreator)
{
}
Session::Session(Session&& other) noexcept:
_pImpl(std::move(other._pImpl)),
_statementCreator(std::move(other._statementCreator))
{
}
Session::~Session()
{
}
Session& Session::operator = (const Session& other)
{
Session tmp(other);
swap(tmp);
return *this;
}
Session& Session::operator = (Session&& other) noexcept
{
_pImpl = std::move(other._pImpl);
_statementCreator = std::move(other._statementCreator);
return *this;
}
void Session::swap(Session& other)
{
using std::swap;
swap(_statementCreator, other._statementCreator);
swap(_pImpl, other._pImpl);
}
} } // namespace Poco::Data

93
vendor/POCO/Data/src/SessionFactory.cpp vendored Normal file
View File

@ -0,0 +1,93 @@
//
// SessionFactory.cpp
//
// Library: Data
// Package: DataCore
// Module: SessionFactory
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/SessionFactory.h"
#include "Poco/URI.h"
#include "Poco/String.h"
namespace Poco {
namespace Data {
SessionFactory::SessionFactory()
{
}
SessionFactory::~SessionFactory()
{
}
SessionFactory& SessionFactory::instance()
{
static SessionFactory sf;
return sf;
}
void SessionFactory::add(Connector* pIn)
{
Poco::FastMutex::ScopedLock lock(_mutex);
SessionInfo info(pIn);
std::pair<Connectors::iterator, bool> res =
_connectors.insert(std::make_pair(pIn->name(), info));
if (!res.second) res.first->second.cnt++;
}
void SessionFactory::remove(const std::string& key)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Connectors::iterator it = _connectors.find(key);
poco_assert (_connectors.end() != it);
--(it->second.cnt);
if (it->second.cnt == 0) _connectors.erase(it);
}
Session SessionFactory::create(const std::string& key,
const std::string& connectionString,
std::size_t timeout)
{
Poco::SharedPtr<Connector> ptrSI;
{
Poco::FastMutex::ScopedLock lock(_mutex);
Connectors::iterator it = _connectors.find(key);
if (_connectors.end() == it) throw Poco::NotFoundException(key);
ptrSI = it->second.ptrSI;
}
return Session(ptrSI->createSession(connectionString, timeout));
}
Session SessionFactory::create(const std::string& uri,
std::size_t timeout)
{
URI u(uri);
poco_assert (!u.getPath().empty());
return create(u.getScheme(), u.getPath().substr(1), timeout);
}
SessionFactory::SessionInfo::SessionInfo(Connector* pSI):
cnt(1),
ptrSI(pSI)
{
}
} } // namespace Poco::Data

58
vendor/POCO/Data/src/SessionImpl.cpp vendored Normal file
View File

@ -0,0 +1,58 @@
//
// SessionImpl.cpp
//
// Library: Data
// Package: DataCore
// Module: SessionImpl
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/SessionImpl.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
SessionImpl::SessionImpl(const std::string& connectionString, std::size_t timeout):
_connectionString(connectionString),
_loginTimeout(timeout)
{
}
SessionImpl::~SessionImpl()
{
}
void SessionImpl::reconnect()
{
close();
open();
}
void SessionImpl::setConnectionString(const std::string& connectionString)
{
if (isConnected())
throw Poco::InvalidAccessException("Can not change connection string on connected session."
" Close the session first.");
_connectionString = connectionString;
}
bool SessionImpl::isGood() const
{
return isConnected();
}
} } // namespace Poco::Data

310
vendor/POCO/Data/src/SessionPool.cpp vendored Normal file
View File

@ -0,0 +1,310 @@
//
// SessionPool.cpp
//
// Library: Data
// Package: SessionPooling
// Module: SessionPool
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/SessionPool.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/Data/DataException.h"
#include <algorithm>
namespace Poco {
namespace Data {
SessionPool::SessionPool(const std::string& connector, const std::string& connectionString, int minSessions, int maxSessions, int idleTime):
_connector(connector),
_connectionString(connectionString),
_minSessions(minSessions),
_maxSessions(maxSessions),
_idleTime(idleTime),
_nSessions(0),
_janitorTimer(1000*idleTime, 1000*idleTime/4),
_shutdown(false)
{
Poco::TimerCallback<SessionPool> callback(*this, &SessionPool::onJanitorTimer);
_janitorTimer.start(callback);
}
SessionPool::~SessionPool()
{
try
{
shutdown();
}
catch (...)
{
poco_unexpected();
}
}
Session SessionPool::get(const std::string& name, bool value)
{
Session s = get();
_addFeatureMap.insert(AddFeatureMap::value_type(s.impl(),
std::make_pair(name, s.getFeature(name))));
s.setFeature(name, value);
return s;
}
Session SessionPool::get()
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pool has been shut down.");
purgeDeadSessions();
if (_idleSessions.empty())
{
if (_nSessions < _maxSessions)
{
Session newSession(SessionFactory::instance().create(_connector, _connectionString));
applySettings(newSession.impl());
customizeSession(newSession);
PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl()));
_idleSessions.push_front(pHolder);
++_nSessions;
}
else throw SessionPoolExhaustedException(_connector);
}
PooledSessionHolderPtr pHolder(_idleSessions.front());
PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder));
_activeSessions.push_front(pHolder);
_idleSessions.pop_front();
return Session(pPSI);
}
void SessionPool::purgeDeadSessions()
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = _idleSessions.begin();
for (; it != _idleSessions.end(); )
{
if (!(*it)->session()->isGood())
{
it = _idleSessions.erase(it);
--_nSessions;
}
else ++it;
}
}
int SessionPool::capacity() const
{
return _maxSessions;
}
int SessionPool::used() const
{
Poco::Mutex::ScopedLock lock(_mutex);
return (int) _activeSessions.size();
}
int SessionPool::idle() const
{
Poco::Mutex::ScopedLock lock(_mutex);
return (int) _idleSessions.size();
}
int SessionPool::dead()
{
Poco::Mutex::ScopedLock lock(_mutex);
int count = 0;
SessionList::iterator it = _activeSessions.begin();
SessionList::iterator itEnd = _activeSessions.end();
for (; it != itEnd; ++it)
{
if (!(*it)->session()->isGood())
++count;
}
return count;
}
int SessionPool::allocated() const
{
Poco::Mutex::ScopedLock lock(_mutex);
return _nSessions;
}
int SessionPool::available() const
{
if (_shutdown) return 0;
return _maxSessions - used();
}
void SessionPool::setFeature(const std::string& name, bool state)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pool has been shut down.");
if (_nSessions > 0)
throw InvalidAccessException("Features can not be set after the first session was created.");
_featureMap.insert(FeatureMap::ValueType(name, state));
}
bool SessionPool::getFeature(const std::string& name)
{
FeatureMap::ConstIterator it = _featureMap.find(name);
if (_shutdown) throw InvalidAccessException("Session pool has been shut down.");
if (_featureMap.end() == it)
throw NotFoundException("Feature not found:" + name);
return it->second;
}
void SessionPool::setProperty(const std::string& name, const Poco::Any& value)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pool has been shut down.");
if (_nSessions > 0)
throw InvalidAccessException("Properties can not be set after first session was created.");
_propertyMap.insert(PropertyMap::ValueType(name, value));
}
Poco::Any SessionPool::getProperty(const std::string& name)
{
PropertyMap::ConstIterator it = _propertyMap.find(name);
if (_propertyMap.end() == it)
throw NotFoundException("Property not found:" + name);
return it->second;
}
void SessionPool::applySettings(SessionImpl* pImpl)
{
FeatureMap::Iterator fmIt = _featureMap.begin();
FeatureMap::Iterator fmEnd = _featureMap.end();
for (; fmIt != fmEnd; ++fmIt) pImpl->setFeature(fmIt->first, fmIt->second);
PropertyMap::Iterator pmIt = _propertyMap.begin();
PropertyMap::Iterator pmEnd = _propertyMap.end();
for (; pmIt != pmEnd; ++pmIt) pImpl->setProperty(pmIt->first, pmIt->second);
}
void SessionPool::customizeSession(Session&)
{
}
void SessionPool::putBack(PooledSessionHolderPtr pHolder)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = std::find(_activeSessions.begin(), _activeSessions.end(), pHolder);
if (it != _activeSessions.end())
{
if (pHolder->session()->isGood())
{
pHolder->session()->reset();
// reverse settings applied at acquisition time, if any
AddPropertyMap::iterator pIt = _addPropertyMap.find(pHolder->session());
if (pIt != _addPropertyMap.end())
pHolder->session()->setProperty(pIt->second.first, pIt->second.second);
AddFeatureMap::iterator fIt = _addFeatureMap.find(pHolder->session());
if (fIt != _addFeatureMap.end())
pHolder->session()->setFeature(fIt->second.first, fIt->second.second);
// re-apply the default pool settings
applySettings(pHolder->session());
pHolder->access();
_idleSessions.push_front(pHolder);
}
else --_nSessions;
_activeSessions.erase(it);
}
else
{
poco_bugcheck_msg("Unknown session passed to SessionPool::putBack()");
}
}
void SessionPool::onJanitorTimer(Poco::Timer&)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = _idleSessions.begin();
while (_nSessions > _minSessions && it != _idleSessions.end())
{
if ((*it)->idle() > _idleTime || !(*it)->session()->isGood())
{
try { (*it)->session()->close(); }
catch (...) { }
it = _idleSessions.erase(it);
--_nSessions;
}
else ++it;
}
}
void SessionPool::shutdown()
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
_shutdown = true;
_janitorTimer.stop();
closeAll(_idleSessions);
closeAll(_activeSessions);
}
void SessionPool::closeAll(SessionList& sessionList)
{
SessionList::iterator it = sessionList.begin();
for (; it != sessionList.end();)
{
try { (*it)->session()->close(); }
catch (...) { }
it = sessionList.erase(it);
if (_nSessions > 0) --_nSessions;
}
}
} } // namespace Poco::Data

View File

@ -0,0 +1,122 @@
//
// SessionPoolContainer.cpp
//
// Library: Data
// Package: SessionPooling
// Module: SessionPoolContainer
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/SessionPoolContainer.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/Data/DataException.h"
#include "Poco/URI.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
#include <algorithm>
using Poco::FastMutex;
namespace Poco {
namespace Data {
SessionPoolContainer::SessionPoolContainer()
{
}
SessionPoolContainer::~SessionPoolContainer()
{
}
void SessionPoolContainer::add(SessionPool* pPool)
{
poco_check_ptr (pPool);
FastMutex::ScopedLock lock(_mutex);
if (_sessionPools.find(pPool->name()) != _sessionPools.end())
throw SessionPoolExistsException("Session pool already exists: " + pPool->name());
pPool->duplicate();
_sessionPools.insert(SessionPoolMap::value_type(pPool->name(), pPool));
}
Session SessionPoolContainer::add(const std::string& sessionKey,
const std::string& connectionString,
int minSessions,
int maxSessions,
int idleTime)
{
std::string name = SessionPool::name(sessionKey, connectionString);
FastMutex::ScopedLock lock(_mutex);
SessionPoolMap::iterator it = _sessionPools.find(name);
// pool already exists, silently return a session from it
if (it != _sessionPools.end()) return it->second->get();
SessionPool* pSP =
new SessionPool(sessionKey, connectionString, minSessions, maxSessions, idleTime);
std::pair<SessionPoolMap::iterator, bool> ins =
_sessionPools.insert(SessionPoolMap::value_type(name, pSP));
return ins.first->second->get();
}
bool SessionPoolContainer::isActive(const std::string& sessionKey,
const std::string& connectionString) const
{
std::string name = connectionString.empty() ?
sessionKey : SessionPool::name(sessionKey, connectionString);
SessionPoolMap::const_iterator it = _sessionPools.find(name);
if (it != _sessionPools.end() && it->second->isActive())
{
return true;
}
return false;
}
Session SessionPoolContainer::get(const std::string& name)
{
return getPool(name).get();
}
SessionPool& SessionPoolContainer::getPool(const std::string& name)
{
URI uri(name);
std::string path = uri.getPath();
poco_assert (!path.empty());
std::string n = Session::uri(uri.getScheme(), path.substr(1));
FastMutex::ScopedLock lock(_mutex);
SessionPoolMap::iterator it = _sessionPools.find(n);
if (_sessionPools.end() == it) throw NotFoundException(n);
return *it->second;
}
void SessionPoolContainer::shutdown()
{
SessionPoolMap::iterator it = _sessionPools.begin();
SessionPoolMap::iterator end = _sessionPools.end();
for (; it != end; ++it) it->second->shutdown();
}
} } // namespace Poco::Data

View File

@ -0,0 +1,113 @@
//
// RowFormatter.cpp
//
// Library: Data
// Package: DataCore
// Module: RowFormatter
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/SimpleRowFormatter.h"
#include "Poco/Exception.h"
#include <iomanip>
namespace Poco {
namespace Data {
SimpleRowFormatter::SimpleRowFormatter(std::streamsize columnWidth, std::streamsize spacing):
_colWidth(columnWidth), _spacing(spacing), _rowCount(0)
{
}
SimpleRowFormatter::SimpleRowFormatter(const SimpleRowFormatter& other):
RowFormatter(other.prefix(), other.postfix()),
_colWidth(other._colWidth),
_spacing(other._spacing),
_rowCount(0)
{
}
SimpleRowFormatter::~SimpleRowFormatter()
{
}
SimpleRowFormatter& SimpleRowFormatter::operator = (const SimpleRowFormatter& row)
{
SimpleRowFormatter tmp(row);
swap(tmp);
return *this;
}
void SimpleRowFormatter::swap(SimpleRowFormatter& other)
{
using std::swap;
setPrefix(other.prefix());
setPostfix(other.postfix());
swap(_colWidth, other._colWidth);
swap(_spacing, other._spacing);
}
std::string& SimpleRowFormatter::formatNames(const NameVecPtr pNames, std::string& formattedNames)
{
_rowCount = 0;
std::ostringstream str;
std::string line(std::string::size_type(pNames->size()*_colWidth + (pNames->size() - 1)*_spacing), '-');
std::string space(_spacing, ' ');
NameVec::const_iterator it = pNames->begin();
NameVec::const_iterator end = pNames->end();
for (; it != end; ++it)
{
if (it != pNames->begin()) str << space;
str << std::left << std::setw(_colWidth) << *it;
}
str << std::endl << line << std::endl;
return formattedNames = str.str();
}
std::string& SimpleRowFormatter::formatValues(const ValueVec& vals, std::string& formattedValues)
{
std::ostringstream str;
std::string space(_spacing, ' ');
ValueVec::const_iterator it = vals.begin();
ValueVec::const_iterator end = vals.end();
for (; it != end; ++it)
{
if (it != vals.begin()) str << space;
if (it->isNumeric())
{
str << std::right
<< std::fixed
<< std::setprecision(2);
}
else str << std::left;
if (!it->isEmpty())
str << std::setw(_colWidth) << it->convert<std::string>();
else
str << std::setw(_colWidth) << "null";
}
str << std::endl;
++_rowCount;
return formattedValues = str.str();
}
} } // namespace Poco::Data

319
vendor/POCO/Data/src/Statement.cpp vendored Normal file
View File

@ -0,0 +1,319 @@
//
// Statement.cpp
//
// Library: Data
// Package: DataCore
// Module: Statement
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Statement.h"
#include "Poco/Data/DataException.h"
#include "Poco/Data/Extraction.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/Bulk.h"
#include "Poco/Any.h"
#include "Poco/Tuple.h"
#include "Poco/ActiveMethod.h"
#include <algorithm>
namespace Poco {
namespace Data {
Statement::Statement(StatementImpl::Ptr pImpl):
_pImpl(pImpl),
_async(false)
{
poco_check_ptr (pImpl);
}
Statement::Statement(Session& session):
_async(false)
{
reset(session);
}
Statement::Statement(const Statement& stmt):
_pImpl(stmt._pImpl),
_async(stmt._async),
_pResult(stmt._pResult),
_pAsyncExec(stmt._pAsyncExec),
_arguments(stmt._arguments),
_pRowFormatter(stmt._pRowFormatter)
{
}
Statement::Statement(Statement&& stmt) noexcept:
_pImpl(std::move(stmt._pImpl)),
_async(std::move(stmt._async)),
_pResult(std::move(stmt._pResult)),
_pAsyncExec(std::move(stmt._pAsyncExec)),
_arguments(std::move(stmt._arguments)),
_pRowFormatter(std::move(stmt._pRowFormatter))
{
}
Statement::~Statement()
{
}
Statement& Statement::operator = (const Statement& stmt)
{
Statement tmp(stmt);
swap(tmp);
return *this;
}
Statement& Statement::operator = (Statement&& stmt) noexcept
{
_pImpl = std::move(stmt._pImpl);
_async = std::move(stmt._async);
_pResult = std::move(stmt._pResult);
_pAsyncExec = std::move(stmt._pAsyncExec);
_arguments = std::move(stmt._arguments);
_pRowFormatter = std::move(stmt._pRowFormatter);
return *this;
}
void Statement::swap(Statement& other)
{
using std::swap;
swap(_pImpl, other._pImpl);
swap(_async, other._async);
swap(_pAsyncExec, other._pAsyncExec);
swap(_pResult, other._pResult);
_arguments.swap(other._arguments);
swap(_pRowFormatter, other._pRowFormatter);
}
Statement& Statement::reset(Session& session)
{
Statement stmt(session.createStatementImpl());
swap(stmt);
return *this;
}
std::size_t Statement::execute(bool reset)
{
Mutex::ScopedLock lock(_mutex);
bool isDone = done();
if (initialized() || paused() || isDone)
{
if (_arguments.size())
{
_pImpl->formatSQL(_arguments);
_arguments.clear();
}
if (!isAsync())
{
if (isDone) _pImpl->reset();
return _pImpl->execute(reset);
}
else
{
doAsyncExec();
return 0;
}
}
else throw InvalidAccessException("Statement still executing.");
}
const Statement::Result& Statement::executeAsync(bool reset)
{
Mutex::ScopedLock lock(_mutex);
if (initialized() || paused() || done())
return doAsyncExec(reset);
else
throw InvalidAccessException("Statement still executing.");
}
const Statement::Result& Statement::doAsyncExec(bool reset)
{
if (done()) _pImpl->reset();
if (!_pAsyncExec)
_pAsyncExec = new AsyncExecMethod(_pImpl, &StatementImpl::execute);
_pResult = new Result((*_pAsyncExec)(reset));
return *_pResult;
}
void Statement::setAsync(bool async)
{
_async = async;
if (_async && !_pAsyncExec)
_pAsyncExec = new AsyncExecMethod(_pImpl, &StatementImpl::execute);
}
std::size_t Statement::wait(long milliseconds)
{
if (!_pResult) return 0;
bool success = true;
if (WAIT_FOREVER != milliseconds)
success = _pResult->tryWait(milliseconds);
else
_pResult->wait();
if (_pResult->exception())
throw *_pResult->exception();
else if (!success)
throw TimeoutException("Statement timed out.");
return _pResult->data();
}
const std::string& Statement::getStorage() const
{
switch (storage())
{
case STORAGE_VECTOR:
return StatementImpl::VECTOR;
case STORAGE_LIST:
return StatementImpl::LIST;
case STORAGE_DEQUE:
return StatementImpl::DEQUE;
case STORAGE_UNKNOWN:
return StatementImpl::UNKNOWN;
}
throw IllegalStateException("Invalid storage setting.");
}
Statement& Statement::operator , (Manipulator manip)
{
manip(*this);
return *this;
}
Statement& Statement::addBind(AbstractBinding::Ptr pBind)
{
if (pBind->isBulk())
{
if (!_pImpl->isBulkSupported())
throw InvalidAccessException("Bulk not supported by this session.");
if(_pImpl->bulkBindingAllowed())
_pImpl->setBulkBinding();
else
throw InvalidAccessException("Bulk and non-bulk binding modes can not be mixed.");
}
else _pImpl->forbidBulk();
_pImpl->addBind(pBind);
return *this;
}
Statement& Statement::addExtract(AbstractExtraction::Ptr pExtract)
{
if (pExtract->isBulk())
{
if (!_pImpl->isBulkSupported())
throw InvalidAccessException("Bulk not supported by this session.");
if(_pImpl->bulkExtractionAllowed())
{
Bulk b(pExtract->getLimit());
_pImpl->setBulkExtraction(b);
}
else
throw InvalidAccessException("Bulk and non-bulk extraction modes can not be mixed.");
}
else _pImpl->forbidBulk();
_pImpl->addExtract(pExtract);
return *this;
}
Statement& Statement::operator , (const Limit& extrLimit)
{
if (_pImpl->isBulkExtraction() && _pImpl->extractionLimit() != extrLimit)
throw InvalidArgumentException("Limit for bulk extraction already set.");
_pImpl->setExtractionLimit(extrLimit);
return *this;
}
Statement& Statement::operator , (const Range& extrRange)
{
if (_pImpl->isBulkExtraction())
throw InvalidAccessException("Can not set range for bulk extraction.");
_pImpl->setExtractionLimit(extrRange.lower());
_pImpl->setExtractionLimit(extrRange.upper());
return *this;
}
Statement& Statement::operator , (const Bulk& bulk)
{
if (!_pImpl->isBulkSupported())
throw InvalidAccessException("Bulk not supported by this session.");
if (0 == _pImpl->extractions().size() &&
0 == _pImpl->bindings().size() &&
_pImpl->bulkExtractionAllowed() &&
_pImpl->bulkBindingAllowed())
{
_pImpl->setBulkExtraction(bulk);
_pImpl->setBulkBinding();
}
else
throw InvalidAccessException("Can not set bulk operations.");
return *this;
}
Statement& Statement::operator , (BulkFnType)
{
const Limit& limit(_pImpl->extractionLimit());
if (limit.isHardLimit() ||
limit.isLowerLimit() ||
Limit::LIMIT_UNLIMITED == limit.value())
{
throw InvalidAccessException("Bulk is only allowed with limited extraction,"
"non-hard and zero-based limits.");
}
Bulk bulk(limit);
_pImpl->setBulkExtraction(bulk);
_pImpl->setBulkBinding();
return *this;
}
Session Statement::session()
{
Poco::AutoPtr<SessionImpl> ps(&impl()->session(), true);
return Session(ps);
}
} } // namespace Poco::Data

View File

@ -0,0 +1,72 @@
//
// StatementCreator.cpp
//
// Library: Data
// Package: DataCore
// Module: StatementCreator
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/StatementCreator.h"
#include <algorithm>
namespace Poco {
namespace Data {
StatementCreator::StatementCreator()
{
}
StatementCreator::StatementCreator(Poco::AutoPtr<SessionImpl> ptrImpl):
_ptrImpl(ptrImpl)
{
}
StatementCreator::StatementCreator(const StatementCreator& other):
_ptrImpl(other._ptrImpl)
{
}
StatementCreator::StatementCreator(StatementCreator&& other) noexcept:
_ptrImpl(std::move(other._ptrImpl))
{
}
StatementCreator& StatementCreator::operator = (const StatementCreator& other)
{
StatementCreator tmp(other);
swap(tmp);
return *this;
}
StatementCreator& StatementCreator::operator = (StatementCreator&& other) noexcept
{
_ptrImpl = std::move(other._ptrImpl);
return *this;
}
void StatementCreator::swap(StatementCreator& other)
{
using std::swap;
swap(_ptrImpl, other._ptrImpl);
}
StatementCreator::~StatementCreator()
{
}
} } // namespace Poco::Data

476
vendor/POCO/Data/src/StatementImpl.cpp vendored Normal file
View File

@ -0,0 +1,476 @@
//
// StatementImpl.cpp
//
// Library: Data
// Package: DataCore
// Module: StatementImpl
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/StatementImpl.h"
#include "Poco/Data/SessionImpl.h"
#include "Poco/Data/DataException.h"
#include "Poco/Data/AbstractBinder.h"
#include "Poco/Data/Extraction.h"
#include "Poco/Data/LOB.h"
#include "Poco/Data/Date.h"
#include "Poco/Data/Time.h"
#include "Poco/SharedPtr.h"
#include "Poco/DateTime.h"
#include "Poco/Exception.h"
#include "Poco/Data/DataException.h"
using Poco::icompare;
namespace Poco {
namespace Data {
using namespace Keywords;
const std::string StatementImpl::VECTOR = "vector";
const std::string StatementImpl::LIST = "list";
const std::string StatementImpl::DEQUE = "deque";
const std::string StatementImpl::UNKNOWN = "unknown";
StatementImpl::StatementImpl(SessionImpl& rSession):
_state(ST_INITIALIZED),
_extrLimit(upperLimit(Limit::LIMIT_UNLIMITED, false)),
_lowerLimit(0),
_rSession(rSession),
_storage(STORAGE_UNKNOWN_IMPL),
_ostr(),
_curDataSet(0),
_bulkBinding(BULK_UNDEFINED),
_bulkExtraction(BULK_UNDEFINED)
{
if (!_rSession.isConnected())
throw NotConnectedException(_rSession.connectionString());
_extractors.resize(1);
_columnsExtracted.resize(1, 0);
_subTotalRowCount.resize(1, 0);
}
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
{
compile();
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
lim += executeWithoutLimit();
else
lim += executeWithLimit();
} while (canCompile());
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
_state = ST_DONE;
if (lim < _lowerLimit)
throw LimitException("Did not receive enough data.");
assignSubTotal(reset);
return lim;
}
void StatementImpl::assignSubTotal(bool reset)
{
if (_extractors.size() == _subTotalRowCount.size())
{
CountVec::iterator it = _subTotalRowCount.begin();
CountVec::iterator end = _subTotalRowCount.end();
for (int counter = 0; it != end; ++it, ++counter)
{
if (_extractors[counter].size())
{
if (reset)
*it = CountVec::value_type(_extractors[counter][0]->numOfRowsHandled());
else
*it += CountVec::value_type(_extractors[counter][0]->numOfRowsHandled());
}
}
}
}
std::size_t StatementImpl::executeWithLimit()
{
poco_assert (_state != ST_DONE);
std::size_t count = 0;
std::size_t limit = _extrLimit.value();
do
{
bind();
while (count < limit && hasNext())
count += next();
} while (count < limit && canBind());
if (!canBind() && (!hasNext() || limit == 0))
_state = ST_DONE;
else if (hasNext() && limit == count && _extrLimit.isHardLimit())
throw LimitException("HardLimit reached (retrieved more data than requested).");
else
_state = ST_PAUSED;
int affectedRows = affectedRowCount();
if (count == 0)
{
if (affectedRows > 0)
return affectedRows;
}
return count;
}
std::size_t StatementImpl::executeWithoutLimit()
{
poco_assert (_state != ST_DONE);
std::size_t count = 0;
do
{
bind();
while (hasNext()) count += next();
} while (canBind());
int affectedRows = affectedRowCount();
if (count == 0)
{
if (affectedRows > 0)
return affectedRows;
}
return count;
}
void StatementImpl::compile()
{
if (_state == ST_INITIALIZED ||
_state == ST_RESET ||
_state == ST_BOUND)
{
compileImpl();
_state = ST_COMPILED;
if (!extractions().size() && !isStoredProcedure())
{
std::size_t cols = columnsReturned();
if (cols) makeExtractors(cols);
}
fixupExtraction();
fixupBinding();
}
}
void StatementImpl::bind()
{
if (_state == ST_COMPILED)
{
bindImpl();
_state = ST_BOUND;
}
else if (_state == ST_BOUND)
{
if (!hasNext())
{
if (canBind()) bindImpl();
else _state = ST_DONE;
}
}
}
void StatementImpl::reset()
{
resetBinding();
resetExtraction();
_state = ST_RESET;
}
void StatementImpl::setExtractionLimit(const Limit& extrLimit)
{
if (!extrLimit.isLowerLimit())
_extrLimit = extrLimit;
else
_lowerLimit = extrLimit.value();
}
void StatementImpl::setBulkExtraction(const Bulk& b)
{
Limit::SizeT limit = getExtractionLimit();
if (Limit::LIMIT_UNLIMITED != limit && b.size() != limit)
throw InvalidArgumentException("Can not set limit for statement.");
setExtractionLimit(b.limit());
_bulkExtraction = BULK_EXTRACTION;
}
void StatementImpl::fixupExtraction()
{
CountVec::iterator sIt = _subTotalRowCount.begin();
CountVec::iterator sEnd = _subTotalRowCount.end();
for (; sIt != sEnd; ++sIt) *sIt = 0;
if (_curDataSet >= _columnsExtracted.size())
{
_columnsExtracted.resize(_curDataSet + 1, 0);
_subTotalRowCount.resize(_curDataSet + 1, 0);
}
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
for (; it != itEnd; ++it)
{
(*it)->setExtractor(extractor());
(*it)->setLimit(_extrLimit.value()),
_columnsExtracted[_curDataSet] += (int)(*it)->numOfColumnsHandled();
}
}
void StatementImpl::fixupBinding()
{
// no need to call binder().reset(); here will be called before each bind anyway
AbstractBindingVec::iterator it = bindings().begin();
AbstractBindingVec::iterator itEnd = bindings().end();
for (; it != itEnd; ++it) (*it)->setBinder(binder());
}
void StatementImpl::resetBinding()
{
AbstractBindingVec::iterator it = bindings().begin();
AbstractBindingVec::iterator itEnd = bindings().end();
for (; it != itEnd; ++it) (*it)->reset();
}
void StatementImpl::resetExtraction()
{
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
for (; it != itEnd; ++it) (*it)->reset();
poco_assert (_curDataSet < _columnsExtracted.size());
_columnsExtracted[_curDataSet] = 0;
}
void StatementImpl::setStorage(const std::string& storage)
{
if (0 == icompare(DEQUE, storage))
_storage = STORAGE_DEQUE_IMPL;
else if (0 == icompare(VECTOR, storage))
_storage = STORAGE_VECTOR_IMPL;
else if (0 == icompare(LIST, storage))
_storage = STORAGE_LIST_IMPL;
else if (0 == icompare(UNKNOWN, storage))
_storage = STORAGE_UNKNOWN_IMPL;
else
throw NotFoundException();
}
void StatementImpl::makeExtractors(std::size_t count)
{
for (int i = 0; i < count; ++i)
{
const MetaColumn& mc = metaColumn(i);
switch (mc.type())
{
case MetaColumn::FDT_BOOL:
addInternalExtract<bool>(mc); break;
case MetaColumn::FDT_INT8:
addInternalExtract<Int8>(mc); break;
case MetaColumn::FDT_UINT8:
addInternalExtract<UInt8>(mc); break;
case MetaColumn::FDT_INT16:
addInternalExtract<Int16>(mc); break;
case MetaColumn::FDT_UINT16:
addInternalExtract<UInt16>(mc); break;
case MetaColumn::FDT_INT32:
addInternalExtract<Int32>(mc); break;
case MetaColumn::FDT_UINT32:
addInternalExtract<UInt32>(mc); break;
case MetaColumn::FDT_INT64:
addInternalExtract<Int64>(mc); break;
case MetaColumn::FDT_UINT64:
addInternalExtract<UInt64>(mc); break;
case MetaColumn::FDT_FLOAT:
addInternalExtract<float>(mc); break;
case MetaColumn::FDT_DOUBLE:
addInternalExtract<double>(mc); break;
case MetaColumn::FDT_STRING:
addInternalExtract<std::string>(mc); break;
case MetaColumn::FDT_WSTRING:
addInternalExtract<Poco::UTF16String>(mc); break;
case MetaColumn::FDT_BLOB:
addInternalExtract<BLOB>(mc); break;
case MetaColumn::FDT_DATE:
addInternalExtract<Date>(mc); break;
case MetaColumn::FDT_TIME:
addInternalExtract<Time>(mc); break;
case MetaColumn::FDT_TIMESTAMP:
addInternalExtract<DateTime>(mc); break;
default:
throw Poco::InvalidArgumentException("Data type not supported.");
}
}
}
const MetaColumn& StatementImpl::metaColumn(const std::string& name) const
{
std::size_t cols = columnsReturned();
for (std::size_t i = 0; i < cols; ++i)
{
const MetaColumn& column = metaColumn(i);
if (0 == icompare(column.name(), name)) return column;
}
throw NotFoundException(format("Invalid column name: %s", name));
}
std::size_t StatementImpl::activateNextDataSet()
{
if (_curDataSet + 1 < dataSetCount())
return ++_curDataSet;
else
throw NoDataException("End of data sets reached.");
}
std::size_t StatementImpl::activatePreviousDataSet()
{
if (_curDataSet > 0)
return --_curDataSet;
else
throw NoDataException("Beginning of data sets reached.");
}
void StatementImpl::addExtract(AbstractExtraction::Ptr pExtraction)
{
poco_check_ptr (pExtraction);
std::size_t pos = pExtraction->position();
if (pos >= _extractors.size())
_extractors.resize(pos + 1);
pExtraction->setEmptyStringIsNull(
_rSession.getFeature("emptyStringIsNull"));
pExtraction->setForceEmptyString(
_rSession.getFeature("forceEmptyString"));
_extractors[pos].push_back(pExtraction);
}
void StatementImpl::removeBind(const std::string& name)
{
bool found = false;
AbstractBindingVec::iterator it = _bindings.begin();
for (; it != _bindings.end();)
{
if ((*it)->name() == name)
{
it = _bindings.erase(it);
found = true;
}
else ++it;
}
if (!found)
throw NotFoundException(name);
}
std::size_t StatementImpl::columnsExtracted(int dataSet) const
{
if (USE_CURRENT_DATA_SET == dataSet) dataSet = static_cast<int>(_curDataSet);
if (_columnsExtracted.size() > 0)
{
poco_assert (dataSet >= 0 && dataSet < _columnsExtracted.size());
return _columnsExtracted[dataSet];
}
return 0;
}
std::size_t StatementImpl::rowsExtracted(int dataSet) const
{
if (USE_CURRENT_DATA_SET == dataSet) dataSet = static_cast<int>(_curDataSet);
if (extractions().size() > 0)
{
poco_assert (dataSet >= 0 && dataSet < _extractors.size());
if (_extractors[dataSet].size() > 0)
return _extractors[dataSet][0]->numOfRowsHandled();
}
return 0;
}
std::size_t StatementImpl::subTotalRowCount(int dataSet) const
{
if (USE_CURRENT_DATA_SET == dataSet) dataSet = static_cast<int>(_curDataSet);
if (_subTotalRowCount.size() > 0)
{
poco_assert (dataSet >= 0 && dataSet < _subTotalRowCount.size());
return _subTotalRowCount[dataSet];
}
return 0;
}
void StatementImpl::formatSQL(std::vector<Any>& arguments)
{
std::string sql;
Poco::format(sql, _ostr.str(), arguments);
_ostr.str("");
_ostr << sql;
}
} } // namespace Poco::Data

139
vendor/POCO/Data/src/Time.cpp vendored Normal file
View File

@ -0,0 +1,139 @@
//
// Time.cpp
//
// Library: Data
// Package: DataCore
// Module: Time
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Time.h"
#include "Poco/Data/DynamicDateTime.h"
#include "Poco/DateTime.h"
#include "Poco/Dynamic/Var.h"
using Poco::DateTime;
using Poco::Dynamic::Var;
namespace Poco {
namespace Data {
Time::Time()
{
DateTime dt;
assign(dt.hour(), dt.minute(), dt.second());
}
Time::Time(int hour, int minute, int second)
{
assign(hour, minute, second);
}
Time::Time(const DateTime& dt)
{
assign(dt.hour(), dt.minute(), dt.second());
}
Time::~Time()
{
}
void Time::assign(int hour, int minute, int second)
{
if (hour < 0 || hour > 23)
throw InvalidArgumentException("Hour must be between 0 and 23.");
if (minute < 0 || minute > 59)
throw InvalidArgumentException("Minute must be between 0 and 59.");
if (second < 0 || second > 59)
throw InvalidArgumentException("Second must be between 0 and 59.");
_hour = hour;
_minute = minute;
_second = second;
}
bool Time::operator < (const Time& time) const
{
int hour = time.hour();
if (_hour < hour) return true;
else if (_hour > hour) return false;
else // hours equal
{
int minute = time.minute();
if (_minute < minute) return true;
else
if (_minute > minute) return false;
else // minutes equal
if (_second < time.second()) return true;
}
return false;
}
Time& Time::operator = (const Var& var)
{
#ifndef __GNUC__
// g++ used to choke on this, newer versions seem to digest it fine
// TODO: determine the version able to handle it properly
*this = var.extract<Time>();
#else
*this = var.operator Time();
#endif
return *this;
}
} } // namespace Poco::Data
#ifdef __GNUC__
// only needed for g++ (see comment in Time::operator = above)
namespace Poco {
namespace Dynamic {
using Poco::Data::Time;
using Poco::DateTime;
template <>
Var::operator Time () const
{
VarHolder* pHolder = content();
if (!pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(Time) == pHolder->type())
return extract<Time>();
else
{
Poco::DateTime result;
pHolder->convert(result);
return Time(result);
}
}
} } // namespace Poco::Dynamic
#endif // __GNUC__

124
vendor/POCO/Data/src/Transaction.cpp vendored Normal file
View File

@ -0,0 +1,124 @@
//
// Transaction.cpp
//
// Library: Data
// Package: DataCore
// Module: Transaction
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Data/Transaction.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
Transaction::Transaction(Poco::Data::Session& rSession, Poco::Logger* pLogger):
_rSession(rSession),
_pLogger(pLogger)
{
begin();
}
Transaction::Transaction(Poco::Data::Session& rSession, bool start):
_rSession(rSession),
_pLogger(0)
{
if (start) begin();
}
Transaction::~Transaction()
{
try
{
if (_rSession.isTransaction())
{
try
{
if (_pLogger)
_pLogger->debug("Rolling back transaction.");
_rSession.rollback();
}
catch (Poco::Exception& exc)
{
if (_pLogger)
_pLogger->error("Error while rolling back database transaction: %s", exc.displayText());
}
catch (...)
{
if (_pLogger)
_pLogger->error("Error while rolling back database transaction.");
}
}
}
catch (...)
{
poco_unexpected();
}
}
void Transaction::begin()
{
if (!_rSession.isTransaction())
_rSession.begin();
else
throw InvalidAccessException("Transaction in progress.");
}
void Transaction::execute(const std::string& sql, bool doCommit)
{
if (!_rSession.isTransaction()) _rSession.begin();
_rSession << sql, Keywords::now;
if (doCommit) commit();
}
void Transaction::execute(const std::vector<std::string>& sql)
{
try
{
std::vector<std::string>::const_iterator it = sql.begin();
std::vector<std::string>::const_iterator end = sql.end();
for (; it != end; ++it) execute(*it, it + 1 == end ? true : false);
return;
}
catch (Exception& ex)
{
if (_pLogger) _pLogger->log(ex);
}
rollback();
}
void Transaction::commit()
{
if (_pLogger)
_pLogger->debug("Committing transaction.");
_rSession.commit();
}
void Transaction::rollback()
{
if (_pLogger)
_pLogger->debug("Rolling back transaction.");
_rSession.rollback();
}
} } // namespace Poco::Data