1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-07-03 23:47:12 +02:00

Update POCO library.

This commit is contained in:
Sandu Liviu Catalin
2023-03-23 20:19:11 +02:00
parent 8d15f4b6e9
commit 233fc103f9
2521 changed files with 257092 additions and 72789 deletions

View File

@ -28,6 +28,7 @@
#include "Poco/Any.h"
#include "Poco/Dynamic/Var.h"
#include "Poco/UTFString.h"
#include "Poco/TextEncoding.h"
#include <vector>
#include <deque>
#include <list>
@ -39,7 +40,7 @@ namespace Data {
using NullData = NullType;
class Transcoder;
namespace Keywords {
@ -64,7 +65,8 @@ public:
PD_IN_OUT
};
AbstractBinder();
AbstractBinder(Poco::TextEncoding::Ptr pFromEncoding = nullptr,
Poco::TextEncoding::Ptr pDBEncoding = nullptr);
/// Creates the AbstractBinder.
virtual ~AbstractBinder();
@ -356,6 +358,19 @@ public:
static bool isInBound(Direction dir);
/// Returns true if direction is in bound;
protected:
bool transcodeRequired() const;
void transcode(const std::string& from, std::string& to);
void reverseTranscode(const std::string& from, std::string& to);
const std::string& toString(const UUID& uuid);
private:
using StringList = std::vector<std::string*>;
std::unique_ptr<Transcoder> _pTranscoder;
std::unique_ptr<StringList> _pStrings;
};
@ -380,6 +395,12 @@ inline bool AbstractBinder::isInBound(Direction dir)
}
inline bool AbstractBinder::transcodeRequired() const
{
return _pTranscoder.operator bool();
}
} } // namespace Poco::Data

View File

@ -68,7 +68,7 @@ public:
virtual std::size_t numOfRowsHandled() const = 0;
/// Returns the number of rows that the binding handles.
///
/// The trivial case will be one single row but
/// The trivial case will be one single row but
/// for collection data types it can be larger.
virtual bool canBind() const = 0;

View File

@ -23,6 +23,8 @@
#include "Poco/Data/LOB.h"
#include "Poco/UUID.h"
#include "Poco/UTFString.h"
#include "Poco/TextEncoding.h"
#include <memory>
#include <vector>
#include <deque>
#include <list>
@ -32,7 +34,6 @@
namespace Poco {
class DateTime;
class Any;
@ -45,6 +46,7 @@ namespace Data {
class Date;
class Time;
class Transcoder;
class Data_API AbstractExtractor
@ -54,7 +56,8 @@ class Data_API AbstractExtractor
public:
using Ptr = SharedPtr<AbstractExtractor>;
AbstractExtractor();
AbstractExtractor(Poco::TextEncoding::Ptr pDBEncoding = nullptr,
Poco::TextEncoding::Ptr pToEncoding = nullptr);
/// Creates the AbstractExtractor.
virtual ~AbstractExtractor();
@ -346,18 +349,33 @@ public:
virtual void reset();
/// Resets any information internally cached by the extractor.
protected:
bool transcodeRequired() const;
void transcode(const std::string& from, std::string& to);
void reverseTranscode(const std::string& from, std::string& to);
private:
std::unique_ptr<Transcoder> _pTranscoder;
};
///
/// inlines
///
inline void AbstractExtractor::reset()
{
//default no-op
}
inline bool AbstractExtractor::transcodeRequired() const
{
return _pTranscoder.operator bool();
}
} } // namespace Poco::Data

View File

@ -40,13 +40,13 @@ class AbstractSessionImpl: public SessionImpl
public:
typedef void (C::*FeatureSetter)(const std::string&, bool);
/// The setter method for a feature.
typedef bool (C::*FeatureGetter)(const std::string&) const;
/// The getter method for a feature.
typedef void (C::*PropertySetter)(const std::string&, const Poco::Any&);
/// The setter method for a property.
typedef Poco::Any (C::*PropertyGetter)(const std::string&) const;
/// The getter method for a property.
@ -57,28 +57,28 @@ public:
_emptyStringIsNull(false),
_forceEmptyString(false)
/// Creates the AbstractSessionImpl.
///
/// Adds "storage" property and sets the default internal storage container
///
/// Adds "storage" property and sets the default internal storage container
/// type to std::deque.
/// The storage is created by statements automatically whenever a query
/// The storage is created by statements automatically whenever a query
/// returning results is executed but external storage is provided by the user.
/// Storage type can be reconfigured at runtime both globally (for the
/// duration of the session) and locally (for a single statement execution only).
/// duration of the session) and locally (for a single statement execution only).
/// See StatementImpl for details on how this property is used at runtime.
///
///
/// Adds "handle" property which, if set by the back end, returns native handle
/// for the back end DB.
///
///
/// Adds "bulk" feature and sets it to false.
/// Bulk feature determines whether the session is capable of bulk operations.
/// Connectors that are capable of it must set this feature prior to attempting
/// Connectors that are capable of it must set this feature prior to attempting
/// bulk operations.
///
/// Adds "emptyStringIsNull" feature and sets it to false. This feature should be
/// set to true in order to modify the behavior of the databases that distinguish
/// between zero-length character strings as nulls. Setting this feature to true
/// between zero-length character strings as nulls. Setting this feature to true
/// shall disregard any difference between empty character strings and nulls,
/// causing the framework to treat them the same (i.e. behave like Oracle).
/// causing the framework to treat them the same (i.e. behave like Oracle).
///
/// Adds "forceEmptyString" feature and sets it to false. This feature should be set
/// to true in order to force the databases that do not distinguish empty strings from
@ -89,23 +89,23 @@ public:
/// resulting in default underlying database behavior.
///
{
addProperty("storage",
&AbstractSessionImpl<C>::setStorage,
addProperty("storage",
&AbstractSessionImpl<C>::setStorage,
&AbstractSessionImpl<C>::getStorage);
addProperty("handle",
addProperty("handle",
&AbstractSessionImpl<C>::setHandle,
&AbstractSessionImpl<C>::getHandle);
addFeature("bulk",
&AbstractSessionImpl<C>::setBulk,
addFeature("bulk",
&AbstractSessionImpl<C>::setBulk,
&AbstractSessionImpl<C>::getBulk);
addFeature("emptyStringIsNull",
addFeature("emptyStringIsNull",
&AbstractSessionImpl<C>::setEmptyStringIsNull,
&AbstractSessionImpl<C>::getEmptyStringIsNull);
addFeature("forceEmptyString",
addFeature("forceEmptyString",
&AbstractSessionImpl<C>::setForceEmptyString,
&AbstractSessionImpl<C>::getForceEmptyString);
}
@ -129,7 +129,7 @@ public:
}
else throw NotSupportedException(name);
}
bool getFeature(const std::string& name)
/// Looks a feature up in the features map
/// and calls the feature's getter, if there is one.
@ -144,7 +144,7 @@ public:
}
else throw NotSupportedException(name);
}
void setProperty(const std::string& name, const Poco::Any& value)
/// Looks a property up in the properties map
/// and calls the property's setter, if there is one.
@ -174,7 +174,7 @@ public:
}
else throw NotSupportedException(name);
}
void setStorage(const std::string& value)
/// Sets the storage type.
{
@ -186,7 +186,7 @@ public:
{
_storage = Poco::RefAnyCast<std::string>(value);
}
Poco::Any getStorage(const std::string& name="") const
/// Returns the storage type
{
@ -194,13 +194,13 @@ public:
}
void setHandle(const std::string& name, const Poco::Any& handle)
/// Sets the native session handle.
/// Sets the native session handle.
{
_handle = handle;
}
Poco::Any getHandle(const std::string& name="") const
/// Returns the native session handle.
/// Returns the native session handle.
{
return _handle;
}
@ -210,7 +210,7 @@ public:
{
_bulk = bulk;
}
bool getBulk(const std::string& name="") const
/// Returns the execution type
{
@ -228,7 +228,7 @@ public:
_emptyStringIsNull = emptyStringIsNull;
}
bool getEmptyStringIsNull(const std::string& name="") const
/// Returns the setting for the behavior regarding empty variable
/// length strings. See setEmptyStringIsNull(const std::string&, bool)
@ -249,7 +249,7 @@ public:
_forceEmptyString = forceEmptyString;
}
bool getForceEmptyString(const std::string& name="") const
/// Returns the setting for the behavior regarding empty variable
/// length strings. See setForceEmptyString(const std::string&, bool)
@ -270,7 +270,7 @@ protected:
feature.getter = getter;
_features[name] = feature;
}
void addProperty(const std::string& name, PropertySetter setter, PropertyGetter getter)
/// Adds a property to the map of supported properties.
///
@ -289,16 +289,16 @@ private:
FeatureSetter setter;
FeatureGetter getter;
};
struct Property
{
PropertySetter setter;
PropertyGetter getter;
};
using FeatureMap = std::map<std::string, Feature>;
using PropertyMap = std::map<std::string, Property>;
FeatureMap _features;
PropertyMap _properties;
std::string _storage;

View File

@ -36,9 +36,9 @@ class Data_API ArchiveStrategy
public:
static const std::string DEFAULT_ARCHIVE_DESTINATION;
ArchiveStrategy(const std::string& connector,
const std::string& connect,
const std::string& source,
ArchiveStrategy(const std::string& connector,
const std::string& connect,
const std::string& source,
const std::string& destination = DEFAULT_ARCHIVE_DESTINATION);
/// Creates archive strategy.
@ -83,7 +83,7 @@ protected:
Statement& getDeleteStatement();
Statement& getCountStatement();
private:
ArchiveStrategy();
ArchiveStrategy(const ArchiveStrategy&);
ArchiveStrategy& operator = (const ArchiveStrategy&);
@ -177,11 +177,11 @@ class Data_API ArchiveByAgeStrategy: public ArchiveStrategy
/// Archives rows scheduled for archiving.
{
public:
ArchiveByAgeStrategy(const std::string& connector,
const std::string& connect,
const std::string& sourceTable,
ArchiveByAgeStrategy(const std::string& connector,
const std::string& connect,
const std::string& sourceTable,
const std::string& destinationTable = DEFAULT_ARCHIVE_DESTINATION);
~ArchiveByAgeStrategy();
void archive();

View File

@ -40,14 +40,14 @@ namespace Data {
template <class T>
class Binding: public AbstractBinding
/// Binding maps a value or multiple values (see Binding specializations for STL containers as
/// well as type handlers) to database column(s). Values to be bound can be either mapped
/// well as type handlers) to database column(s). Values to be bound can be either mapped
/// directly (by reference) or a copy can be created, depending on the value of the copy argument.
/// To pass a reference to a variable, it is recommended to pass it to the intermediate
/// utility function use(), which will create the proper binding. In cases when a reference
/// utility function use(), which will create the proper binding. In cases when a reference
/// is passed to binding, the storage it refers to must be valid at the statement execution time.
/// To pass a copy of a variable, constant or string literal, use utility function bind().
/// Variables can be passed as either copies or references (i.e. using either use() or bind()).
/// Constants, however, can only be passed as copies. this is best achieved using bind() utility
/// Constants, however, can only be passed as copies. This is best achieved using bind() utility
/// function. An attempt to pass a constant by reference shall result in compile-time error.
{
public:
@ -57,10 +57,10 @@ public:
using Ptr = SharedPtr<Type>;
explicit Binding(T& val,
const std::string& name = "",
Direction direction = PD_IN):
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_val(val),
_bound(false)
/// Creates the Binding using the passed reference as bound value.
/// If copy is true, a copy of the value referred to is created.
@ -112,10 +112,10 @@ private:
template <class T>
class CopyBinding: public AbstractBinding
/// Binding maps a value or multiple values (see Binding specializations for STL containers as
/// well as type handlers) to database column(s). Values to be bound can be either mapped
/// well as type handlers) to database column(s). Values to be bound can be either mapped
/// directly (by reference) or a copy can be created, depending on the value of the copy argument.
/// To pass a reference to a variable, it is recommended to pass it to the intermediate
/// utility function use(), which will create the proper binding. In cases when a reference
/// utility function use(), which will create the proper binding. In cases when a reference
/// is passed to binding, the storage it refers to must be valid at the statement execution time.
/// To pass a copy of a variable, constant or string literal, use utility function bind().
/// Variables can be passed as either copies or references (i.e. using either use() or bind()).
@ -127,8 +127,8 @@ public:
using Ptr = SharedPtr<Type>;
explicit CopyBinding(T& val,
const std::string& name = "",
Direction direction = PD_IN):
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_pVal(new T(val)),
_bound(false)
@ -189,10 +189,10 @@ public:
using Type = Binding<const char*>;
using Ptr = SharedPtr<Type>;
explicit Binding(const char* pVal,
explicit Binding(const char* pVal,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(pVal ? pVal : throw NullPointerException() ),
_bound(false)
/// Creates the Binding by copying the passed string.
@ -251,10 +251,10 @@ public:
using Type = CopyBinding<const char*>;
using Ptr = SharedPtr<Type>;
explicit CopyBinding(const char* pVal,
explicit CopyBinding(const char* pVal,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(pVal ? pVal : throw NullPointerException() ),
_bound(false)
/// Creates the Binding by copying the passed string.
@ -312,12 +312,12 @@ public:
using Ptr = SharedPtr<Binding<ValType>>;
using Iterator = typename ValType::const_iterator;
explicit Binding(std::vector<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
explicit Binding(std::vector<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
_val(val),
_begin(),
_end()
/// Creates the Binding.
{
@ -350,7 +350,7 @@ public:
{
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
}
@ -373,18 +373,18 @@ class CopyBinding<std::vector<T>>: public AbstractBinding
/// Specialization for std::vector.
{
public:
using ValType = std::vector<T>;
using ValPtr = SharedPtr<ValType>;
using Ptr = SharedPtr<CopyBinding<ValType>>;
using Iterator = typename ValType::const_iterator;
explicit CopyBinding(std::vector<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
explicit CopyBinding(std::vector<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_pVal(new std::vector<T>(val)),
_begin(),
_begin(),
_end()
/// Creates the Binding.
{
@ -417,7 +417,7 @@ public:
{
poco_assert_dbg(!getBinder().isNull());
poco_assert_dbg(canBind());
TypeHandler<T>::bind(pos, *_begin, getBinder(), getDirection());
++_begin;
}
@ -439,14 +439,14 @@ template <>
class Binding<std::vector<bool>>: public AbstractBinding
/// Specialization for std::vector<bool>.
/// This specialization is necessary due to the nature of std::vector<bool>.
/// For details, see the standard library implementation of std::vector<bool>
/// For details, see the standard library implementation of std::vector<bool>
/// or
/// S. Meyers: "Effective STL" (Copyright Addison-Wesley 2001),
/// Item 18: "Avoid using vector<bool>."
///
///
/// The workaround employed here is using std::deque<bool> as an
/// internal replacement container.
///
/// internal replacement container.
///
/// IMPORTANT:
/// Only IN binding is supported.
{
@ -456,13 +456,13 @@ public:
using Ptr = SharedPtr<Binding<ValType>>;
using Iterator = ValType::const_iterator;
explicit Binding(const std::vector<bool>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
explicit Binding(const std::vector<bool>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_deq(_val.begin(), _val.end()),
_begin(),
_begin(),
_end()
/// Creates the Binding.
{
@ -520,14 +520,14 @@ template <>
class CopyBinding<std::vector<bool>>: public AbstractBinding
/// Specialization for std::vector<bool>.
/// This specialization is necessary due to the nature of std::vector<bool>.
/// For details, see the standard library implementation of std::vector<bool>
/// For details, see the standard library implementation of std::vector<bool>
/// or
/// S. Meyers: "Effective STL" (Copyright Addison-Wesley 2001),
/// Item 18: "Avoid using vector<bool>."
///
///
/// The workaround employed here is using std::deque<bool> as an
/// internal replacement container.
///
/// internal replacement container.
///
/// IMPORTANT:
/// Only IN binding is supported.
{
@ -537,12 +537,12 @@ public:
using Ptr = SharedPtr<CopyBinding<ValType>>;
using Iterator = ValType::const_iterator;
explicit CopyBinding(const std::vector<bool>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
explicit CopyBinding(const std::vector<bool>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_deq(val.begin(), val.end()),
_begin(),
_begin(),
_end()
/// Creates the Binding.
{
@ -608,10 +608,10 @@ public:
explicit Binding(std::list<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
_end()
/// Creates the Binding.
{
@ -673,10 +673,10 @@ public:
explicit CopyBinding(ValType& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_pVal(new std::list<T>(val)),
_begin(),
_begin(),
_end()
/// Creates the Binding.
{
@ -738,10 +738,10 @@ public:
explicit Binding(std::deque<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
_end()
/// Creates the Binding.
{
@ -803,10 +803,10 @@ public:
explicit CopyBinding(std::deque<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_pVal(new std::deque<T>(val)),
_begin(),
_begin(),
_end()
/// Creates the Binding.
{
@ -868,10 +868,10 @@ public:
explicit Binding(std::set<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
_end()
/// Creates the Binding.
{
@ -933,10 +933,10 @@ public:
explicit CopyBinding(std::set<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_pVal(new std::set<T>(val)),
_begin(),
_begin(),
_end()
/// Creates the Binding.
{
@ -998,10 +998,10 @@ public:
explicit Binding(std::multiset<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
_end()
/// Creates the Binding.
{
@ -1063,10 +1063,10 @@ public:
explicit CopyBinding(std::multiset<T>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_pVal(new std::multiset<T>(val)),
_begin(),
_begin(),
_end()
/// Creates the Binding.
{
@ -1128,10 +1128,10 @@ public:
explicit Binding(std::map<K, V>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
_end()
/// Creates the Binding.
{
@ -1193,10 +1193,10 @@ public:
explicit CopyBinding(std::map<K, V>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_pVal(new std::map<K, V>(val)),
_begin(),
_begin(),
_end()
/// Creates the Binding.
{
@ -1258,10 +1258,10 @@ public:
explicit Binding(std::multimap<K, V>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_val(val),
_begin(),
_end()
/// Creates the Binding.
{
@ -1323,10 +1323,10 @@ public:
explicit CopyBinding(std::multimap<K, V>& val,
const std::string& name = "",
Direction direction = PD_IN):
AbstractBinding(name, direction),
Direction direction = PD_IN):
AbstractBinding(name, direction),
_pVal(new std::multimap<K, V>(val)),
_begin(),
_begin(),
_end()
/// Creates the Binding.
{
@ -1379,13 +1379,13 @@ private:
namespace Keywords {
template <typename T>
template <typename T>
inline AbstractBinding::Ptr use(T& t, const std::string& name = "")
/// Convenience function for a more compact Binding creation.
{
// If this fails to compile, a const ref was passed to use().
// This can be resolved by either (a) using bind (which will copy the value),
// or (b) if the const ref is guaranteed to exist when execute is called
// or (b) if the const ref is guaranteed to exist when execute is called
// (which can be much later!), by using the "useRef" keyword instead
poco_static_assert (!IsConst<T>::VALUE);
return new Binding<T>(t, name, AbstractBinding::PD_IN);
@ -1399,7 +1399,7 @@ inline AbstractBinding::Ptr use(const NullData& t, const std::string& name = "")
}
template <typename T>
template <typename T>
inline AbstractBinding::Ptr useRef(T& t, const std::string& name = "")
/// Convenience function for a more compact Binding creation.
{
@ -1407,7 +1407,7 @@ inline AbstractBinding::Ptr useRef(T& t, const std::string& name = "")
}
template <typename T>
template <typename T>
inline AbstractBinding::Ptr in(T& t, const std::string& name = "")
/// Convenience function for a more compact Binding creation.
{
@ -1422,7 +1422,7 @@ inline AbstractBinding::Ptr in(const NullData& t, const std::string& name = "")
}
template <typename T>
template <typename T>
inline AbstractBinding::Ptr out(T& t)
/// Convenience function for a more compact Binding creation.
{
@ -1431,7 +1431,7 @@ inline AbstractBinding::Ptr out(T& t)
}
template <typename T>
template <typename T>
inline AbstractBinding::Ptr io(T& t)
/// Convenience function for a more compact Binding creation.
{
@ -1468,7 +1468,7 @@ inline AbstractBindingVec& io(AbstractBindingVec& bv)
}
template <typename T>
template <typename T>
inline AbstractBinding::Ptr bind(T t, const std::string& name)
/// Convenience function for a more compact Binding creation.
/// This funtion differs from use() in its value copy semantics.
@ -1477,7 +1477,7 @@ inline AbstractBinding::Ptr bind(T t, const std::string& name)
}
template <typename T>
template <typename T>
inline AbstractBinding::Ptr bind(T t)
/// Convenience function for a more compact Binding creation.
/// This funtion differs from use() in its value copy semantics.

View File

@ -42,9 +42,9 @@ public:
/// Returns the limit asociated with this bulk object.
Poco::UInt32 size() const;
/// Returns the value of the limit asociated with
/// Returns the value of the limit asociated with
/// this bulk object.
private:
Bulk();
@ -55,15 +55,15 @@ private:
///
/// inlines
///
inline const Limit& Bulk::limit() const
{
return _limit;
inline const Limit& Bulk::limit() const
{
return _limit;
}
inline Poco::UInt32 Bulk::size() const
{
return _limit.value();
inline Poco::UInt32 Bulk::size() const
{
return _limit.value();
}

View File

@ -35,13 +35,13 @@ namespace Data {
template <class T>
class BulkBinding: public AbstractBinding
/// A BulkBinding maps a value to a column.
/// A BulkBinding maps a value to a column.
/// Bulk binding support is provided only for std::vector.
{
public:
BulkBinding(const T& val, Poco::UInt32 bulkSize, const std::string& name = "", Direction direction = PD_IN):
AbstractBinding(name, direction, bulkSize),
_val(val),
BulkBinding(const T& val, Poco::UInt32 bulkSize, const std::string& name = "", Direction direction = PD_IN):
AbstractBinding(name, direction, bulkSize),
_val(val),
_bound(false)
/// Creates the BulkBinding.
{
@ -91,7 +91,7 @@ private:
namespace Keywords {
template <typename T>
template <typename T>
AbstractBinding::Ptr use(const std::vector<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::vector.
{
@ -99,7 +99,7 @@ AbstractBinding::Ptr use(const std::vector<T>& t, BulkFnType, const std::string&
}
template <typename T>
template <typename T>
AbstractBinding::Ptr in(const std::vector<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::vector.
{
@ -107,7 +107,7 @@ AbstractBinding::Ptr in(const std::vector<T>& t, BulkFnType, const std::string&
}
template <typename T>
template <typename T>
AbstractBinding::Ptr use(const std::deque<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::deque.
{
@ -115,7 +115,7 @@ AbstractBinding::Ptr use(const std::deque<T>& t, BulkFnType, const std::string&
}
template <typename T>
template <typename T>
AbstractBinding::Ptr in(const std::deque<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::deque.
{
@ -123,7 +123,7 @@ AbstractBinding::Ptr in(const std::deque<T>& t, BulkFnType, const std::string& n
}
template <typename T>
template <typename T>
AbstractBinding::Ptr use(const std::list<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::list.
{
@ -131,7 +131,7 @@ AbstractBinding::Ptr use(const std::list<T>& t, BulkFnType, const std::string& n
}
template <typename T>
template <typename T>
AbstractBinding::Ptr in(const std::list<T>& t, BulkFnType, const std::string& name = "")
/// Convenience function for a more compact BulkBinding creation for std::list.
{

View File

@ -44,18 +44,18 @@ public:
using Type = BulkExtraction<ValType>;
using Ptr = SharedPtr<Type>;
BulkExtraction(C& result, Poco::UInt32 limit, const Position& pos = Position(0)):
BulkExtraction(C& result, Poco::UInt32 limit, const Position& pos = Position(0)):
AbstractExtraction(limit, pos.value(), true),
_rResult(result),
_rResult(result),
_default()
{
if (static_cast<Poco::UInt32>(result.size()) != limit)
result.resize(limit);
}
BulkExtraction(C& result, const CValType& def, Poco::UInt32 limit, const Position& pos = Position(0)):
BulkExtraction(C& result, const CValType& def, Poco::UInt32 limit, const Position& pos = Position(0)):
AbstractExtraction(limit, pos.value(), true),
_rResult(result),
_rResult(result),
_default(def)
{
if (static_cast<Poco::UInt32>(result.size()) != limit)
@ -88,8 +88,8 @@ public:
return _nulls.at(row);
}
catch (std::out_of_range& ex)
{
throw RangeException(ex.what());
{
throw RangeException(ex.what());
}
}
@ -137,7 +137,7 @@ template <class C>
class InternalBulkExtraction: public BulkExtraction<C>
/// Container Data Type specialization extension for extraction of values from a query result set.
///
/// This class is intended for PocoData internal use - it is used by StatementImpl
/// This class is intended for PocoData internal use - it is used by StatementImpl
/// to automaticaly create internal BulkExtraction in cases when statement returns data and no external storage
/// was supplied. It is later used by RecordSet to retrieve the fetched data after statement execution.
/// It takes ownership of the Column pointer supplied as constructor argument. Column object, in turn
@ -155,8 +155,8 @@ public:
InternalBulkExtraction(C& result,
Column<C>* pColumn,
Poco::UInt32 limit,
const Position& pos = Position(0)):
BulkExtraction<C>(result, CValType(), limit, pos),
const Position& pos = Position(0)):
BulkExtraction<C>(result, CValType(), limit, pos),
_pColumn(pColumn)
/// Creates InternalBulkExtraction.
{
@ -171,17 +171,17 @@ public:
void reset()
{
_pColumn->reset();
}
}
const CValType& value(int index) const
{
try
{
return BulkExtraction<C>::result().at(index);
{
return BulkExtraction<C>::result().at(index);
}
catch (std::out_of_range& ex)
{
throw RangeException(ex.what());
{
throw RangeException(ex.what());
}
}
@ -207,7 +207,7 @@ private:
namespace Keywords {
template <typename T>
template <typename T>
AbstractExtraction::Ptr into(std::vector<T>& t, const Bulk& bulk, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::vector bulk extraction support.
@ -216,7 +216,7 @@ AbstractExtraction::Ptr into(std::vector<T>& t, const Bulk& bulk, const Position
}
template <typename T>
template <typename T>
AbstractExtraction::Ptr into(std::vector<T>& t, BulkFnType, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::vector bulk extraction support.
@ -227,7 +227,7 @@ AbstractExtraction::Ptr into(std::vector<T>& t, BulkFnType, const Position& pos
}
template <typename T>
template <typename T>
AbstractExtraction::Ptr into(std::deque<T>& t, const Bulk& bulk, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::deque bulk extraction support.
@ -236,7 +236,7 @@ AbstractExtraction::Ptr into(std::deque<T>& t, const Bulk& bulk, const Position&
}
template <typename T>
template <typename T>
AbstractExtraction::Ptr into(std::deque<T>& t, BulkFnType, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::deque bulk extraction support.
@ -247,7 +247,7 @@ AbstractExtraction::Ptr into(std::deque<T>& t, BulkFnType, const Position& pos =
}
template <typename T>
template <typename T>
AbstractExtraction::Ptr into(std::list<T>& t, const Bulk& bulk, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::list bulk extraction support.
@ -256,7 +256,7 @@ AbstractExtraction::Ptr into(std::list<T>& t, const Bulk& bulk, const Position&
}
template <typename T>
template <typename T>
AbstractExtraction::Ptr into(std::list<T>& t, BulkFnType, const Position& pos = Position(0))
/// Convenience function to allow for a more compact creation of an extraction object
/// with std::list bulk extraction support.

View File

@ -34,7 +34,7 @@ namespace Data {
template <class C>
class Column
/// Column class is column data container.
/// Data (a pointer to underlying STL container) is assigned to the class
/// Data (a pointer to underlying STL container) is assigned to the class
/// at construction time. Construction with null pointer is not allowed.
/// This class owns the data assigned to it and deletes the storage on destruction.
{
@ -46,7 +46,7 @@ public:
using Size = typename C::size_type;
using Type = typename C::value_type;
Column(const MetaColumn& metaColumn, Container* pData):
Column(const MetaColumn& metaColumn, Container* pData):
_metaColumn(metaColumn),
_pData(pData)
/// Creates the Column.
@ -55,15 +55,15 @@ public:
throw NullPointerException("Container pointer must point to valid storage.");
}
Column(const Column& col):
_metaColumn(col._metaColumn),
Column(const Column& col):
_metaColumn(col._metaColumn),
_pData(col._pData)
/// Creates the Column.
{
}
Column(Column&& col) noexcept:
_metaColumn(std::move(col._metaColumn)),
Column(Column&& col) noexcept:
_metaColumn(std::move(col._metaColumn)),
_pData(std::move(col._pData))
/// Creates the Column.
{
@ -90,7 +90,7 @@ public:
return *this;
}
void swap(Column& other)
void swap(Column& other) noexcept
/// Swaps the column with another one.
{
using std::swap;
@ -112,8 +112,8 @@ public:
return _pData->at(row);
}
catch (std::out_of_range& ex)
{
throw RangeException(ex.what());
{
throw RangeException(ex.what());
}
}
@ -189,13 +189,13 @@ private:
template <>
class Column<std::vector<bool>>
/// The std::vector<bool> specialization for the Column class.
///
///
/// This specialization is necessary due to the nature of std::vector<bool>.
/// For details, see the standard library implementation of vector<bool>
/// For details, see the standard library implementation of vector<bool>
/// or
/// S. Meyers: "Effective STL" (Copyright Addison-Wesley 2001),
/// Item 18: "Avoid using vector<bool>."
///
///
/// The workaround employed here is using deque<bool> as an
/// internal "companion" container kept in sync with the vector<bool>
/// column data.
@ -207,8 +207,8 @@ public:
using RIterator = Container::const_reverse_iterator;
using Size = Container::size_type;
Column(const MetaColumn& metaColumn, Container* pData):
_metaColumn(metaColumn),
Column(const MetaColumn& metaColumn, Container* pData):
_metaColumn(metaColumn),
_pData(pData)
/// Creates the Column.
{
@ -216,8 +216,8 @@ public:
_deque.assign(_pData->begin(), _pData->end());
}
Column(const Column& col):
_metaColumn(col._metaColumn),
Column(const Column& col):
_metaColumn(col._metaColumn),
_pData(col._pData)
/// Creates the Column.
{
@ -237,7 +237,7 @@ public:
return *this;
}
void swap(Column& other)
void swap(Column& other) noexcept
/// Swaps the column with another one.
{
using std::swap;
@ -263,8 +263,8 @@ public:
return _deque.at(row) = _pData->at(row);
}
catch (std::out_of_range& ex)
{
throw RangeException(ex.what());
{
throw RangeException(ex.what());
}
}
@ -350,8 +350,8 @@ public:
using RIterator = typename Container::const_reverse_iterator;
using Size = typename Container::size_type;
Column(const MetaColumn& metaColumn, std::list<T>* pData):
_metaColumn(metaColumn),
Column(const MetaColumn& metaColumn, std::list<T>* pData):
_metaColumn(metaColumn),
_pData(pData)
/// Creates the Column.
{
@ -378,7 +378,7 @@ public:
return *this;
}
void swap(Column& other)
void swap(Column& other) noexcept
/// Swaps the column with another one.
{
using std::swap;
@ -395,7 +395,7 @@ public:
const T& value(std::size_t row) const
/// Returns the field value in specified row.
/// This is the std::list specialization and std::list
/// is not the optimal solution for cases where random
/// is not the optimal solution for cases where random
/// access is needed.
/// However, to allow for compatibility with other
/// containers, this functionality is provided here.
@ -419,7 +419,7 @@ public:
if (i == row) return *it;
}
throw RangeException("Invalid row number.");
throw RangeException("Invalid row number.");
}
const T& operator [] (std::size_t row) const
@ -492,7 +492,7 @@ private:
template <typename C>
inline void swap(Column<C>& c1, Column<C>& c2)
inline void swap(Column<C>& c1, Column<C>& c2) noexcept
{
c1.swap(c2);
}

View File

@ -174,7 +174,7 @@ public:
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Poco::Data::Date);
@ -207,7 +207,7 @@ public:
{
return cloneHolder(pVarHolder, _val);
}
const Poco::Data::Date& value() const
{
return _val;

View File

@ -0,0 +1,159 @@
//
// JSONRowFormatter.h
//
// Library: Data
// Package: DataCore
// Module: JSONRowFormatter
//
// Definition of the JSONRowFormatter class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Data_JSONRowFormatter_INCLUDED
#define Data_JSONRowFormatter_INCLUDED
#include "Poco/Data/RowFormatter.h"
namespace Poco {
namespace Data {
class Data_API JSONRowFormatter: public Poco::Data::RowFormatter
/// Class for JSON formatting of data rows.
///
/// Formatter can be configured to operate in four modes (and
/// certain combinations thereof) :
///
/// - small (condensed mode, only array of values)
///
/// Example:
/// {
/// [["Simpson", "Bart", "Springfield", 12],
/// ["Simpson", "Lisa", "Springfield", 10]]
/// }
///
/// - row count (total row count provided)
///
/// Example:
/// {
/// "count":2,
/// [["Simpson", "Bart", "Springfield", 12],
/// ["Simpson", "Lisa", "Springfield", 10]]
/// }
///
/// - column names (column names provided as a string array)
///
/// Example:
/// {
/// "names":["LastName", "FirstName", "Address", "Age"],
/// [["Simpson", "Bart", "Springfield", 12],
/// ["Simpson", "Lisa", "Springfield", 10]]
/// }
///
/// - full (total row count, column names provided in every row of data)
///
/// Example:
/// {
/// "count":2,
/// [
/// {"LastName": "Simpson", "FirstName": "Bart", "Address": "Springfield", "Age": 12},
/// {"LastName": "Simpson", "FirstName": "Lisa", "Address": "Springfield", "Age": 10}
/// ]
/// }
///
/// Total row count will be specified by the Poco::SQLRecordSet. Note, however, that this is
/// not possible to do accurately in case of result set paging. For those cases, there is
/// setTotalRowCount() member function, which allows to explicitly set the total row count.
/// If the total row count is preset on the formatter, the Data framework shall not interfere.
{
public:
static const int JSON_FMT_MODE_SMALL = 1;
static const int JSON_FMT_MODE_ROW_COUNT = 2;
static const int JSON_FMT_MODE_COLUMN_NAMES = 4;
static const int JSON_FMT_MODE_FULL = 8;
JSONRowFormatter(int mode = (JSON_FMT_MODE_COLUMN_NAMES | JSON_FMT_MODE_SMALL));
/// Creates a new JSONRowFormatter.
~JSONRowFormatter();
/// Destroys the JSONRowFormatter.
std::string& formatNames(const NameVecPtr pNames, std::string& formattedNames);
/// Formats names.
std::string& formatValues(const ValueVec& vals, std::string& formattedValues);
// Formats values.
void setJSONMode(int mode);
/// Sets the mode. Valid mode values are:
/// JSON_FMT_MODE_SMALL
/// JSON_FMT_MODE_ROW_COUNT
/// JSON_FMT_MODE_COLUMN_NAMES
/// JSON_FMT_MODE_FULL
bool printRowCount() const;
/// Returns true if row count printing is enabled,
/// false otherwise.
bool printColumnNames() const;
/// Returns true if column names printing is enabled,
/// false otherwise.
bool isSmall() const;
/// Returns true if compact mode formatting is enabled,
/// false otherwise.
bool isFull() const;
/// Returns true if full mode formatting is enabled,
/// false otherwise.
private:
void adjustPrefix() const;
NameVecPtr _pNames;
int _mode;
bool _firstTime;
};
//
// inlines
//
inline bool JSONRowFormatter::printRowCount() const
{
return (_mode & JSON_FMT_MODE_ROW_COUNT) != 0;
}
inline bool JSONRowFormatter::printColumnNames() const
{
return (_mode & JSON_FMT_MODE_COLUMN_NAMES) != 0;
}
inline bool JSONRowFormatter::isSmall() const
{
return (_mode & JSON_FMT_MODE_SMALL) != 0;
}
inline bool JSONRowFormatter::isFull() const
{
return (_mode & JSON_FMT_MODE_FULL) != 0;
}
} } // namespace Poco::Data
#endif // Data_JSONRowFormatter_INCLUDED

View File

@ -109,7 +109,7 @@ public:
return *_pContent != *other._pContent;
}
void swap(LOB& other)
void swap(LOB& other) noexcept
/// Swaps the LOB with another one.
{
using std::swap;
@ -221,14 +221,14 @@ private:
using BLOB = LOB<unsigned char>;
using CLOB = LOB<char>;
using JSON = std::string;
//
// inlines
//
template <typename T>
inline void swap(LOB<T>& b1, LOB<T>& b2)
inline void swap(LOB<T>& b1, LOB<T>& b2) noexcept
{
b1.swap(b2);
}

View File

@ -33,7 +33,7 @@ template <typename T>
class LOBStreamBuf: public BasicUnbufferedStreamBuf<T, std::char_traits<T>>
/// This is the streambuf class used for reading from and writing to a LOB.
{
public:
public:
LOBStreamBuf(LOB<T>& lob): _lob(lob), _it(_lob.begin())
/// Creates LOBStreamBuf.
{

View File

@ -35,9 +35,9 @@ public:
{
LIMIT_UNLIMITED = ~((SizeT) 0)
};
Limit(SizeT value, bool hardLimit = false, bool isLowerLimit = false);
/// Creates the Limit.
/// Creates the Limit.
///
/// Value contains the upper row hint, if hardLimit is set to true, the limit acts as a hard
/// border, ie. every query must return exactly value rows, returning more than value objects will throw an exception!

View File

@ -51,6 +51,7 @@ public:
FDT_TIME,
FDT_TIMESTAMP,
FDT_UUID,
FDT_JSON,
FDT_UNKNOWN
};
@ -77,7 +78,7 @@ public:
MetaColumn& operator = (MetaColumn&& other) noexcept;
/// Assignment operator.
void swap(MetaColumn& other);
void swap(MetaColumn& other) noexcept;
/// Swaps the contents with another instance.
~MetaColumn();

View File

@ -80,7 +80,7 @@ inline SessionPool& PooledSessionHolder::owner()
inline void PooledSessionHolder::access()
{
Poco::FastMutex::ScopedLock lock(_mutex);
_lastUsed.update();
}

View File

@ -62,11 +62,11 @@ public:
bool hasTransactionIsolation(Poco::UInt32) const;
bool isTransactionIsolation(Poco::UInt32) const;
const std::string& connectorName() const;
void setFeature(const std::string& name, bool state);
void setFeature(const std::string& name, bool state);
bool getFeature(const std::string& name);
void setProperty(const std::string& name, const Poco::Any& value);
Poco::Any getProperty(const std::string& name);
protected:
SessionImpl* access() const;
/// Updates the last access timestamp,
@ -75,11 +75,11 @@ protected:
///
/// Throws an SessionUnavailableException if the
/// session is no longer valid.
SessionImpl* impl() const;
/// Returns a pointer to the SessionImpl.
private:
private:
mutable Poco::AutoPtr<PooledSessionHolder> _pHolder;
};

View File

@ -38,7 +38,7 @@ public:
Poco::UInt32 value() const;
/// Returns the position value.
private:
Position();
@ -49,9 +49,9 @@ private:
///
/// inlines
///
inline Poco::UInt32 Position::value() const
{
return _value;
inline Poco::UInt32 Position::value() const
{
return _value;
}

View File

@ -34,9 +34,9 @@ class Preparation: public AbstractPreparation
/// Class for calling the appropriate AbstractPreparator method.
{
public:
Preparation(AbstractPreparator::Ptr& pPreparator, std::size_t pos, T& val):
AbstractPreparation(pPreparator),
_pos(pos),
Preparation(AbstractPreparator::Ptr& pPreparator, std::size_t pos, T& val):
AbstractPreparation(pPreparator),
_pos(pos),
_val(val)
/// Creates the Preparation.
{
@ -66,9 +66,9 @@ class Preparation<std::vector<T>>: public AbstractPreparation
/// the whole vector preparation, rather than only individual contained values.
{
public:
Preparation(AbstractPreparator::Ptr pPreparator, std::size_t pos, std::vector<T>& val = std::vector<T>()):
AbstractPreparation(pPreparator),
_pos(pos),
Preparation(AbstractPreparator::Ptr pPreparator, std::size_t pos, std::vector<T>& val = std::vector<T>()):
AbstractPreparation(pPreparator),
_pos(pos),
_val(val)
/// Creates the Preparation.
{
@ -98,9 +98,9 @@ class Preparation<std::deque<T>>: public AbstractPreparation
/// the whole deque preparation, rather than only individual contained values.
{
public:
Preparation(AbstractPreparator::Ptr pPreparator, std::size_t pos, std::deque<T>& val = std::deque<T>()):
AbstractPreparation(pPreparator),
_pos(pos),
Preparation(AbstractPreparator::Ptr pPreparator, std::size_t pos, std::deque<T>& val = std::deque<T>()):
AbstractPreparation(pPreparator),
_pos(pos),
_val(val)
/// Creates the Preparation.
{
@ -130,9 +130,9 @@ class Preparation<std::list<T>>: public AbstractPreparation
/// the whole list preparation, rather than only individual contained values.
{
public:
Preparation(AbstractPreparator::Ptr pPreparator, std::size_t pos, std::list<T>& val = std::list<T>()):
AbstractPreparation(pPreparator),
_pos(pos),
Preparation(AbstractPreparator::Ptr pPreparator, std::size_t pos, std::list<T>& val = std::list<T>()):
AbstractPreparation(pPreparator),
_pos(pos),
_val(val)
/// Creates the Preparation.
{

View File

@ -66,7 +66,7 @@ inline const Limit& Range::upper() const
namespace Keywords {
template <typename T>
template <typename T>
Limit limit(T lim, bool hard = false)
/// Creates an upperLimit
{
@ -74,21 +74,21 @@ Limit limit(T lim, bool hard = false)
}
template <typename T>
template <typename T>
Limit upperLimit(T lim, bool hard = false)
{
return limit(lim, hard);
}
template <typename T>
template <typename T>
Limit lowerLimit(T lim)
{
return Limit(static_cast<Limit::SizeT>(lim), true, true);
}
template <typename T>
template <typename T>
Range range(T low, T upp, bool hard = false)
{
return Range(static_cast<Limit::SizeT>(low), static_cast<Limit::SizeT>(upp), hard);

View File

@ -44,7 +44,7 @@ class RowFilter;
class Data_API RecordSet: private Statement
/// RecordSet provides access to data returned from a query.
/// Data access indices (row and column) are 0-based, as usual in C++.
///
///
/// Recordset provides navigation methods to iterate through the
/// recordset, retrieval methods to extract data, and methods
/// to get metadata (type, etc.) about columns.
@ -64,7 +64,7 @@ class Data_API RecordSet: private Statement
/// The third (optional) argument passed to the Recordset constructor is a RowFormatter
/// implementation. The formatter is used in conjunction with << operator for recordset
/// data formating.
///
///
/// The number of rows in the RecordSet can be limited by specifying
/// a limit for the Statement.
{
@ -82,18 +82,18 @@ public:
RowFormatter::Ptr pRowFormatter = 0);
/// Creates the RecordSet.
RecordSet(Session& rSession,
RecordSet(Session& rSession,
const std::string& query,
RowFormatter::Ptr pRowFormatter = 0);
/// Creates the RecordSet.
RecordSet(Session& rSession,
RecordSet(Session& rSession,
const std::string& query,
const RowFormatter& rowFormatter);
/// Creates the RecordSet.
template <class RF>
RecordSet(Session& rSession, const std::string& query, const RF& rowFormatter):
RecordSet(Session& rSession, const std::string& query, const RF& rowFormatter):
Statement((rSession << query, Keywords::now)),
_currentRow(0),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
@ -145,7 +145,7 @@ public:
std::size_t getTotalRowCount() const;
/// Returns the total number of rows in the RecordSet.
/// The number of rows reported is independent of filtering.
/// If the total row count has not been set externally
/// If the total row count has not been set externally
/// (either explicitly or implicitly through SQL), the value
/// returned shall only be accurate if the statement limit
/// is less or equal to the total row count.
@ -274,7 +274,7 @@ public:
else
return value(name, _currentRow);
}
template <typename T>
Poco::Dynamic::Var nvl(std::size_t index, const T& deflt = T()) const
/// Returns the value in the given column of the current row
@ -378,11 +378,11 @@ public:
void formatNames() const;
/// Formats names using the current RowFormatter.
std::ostream& copyValues(std::ostream& os,
std::size_t offset = 0,
std::ostream& copyValues(std::ostream& os,
std::size_t offset = 0,
std::size_t length = RowIterator::POSITION_END) const;
/// Copies the data values to the supplied output stream.
/// The data set to be copied is starting at the specified offset
/// The data set to be copied is starting at the specified offset
/// from the recordset beginning. The number of rows to be copied
/// is specified by length argument.
/// An invalid combination of offset/length arguments shall
@ -391,7 +391,7 @@ public:
void formatValues(std::size_t offset, std::size_t length) const;
/// Formats values using the current RowFormatter.
/// The data set to be formatted is starting at the specified offset
/// The data set to be formatted is starting at the specified offset
/// from the recordset beginning. The number of rows to be copied
/// is specified by length argument.
/// An invalid combination of offset/length arguments shall
@ -421,7 +421,7 @@ private:
const AbstractExtractionVec& rExtractions = extractions();
AbstractExtractionVec::const_iterator it = rExtractions.begin();
AbstractExtractionVec::const_iterator end = rExtractions.end();
for (; it != end; ++it)
{
ExtractionVecPtr pExtraction = dynamic_cast<ExtractionVecPtr>(it->get());
@ -467,9 +467,9 @@ private:
{
return pExtraction->column();
}
else
else
{
throw Poco::BadCastException(Poco::format("Type cast failed!\nColumn: %z\nTarget type:\t%s",
throw Poco::BadCastException(Poco::format("Type cast failed!\nColumn: %z\nTarget type:\t%s",
pos,
std::string(typeid(T).name())));
}

View File

@ -41,12 +41,12 @@ class Data_API Row
/// Rows are sortable. The sortability is maintained at all times (i.e. there
/// is always at least one column specified as a sorting criteria) .
/// The default and minimal sorting criteria is the first field (position 0).
/// The default sorting criteria can be replaced with any other field by
/// The default sorting criteria can be replaced with any other field by
/// calling replaceSortField() member function.
/// Additional fields can be added to sorting criteria, in which case the
/// field precedence corresponds to addition order (i.e. later added fields
/// have lower sorting precedence).
/// These features make Row suitable for use with standard sorted
/// These features make Row suitable for use with standard sorted
/// containers and algorithms. The main constraint is that all the rows from
/// a set that is being sorted must have the same sorting criteria (i.e., the same
/// set of fields must be in sorting criteria in the same order). Since rows don't
@ -73,7 +73,7 @@ public:
using SortMap = std::vector<SortTuple>;
/// The type for map holding fields used for sorting criteria.
/// Fields are added sequentially and have precedence that
/// corresponds to field adding sequence order (rather than field's
/// corresponds to field adding sequence order (rather than field's
/// position in the row).
/// This requirement rules out use of std::map due to its sorted nature.
using SortMapPtr = SharedPtr<SortMap>;
@ -111,7 +111,7 @@ public:
_pNames->push_back(name);
if (1 == _values.size()) addSortField(0);
}
template <typename T>
void set(std::size_t pos, const T& val)
/// Assigns the value to the row.

View File

@ -167,7 +167,7 @@ private:
RecordSet& recordSet() const;
Comparison getComparison(const std::string& comp) const;
void rewindRecordSet();
Comparisons _comparisons;

View File

@ -50,8 +50,8 @@ class Data_API RowFormatter
/// it with rows through RecordSet.
///
/// To accomodate for various formatting needs, a formatter can operate in two modes:
///
/// - progressive: formatted individual row strings are gemerated and returned from each
///
/// - progressive: formatted individual row strings are gemerated and returned from each
/// call to formatValues;
/// std::string& formatNames(const NameVecPtr, std::string&) and
/// std::string& formatValues(const ValueVec&, std::string&) member calls should be
@ -106,7 +106,7 @@ public:
/// The default implementation does nothing.
virtual const std::string& toString();
/// Throws NotImplementedException. Formatters operating in bulk mode should
/// Throws NotImplementedException. Formatters operating in bulk mode should
/// implement this member function to return valid pointer to the formatted result.
virtual int rowCount() const;
@ -139,7 +139,12 @@ public:
protected:
void setPrefix(const std::string& prefix);
virtual void adjustPrefix() const;
/// Adjusts the prefix, if needed
/// (eg. to contain the total row count);
/// default no-op.
void setPrefix(const std::string& prefix) const;
/// Sets the prefix for the formatter.
void setPostfix(const std::string& postfix);
@ -175,7 +180,7 @@ inline void RowFormatter::setTotalRowCount(int count)
}
inline void RowFormatter::setPrefix(const std::string& prefix)
inline void RowFormatter::setPrefix(const std::string& prefix) const
{
_prefix = prefix;
}
@ -189,6 +194,7 @@ inline void RowFormatter::setPostfix(const std::string& postfix)
inline const std::string& RowFormatter::prefix() const
{
adjustPrefix();
return _prefix;
}

View File

@ -98,7 +98,7 @@ public:
/// Returns a copy the RowIterator backed by diff positions.
/// Throws RangeException if diff is larger than current position.
void swap(RowIterator& other);
void swap(RowIterator& other) noexcept;
/// Swaps the RowIterator with another one.
private:

View File

@ -32,16 +32,16 @@ namespace Data {
class Data_API SessionFactory
/// A SessionFactory is a singleton class that stores Connectors and allows to
/// A SessionFactory is a singleton class that stores Connectors and allows to
/// create Sessions of the required type:
///
///
/// Session ses(SessionFactory::instance().create(connector, connectionString));
///
///
/// where the first param presents the type of session one wants to create (e.g. for SQLite one would choose "SQLite")
/// and the second param is the connection string that the connector requires to connect to the database.
///
/// A concrete example to open an SQLite database stored in the file "dummy.db" would be
///
///
/// Session ses(SessionFactory::instance().create(SQLite::Connector::KEY, "dummy.db"));
///
/// An even simpler way to create a session is to use the two argument constructor of Session, which
@ -50,7 +50,7 @@ class Data_API SessionFactory
/// Session ses("SQLite", "dummy.db");
{
public:
static SessionFactory& instance();
/// returns the static instance of the singleton.
@ -71,7 +71,7 @@ public:
Session create(const std::string& uri,
std::size_t timeout = Session::LOGIN_TIMEOUT_DEFAULT);
/// Creates a Session for the given URI (must be in key:///connectionString format).
/// Creates a Session for the given URI (must be in key:///connectionString format).
/// Throws a Poco:Data::UnknownDataBaseException if no Connector is registered for the key.
private:
@ -86,7 +86,7 @@ private:
Poco::SharedPtr<Connector> ptrSI;
SessionInfo(Connector* pSI);
};
typedef std::map<std::string, SessionInfo, Poco::CILess> Connectors;
Connectors _connectors;
Poco::FastMutex _mutex;

View File

@ -40,7 +40,7 @@ class Data_API SessionPool: public RefCountedObject
/// operation. Therefore it makes sense to reuse a session object
/// once it is no longer needed.
///
/// A SessionPool manages a collection of SessionImpl objects
/// A SessionPool manages a collection of SessionImpl objects
/// (decorated with a PooledSessionImpl).
///
/// When a SessionImpl object is requested, the SessionPool first
@ -52,7 +52,7 @@ class Data_API SessionPool: public RefCountedObject
/// can be set on the maximum number of objects.
/// Sessions found not to be connected to the database are purged
/// from the pool whenever one of the following events occurs:
///
///
/// - JanitorTimer event
/// - get() request
/// - putBack() request
@ -67,11 +67,12 @@ class Data_API SessionPool: public RefCountedObject
/// ...
{
public:
SessionPool(const std::string& connector,
const std::string& connectionString,
int minSessions = 1,
int maxSessions = 32,
int idleTime = 60);
SessionPool(const std::string& connector,
const std::string& connectionString,
int minSessions = 1,
int maxSessions = 32,
int idleTime = 60,
int connTimeout = 60);
/// Creates the SessionPool for sessions with the given connector
/// and connectionString.
///
@ -81,23 +82,23 @@ public:
~SessionPool();
/// Destroys the SessionPool.
Session get();
/// Returns a Session.
///
/// If there are unused sessions available, one of the
/// unused sessions is recycled. Otherwise, a new session
/// is created.
/// is created.
///
/// If the maximum number of sessions for this pool has
/// already been created, a SessionPoolExhaustedException
/// is thrown.
template <typename T>
Session get(const std::string& name, const T& value)
/// Returns a Session with requested property set.
/// The property can be different from the default pool
/// value, in which case it is reset back to the pool
/// value, in which case it is reset back to the pool
/// value when the session is reclaimed by the pool.
{
Session s = get();
@ -111,24 +112,27 @@ public:
Session get(const std::string& name, bool value);
/// Returns a Session with requested feature set.
/// The feature can be different from the default pool
/// value, in which case it is reset back to the pool
/// value, in which case it is reset back to the pool
/// value when the session is reclaimed by the pool.
int capacity() const;
/// Returns the maximum number of sessions the SessionPool will manage.
int used() const;
/// Returns the number of sessions currently in use.
int idle() const;
/// Returns the number of idle sessions.
int connTimeout() const;
/// Returns the connection timeout.
int dead();
/// Returns the number of not connected active sessions.
int allocated() const;
/// Returns the number of allocated sessions.
int available() const;
/// Returns the number of available (idle + remaining capacity) sessions.
@ -177,14 +181,14 @@ protected:
void onJanitorTimer(Poco::Timer&);
private:
typedef std::pair<std::string, Poco::Any> PropertyPair;
typedef std::pair<std::string, bool> FeaturePair;
typedef std::pair<std::string, Poco::Any> PropertyPair;
typedef std::pair<std::string, bool> FeaturePair;
typedef std::map<SessionImpl*, PropertyPair> AddPropertyMap;
typedef std::map<SessionImpl*, FeaturePair> AddFeatureMap;
SessionPool(const SessionPool&);
SessionPool& operator = (const SessionPool&);
void closeAll(SessionList& sessionList);
std::string _connector;
@ -192,6 +196,7 @@ private:
int _minSessions;
int _maxSessions;
int _idleTime;
int _connTimeout;
int _nSessions;
SessionList _idleSessions;
SessionList _activeSessions;
@ -203,7 +208,7 @@ private:
AddFeatureMap _addFeatureMap;
mutable
Poco::Mutex _mutex;
friend class PooledSessionImpl;
};

View File

@ -38,15 +38,15 @@ public:
~SessionPoolContainer();
/// Destroys the SessionPoolContainer.
void add(SessionPool* pPool);
/// Adds existing session pool to the container.
/// Throws SessionPoolExistsException if pool already exists.
Session add(const std::string& sessionKey,
Session add(const std::string& sessionKey,
const std::string& connectionString,
int minSessions = 1,
int maxSessions = 32,
int minSessions = 1,
int maxSessions = 32,
int idleTime = 60);
/// Adds a new session pool to the container and returns a Session from
/// newly created pool. If pool already exists, request to add is silently
@ -58,7 +58,7 @@ public:
bool isActive(const std::string& sessionKey,
const std::string& connectionString = "") const;
/// Returns true if the session is active (i.e. not shut down).
/// If connectionString is empty string, sessionKey must be a
/// If connectionString is empty string, sessionKey must be a
/// fully qualified session name as registered with the pool
/// container.
@ -72,7 +72,7 @@ public:
void remove(const std::string& name);
/// Removes a SessionPool.
int count() const;
/// Returns the number of session pols in the container.
@ -84,7 +84,7 @@ private:
SessionPoolContainer(const SessionPoolContainer&);
SessionPoolContainer& operator = (const SessionPoolContainer&);
SessionPoolMap _sessionPools;
Poco::FastMutex _mutex;
};

View File

@ -49,7 +49,7 @@ public:
~SimpleRowFormatter();
/// Destroys the SimpleRowFormatter.
void swap(SimpleRowFormatter& other);
void swap(SimpleRowFormatter& other) noexcept;
/// Swaps the row formatter with another one.
std::string& formatNames(const NameVecPtr pNames, std::string& formattedNames);
@ -66,7 +66,7 @@ public:
std::streamsize getColumnWidth() const;
/// Returns the column width.
std::streamsize getSpacing() const;
/// Returns the spacing.
@ -109,9 +109,13 @@ inline std::streamsize SimpleRowFormatter::getSpacing() const
namespace std
{
// Note: for an unknown reason, clang refuses to compile this function as noexcept
template<>
inline void swap<Poco::Data::SimpleRowFormatter>(Poco::Data::SimpleRowFormatter& s1,
inline void swap<Poco::Data::SimpleRowFormatter>(Poco::Data::SimpleRowFormatter& s1,
Poco::Data::SimpleRowFormatter& s2)
#ifndef POCO_COMPILER_CLANG
noexcept
#endif
/// Full template specalization of std:::swap for SimpleRowFormatter
{
s1.swap(s2);

View File

@ -78,6 +78,7 @@ public:
using ResultPtr = SharedPtr<Result>;
using AsyncExecMethod = ActiveMethod<std::size_t, bool, StatementImpl>;
using AsyncExecMethodPtr = SharedPtr<AsyncExecMethod>;
using State = StatementImpl::State;
static const int WAIT_FOREVER = -1;
@ -124,7 +125,7 @@ public:
Statement& operator = (Statement&& stmt) noexcept;
/// Move assignment.
void swap(Statement& other);
void swap(Statement& other) noexcept;
/// Swaps the statement with another one.
template <typename T>
@ -385,6 +386,9 @@ public:
/// Sets the row formatter for this statement.
/// Statement takes the ownership of the formatter.
State state() const;
/// Returns the statement state.
protected:
using ImplPtr = StatementImpl::Ptr;
@ -791,6 +795,12 @@ inline bool Statement::isAsync() const
}
inline Statement::State Statement::state() const
{
return _pImpl->getState();
}
inline void Statement::setRowFormatter(RowFormatter::Ptr pRowFormatter)
{
_pRowFormatter = pRowFormatter;
@ -804,7 +814,7 @@ inline const RowFormatter::Ptr& Statement::getRowFormatter()
}
inline void swap(Statement& s1, Statement& s2)
inline void swap(Statement& s1, Statement& s2) noexcept
{
s1.swap(s2);
}

View File

@ -34,7 +34,7 @@ class Data_API StatementCreator
public:
StatementCreator();
/// Creates an unitialized StatementCreator.
StatementCreator(Poco::AutoPtr<SessionImpl> ptrImpl);
/// Creates a StatementCreator.
@ -52,10 +52,10 @@ public:
StatementCreator& operator = (StatementCreator&& other) noexcept;
/// Assignment operator.
void swap(StatementCreator& other);
/// Swaps the StatementCreator with another one.
void swap(StatementCreator& other) noexcept;
/// Swaps the StatementCreator with another one.
template <typename T>
Statement operator << (const T& t)
/// Creates a Statement.

View File

@ -432,7 +432,7 @@ private:
using CountVec = std::vector<std::size_t>;
State _state;
std::atomic<State> _state;
Limit _extrLimit;
std::size_t _lowerLimit;
std::vector<int> _columnsExtracted;

View File

@ -174,7 +174,7 @@ public:
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Poco::Data::Time);
@ -211,7 +211,7 @@ public:
{
return cloneHolder(pVarHolder, _val);
}
const Poco::Data::Time& value() const
{
return _val;

View File

@ -44,22 +44,22 @@ public:
/// Creates the Transaction, using the given database session.
/// If start is true, transaction is started, otherwise begin() must be called
/// to start the transaction.
template <typename T>
Transaction(Poco::Data::Session& rSession, T& t, Poco::Logger* pLogger = 0):
Transaction(Poco::Data::Session& rSession, T& t, Poco::Logger* pLogger = 0):
_rSession(rSession),
_pLogger(pLogger)
/// Creates the Transaction, using the given database session, transactor and logger.
/// The transactor type must provide operator () overload taking non-const Session
/// The transactor type must provide operator () overload taking non-const Session
/// reference as an argument.
///
/// When transaction is created using this constructor, it is executed and
/// commited automatically. If no error occurs, rollback is disabled and does
/// not occur at destruction time. If an error occurs resulting in exception being
/// thrown, the transaction is rolled back and exception propagated to calling code.
///
///
/// Example usage:
///
///
/// struct Transactor
/// {
/// void operator () (Session& session) const
@ -67,9 +67,9 @@ public:
/// // do something ...
/// }
/// };
///
///
/// Transactor tr;
/// Transaction tn(session, tr);
/// Transaction tn(session, tr);
{
try { transact(t); }
catch (...)
@ -86,7 +86,7 @@ public:
/// (by calling commit()), or rolled back (by calling rollback()).
///
/// If an exception is thrown during rollback, the exception is logged
/// and no further action is taken.
/// and no further action is taken.
void setIsolation(Poco::UInt32 ti);
/// Sets the transaction isolation level.
@ -116,7 +116,7 @@ public:
template <typename T>
void transact(T& t)
/// Executes the transactor and, unless transactor throws an exception,
/// Executes the transactor and, unless transactor throws an exception,
/// commits the transaction.
{
if (!isActive()) begin();
@ -126,10 +126,10 @@ public:
void commit();
/// Commits the current transaction.
void rollback();
/// Rolls back the current transaction.
bool isActive();
/// Returns false after the transaction has been committed or rolled back,
/// true if the transaction is ongoing.
@ -142,7 +142,7 @@ private:
Transaction();
Transaction(const Transaction&);
Transaction& operator = (const Transaction&);
void begin();
/// Begins the transaction if the session is already not in transaction.
/// Otherwise does nothing.

View File

@ -0,0 +1,97 @@
//
// Transcoder.h
//
// Library: Data
// Package: DataCore
// Module: Transcoder
//
// Definition of the Transcoder class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Data_Transcoder_INCLUDED
#define Data_Transcoder_INCLUDED
#include "Poco/Data/Data.h"
#include "Poco/TextConverter.h"
#include "Poco/TextEncoding.h"
#include <memory>
#include <string>
namespace Poco {
namespace Data {
class Data_API Transcoder
/// Utility class used to convert string data encoding.
///
/// The purpose of this class is to help with deciding
/// whether conversion is actually required, and to keep
/// the encodings lifetimes aligned with the converter lifetime.
{
public:
using Ptr = std::unique_ptr<Transcoder>;
using ConverterPtr = std::unique_ptr<Poco::TextConverter>;
virtual ~Transcoder();
/// Destroys the Transcoder.
static Ptr create(Poco::TextEncoding::Ptr pFromEncoding = nullptr,
Poco::TextEncoding::Ptr pToEncoding = nullptr);
/// Returns a unique pointer to Transcode instance;
/// if there is no need for transcoding, null pointer
/// is returned.
std::string fromEncoding() const;
/// Returns "from" encoding canonical name.
std::string toEncoding() const;
/// Returns "from" encoding canonical name.
void transcode(const std::string& from, std::string& to);
/// Performs the conversion. Any prior content of the
/// destination string is cleared.
void reverseTranscode(const std::string& from, std::string& to);
/// Performs the reverse conversion. Any prior content of the
/// destination string is cleared.
private:
Transcoder(Poco::TextEncoding::Ptr pFromEncoding,
Poco::TextEncoding::Ptr pToEncoding);
/// Creates the Transcoder.
Poco::TextEncoding::Ptr _pFromEncoding;
Poco::TextEncoding::Ptr _pToEncoding;
ConverterPtr _pConverter;
ConverterPtr _pReverseConverter;
};
//
// inlines
//
inline std::string Transcoder::fromEncoding() const
{
return _pFromEncoding->canonicalName();
}
inline std::string Transcoder::toEncoding() const
{
return _pToEncoding->canonicalName();
}
} } // namespace Poco::Data
#endif // Data_Transcoder_INCLUDED

File diff suppressed because it is too large Load Diff