merge some changes from develop branch; modernize and clean-up code; remove support for compiling without POCO_WIN32_UTF8

This commit is contained in:
Günter Obiltschnig 2020-01-09 10:08:09 +01:00
parent 7c177b6f89
commit 1bf40a0cd2
389 changed files with 3029 additions and 4111 deletions

View File

@ -9,7 +9,7 @@
#include "CppUnit/CppUnit.h" #include "CppUnit/CppUnit.h"
#include <string> #include <string>
#include <stdio.h> #include <cstdio>
namespace CppUnit { namespace CppUnit {
@ -33,7 +33,7 @@ inline std::string estring(std::string& expandedString)
inline std::string estring(int number) inline std::string estring(int number)
{ {
char buffer[50]; char buffer[50];
sprintf(buffer, "%d", number); std::snprintf(buffer, sizeof(buffer), "%d", number);
return std::string (buffer); return std::string (buffer);
} }
@ -42,7 +42,7 @@ inline std::string estring(int number)
inline std::string estring(long number) inline std::string estring(long number)
{ {
char buffer[50]; char buffer[50];
sprintf(buffer, "%ld", number); std::snprintf(buffer, sizeof(buffer), "%ld", number);
return std::string (buffer); return std::string (buffer);
} }
@ -51,7 +51,7 @@ inline std::string estring(long number)
inline std::string estring(double number) inline std::string estring(double number)
{ {
char buffer[50]; char buffer[50];
sprintf(buffer, "%lf", number); std::snprintf(buffer, sizeof(buffer), "%lf", number);
return std::string(buffer); return std::string(buffer);
} }
@ -60,7 +60,7 @@ inline std::string estring(double number)
inline std::string estring(const void* ptr) inline std::string estring(const void* ptr)
{ {
char buffer[50]; char buffer[50];
sprintf(buffer, "%p", ptr); std::snprintf(buffer, sizeof(buffer), "%p", ptr);
return std::string(buffer); return std::string(buffer);
} }

View File

@ -37,7 +37,7 @@ namespace Poco {
namespace Data { namespace Data {
typedef NullType NullData; using NullData = NullType;
namespace Keywords { namespace Keywords {
@ -53,7 +53,7 @@ class Data_API AbstractBinder
/// Interface for Binding data types to placeholders. /// Interface for Binding data types to placeholders.
{ {
public: public:
typedef SharedPtr<AbstractBinder> Ptr; using Ptr = SharedPtr<AbstractBinder>;
enum Direction enum Direction
/// Binding direction for a parameter. /// Binding direction for a parameter.

View File

@ -37,8 +37,8 @@ class Data_API AbstractBinding
/// AbstractBinding connects a value with a placeholder via an AbstractBinder interface. /// AbstractBinding connects a value with a placeholder via an AbstractBinder interface.
{ {
public: public:
typedef SharedPtr<AbstractBinding> Ptr; using Ptr = SharedPtr<AbstractBinding>;
typedef AbstractBinder::Ptr BinderPtr; using BinderPtr = AbstractBinder::Ptr;
enum Direction enum Direction
{ {
@ -100,9 +100,9 @@ private:
}; };
typedef std::vector<AbstractBinding::Ptr> AbstractBindingVec; using AbstractBindingVec = std::vector<AbstractBinding::Ptr>;
typedef std::deque<AbstractBinding::Ptr> AbstractBindingDeq; using AbstractBindingDeq = std::deque<AbstractBinding::Ptr>;
typedef std::list<AbstractBinding::Ptr> AbstractBindingLst; using AbstractBindingLst = std::list<AbstractBinding::Ptr>;
// //

View File

@ -43,9 +43,9 @@ class Data_API AbstractExtraction
/// retrieved via an AbstractExtractor. /// retrieved via an AbstractExtractor.
{ {
public: public:
typedef SharedPtr<AbstractExtraction> Ptr; using Ptr = SharedPtr<AbstractExtraction>;
typedef SharedPtr<AbstractExtractor> ExtractorPtr; using ExtractorPtr = SharedPtr<AbstractExtractor>;
typedef SharedPtr<AbstractPreparator> PreparatorPtr; using PreparatorPtr = SharedPtr<AbstractPreparator>;
AbstractExtraction(Poco::UInt32 limit = Limit::LIMIT_UNLIMITED, AbstractExtraction(Poco::UInt32 limit = Limit::LIMIT_UNLIMITED,
Poco::UInt32 position = 0, bool bulk = false); Poco::UInt32 position = 0, bool bulk = false);
@ -172,12 +172,12 @@ private:
}; };
typedef std::vector<AbstractExtraction::Ptr> AbstractExtractionVec; using AbstractExtractionVec = std::vector<AbstractExtraction::Ptr>;
typedef std::vector<AbstractExtractionVec> AbstractExtractionVecVec; using AbstractExtractionVecVec = std::vector<AbstractExtractionVec>;
typedef std::deque<AbstractExtraction::Ptr> AbstractExtractionDeq; using AbstractExtractionDeq = std::deque<AbstractExtraction::Ptr>;
typedef std::vector<AbstractExtractionDeq> AbstractExtractionDeqVec; using AbstractExtractionDeqVec = std::vector<AbstractExtractionDeq>;
typedef std::list<AbstractExtraction::Ptr> AbstractExtractionLst; using AbstractExtractionLst = std::list<AbstractExtraction::Ptr>;
typedef std::vector<AbstractExtractionLst> AbstractExtractionLstVec; using AbstractExtractionLstVec = std::vector<AbstractExtractionLst>;
// //

View File

@ -51,7 +51,7 @@ class Data_API AbstractExtractor
/// If an extractor receives null it is not allowed to change val! /// If an extractor receives null it is not allowed to change val!
{ {
public: public:
typedef SharedPtr<AbstractExtractor> Ptr; using Ptr = SharedPtr<AbstractExtractor>;
AbstractExtractor(); AbstractExtractor();
/// Creates the AbstractExtractor. /// Creates the AbstractExtractor.

View File

@ -32,8 +32,8 @@ class Data_API AbstractPreparation
/// Interface for calling the appropriate AbstractPreparator method /// Interface for calling the appropriate AbstractPreparator method
{ {
public: public:
typedef SharedPtr<AbstractPreparation> Ptr; using Ptr = SharedPtr<AbstractPreparation>;
typedef AbstractPreparator::Ptr PreparatorPtr; using PreparatorPtr = AbstractPreparator::Ptr;
AbstractPreparation(PreparatorPtr pPreparator); AbstractPreparation(PreparatorPtr pPreparator);
/// Creates the AbstractPreparation. /// Creates the AbstractPreparation.

View File

@ -57,7 +57,7 @@ class Data_API AbstractPreparator
/// after SQL execution (e.g. SQLite) do not need this functionality at all. /// after SQL execution (e.g. SQLite) do not need this functionality at all.
{ {
public: public:
typedef SharedPtr<AbstractPreparator> Ptr; using Ptr = SharedPtr<AbstractPreparator>;
AbstractPreparator(Poco::UInt32 length = 1u); AbstractPreparator(Poco::UInt32 length = 1u);
/// Creates the AbstractPreparator. /// Creates the AbstractPreparator.

View File

@ -59,7 +59,7 @@ public:
/// Creates the AbstractSessionImpl. /// 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. /// type to std::vector.
/// 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. /// returning results is executed but external storage is provided by the user.
/// Storage type can be reconfigured at runtime both globally (for the /// Storage type can be reconfigured at runtime both globally (for the
@ -296,8 +296,8 @@ private:
PropertyGetter getter; PropertyGetter getter;
}; };
typedef std::map<std::string, Feature> FeatureMap; using FeatureMap = std::map<std::string, Feature>;
typedef std::map<std::string, Property> PropertyMap; using PropertyMap = std::map<std::string, Property>;
FeatureMap _features; FeatureMap _features;
PropertyMap _properties; PropertyMap _properties;

View File

@ -70,8 +70,8 @@ public:
/// Sets the archive threshold. /// Sets the archive threshold.
protected: protected:
typedef Poco::SharedPtr<Session> SessionPtr; using SessionPtr = Poco::SharedPtr<Session>;
typedef Poco::SharedPtr<Statement> StatementPtr; using StatementPtr = Poco::SharedPtr<Statement>;
Session& session(); Session& session();

View File

@ -26,7 +26,7 @@ namespace Poco {
namespace Data { namespace Data {
typedef Transaction AutoTransaction; using AutoTransaction = Transaction;
} } // namespace Poco::Data } } // namespace Poco::Data

View File

@ -51,10 +51,10 @@ class Binding: public AbstractBinding
/// function. An attempt to pass a constant by reference shall result in compile-time error. /// function. An attempt to pass a constant by reference shall result in compile-time error.
{ {
public: public:
typedef T ValType; using ValType = T;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Binding<ValType> Type; using Type = Binding<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
explicit Binding(T& val, explicit Binding(T& val,
const std::string& name = "", const std::string& name = "",
@ -121,10 +121,10 @@ class CopyBinding: public AbstractBinding
/// Variables can be passed as either copies or references (i.e. using either use() or bind()). /// Variables can be passed as either copies or references (i.e. using either use() or bind()).
{ {
public: public:
typedef T ValType; using ValType = T;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef CopyBinding<ValType> Type; using Type = CopyBinding<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
explicit CopyBinding(T& val, explicit CopyBinding(T& val,
const std::string& name = "", const std::string& name = "",
@ -184,10 +184,10 @@ class Binding<const char*>: public AbstractBinding
/// Binding const char* specialization wraps char pointer into string. /// Binding const char* specialization wraps char pointer into string.
{ {
public: public:
typedef const char* ValType; using ValType = const char*;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Binding<const char*> Type; using Type = Binding<const char*>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
explicit Binding(const char* pVal, explicit Binding(const char* pVal,
const std::string& name = "", const std::string& name = "",
@ -246,10 +246,10 @@ class CopyBinding<const char*>: public AbstractBinding
/// Binding const char* specialization wraps char pointer into string. /// Binding const char* specialization wraps char pointer into string.
{ {
public: public:
typedef const char* ValType; using ValType = const char*;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef CopyBinding<const char*> Type; using Type = CopyBinding<const char*>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
explicit CopyBinding(const char* pVal, explicit CopyBinding(const char* pVal,
const std::string& name = "", const std::string& name = "",
@ -307,10 +307,10 @@ class Binding<std::vector<T> >: public AbstractBinding
/// Specialization for std::vector. /// Specialization for std::vector.
{ {
public: public:
typedef std::vector<T> ValType; using ValType = std::vector<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<Binding<ValType> > Ptr; using Ptr = SharedPtr<Binding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit Binding(std::vector<T>& val, explicit Binding(std::vector<T>& val,
const std::string& name = "", const std::string& name = "",
@ -374,10 +374,10 @@ class CopyBinding<std::vector<T> >: public AbstractBinding
{ {
public: public:
typedef std::vector<T> ValType; using ValType = std::vector<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<CopyBinding<ValType> > Ptr; using Ptr = SharedPtr<CopyBinding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit CopyBinding(std::vector<T>& val, explicit CopyBinding(std::vector<T>& val,
const std::string& name = "", const std::string& name = "",
@ -451,10 +451,10 @@ class Binding<std::vector<bool> >: public AbstractBinding
/// Only IN binding is supported. /// Only IN binding is supported.
{ {
public: public:
typedef std::vector<bool> ValType; using ValType = std::vector<bool>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<Binding<ValType> > Ptr; using Ptr = SharedPtr<Binding<ValType>>;
typedef ValType::const_iterator Iterator; using Iterator = ValType::const_iterator;
explicit Binding(const std::vector<bool>& val, explicit Binding(const std::vector<bool>& val,
const std::string& name = "", const std::string& name = "",
@ -500,7 +500,6 @@ public:
poco_assert_dbg(canBind()); poco_assert_dbg(canBind());
TypeHandler<bool>::bind(pos, *_begin, getBinder(), getDirection()); TypeHandler<bool>::bind(pos, *_begin, getBinder(), getDirection());
++_begin; ++_begin;
} }
void reset() void reset()
@ -533,10 +532,10 @@ class CopyBinding<std::vector<bool> >: public AbstractBinding
/// Only IN binding is supported. /// Only IN binding is supported.
{ {
public: public:
typedef std::vector<bool> ValType; using ValType = std::vector<bool>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<CopyBinding<ValType> > Ptr; using Ptr = SharedPtr<CopyBinding<ValType>>;
typedef ValType::const_iterator Iterator; using Iterator = ValType::const_iterator;
explicit CopyBinding(const std::vector<bool>& val, explicit CopyBinding(const std::vector<bool>& val,
const std::string& name = "", const std::string& name = "",
@ -602,10 +601,10 @@ class Binding<std::list<T> >: public AbstractBinding
/// Specialization for std::list. /// Specialization for std::list.
{ {
public: public:
typedef std::list<T> ValType; using ValType = std::list<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<Binding<ValType> > Ptr; using Ptr = SharedPtr<Binding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit Binding(std::list<T>& val, explicit Binding(std::list<T>& val,
const std::string& name = "", const std::string& name = "",
@ -667,10 +666,10 @@ class CopyBinding<std::list<T> >: public AbstractBinding
/// Specialization for std::list. /// Specialization for std::list.
{ {
public: public:
typedef typename std::list<T> ValType; using ValType = typename std::list<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<CopyBinding<ValType> > Ptr; using Ptr = SharedPtr<CopyBinding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit CopyBinding(ValType& val, explicit CopyBinding(ValType& val,
const std::string& name = "", const std::string& name = "",
@ -732,10 +731,10 @@ class Binding<std::deque<T> >: public AbstractBinding
/// Specialization for std::deque. /// Specialization for std::deque.
{ {
public: public:
typedef std::deque<T> ValType; using ValType = std::deque<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<Binding<ValType> > Ptr; using Ptr = SharedPtr<Binding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit Binding(std::deque<T>& val, explicit Binding(std::deque<T>& val,
const std::string& name = "", const std::string& name = "",
@ -797,10 +796,10 @@ class CopyBinding<std::deque<T> >: public AbstractBinding
/// Specialization for std::deque. /// Specialization for std::deque.
{ {
public: public:
typedef std::deque<T> ValType; using ValType = std::deque<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<CopyBinding<ValType> > Ptr; using Ptr = SharedPtr<CopyBinding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit CopyBinding(std::deque<T>& val, explicit CopyBinding(std::deque<T>& val,
const std::string& name = "", const std::string& name = "",
@ -862,10 +861,10 @@ class Binding<std::set<T> >: public AbstractBinding
/// Specialization for std::set. /// Specialization for std::set.
{ {
public: public:
typedef std::set<T> ValType; using ValType = std::set<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<Binding<ValType> > Ptr; using Ptr = SharedPtr<Binding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit Binding(std::set<T>& val, explicit Binding(std::set<T>& val,
const std::string& name = "", const std::string& name = "",
@ -927,10 +926,10 @@ class CopyBinding<std::set<T> >: public AbstractBinding
/// Specialization for std::set. /// Specialization for std::set.
{ {
public: public:
typedef std::set<T> ValType; using ValType = std::set<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<CopyBinding<ValType> > Ptr; using Ptr = SharedPtr<CopyBinding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit CopyBinding(std::set<T>& val, explicit CopyBinding(std::set<T>& val,
const std::string& name = "", const std::string& name = "",
@ -992,10 +991,10 @@ class Binding<std::multiset<T> >: public AbstractBinding
/// Specialization for std::multiset. /// Specialization for std::multiset.
{ {
public: public:
typedef std::multiset<T> ValType; using ValType = std::multiset<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<Binding<ValType> > Ptr; using Ptr = SharedPtr<Binding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit Binding(std::multiset<T>& val, explicit Binding(std::multiset<T>& val,
const std::string& name = "", const std::string& name = "",
@ -1057,10 +1056,10 @@ class CopyBinding<std::multiset<T> >: public AbstractBinding
/// Specialization for std::multiset. /// Specialization for std::multiset.
{ {
public: public:
typedef std::multiset<T> ValType; using ValType = std::multiset<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<CopyBinding<ValType> > Ptr; using Ptr = SharedPtr<CopyBinding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit CopyBinding(std::multiset<T>& val, explicit CopyBinding(std::multiset<T>& val,
const std::string& name = "", const std::string& name = "",
@ -1122,10 +1121,10 @@ class Binding<std::map<K, V> >: public AbstractBinding
/// Specialization for std::map. /// Specialization for std::map.
{ {
public: public:
typedef std::map<K, V> ValType; using ValType = std::map<K, V>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<Binding<ValType> > Ptr; using Ptr = SharedPtr<Binding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit Binding(std::map<K, V>& val, explicit Binding(std::map<K, V>& val,
const std::string& name = "", const std::string& name = "",
@ -1187,10 +1186,10 @@ class CopyBinding<std::map<K, V> >: public AbstractBinding
/// Specialization for std::map. /// Specialization for std::map.
{ {
public: public:
typedef std::map<K, V> ValType; using ValType = std::map<K, V>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<CopyBinding<ValType> > Ptr; using Ptr = SharedPtr<CopyBinding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit CopyBinding(std::map<K, V>& val, explicit CopyBinding(std::map<K, V>& val,
const std::string& name = "", const std::string& name = "",
@ -1252,10 +1251,10 @@ class Binding<std::multimap<K, V> >: public AbstractBinding
/// Specialization for std::multimap. /// Specialization for std::multimap.
{ {
public: public:
typedef std::multimap<K, V> ValType; using ValType = std::multimap<K, V>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<Binding<ValType> > Ptr; using Ptr = SharedPtr<Binding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit Binding(std::multimap<K, V>& val, explicit Binding(std::multimap<K, V>& val,
const std::string& name = "", const std::string& name = "",
@ -1317,10 +1316,10 @@ class CopyBinding<std::multimap<K, V> >: public AbstractBinding
/// Specialization for std::multimap. /// Specialization for std::multimap.
{ {
public: public:
typedef std::multimap<K, V> ValType; using ValType = std::multimap<K, V>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<CopyBinding<ValType> > Ptr; using Ptr = SharedPtr<CopyBinding<ValType>>;
typedef typename ValType::const_iterator Iterator; using Iterator = typename ValType::const_iterator;
explicit CopyBinding(std::multimap<K, V>& val, explicit CopyBinding(std::multimap<K, V>& val,
const std::string& name = "", const std::string& name = "",

View File

@ -38,11 +38,11 @@ class BulkExtraction: public AbstractExtraction
/// - std::list /// - std::list
{ {
public: public:
typedef C ValType; using ValType = C;
typedef typename C::value_type CValType; using CValType = typename C::value_type;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef BulkExtraction<ValType> Type; using Type = BulkExtraction<ValType>;
typedef SharedPtr<Type> Ptr; 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), AbstractExtraction(limit, pos.value(), true),
@ -146,11 +146,11 @@ class InternalBulkExtraction: public BulkExtraction<C>
/// InternalBulkExtraction objects can not be copied or assigned. /// InternalBulkExtraction objects can not be copied or assigned.
{ {
public: public:
typedef C ValType; using ValType = C;
typedef typename C::value_type CValType; using CValType = typename C::value_type;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef InternalBulkExtraction<ValType> Type; using Type = InternalBulkExtraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
InternalBulkExtraction(C& result, InternalBulkExtraction(C& result,
Column<C>* pColumn, Column<C>* pColumn,

View File

@ -39,12 +39,12 @@ class Column
/// This class owns the data assigned to it and deletes the storage on destruction. /// This class owns the data assigned to it and deletes the storage on destruction.
{ {
public: public:
typedef C Container; using Container = C;
typedef Poco::SharedPtr<C> ContainerPtr; using ContainerPtr = Poco::SharedPtr<C>;
typedef typename C::const_iterator Iterator; using Iterator = typename C::const_iterator;
typedef typename C::const_reverse_iterator RIterator; using RIterator = typename C::const_reverse_iterator;
typedef typename C::size_type Size; using Size = typename C::size_type;
typedef typename C::value_type Type; using Type = typename C::value_type;
Column(const MetaColumn& metaColumn, Container* pData): Column(const MetaColumn& metaColumn, Container* pData):
_metaColumn(metaColumn), _metaColumn(metaColumn),
@ -62,6 +62,13 @@ public:
{ {
} }
Column(Column&& col) noexcept:
_metaColumn(std::move(col._metaColumn)),
_pData(std::move(col._pData))
/// Creates the Column.
{
}
~Column() ~Column()
/// Destroys the Column. /// Destroys the Column.
{ {
@ -75,6 +82,14 @@ public:
return *this; return *this;
} }
Column& operator = (Column&& col) noexcept
/// Assignment operator.
{
_metaColumn = std::move(col._metaColumn);
_pData = std::move(col._pData);
return *this;
}
void swap(Column& other) void swap(Column& other)
/// Swaps the column with another one. /// Swaps the column with another one.
{ {
@ -186,11 +201,11 @@ class Column<std::vector<bool> >
/// column data. /// column data.
{ {
public: public:
typedef std::vector<bool> Container; using Container = std::vector<bool>;
typedef Poco::SharedPtr<Container> ContainerPtr; using ContainerPtr = Poco::SharedPtr<Container>;
typedef Container::const_iterator Iterator; using Iterator = Container::const_iterator;
typedef Container::const_reverse_iterator RIterator; using RIterator = Container::const_reverse_iterator;
typedef Container::size_type Size; using Size = Container::size_type;
Column(const MetaColumn& metaColumn, Container* pData): Column(const MetaColumn& metaColumn, Container* pData):
_metaColumn(metaColumn), _metaColumn(metaColumn),
@ -329,11 +344,11 @@ class Column<std::list<T> >
/// Column specialization for std::list /// Column specialization for std::list
{ {
public: public:
typedef std::list<T> Container; using Container = std::list<T>;
typedef Poco::SharedPtr<Container> ContainerPtr; using ContainerPtr = Poco::SharedPtr<Container>;
typedef typename Container::const_iterator Iterator; using Iterator = typename Container::const_iterator;
typedef typename Container::const_reverse_iterator RIterator; using RIterator = typename Container::const_reverse_iterator;
typedef typename Container::size_type Size; using Size = typename Container::size_type;
Column(const MetaColumn& metaColumn, std::list<T>* pData): Column(const MetaColumn& metaColumn, std::list<T>* pData):
_metaColumn(metaColumn), _metaColumn(metaColumn),

View File

@ -27,8 +27,8 @@ namespace Poco {
namespace Data { namespace Data {
template <typename T> class LOB; template <typename T> class LOB;
typedef LOB<unsigned char> BLOB; using BLOB = LOB<unsigned char>;
typedef LOB<char> CLOB; using CLOB = LOB<char>;
} } // namespace Poco::Data } } // namespace Poco::Data

View File

@ -42,10 +42,10 @@ class Extraction: public AbstractExtraction
/// Concrete Data Type specific extraction of values from a query result set. /// Concrete Data Type specific extraction of values from a query result set.
{ {
public: public:
typedef T ValType; using ValType = T;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Extraction<ValType> Type; using Type = Extraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
Extraction(T& result, const Position& pos = Position(0)): Extraction(T& result, const Position& pos = Position(0)):
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
@ -133,11 +133,10 @@ class Extraction<std::vector<T> >: public AbstractExtraction
/// Vector Data Type specialization for extraction of values from a query result set. /// Vector Data Type specialization for extraction of values from a query result set.
{ {
public: public:
using ValType = std::vector<T>;
typedef std::vector<T> ValType; using ValPtr = SharedPtr<ValType>;
typedef SharedPtr<ValType> ValPtr; using Type = Extraction<ValType>;
typedef Extraction<ValType> Type; using Ptr = SharedPtr<Type>;
typedef SharedPtr<Type> Ptr;
Extraction(std::vector<T>& result, const Position& pos = Position(0)): Extraction(std::vector<T>& result, const Position& pos = Position(0)):
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
@ -224,10 +223,10 @@ class Extraction<std::vector<bool> >: public AbstractExtraction
/// Vector bool specialization for extraction of values from a query result set. /// Vector bool specialization for extraction of values from a query result set.
{ {
public: public:
typedef std::vector<bool> ValType; using ValType = std::vector<bool>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Extraction<ValType> Type; using Type = Extraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
Extraction(std::vector<bool>& result, const Position& pos = Position(0)): Extraction(std::vector<bool>& result, const Position& pos = Position(0)):
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
@ -316,10 +315,10 @@ class Extraction<std::list<T> >: public AbstractExtraction
/// List Data Type specialization for extraction of values from a query result set. /// List Data Type specialization for extraction of values from a query result set.
{ {
public: public:
typedef std::list<T> ValType; using ValType = std::list<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Extraction<ValType> Type; using Type = Extraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
Extraction(std::list<T>& result, const Position& pos = Position(0)): Extraction(std::list<T>& result, const Position& pos = Position(0)):
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
@ -406,10 +405,10 @@ class Extraction<std::deque<T> >: public AbstractExtraction
/// Deque Data Type specialization for extraction of values from a query result set. /// Deque Data Type specialization for extraction of values from a query result set.
{ {
public: public:
typedef std::deque<T> ValType; using ValType = std::deque<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Extraction<ValType> Type; using Type = Extraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
Extraction(std::deque<T>& result, const Position& pos = Position(0)): Extraction(std::deque<T>& result, const Position& pos = Position(0)):
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
@ -504,10 +503,10 @@ class InternalExtraction: public Extraction<C>
/// InternalExtraction objects can not be copied or assigned. /// InternalExtraction objects can not be copied or assigned.
{ {
public: public:
typedef typename C::value_type ValType; using ValType = typename C::value_type;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Extraction<ValType> Type; using Type = Extraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
InternalExtraction(C& result, Column<C>* pColumn, const Position& pos = Position(0)): InternalExtraction(C& result, Column<C>* pColumn, const Position& pos = Position(0)):
@ -565,11 +564,11 @@ class Extraction<std::set<T> >: public AbstractExtraction
/// Set Data Type specialization for extraction of values from a query result set. /// Set Data Type specialization for extraction of values from a query result set.
{ {
public: public:
typedef std::set<T> ValType; using ValType = std::set<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Extraction<ValType> Type; using Type = Extraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
typedef typename ValType::iterator Iterator; using Iterator = typename ValType::iterator;
Extraction(std::set<T>& result, const Position& pos = Position(0)): Extraction(std::set<T>& result, const Position& pos = Position(0)):
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
@ -630,10 +629,10 @@ class Extraction<std::multiset<T> >: public AbstractExtraction
/// Multiset Data Type specialization for extraction of values from a query result set. /// Multiset Data Type specialization for extraction of values from a query result set.
{ {
public: public:
typedef std::multiset<T> ValType; using ValType = std::multiset<T>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Extraction<ValType> Type; using Type = Extraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
Extraction(std::multiset<T>& result, const Position& pos = Position(0)): Extraction(std::multiset<T>& result, const Position& pos = Position(0)):
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
@ -694,10 +693,10 @@ class Extraction<std::map<K, V> >: public AbstractExtraction
/// Map Data Type specialization for extraction of values from a query result set. /// Map Data Type specialization for extraction of values from a query result set.
{ {
public: public:
typedef std::map<K, V> ValType; using ValType = std::map<K, V>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Extraction<ValType> Type; using Type = Extraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
Extraction(std::map<K, V>& result, const Position& pos = Position(0)): Extraction(std::map<K, V>& result, const Position& pos = Position(0)):
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),
@ -758,10 +757,10 @@ class Extraction<std::multimap<K, V> >: public AbstractExtraction
/// Multimap Data Type specialization for extraction of values from a query result set. /// Multimap Data Type specialization for extraction of values from a query result set.
{ {
public: public:
typedef std::multimap<K, V> ValType; using ValType = std::multimap<K, V>;
typedef SharedPtr<ValType> ValPtr; using ValPtr = SharedPtr<ValType>;
typedef Extraction<ValType> Type; using Type = Extraction<ValType>;
typedef SharedPtr<Type> Ptr; using Ptr = SharedPtr<Type>;
Extraction(std::multimap<K, V>& result, const Position& pos = Position(0)): Extraction(std::multimap<K, V>& result, const Position& pos = Position(0)):
AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()),

View File

@ -41,10 +41,10 @@ class LOB
/// a convenient way to access the data in a LOB. /// a convenient way to access the data in a LOB.
{ {
public: public:
typedef typename std::vector<T>::const_iterator Iterator; using Iterator = typename std::vector<T>::const_iterator;
typedef T ValueType; using ValueType = T;
typedef typename std::vector<T> Container; using Container = std::vector<T>;
typedef Poco::SharedPtr<Container> ContentPtr; using ContentPtr = Poco::SharedPtr<Container>;
LOB(): _pContent(new std::vector<T>()) LOB(): _pContent(new std::vector<T>())
/// Creates an empty LOB. /// Creates an empty LOB.
@ -74,6 +74,10 @@ public:
{ {
} }
LOB(LOB&& other) noexcept: _pContent(std::move(other._pContent))
{
}
~LOB() ~LOB()
/// Destroys the LOB. /// Destroys the LOB.
{ {
@ -87,6 +91,12 @@ public:
return *this; return *this;
} }
LOB& operator = (LOB&& other) noexcept
{
_pContent = std::move(other._pContent);
return *this;
}
bool operator == (const LOB& other) const bool operator == (const LOB& other) const
/// Compares for equality LOB by value. /// Compares for equality LOB by value.
{ {
@ -180,8 +190,8 @@ private:
}; };
typedef LOB<unsigned char> BLOB; using BLOB = LOB<unsigned char>;
typedef LOB<char> CLOB; using CLOB = LOB<char>;
// //

View File

@ -46,8 +46,8 @@ public:
} }
protected: protected:
typedef std::char_traits<T> TraitsType; using TraitsType = std::char_traits<T>;
typedef BasicUnbufferedStreamBuf<T, TraitsType> BaseType; using BaseType = BasicUnbufferedStreamBuf<T, TraitsType>;
typename BaseType::int_type readFromDevice() typename BaseType::int_type readFromDevice()
{ {
@ -138,11 +138,11 @@ public:
}; };
typedef LOBOutputStream<unsigned char> BLOBOutputStream; using BLOBOutputStream = LOBOutputStream<unsigned char>;
typedef LOBOutputStream<char> CLOBOutputStream; using CLOBOutputStream = LOBOutputStream<char>;
typedef LOBInputStream<unsigned char> BLOBInputStream; using BLOBInputStream = LOBInputStream<unsigned char>;
typedef LOBInputStream<char> CLOBInputStream; using CLOBInputStream = LOBInputStream<char>;
} } // namespace Poco::Data } } // namespace Poco::Data

View File

@ -29,7 +29,7 @@ class Data_API Limit
/// Limit stores information how many rows a query should return. /// Limit stores information how many rows a query should return.
{ {
public: public:
typedef Poco::UInt32 SizeT; using SizeT = Poco::UInt32;
enum Type enum Type
{ {

View File

@ -64,7 +64,22 @@ public:
bool nullable = false); bool nullable = false);
/// Creates the MetaColumn. /// Creates the MetaColumn.
virtual ~MetaColumn(); MetaColumn(const MetaColumn& other);
/// Copy constructor.
MetaColumn(MetaColumn&& other) noexcept;
/// Move constructor.
MetaColumn& operator = (const MetaColumn& other);
/// Assignment operator.
MetaColumn& operator = (MetaColumn&& other) noexcept;
/// Assignment operator.
void swap(MetaColumn& other);
/// Swaps the contents with another instance.
~MetaColumn();
/// Destroys the MetaColumn. /// Destroys the MetaColumn.
const std::string& name() const; const std::string& name() const;

View File

@ -69,9 +69,9 @@ class Data_API RecordSet: private Statement
/// a limit for the Statement. /// a limit for the Statement.
{ {
public: public:
typedef std::map<std::size_t, Row*> RowMap; using RowMap = std::map<std::size_t, Row*>;
typedef const RowIterator ConstIterator; using ConstIterator = const RowIterator;
typedef RowIterator Iterator; using Iterator = RowIterator;
using Statement::isNull; using Statement::isNull;
using Statement::subTotalRowCount; using Statement::subTotalRowCount;
@ -107,15 +107,24 @@ public:
RecordSet(const RecordSet& other); RecordSet(const RecordSet& other);
/// Copy-creates the recordset. /// Copy-creates the recordset.
RecordSet(RecordSet&& other) noexcept;
/// Move-creates the recordset.
~RecordSet(); ~RecordSet();
/// Destroys the RecordSet. /// Destroys the RecordSet.
void setRowFormatter(RowFormatter::Ptr pRowFormatter); void setRowFormatter(RowFormatter::Ptr pRowFormatter);
/// Assigns the row formatter to the statement and all recordset rows. /// Assigns the row formatter to the statement and all recordset rows.
Statement& operator = (const Statement& stmt); RecordSet& operator = (const Statement& stmt);
/// Assignment operator. /// Assignment operator.
RecordSet& operator = (const RecordSet& other);
/// Assignment operator.
RecordSet& operator = (RecordSet&& other) noexcept;
/// Move assignment.
std::size_t rowCount() const; std::size_t rowCount() const;
/// Returns the number of rows in the RecordSet. /// Returns the number of rows in the RecordSet.
/// The number of rows reported is dependent on filtering. /// The number of rows reported is dependent on filtering.
@ -159,12 +168,12 @@ public:
{ {
if (isBulkExtraction()) if (isBulkExtraction())
{ {
typedef InternalBulkExtraction<C> E; using E = InternalBulkExtraction<C>;
return columnImpl<C,E>(name); return columnImpl<C,E>(name);
} }
else else
{ {
typedef InternalExtraction<C> E; using E = InternalExtraction<C>;
return columnImpl<C,E>(name); return columnImpl<C,E>(name);
} }
} }
@ -175,12 +184,12 @@ public:
{ {
if (isBulkExtraction()) if (isBulkExtraction())
{ {
typedef InternalBulkExtraction<C> E; using E = InternalBulkExtraction<C>;
return columnImpl<C,E>(pos); return columnImpl<C,E>(pos);
} }
else else
{ {
typedef InternalExtraction<C> E; using E = InternalExtraction<C>;
return columnImpl<C,E>(pos); return columnImpl<C,E>(pos);
} }
} }
@ -200,18 +209,18 @@ public:
{ {
case STORAGE_VECTOR: case STORAGE_VECTOR:
{ {
typedef typename std::vector<T> C; using C = typename std::vector<T>;
return column<C>(col).value(row); return column<C>(col).value(row);
} }
case STORAGE_LIST: case STORAGE_LIST:
{ {
typedef typename std::list<T> C; using C = typename std::list<T>;
return column<C>(col).value(row); return column<C>(col).value(row);
} }
case STORAGE_DEQUE: case STORAGE_DEQUE:
case STORAGE_UNKNOWN: case STORAGE_UNKNOWN:
{ {
typedef typename std::deque<T> C; using C = typename std::deque<T>;
return column<C>(col).value(row); return column<C>(col).value(row);
} }
default: default:
@ -230,18 +239,18 @@ public:
{ {
case STORAGE_VECTOR: case STORAGE_VECTOR:
{ {
typedef typename std::vector<T> C; using C = typename std::vector<T>;
return column<C>(name).value(row); return column<C>(name).value(row);
} }
case STORAGE_LIST: case STORAGE_LIST:
{ {
typedef typename std::list<T> C; using C = typename std::list<T>;
return column<C>(name).value(row); return column<C>(name).value(row);
} }
case STORAGE_DEQUE: case STORAGE_DEQUE:
case STORAGE_UNKNOWN: case STORAGE_UNKNOWN:
{ {
typedef typename std::deque<T> C; using C = typename std::deque<T>;
return column<C>(name).value(row); return column<C>(name).value(row);
} }
default: default:
@ -404,8 +413,8 @@ private:
std::size_t columnPosition(const std::string& name) const std::size_t columnPosition(const std::string& name) const
/// Returns the position of the column with specified name. /// Returns the position of the column with specified name.
{ {
typedef typename C::value_type T; using T = typename C::value_type;
typedef const E* ExtractionVecPtr; using ExtractionVecPtr = const E*;
bool typeFound = false; bool typeFound = false;
@ -443,8 +452,8 @@ private:
const Column<C>& columnImpl(std::size_t pos) const const Column<C>& columnImpl(std::size_t pos) const
/// Returns the reference to column at specified position. /// Returns the reference to column at specified position.
{ {
typedef typename C::value_type T; using T = typename C::value_type;
typedef const E* ExtractionVecPtr; using ExtractionVecPtr = const E*;
const AbstractExtractionVec& rExtractions = extractions(); const AbstractExtractionVec& rExtractions = extractions();
@ -532,13 +541,20 @@ inline std::size_t RecordSet::columnCount() const
} }
inline Statement& RecordSet::operator = (const Statement& stmt) inline RecordSet& RecordSet::operator = (const Statement& stmt)
{ {
reset(stmt); reset(stmt);
return *this; return *this;
} }
inline RecordSet& RecordSet::operator = (const RecordSet& other)
{
reset(other);
return *this;
}
inline Poco::Dynamic::Var RecordSet::value(const std::string& name) inline Poco::Dynamic::Var RecordSet::value(const std::string& name)
{ {
return value(name, _currentRow); return value(name, _currentRow);

View File

@ -57,9 +57,9 @@ class Data_API Row
/// The stream operator is provided for Row data type as a free-standing function. /// The stream operator is provided for Row data type as a free-standing function.
{ {
public: public:
typedef RowFormatter::NameVec NameVec; using NameVec = RowFormatter::NameVec;
typedef RowFormatter::NameVecPtr NameVecPtr; using NameVecPtr = RowFormatter::NameVecPtr;
typedef RowFormatter::ValueVec ValueVec; using ValueVec = RowFormatter::ValueVec;
enum ComparisonType enum ComparisonType
{ {
@ -69,14 +69,14 @@ public:
COMPARE_AS_STRING COMPARE_AS_STRING
}; };
typedef Tuple<std::size_t, ComparisonType> SortTuple; using SortTuple = Tuple<std::size_t, ComparisonType>;
typedef std::vector<SortTuple> SortMap; using SortMap = std::vector<SortTuple>;
/// The type for map holding fields used for sorting criteria. /// The type for map holding fields used for sorting criteria.
/// Fields are added sequentially and have precedence that /// 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). /// position in the row).
/// This requirement rules out use of std::map due to its sorted nature. /// This requirement rules out use of std::map due to its sorted nature.
typedef SharedPtr<SortMap> SortMapPtr; using SortMapPtr = SharedPtr<SortMap>;
Row(); Row();
/// Creates the Row. /// Creates the Row.

View File

@ -68,11 +68,11 @@ public:
}; };
typedef bool (*CompT)(const Poco::Dynamic::Var&, const Poco::Dynamic::Var&); typedef bool (*CompT)(const Poco::Dynamic::Var&, const Poco::Dynamic::Var&);
typedef AutoPtr<RowFilter> Ptr; using Ptr = AutoPtr<RowFilter>;
typedef std::map<std::string, Comparison> Comparisons; using Comparisons = std::map<std::string, Comparison>;
typedef Tuple<Poco::Dynamic::Var, Comparison, LogicOperator> ComparisonEntry; using ComparisonEntry = Tuple<Poco::Dynamic::Var, Comparison, LogicOperator>;
typedef std::multimap<std::string, ComparisonEntry> ComparisonMap; using ComparisonMap = std::multimap<std::string, ComparisonEntry>;
typedef std::map<AutoPtr<RowFilter>, LogicOperator> FilterMap; using FilterMap = std::map<AutoPtr<RowFilter>, LogicOperator>;
RowFilter(RecordSet* pRecordSet); RowFilter(RecordSet* pRecordSet);
/// Creates the top-level RowFilter and associates it with the recordset. /// Creates the top-level RowFilter and associates it with the recordset.

View File

@ -68,10 +68,10 @@ class Data_API RowFormatter
/// ///
{ {
public: public:
typedef SharedPtr<RowFormatter> Ptr; using Ptr = SharedPtr<RowFormatter>;
typedef std::vector<std::string> NameVec; using NameVec = std::vector<std::string>;
typedef SharedPtr<std::vector<std::string> > NameVecPtr; using NameVecPtr = SharedPtr<std::vector<std::string>>;
typedef std::vector<Poco::Dynamic::Var> ValueVec; using ValueVec = std::vector<Poco::Dynamic::Var>;
static const int INVALID_ROW_COUNT = -1; static const int INVALID_ROW_COUNT = -1;

View File

@ -36,11 +36,11 @@ class Data_API RowIterator
/// RowIterator class. /// RowIterator class.
{ {
public: public:
typedef std::bidirectional_iterator_tag iterator_category; using iterator_category = std::bidirectional_iterator_tag;
typedef Row value_type; using value_type = Row;
typedef std::ptrdiff_t difference_type; using difference_type = std::ptrdiff_t;
typedef Row* pointer; using pointer = Row*;
typedef Row& reference; using reference = Row&;
static const std::size_t POSITION_END; static const std::size_t POSITION_END;
/// End position indicator. /// End position indicator.
@ -53,12 +53,18 @@ public:
RowIterator(const RowIterator& other); RowIterator(const RowIterator& other);
/// Creates a copy of other RowIterator. /// Creates a copy of other RowIterator.
RowIterator(RowIterator&& other) noexcept;
/// Move constructor.
~RowIterator(); ~RowIterator();
/// Destroys the RowIterator. /// Destroys the RowIterator.
RowIterator& operator = (const RowIterator& other); RowIterator& operator = (const RowIterator& other);
/// Assigns the other RowIterator. /// Assigns the other RowIterator.
RowIterator& operator = (RowIterator&& other) noexcept;
/// Move assignment.
bool operator == (const RowIterator& other) const; bool operator == (const RowIterator& other) const;
/// Equality operator. /// Equality operator.

View File

@ -61,6 +61,8 @@ class Data_API SQLChannel: public Poco::Channel
/// a risk of long blocking periods in case of remote server communication delays. /// a risk of long blocking periods in case of remote server communication delays.
{ {
public: public:
using Ptr = Poco::AutoPtr<SQLChannel>;
SQLChannel(); SQLChannel();
/// Creates SQLChannel. /// Creates SQLChannel.
@ -140,10 +142,10 @@ protected:
~SQLChannel(); ~SQLChannel();
private: private:
typedef Poco::SharedPtr<Session> SessionPtr; using SessionPtr = Poco::SharedPtr<Session>;
typedef Poco::SharedPtr<Statement> StatementPtr; using StatementPtr = Poco::SharedPtr<Statement>;
typedef Poco::Message::Priority Priority; using Priority = Poco::Message::Priority;
typedef Poco::SharedPtr<ArchiveStrategy> StrategyPtr; using StrategyPtr = Poco::SharedPtr<ArchiveStrategy>;
void initLogStatement(); void initLogStatement();
/// Initiallizes the log statement. /// Initiallizes the log statement.

View File

@ -176,9 +176,15 @@ public:
Session(const Session&); Session(const Session&);
/// Creates a session by copying another one. /// Creates a session by copying another one.
Session(Session&&) noexcept;
/// Creates a session by moving another one.
Session& operator = (const Session&); Session& operator = (const Session&);
/// Assignment operator. /// Assignment operator.
Session& operator = (Session&&) noexcept;
/// Move assignment.
~Session(); ~Session();
/// Destroys the Session. /// Destroys the Session.

View File

@ -39,7 +39,7 @@ class Data_API SessionImpl: public Poco::RefCountedObject
/// SessionImpl objects are noncopyable. /// SessionImpl objects are noncopyable.
{ {
public: public:
typedef Poco::AutoPtr<SessionImpl> Ptr; using Ptr = Poco::AutoPtr<SessionImpl>;
static const std::size_t LOGIN_TIMEOUT_INFINITE = 0; static const std::size_t LOGIN_TIMEOUT_INFINITE = 0;
/// Infinite connection/login timeout. /// Infinite connection/login timeout.

View File

@ -30,9 +30,9 @@ class Data_API SimpleRowFormatter: public RowFormatter
/// A simple row formatting class. /// A simple row formatting class.
{ {
public: public:
//typedef RowFormatter::NameVec NameVec; //using NameVec = RowFormatter::NameVec;
//typedef RowFormatter::NameVecPtr NameVecPtr; //using NameVecPtr = RowFormatter::NameVecPtr;
//typedef RowFormatter::ValueVec ValueVec; //using ValueVec = RowFormatter::ValueVec;
static const int DEFAULT_COLUMN_WIDTH = 16; static const int DEFAULT_COLUMN_WIDTH = 16;
static const int DEFAULT_SPACING = 1; static const int DEFAULT_SPACING = 1;

View File

@ -74,10 +74,10 @@ class Data_API Statement
public: public:
typedef void (*Manipulator)(Statement&); typedef void (*Manipulator)(Statement&);
typedef ActiveResult<std::size_t> Result; using Result = ActiveResult<std::size_t>;
typedef SharedPtr<Result> ResultPtr; using ResultPtr = SharedPtr<Result>;
typedef ActiveMethod<std::size_t, bool, StatementImpl> AsyncExecMethod; using AsyncExecMethod = ActiveMethod<std::size_t, bool, StatementImpl>;
typedef SharedPtr<AsyncExecMethod> AsyncExecMethodPtr; using AsyncExecMethodPtr = SharedPtr<AsyncExecMethod>;
static const int WAIT_FOREVER = -1; static const int WAIT_FOREVER = -1;
@ -115,9 +115,15 @@ public:
/// synchronized prior to copy operation (i.e. is copied while executing), /// synchronized prior to copy operation (i.e. is copied while executing),
/// this constructor shall synchronize it. /// this constructor shall synchronize it.
Statement(Statement&& other) noexcept;
/// Move constructor.
Statement& operator = (const Statement& stmt); Statement& operator = (const Statement& stmt);
/// Assignment operator. /// Assignment operator.
Statement& operator = (Statement&& stmt) noexcept;
/// Move assignment.
void swap(Statement& other); void swap(Statement& other);
/// Swaps the statement with another one. /// Swaps the statement with another one.
@ -379,7 +385,7 @@ public:
/// Statement takes the ownership of the formatter. /// Statement takes the ownership of the formatter.
protected: protected:
typedef StatementImpl::Ptr ImplPtr; using ImplPtr = StatementImpl::Ptr;
const AbstractExtractionVec& extractions() const; const AbstractExtractionVec& extractions() const;
/// Returns the extractions vector. /// Returns the extractions vector.
@ -406,7 +412,6 @@ protected:
/// Returns the underlying session. /// Returns the underlying session.
private: private:
const Result& doAsyncExec(bool reset = true); const Result& doAsyncExec(bool reset = true);
/// Asynchronously executes the statement. /// Asynchronously executes the statement.

View File

@ -41,12 +41,18 @@ public:
StatementCreator(const StatementCreator& other); StatementCreator(const StatementCreator& other);
/// Creates a StatementCreator by copying another one. /// Creates a StatementCreator by copying another one.
StatementCreator(StatementCreator&& other) noexcept;
/// Creates a StatementCreator by moving another one.
~StatementCreator(); ~StatementCreator();
/// Destroys the StatementCreator. /// Destroys the StatementCreator.
StatementCreator& operator = (const StatementCreator& other); StatementCreator& operator = (const StatementCreator& other);
/// Assignment operator. /// Assignment operator.
StatementCreator& operator = (StatementCreator&& other) noexcept;
/// Assignment operator.
void swap(StatementCreator& other); void swap(StatementCreator& other);
/// Swaps the StatementCreator with another one. /// Swaps the StatementCreator with another one.

View File

@ -48,7 +48,7 @@ class Data_API StatementImpl
/// StatementImpl's are noncopyable. /// StatementImpl's are noncopyable.
{ {
public: public:
typedef Poco::SharedPtr<StatementImpl> Ptr; using Ptr = Poco::SharedPtr<StatementImpl>;
enum State enum State
{ {
@ -243,11 +243,11 @@ protected:
/// session is queried for container type setting. If the /// session is queried for container type setting. If the
/// session container type setting is found, it is used. /// session container type setting is found, it is used.
/// 3. If neither session nor statement have the internal /// 3. If neither session nor statement have the internal
/// container type set, std::deque is used. /// container type set, std::vector is used.
/// ///
/// Supported internal extraction container types are: /// Supported internal extraction container types are:
/// - std::deque (default) /// - std::vector (default)
/// - std::vector /// - std::deque
/// - std::list /// - std::list
SessionImpl& session(); SessionImpl& session();
@ -346,7 +346,7 @@ private:
/// overrides the session setting for storage, otherwise the /// overrides the session setting for storage, otherwise the
/// session setting is used. /// session setting is used.
/// If neither this statement nor the session have the storage /// If neither this statement nor the session have the storage
/// type set, std::deque is the default container type used. /// type set, std::vector is the default container type used.
{ {
std::string storage; std::string storage;
@ -430,7 +430,7 @@ private:
StatementImpl(const StatementImpl& stmt); StatementImpl(const StatementImpl& stmt);
StatementImpl& operator = (const StatementImpl& stmt); StatementImpl& operator = (const StatementImpl& stmt);
typedef std::vector<std::size_t> CountVec; using CountVec = std::vector<std::size_t>;
State _state; State _state;
Limit _extrLimit; Limit _extrLimit;

View File

@ -366,8 +366,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -496,8 +496,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -621,8 +621,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -741,8 +741,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -856,8 +856,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -966,8 +966,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1071,8 +1071,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1171,8 +1171,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1266,8 +1266,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1356,8 +1356,8 @@ template <class T0,
class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>> class TypeHandler<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1432,8 +1432,8 @@ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>> class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1504,8 +1504,8 @@ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, NullTypeList>> class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, NullTypeList>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, NullTypeList> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, NullTypeList>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, NullTypeList> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, NullTypeList>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1572,8 +1572,8 @@ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6,
class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, NullTypeList>> class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, NullTypeList>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, NullTypeList> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, NullTypeList>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, NullTypeList> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, T7, NullTypeList>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1636,8 +1636,8 @@ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6>
class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, NullTypeList>> class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, NullTypeList>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, NullTypeList> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, NullTypeList>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, NullTypeList> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, T6, NullTypeList>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1696,8 +1696,8 @@ template <class T0, class T1, class T2, class T3, class T4, class T5>
class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, NullTypeList>> class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, T5, NullTypeList>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, NullTypeList> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, NullTypeList>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, NullTypeList> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, T5, NullTypeList>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1752,8 +1752,8 @@ template <class T0, class T1, class T2, class T3, class T4>
class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, NullTypeList>> class TypeHandler<Poco::Tuple<T0, T1, T2, T3, T4, NullTypeList>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, NullTypeList> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, NullTypeList>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, NullTypeList> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, T4, NullTypeList>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1804,8 +1804,8 @@ template <class T0, class T1, class T2, class T3>
class TypeHandler<Poco::Tuple<T0, T1, T2, T3, NullTypeList>> class TypeHandler<Poco::Tuple<T0, T1, T2, T3, NullTypeList>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, NullTypeList> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, NullTypeList>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, NullTypeList> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, T3, NullTypeList>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1852,8 +1852,8 @@ template <class T0, class T1, class T2>
class TypeHandler<Poco::Tuple<T0, T1, T2, NullTypeList>> class TypeHandler<Poco::Tuple<T0, T1, T2, NullTypeList>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, NullTypeList> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, NullTypeList>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, NullTypeList> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, T2, NullTypeList>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1896,8 +1896,8 @@ template <class T0, class T1>
class TypeHandler<Poco::Tuple<T0, T1, NullTypeList>> class TypeHandler<Poco::Tuple<T0, T1, NullTypeList>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, NullTypeList> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, NullTypeList>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, T1, NullTypeList> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, T1, NullTypeList>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {
@ -1936,8 +1936,8 @@ template <class T0>
class TypeHandler<Poco::Tuple<T0, NullTypeList>> class TypeHandler<Poco::Tuple<T0, NullTypeList>>
{ {
public: public:
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, NullTypeList> >::CONSTREFTYPE TupleConstRef; using TupleConstRef = typename Poco::TypeWrapper<Poco::Tuple<T0, NullTypeList>>::CONSTREFTYPE;
typedef typename Poco::TypeWrapper<Poco::Tuple<T0, NullTypeList> >::REFTYPE TupleRef; using TupleRef = typename Poco::TypeWrapper<Poco::Tuple<T0, NullTypeList>>::REFTYPE;
static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir)
{ {

View File

@ -45,9 +45,61 @@ MetaColumn::MetaColumn(std::size_t position,
} }
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()
{ {
} }
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 } } // namespace Poco::Data

View File

@ -69,6 +69,17 @@ RecordSet::RecordSet(const RecordSet& other):
} }
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() RecordSet::~RecordSet()
{ {
try try
@ -87,6 +98,19 @@ RecordSet::~RecordSet()
} }
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) void RecordSet::reset(const Statement& stmt)
{ {
delete _pBegin; delete _pBegin;

View File

@ -40,6 +40,12 @@ RowIterator::RowIterator(const RowIterator& other):
} }
RowIterator::RowIterator(RowIterator&& other) noexcept:
_pRecordSet(std::move(other._pRecordSet)),
_position(std::move(other._position))
{
}
RowIterator::~RowIterator() RowIterator::~RowIterator()
{ {
} }
@ -53,6 +59,14 @@ RowIterator& RowIterator::operator = (const RowIterator& other)
} }
RowIterator& RowIterator::operator = (RowIterator&& other) noexcept
{
_pRecordSet = std::move(other._pRecordSet);
_position = std::move(other._position);
return *this;
}
void RowIterator::swap(RowIterator& other) void RowIterator::swap(RowIterator& other)
{ {
using std::swap; using std::swap;

View File

@ -48,12 +48,19 @@ Session::Session(const std::string& connection,
} }
Session::Session(const Session& other): _pImpl(other._pImpl), Session::Session(const Session& other):
_pImpl(other._pImpl),
_statementCreator(other._pImpl) _statementCreator(other._pImpl)
{ {
} }
Session::Session(Session&& other) noexcept:
_pImpl(std::move(other._pImpl)),
_statementCreator(std::move(other._pImpl))
{
}
Session::~Session() Session::~Session()
{ {
} }
@ -67,6 +74,14 @@ Session& Session::operator = (const Session& other)
} }
Session& Session::operator = (Session&& other) noexcept
{
_pImpl = std::move(other._pImpl);
_statementCreator = std::move(other._statementCreator);
return *this;
}
void Session::swap(Session& other) void Session::swap(Session& other)
{ {
using std::swap; using std::swap;

View File

@ -53,6 +53,17 @@ Statement::Statement(const Statement& stmt):
} }
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()
{ {
} }
@ -66,6 +77,18 @@ Statement& Statement::operator = (const Statement& stmt)
} }
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) void Statement::swap(Statement& other)
{ {
using std::swap; using std::swap;

View File

@ -37,6 +37,12 @@ StatementCreator::StatementCreator(const StatementCreator& other):
} }
StatementCreator::StatementCreator(StatementCreator&& other) noexcept:
_ptrImpl(std::move(other._ptrImpl))
{
}
StatementCreator& StatementCreator::operator = (const StatementCreator& other) StatementCreator& StatementCreator::operator = (const StatementCreator& other)
{ {
StatementCreator tmp(other); StatementCreator tmp(other);
@ -45,6 +51,12 @@ StatementCreator& StatementCreator::operator = (const StatementCreator& other)
} }
StatementCreator& StatementCreator::operator = (StatementCreator&& other) noexcept
{
_ptrImpl = std::move(other._ptrImpl);
return *this;
}
void StatementCreator::swap(StatementCreator& other) void StatementCreator::swap(StatementCreator& other)
{ {
using std::swap; using std::swap;

View File

@ -642,8 +642,8 @@ void DataTest::testColumnVectorBool()
void DataTest::testColumnDeque() void DataTest::testColumnDeque()
{ {
typedef std::deque<int> ContainerType; using ContainerType = std::deque<int>;
typedef Column<ContainerType> ColumnType; using ColumnType = Column<ContainerType>;
MetaColumn mc(0, "mc", MetaColumn::FDT_DOUBLE, 2, 3, true); MetaColumn mc(0, "mc", MetaColumn::FDT_DOUBLE, 2, 3, true);
@ -759,8 +759,8 @@ void DataTest::testColumnDeque()
void DataTest::testColumnList() void DataTest::testColumnList()
{ {
typedef std::list<int> ContainerType; using ContainerType = std::list<int>;
typedef Column<ContainerType> ColumnType; using ColumnType = Column<ContainerType>;
MetaColumn mc(0, "mc", MetaColumn::FDT_DOUBLE, 2, 3, true); MetaColumn mc(0, "mc", MetaColumn::FDT_DOUBLE, 2, 3, true);

View File

@ -48,7 +48,7 @@ bool TestStatementImpl::canBind() const
void TestStatementImpl::bindImpl() void TestStatementImpl::bindImpl()
{ {
// bind // bind
typedef Poco::Data::AbstractBindingVec Bindings; using Bindings = Poco::Data::AbstractBindingVec;
Bindings& binds = bindings(); Bindings& binds = bindings();
if (binds.empty()) if (binds.empty())
return; return;

View File

@ -244,14 +244,16 @@ public:
strategy.notify(pSender, args); strategy.notify(pSender, args);
} }
bool hasDelegates() const { bool hasDelegates() const
/// Returns true if there are registered delegates.
{
return !empty(); return !empty();
} }
ActiveResult<TArgs> notifyAsync(const void* pSender, const TArgs& args) ActiveResult<TArgs> notifyAsync(const void* pSender, const TArgs& args)
/// Sends a notification to all registered delegates. The order is /// Sends a notification to all registered delegates. The order is
/// determined by the TStrategy. This method is not blocking and will /// determined by the TStrategy. This method is not blocking and will
/// immediately return. The delegates are invoked in a seperate thread. /// immediately return. The delegates are invoked in a separate thread.
/// Call activeResult.wait() to wait until the notification has ended. /// Call activeResult.wait() to wait until the notification has ended.
/// While executing, other objects can change the delegate list. These changes don't /// While executing, other objects can change the delegate list. These changes don't
/// influence the current active notifications but are activated with /// influence the current active notifications but are activated with
@ -293,6 +295,7 @@ public:
} }
bool isEnabled() const bool isEnabled() const
/// Returns true if event is enabled.
{ {
typename TMutex::ScopedLock lock(_mutex); typename TMutex::ScopedLock lock(_mutex);
return _enabled; return _enabled;
@ -342,7 +345,7 @@ protected:
} }
TStrategy _strategy; /// The strategy used to notify observers. TStrategy _strategy; /// The strategy used to notify observers.
bool _enabled; /// Stores if an event is enabled. Notfies on disabled events have no effect bool _enabled; /// Stores if an event is enabled. Notifies on disabled events have no effect
/// but it is possible to change the observers. /// but it is possible to change the observers.
mutable TMutex _mutex; mutable TMutex _mutex;
@ -453,7 +456,7 @@ public:
ActiveResult<void> notifyAsync(const void* pSender) ActiveResult<void> notifyAsync(const void* pSender)
/// Sends a notification to all registered delegates. The order is /// Sends a notification to all registered delegates. The order is
/// determined by the TStrategy. This method is not blocking and will /// determined by the TStrategy. This method is not blocking and will
/// immediately return. The delegates are invoked in a seperate thread. /// immediately return. The delegates are invoked in a separate thread.
/// Call activeResult.wait() to wait until the notification has ended. /// Call activeResult.wait() to wait until the notification has ended.
/// While executing, other objects can change the delegate list. These changes don't /// While executing, other objects can change the delegate list. These changes don't
/// influence the current active notifications but are activated with /// influence the current active notifications but are activated with
@ -542,7 +545,7 @@ protected:
} }
TStrategy _strategy; /// The strategy used to notify observers. TStrategy _strategy; /// The strategy used to notify observers.
bool _enabled; /// Stores if an event is enabled. Notfies on disabled events have no effect bool _enabled; /// Stores if an event is enabled. Notifies on disabled events have no effect
/// but it is possible to change the observers. /// but it is possible to change the observers.
mutable TMutex _mutex; mutable TMutex _mutex;

View File

@ -67,7 +67,7 @@ public:
virtual void onReplace(const void* pSender, std::set<TKey>& elemsToRemove) = 0; virtual void onReplace(const void* pSender, std::set<TKey>& elemsToRemove) = 0;
/// Used by the Strategy to indicate which elements should be removed from /// Used by the Strategy to indicate which elements should be removed from
/// the cache. Note that onReplace does not change the current list of keys. /// the cache. Note that onReplace does not change the current list of keys.
/// The cache object is reponsible to remove the elements. /// The cache object is responsible to remove the elements.
}; };

View File

@ -39,7 +39,7 @@ class AccessExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollectio
/// but also limits the size of the cache (per default: 1024). /// but also limits the size of the cache (per default: 1024).
{ {
public: public:
AccessExpireLRUCache(long cacheSize = 1024, Timestamp::TimeDiff expire = 600000): AccessExpireLRUCache(std::size_t cacheSize = 1024, Timestamp::TimeDiff expire = 600000):
AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex >(StrategyCollection<TKey, TValue>()) AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex >(StrategyCollection<TKey, TValue>())
{ {
this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize)); this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize));

View File

@ -41,7 +41,7 @@ public:
ActiveResultHolder(): ActiveResultHolder():
_pData(0), _pData(0),
_pExc(0), _pExc(0),
_event(false) _event(Event::EVENT_MANUALRESET)
/// Creates an ActiveResultHolder. /// Creates an ActiveResultHolder.
{ {
} }
@ -147,7 +147,7 @@ class ActiveResultHolder<void>: public RefCountedObject
public: public:
ActiveResultHolder(): ActiveResultHolder():
_pExc(0), _pExc(0),
_event(false) _event(Event::EVENT_MANUALRESET)
/// Creates an ActiveResultHolder. /// Creates an ActiveResultHolder.
{ {
} }

View File

@ -33,7 +33,7 @@ class ActiveRunnableBase: public Runnable, public RefCountedObject
/// The base class for all ActiveRunnable instantiations. /// The base class for all ActiveRunnable instantiations.
{ {
public: public:
typedef AutoPtr<ActiveRunnableBase> Ptr; using Ptr = AutoPtr<ActiveRunnableBase>;
}; };

View File

@ -82,7 +82,7 @@ public:
_runnable(*pOwner, method), _runnable(*pOwner, method),
_stopped(true), _stopped(true),
_running(false), _running(false),
_done(false) _done(Event::EVENT_MANUALRESET)
/// Creates the activity. Call start() to /// Creates the activity. Call start() to
/// start it. /// start it.
{ {
@ -134,8 +134,6 @@ public:
void stop() void stop()
/// Requests to stop the activity. /// Requests to stop the activity.
{ {
FastMutex::ScopedLock lock(_mutex);
_stopped = true; _stopped = true;
} }
@ -195,8 +193,8 @@ private:
C* _pOwner; C* _pOwner;
RunnableAdapterType _runnable; RunnableAdapterType _runnable;
volatile bool _stopped; std::atomic<bool> _stopped;
volatile bool _running; std::atomic<bool> _running;
Event _done; Event _done;
FastMutex _mutex; FastMutex _mutex;
}; };

View File

@ -14,233 +14,12 @@
// //
// Adapted for POCO from LLVM Compiler Infrastructure code: #ifndef Foundation_Alignment_INCLUDED
// #define Foundation_Alignment_INCLUDED
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source License
//
//===----------------------------------------------------------------------===//
//
// This file defines the AlignOf function that computes alignments for
// arbitrary types.
//
//===----------------------------------------------------------------------===//
#ifndef Foundation_AlignOf_INCLUDED
#define Foundation_AlignOf_INCLUDED
#include <cstddef>
#ifdef POCO_ENABLE_CPP11
#include <type_traits> #include <type_traits>
#define POCO_HAVE_ALIGNMENT #define POCO_HAVE_ALIGNMENT
#else #endif // Foundation_Alignment_INCLUDED
namespace Poco {
template <typename T>
struct AlignmentCalcImpl
{
char x;
T t;
private:
AlignmentCalcImpl() {} // Never instantiate.
};
template <typename T>
struct AlignOf
/// A templated class that contains an enum value representing
/// the alignment of the template argument. For example,
/// AlignOf<int>::Alignment represents the alignment of type "int". The
/// alignment calculated is the minimum alignment, and not necessarily
/// the "desired" alignment returned by GCC's __alignof__ (for example). Note
/// that because the alignment is an enum value, it can be used as a
/// compile-time constant (e.g., for template instantiation).
{
enum
{
Alignment = static_cast<unsigned int>(sizeof(AlignmentCalcImpl<T>) - sizeof(T))
};
enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 };
enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 };
enum { Alignment_GreaterEqual_8Bytes = Alignment >= 8 ? 1 : 0 };
enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 1 : 0 };
enum { Alignment_LessEqual_2Bytes = Alignment <= 2 ? 1 : 0 };
enum { Alignment_LessEqual_4Bytes = Alignment <= 4 ? 1 : 0 };
enum { Alignment_LessEqual_8Bytes = Alignment <= 8 ? 1 : 0 };
enum { Alignment_LessEqual_16Bytes = Alignment <= 16 ? 1 : 0 };
};
template <typename T>
inline unsigned alignOf()
/// A templated function that returns the minimum alignment of
/// of a type. This provides no extra functionality beyond the AlignOf
/// class besides some cosmetic cleanliness. Example usage:
/// alignOf<int>() returns the alignment of an int.
{
return AlignOf<T>::Alignment;
}
template <std::size_t Alignment> struct AlignedCharArrayImpl;
/// Helper for building an aligned character array type.
///
/// This template is used to explicitly build up a collection of aligned
/// character types. We have to build these up using a macro and explicit
/// specialization to cope with old versions of MSVC and GCC where only an
/// integer literal can be used to specify an alignment constraint. Once built
/// up here, we can then begin to indirect between these using normal C++
/// template parameters.
// MSVC requires special handling here.
#ifndef _MSC_VER
#ifdef POCO_COMPILER_CLANG
#if __has_feature(cxx_alignas)
#define POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \
template <> struct AlignedCharArrayImpl<x> \
{ \
char aligned alignas(x); \
}
#define POCO_HAVE_ALIGNMENT
#endif
#elif defined(__GNUC__) || defined(__IBM_ATTRIBUTES)
#define POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \
template <> struct AlignedCharArrayImpl<x> \
{ \
char aligned __attribute__((aligned(x))); \
}
#define POCO_HAVE_ALIGNMENT
#endif
#ifdef POCO_HAVE_ALIGNMENT
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(512);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1024);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2048);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4096);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8192);
#undef POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT
#endif // POCO_HAVE_ALIGNMENT
#else // _MSC_VER
// We provide special variations of this template for the most common
// alignments because __declspec(align(...)) doesn't actually work when it is
// a member of a by-value function argument in MSVC, even if the alignment
// request is something reasonably like 8-byte or 16-byte.
template <> struct AlignedCharArrayImpl<1> { char aligned; };
template <> struct AlignedCharArrayImpl<2> { short aligned; };
template <> struct AlignedCharArrayImpl<4> { int aligned; };
template <> struct AlignedCharArrayImpl<8> { double aligned; };
#define POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \
template <> struct AlignedCharArrayImpl<x> { \
__declspec(align(x)) char aligned; \
}
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128);
#if (_MSC_VER > 1600) // MSVC 2010 complains on alignment larger than 128
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(512);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1024);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2048);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4096);
POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8192);
#endif // _MSC_VER > 1600
// Any larger and MSVC complains.
#undef POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT
#define POCO_HAVE_ALIGNMENT
#endif // _MSC_VER
// POCO_HAVE_ALIGNMENT will be defined on the pre-C++11 platforms/compilers where
// it can be reliably determined and used. Uncomment the line below to explicitly
// disable use of alignment even for those platforms.
// #undef POCO_HAVE_ALIGNMENT
#ifdef POCO_HAVE_ALIGNMENT
template <typename T1, typename T2 = char, typename T3 = char, typename T4 = char>
union AlignedCharArrayUnion
/// This union template exposes a suitably aligned and sized character
/// array member which can hold elements of any of up to four types.
///
/// These types may be arrays, structs, or any other types. The goal is to
/// produce a union type containing a character array which, when used, forms
/// storage suitable to placement new any of these types over. Support for more
/// than four types can be added at the cost of more boiler plate.
{
private:
class AlignerImpl
{
T1 t1;
T2 t2;
T3 t3;
T4 t4;
AlignerImpl(); // Never defined or instantiated.
};
union SizerImpl
{
char arr1[sizeof(T1)];
char arr2[sizeof(T2)];
char arr3[sizeof(T3)];
char arr4[sizeof(T4)];
};
public:
char buffer[sizeof(SizerImpl)];
/// The character array buffer for use by clients.
///
/// No other member of this union should be referenced. They exist purely to
/// constrain the layout of this character array.
private:
Poco::AlignedCharArrayImpl<AlignOf<AlignerImpl>::Alignment> _nonceMember;
};
#endif // POCO_HAVE_ALIGNMENT
} // namespace Poco
#endif // POCO_ENABLE_CPP11
#endif // Foundation_AlignOf_INCLUDED

View File

@ -33,16 +33,13 @@ namespace Dynamic {
class Var; class Var;
class VarHolder; class VarHolder;
template <class> class VarHolderImpl; template <class T> class VarHolderImpl;
} }
#ifndef POCO_NO_SOO #ifndef POCO_NO_SOO
#ifndef POCO_ENABLE_CPP11
// C++11 needed for std::aligned_storage
#error "Any SOO can only be enabled with C++11 support"
#endif
template <typename PlaceholderT, unsigned int SizeV = POCO_SMALL_OBJECT_SIZE> template <typename PlaceholderT, unsigned int SizeV = POCO_SMALL_OBJECT_SIZE>
union Placeholder union Placeholder
@ -121,7 +118,6 @@ union Placeholder
/// where the object was allocated (0 => heap, 1 => local). /// where the object was allocated (0 => heap, 1 => local).
{ {
public: public:
Placeholder () Placeholder ()
{ {
} }
@ -201,7 +197,7 @@ public:
Any& swap(Any& other) Any& swap(Any& other)
/// Swaps the content of the two Anys. /// Swaps the content of the two Anys.
/// ///
/// When small object optimizaton is enabled, swap only /// When small object optimization is enabled, swap only
/// has no-throw guarantee when both (*this and other) /// has no-throw guarantee when both (*this and other)
/// objects are allocated on the heap. /// objects are allocated on the heap.
{ {
@ -270,14 +266,10 @@ public:
} }
private: private:
class ValueHolder class ValueHolder
{ {
public: public:
virtual ~ValueHolder() = default;
virtual ~ValueHolder()
{
}
virtual const std::type_info & type() const = 0; virtual const std::type_info & type() const = 0;
virtual void clone(Placeholder<ValueHolder>*) const = 0; virtual void clone(Placeholder<ValueHolder>*) const = 0;
@ -427,9 +419,7 @@ private:
class ValueHolder class ValueHolder
{ {
public: public:
virtual ~ValueHolder() virtual ~ValueHolder() = default;
{
}
virtual const std::type_info& type() const = 0; virtual const std::type_info& type() const = 0;
virtual ValueHolder* clone() const = 0; virtual ValueHolder* clone() const = 0;
@ -476,6 +466,14 @@ private:
template <typename ValueType> template <typename ValueType>
friend ValueType* UnsafeAnyCast(Any*); friend ValueType* UnsafeAnyCast(Any*);
template <typename ValueType>
friend const ValueType& RefAnyCast(const Any&);
template <typename ValueType>
friend ValueType& RefAnyCast(Any&);
template <typename ValueType>
friend ValueType AnyCast(Any&);
}; };
@ -514,14 +512,26 @@ ValueType AnyCast(Any& operand)
/// Example Usage: /// Example Usage:
/// MyType tmp = AnyCast<MyType>(anAny). /// MyType tmp = AnyCast<MyType>(anAny).
/// Will throw a BadCastException if the cast fails. /// Will throw a BadCastException if the cast fails.
/// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& tmp = ... /// Do not use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& tmp = ...
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in /// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
/// these cases. /// these cases.
{ {
typedef typename TypeWrapper<ValueType>::TYPE NonRef; typedef typename TypeWrapper<ValueType>::TYPE NonRef;
NonRef* result = AnyCast<NonRef>(&operand); NonRef* result = AnyCast<NonRef>(&operand);
if (!result) throw BadCastException("Failed to convert between Any types"); if (!result)
{
std::string s = "RefAnyCast: Failed to convert between Any types ";
if (operand._pHolder)
{
s.append(1, '(');
s.append(operand._pHolder->type().name());
s.append(" => ");
s.append(typeid(ValueType).name());
s.append(1, ')');
}
throw BadCastException(s);
}
return *result; return *result;
} }
@ -533,7 +543,7 @@ ValueType AnyCast(const Any& operand)
/// Example Usage: /// Example Usage:
/// MyType tmp = AnyCast<MyType>(anAny). /// MyType tmp = AnyCast<MyType>(anAny).
/// Will throw a BadCastException if the cast fails. /// Will throw a BadCastException if the cast fails.
/// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& = ... /// Do not use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& = ...
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in /// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
/// these cases. /// these cases.
{ {
@ -551,7 +561,15 @@ const ValueType& RefAnyCast(const Any & operand)
/// const MyType& tmp = RefAnyCast<MyType>(anAny); /// const MyType& tmp = RefAnyCast<MyType>(anAny);
{ {
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand)); ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
if (!result) throw BadCastException("RefAnyCast: Failed to convert between const Any types"); std::string s = "RefAnyCast: Failed to convert between Any types ";
if (operand._pHolder)
{
s.append(1, '(');
s.append(operand._pHolder->type().name());
s.append(" => ");
s.append(typeid(ValueType).name());
s.append(1, ')');
}
return *result; return *result;
} }
@ -564,7 +582,19 @@ ValueType& RefAnyCast(Any& operand)
/// MyType& tmp = RefAnyCast<MyType>(anAny); /// MyType& tmp = RefAnyCast<MyType>(anAny);
{ {
ValueType* result = AnyCast<ValueType>(&operand); ValueType* result = AnyCast<ValueType>(&operand);
if (!result) throw BadCastException("RefAnyCast: Failed to convert between Any types"); if (!result)
{
std::string s = "RefAnyCast: Failed to convert between Any types ";
if (operand._pHolder)
{
s.append(1, '(');
s.append(operand._pHolder->type().name());
s.append(" => ");
s.append(typeid(ValueType).name());
s.append(1, ')');
}
throw BadCastException(s);
}
return *result; return *result;
} }

View File

@ -24,12 +24,15 @@
#ifndef Foundation_Array_INCLUDED #ifndef Foundation_Array_INCLUDED
#define Foundation_Array_INCLUDED #define Foundation_Array_INCLUDED
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/Bugcheck.h" #include "Poco/Bugcheck.h"
#include <algorithm> #include <algorithm>
namespace Poco { namespace Poco {
template<class T, std::size_t N> template<class T, std::size_t N>
class Array class Array
/// STL container like C-style array replacement class. /// STL container like C-style array replacement class.
@ -37,9 +40,7 @@ class Array
/// This implementation is based on the idea of Nicolai Josuttis. /// This implementation is based on the idea of Nicolai Josuttis.
/// His original implementation can be found at http://www.josuttis.com/cppcode/array.html . /// His original implementation can be found at http://www.josuttis.com/cppcode/array.html .
{ {
public: public:
typedef T value_type; typedef T value_type;
typedef T* iterator; typedef T* iterator;
typedef const T* const_iterator; typedef const T* const_iterator;
@ -158,7 +159,8 @@ public:
enum { static_size = N }; enum { static_size = N };
void swap (Array<T,N>& y) { void swap (Array<T,N>& y)
{
std::swap_ranges(begin(),end(),y.begin()); std::swap_ranges(begin(),end(),y.begin());
} }
@ -173,7 +175,8 @@ public:
return elems; return elems;
} }
T* c_array(){ T* c_array()
{
/// Use array as C array (direct read/write access to data) /// Use array as C array (direct read/write access to data)
return elems; return elems;
} }
@ -193,12 +196,12 @@ public:
} }
public: public:
T elems[N]; T elems[N];
/// Fixed-size array of elements of type T, public specifier used to make this class a aggregate. /// Fixed-size array of elements of type T, public specifier used to make this class a aggregate.
}; };
// comparisons // comparisons
template<class T, std::size_t N> template<class T, std::size_t N>
bool operator== (const Array<T,N>& x, const Array<T,N>& y) bool operator== (const Array<T,N>& x, const Array<T,N>& y)
@ -206,36 +209,42 @@ bool operator== (const Array<T,N>& x, const Array<T,N>& y)
return std::equal(x.begin(), x.end(), y.begin()); return std::equal(x.begin(), x.end(), y.begin());
} }
template<class T, std::size_t N> template<class T, std::size_t N>
bool operator< (const Array<T,N>& x, const Array<T,N>& y) bool operator< (const Array<T,N>& x, const Array<T,N>& y)
{ {
return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
} }
template<class T, std::size_t N> template<class T, std::size_t N>
bool operator!= (const Array<T,N>& x, const Array<T,N>& y) bool operator!= (const Array<T,N>& x, const Array<T,N>& y)
{ {
return !(x==y); return !(x==y);
} }
template<class T, std::size_t N> template<class T, std::size_t N>
bool operator> (const Array<T,N>& x, const Array<T,N>& y) bool operator> (const Array<T,N>& x, const Array<T,N>& y)
{ {
return y<x; return y<x;
} }
template<class T, std::size_t N> template<class T, std::size_t N>
bool operator<= (const Array<T,N>& x, const Array<T,N>& y) bool operator<= (const Array<T,N>& x, const Array<T,N>& y)
{ {
return !(y<x); return !(y<x);
} }
template<class T, std::size_t N> template<class T, std::size_t N>
bool operator>= (const Array<T,N>& x, const Array<T,N>& y) bool operator>= (const Array<T,N>& x, const Array<T,N>& y)
{ {
return !(x<y); return !(x<y);
} }
template<class T, std::size_t N> template<class T, std::size_t N>
inline void swap (Array<T,N>& x, Array<T,N>& y) inline void swap (Array<T,N>& x, Array<T,N>& y)
/// global swap() /// global swap()
@ -243,7 +252,9 @@ inline void swap (Array<T,N>& x, Array<T,N>& y)
x.swap(y); x.swap(y);
} }
}// namespace Poco }// namespace Poco
#endif // Foundation_Array_INCLUDED #endif // Foundation_Array_INCLUDED

View File

@ -103,6 +103,9 @@ public:
/// Returns true iff the given character is an uppercase alphabetic /// Returns true iff the given character is an uppercase alphabetic
/// character. /// character.
static bool isPrintable(int ch);
/// Returns true iff the given character is printable.
static int toLower(int ch); static int toLower(int ch);
/// If the given character is an uppercase character, /// If the given character is an uppercase character,
/// return its lowercase counterpart, otherwise return /// return its lowercase counterpart, otherwise return
@ -196,6 +199,12 @@ inline bool Ascii::isUpper(int ch)
} }
inline bool Ascii::isPrintable(int ch)
{
return hasProperties(ch, ACP_PRINT);
}
inline int Ascii::toLower(int ch) inline int Ascii::toLower(int ch)
{ {
if (isUpper(ch)) if (isUpper(ch))

View File

@ -23,6 +23,7 @@
#include "Poco/Thread.h" #include "Poco/Thread.h"
#include "Poco/Mutex.h" #include "Poco/Mutex.h"
#include "Poco/Runnable.h" #include "Poco/Runnable.h"
#include "Poco/AutoPtr.h"
#include "Poco/NotificationQueue.h" #include "Poco/NotificationQueue.h"
@ -40,15 +41,17 @@ class Foundation_API AsyncChannel: public Channel, public Runnable
/// then processed by a separate thread. /// then processed by a separate thread.
{ {
public: public:
AsyncChannel(Channel* pChannel = 0, Thread::Priority prio = Thread::PRIO_NORMAL); using Ptr = AutoPtr<AsyncChannel>;
AsyncChannel(Channel::Ptr pChannel = 0, Thread::Priority prio = Thread::PRIO_NORMAL);
/// Creates the AsyncChannel and connects it to /// Creates the AsyncChannel and connects it to
/// the given channel. /// the given channel.
void setChannel(Channel* pChannel); void setChannel(Channel::Ptr pChannel);
/// Connects the AsyncChannel to the given target channel. /// Connects the AsyncChannel to the given target channel.
/// All messages will be forwarded to this channel. /// All messages will be forwarded to this channel.
Channel* getChannel() const; Channel::Ptr getChannel() const;
/// Returns the target channel. /// Returns the target channel.
void open(); void open();
@ -86,7 +89,7 @@ protected:
void setPriority(const std::string& value); void setPriority(const std::string& value);
private: private:
Channel* _pChannel; Channel::Ptr _pChannel;
Thread _thread; Thread _thread;
FastMutex _threadMutex; FastMutex _threadMutex;
FastMutex _channelMutex; FastMutex _channelMutex;

View File

@ -19,33 +19,7 @@
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
#if POCO_OS == POCO_OS_WINDOWS_NT
#include "Poco/UnWindows.h"
#elif POCO_OS == POCO_OS_MAC_OS_X
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000 || __TV_OS_VERSION_MAX_ALLOWED >= 100000 || __WATCH_OS_VERSION_MAX_ALLOWED >= 30000
#if __cplusplus >= 201103L
#ifndef POCO_HAVE_STD_ATOMICS
#define POCO_HAVE_STD_ATOMICS
#endif
#else
#include <libkern/OSAtomic.h>
#endif
#else
#include <libkern/OSAtomic.h>
#endif
#elif ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2) || __GNUC__ > 4) && (defined(__x86_64__) || defined(__i386__))
#if !defined(POCO_HAVE_GCC_ATOMICS) && !defined(POCO_NO_GCC_ATOMICS)
#define POCO_HAVE_GCC_ATOMICS
#endif
#elif ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) || __GNUC__ > 4)
#if !defined(POCO_HAVE_GCC_ATOMICS) && !defined(POCO_NO_GCC_ATOMICS)
#define POCO_HAVE_GCC_ATOMICS
#endif
#endif // POCO_OS
#include "Poco/Mutex.h"
#ifdef POCO_HAVE_STD_ATOMICS
#include <atomic> #include <atomic>
#endif
namespace Poco { namespace Poco {
@ -57,19 +31,7 @@ class Foundation_API AtomicCounter
/// use in a multithreaded environment. /// use in a multithreaded environment.
/// ///
/// Typical usage of AtomicCounter is for implementing /// Typical usage of AtomicCounter is for implementing
/// reference counting and similar things. /// reference counting and similar functionality.
///
/// On some platforms, the implementation of AtomicCounter
/// is based on atomic primitives specific to the platform
/// (such as InterlockedIncrement, etc. on Windows), and
/// thus very efficient. On platforms that do not support
/// atomic primitives, operations are guarded by a FastMutex.
///
/// The following platforms currently have atomic
/// primitives:
/// - Windows
/// - Mac OS X
/// - GCC 4.1+ (Intel platforms only)
{ {
public: public:
typedef int ValueType; /// The underlying integer type. typedef int ValueType; /// The underlying integer type.
@ -94,7 +56,7 @@ public:
/// Assigns a value to the counter. /// Assigns a value to the counter.
operator ValueType () const; operator ValueType () const;
/// Returns the value of the counter. /// Converts the AtomicCounter to ValueType.
ValueType value() const; ValueType value() const;
/// Returns the value of the counter. /// Returns the value of the counter.
@ -115,23 +77,7 @@ public:
/// Returns true if the counter is zero, false otherwise. /// Returns true if the counter is zero, false otherwise.
private: private:
#if defined(POCO_HAVE_STD_ATOMICS) std::atomic<int> _counter;
typedef std::atomic<int> ImplType;
#elif POCO_OS == POCO_OS_WINDOWS_NT
typedef volatile LONG ImplType;
#elif POCO_OS == POCO_OS_MAC_OS_X
typedef int32_t ImplType;
#elif defined(POCO_HAVE_GCC_ATOMICS)
typedef int ImplType;
#else // generic implementation based on FastMutex
struct ImplType
{
mutable FastMutex mutex;
volatile int value;
};
#endif // POCO_OS
ImplType _counter;
}; };
@ -139,11 +85,6 @@ private:
// inlines // inlines
// //
#if defined(POCO_HAVE_STD_ATOMICS)
//
// C++11 atomics
//
inline AtomicCounter::operator AtomicCounter::ValueType () const inline AtomicCounter::operator AtomicCounter::ValueType () const
{ {
return _counter.load(); return _counter.load();
@ -186,231 +127,6 @@ inline bool AtomicCounter::operator ! () const
} }
#elif POCO_OS == POCO_OS_WINDOWS_NT
//
// Windows
//
inline AtomicCounter::operator AtomicCounter::ValueType () const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::value() const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix
{
return InterlockedIncrement(&_counter);
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix
{
ValueType result = InterlockedIncrement(&_counter);
return --result;
}
inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix
{
return InterlockedDecrement(&_counter);
}
inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix
{
ValueType result = InterlockedDecrement(&_counter);
return ++result;
}
inline bool AtomicCounter::operator ! () const
{
return _counter == 0;
}
#elif POCO_OS == POCO_OS_MAC_OS_X
//
// Mac OS X
//
inline AtomicCounter::operator AtomicCounter::ValueType () const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::value() const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix
{
return OSAtomicIncrement32(&_counter);
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix
{
ValueType result = OSAtomicIncrement32(&_counter);
return --result;
}
inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix
{
return OSAtomicDecrement32(&_counter);
}
inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix
{
ValueType result = OSAtomicDecrement32(&_counter);
return ++result;
}
inline bool AtomicCounter::operator ! () const
{
return _counter == 0;
}
#elif defined(POCO_HAVE_GCC_ATOMICS)
//
// GCC 4.1+ atomic builtins.
//
inline AtomicCounter::operator AtomicCounter::ValueType () const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::value() const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix
{
return __sync_add_and_fetch(&_counter, 1);
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix
{
return __sync_fetch_and_add(&_counter, 1);
}
inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix
{
return __sync_sub_and_fetch(&_counter, 1);
}
inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix
{
return __sync_fetch_and_sub(&_counter, 1);
}
inline bool AtomicCounter::operator ! () const
{
return _counter == 0;
}
#else
//
// Generic implementation based on FastMutex
//
inline AtomicCounter::operator AtomicCounter::ValueType () const
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::value() const
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = ++_counter.value;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value++;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = --_counter.value;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value--;
}
return result;
}
inline bool AtomicCounter::operator ! () const
{
bool result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value == 0;
}
return result;
}
#endif // POCO_OS
} // namespace Poco } // namespace Poco

View File

@ -14,9 +14,6 @@
// //
#ifdef POCO_HAVE_STD_ATOMICS
#ifndef Foundation_AtomicFlag_INCLUDED #ifndef Foundation_AtomicFlag_INCLUDED
#define Foundation_AtomicFlag_INCLUDED #define Foundation_AtomicFlag_INCLUDED
@ -67,10 +64,10 @@ class Foundation_API AtomicFlag
/// while (++i < 10) myClass.myFunc(); /// while (++i < 10) myClass.myFunc();
{ {
public: public:
AtomicFlag(); AtomicFlag() = default;
/// Creates AtomicFlag. /// Creates AtomicFlag.
~AtomicFlag(); ~AtomicFlag() = default;
/// Destroys AtomicFlag. /// Destroys AtomicFlag.
bool set(); bool set();
@ -98,6 +95,7 @@ private:
// inlines // inlines
// //
inline bool AtomicFlag::set() inline bool AtomicFlag::set()
{ {
return _flag.test_and_set(std::memory_order_acquire); return _flag.test_and_set(std::memory_order_acquire);
@ -121,5 +119,3 @@ inline AtomicFlag::operator bool ()
#endif // Foundation_AtomicFlag_INCLUDED #endif // Foundation_AtomicFlag_INCLUDED
#endif // POCO_HAVE_STD_ATOMICS

View File

@ -61,7 +61,7 @@ class AutoPtr
/// Note that AutoPtr allows casting of its encapsulated data types. /// Note that AutoPtr allows casting of its encapsulated data types.
{ {
public: public:
AutoPtr(): _ptr(0) AutoPtr(): _ptr(nullptr)
{ {
} }
@ -79,6 +79,11 @@ public:
if (_ptr) _ptr->duplicate(); if (_ptr) _ptr->duplicate();
} }
AutoPtr(AutoPtr&& ptr) noexcept: _ptr(std::move(ptr._ptr))
{
ptr._ptr = nullptr;
}
template <class Other> template <class Other>
AutoPtr(const AutoPtr<Other>& ptr): _ptr(const_cast<Other*>(ptr.get())) AutoPtr(const AutoPtr<Other>& ptr): _ptr(const_cast<Other*>(ptr.get()))
{ {
@ -139,7 +144,7 @@ public:
if (_ptr) if (_ptr)
{ {
_ptr->release(); _ptr->release();
_ptr = 0; _ptr = nullptr;
} }
} }
@ -174,6 +179,14 @@ public:
return assign(ptr); return assign(ptr);
} }
AutoPtr& operator = (AutoPtr&& ptr) noexcept
{
if (_ptr) _ptr->release();
_ptr = std::move(ptr._ptr);
ptr._ptr = nullptr;
return *this;
}
template <class Other> template <class Other>
AutoPtr& operator = (const AutoPtr<Other>& ptr) AutoPtr& operator = (const AutoPtr<Other>& ptr)
{ {
@ -264,12 +277,12 @@ public:
bool operator ! () const bool operator ! () const
{ {
return _ptr == 0; return _ptr == nullptr;
} }
bool isNull() const bool isNull() const
{ {
return _ptr == 0; return _ptr == nullptr;
} }
C* duplicate() C* duplicate()
@ -380,6 +393,13 @@ inline void swap(AutoPtr<C>& p1, AutoPtr<C>& p2)
} }
template<typename T, typename... Args>
AutoPtr<T> makeAuto(Args&&... args)
{
return AutoPtr<T>(new T(std::forward<Args>(args)...));
}
} // namespace Poco } // namespace Poco

View File

@ -29,7 +29,7 @@ template <class C>
class AutoReleasePool class AutoReleasePool
/// An AutoReleasePool implements simple garbage collection for /// An AutoReleasePool implements simple garbage collection for
/// reference-counted objects. /// reference-counted objects.
/// It temporarily takes ownwership of reference-counted objects that /// It temporarily takes ownership of reference-counted objects that
/// nobody else wants to take ownership of and releases them /// nobody else wants to take ownership of and releases them
/// at a later, appropriate point in time. /// at a later, appropriate point in time.
/// ///

View File

@ -82,6 +82,8 @@ class Foundation_API Base32Decoder: public Base32DecoderIOS, public std::istream
/// This istream base32-decodes all data /// This istream base32-decodes all data
/// read from the istream connected to it. /// read from the istream connected to it.
/// ///
/// The class implements RFC 4648 - https://tools.ietf.org/html/rfc4648
///
/// Note: For performance reasons, the characters /// Note: For performance reasons, the characters
/// are read directly from the given istream's /// are read directly from the given istream's
/// underlying streambuf, so the state /// underlying streambuf, so the state

View File

@ -89,6 +89,8 @@ class Foundation_API Base32Encoder: public Base32EncoderIOS, public std::ostream
/// writing data, to ensure proper /// writing data, to ensure proper
/// completion of the encoding operation. /// completion of the encoding operation.
/// ///
/// The class implements RFC 4648 - https://tools.ietf.org/html/rfc4648
///
/// Note: The characters are directly written /// Note: The characters are directly written
/// to the ostream's streambuf, thus bypassing /// to the ostream's streambuf, thus bypassing
/// the ostream. The ostream's state is therefore /// the ostream. The ostream's state is therefore

View File

@ -86,6 +86,8 @@ class Foundation_API Base64Decoder: public Base64DecoderIOS, public std::istream
/// This istream base64-decodes all data /// This istream base64-decodes all data
/// read from the istream connected to it. /// read from the istream connected to it.
/// ///
/// The class implements RFC 4648 - https://tools.ietf.org/html/rfc4648
///
/// Note: For performance reasons, the characters /// Note: For performance reasons, the characters
/// are read directly from the given istream's /// are read directly from the given istream's
/// underlying streambuf, so the state /// underlying streambuf, so the state

View File

@ -117,6 +117,8 @@ class Foundation_API Base64Encoder: public Base64EncoderIOS, public std::ostream
/// writing data, to ensure proper /// writing data, to ensure proper
/// completion of the encoding operation. /// completion of the encoding operation.
/// ///
/// The class implements RFC 4648 - https://tools.ietf.org/html/rfc4648
///
/// Note: The characters are directly written /// Note: The characters are directly written
/// to the ostream's streambuf, thus bypassing /// to the ostream's streambuf, thus bypassing
/// the ostream. The ostream's state is therefore /// the ostream. The ostream's state is therefore

View File

@ -94,9 +94,9 @@ public:
Poco::UInt32 size(static_cast<Poco::UInt32>(value.size())); Poco::UInt32 size(static_cast<Poco::UInt32>(value.size()));
*this << size; *this << size;
for (typename std::vector<T>::const_iterator it = value.begin(); it != value.end(); ++it) for (const auto& v: value)
{ {
*this << *it; *this << v;
} }
return *this; return *this;

View File

@ -36,16 +36,16 @@ class Buffer
/// is needed. /// is needed.
{ {
public: public:
Buffer(std::size_t capacity): Buffer(std::size_t length):
_capacity(capacity), _capacity(length),
_used(capacity), _used(length),
_ptr(0), _ptr(0),
_ownMem(true) _ownMem(true)
/// Creates and allocates the Buffer. /// Creates and allocates the Buffer.
{ {
if (capacity > 0) if (length > 0)
{ {
_ptr = new T[capacity]; _ptr = new T[length];
} }
} }
@ -94,6 +94,19 @@ public:
} }
} }
Buffer(Buffer&& other) :
/// Copy constructor.
_capacity(other._capacity),
_used(other._used),
_ptr(other._ptr),
_ownMem(other._ownMem)
{
other._capacity = 0;
other._used = 0;
other._ownMem = false;
other._ptr = nullptr;
}
Buffer& operator = (const Buffer& other) Buffer& operator = (const Buffer& other)
/// Assignment operator. /// Assignment operator.
{ {
@ -106,6 +119,25 @@ public:
return *this; return *this;
} }
Buffer& operator = (Buffer&& other)
/// Assignment operator.
{
if (this != &other)
{
_capacity = other._capacity;
_used = other._used;
_ptr = other._ptr;
_ownMem = other._ownMem;
other._capacity = 0;
other._used = 0;
other._ownMem = false;
other._ptr = nullptr;
}
return *this;
}
~Buffer() ~Buffer()
/// Destroys the Buffer. /// Destroys the Buffer.
{ {
@ -225,6 +257,7 @@ public:
swap(_ptr, other._ptr); swap(_ptr, other._ptr);
swap(_capacity, other._capacity); swap(_capacity, other._capacity);
swap(_used, other._used); swap(_used, other._used);
swap(_ownMem, other._ownMem);
} }
bool operator == (const Buffer& other) const bool operator == (const Buffer& other) const

View File

@ -39,7 +39,7 @@ public:
return new char_type[static_cast<std::size_t>(size)]; return new char_type[static_cast<std::size_t>(size)];
} }
static void deallocate(char_type* ptr, std::streamsize /*size*/) throw() static void deallocate(char_type* ptr, std::streamsize /*size*/) noexcept
{ {
delete [] ptr; delete [] ptr;
} }

View File

@ -64,9 +64,16 @@ public:
} }
~BasicBufferedStreamBuf() ~BasicBufferedStreamBuf()
{
try
{ {
Allocator::deallocate(_pBuffer, _bufsize); Allocator::deallocate(_pBuffer, _bufsize);
} }
catch (...)
{
poco_unexpected();
}
}
virtual int_type overflow(int_type c) virtual int_type overflow(int_type c)
{ {

View File

@ -36,6 +36,8 @@ public:
static UInt16 flipBytes(UInt16 value); static UInt16 flipBytes(UInt16 value);
static Int32 flipBytes(Int32 value); static Int32 flipBytes(Int32 value);
static UInt32 flipBytes(UInt32 value); static UInt32 flipBytes(UInt32 value);
static float flipBytes(float value);
static double flipBytes(double value);
#if defined(POCO_HAVE_INT64) #if defined(POCO_HAVE_INT64)
static Int64 flipBytes(Int64 value); static Int64 flipBytes(Int64 value);
static UInt64 flipBytes(UInt64 value); static UInt64 flipBytes(UInt64 value);
@ -94,6 +96,21 @@ public:
static Int64 fromNetwork(Int64 value); static Int64 fromNetwork(Int64 value);
static UInt64 fromNetwork (UInt64 value); static UInt64 fromNetwork (UInt64 value);
#endif #endif
private:
template<typename T>
static T flip(T value)
{
T flip = value;
std::size_t halfSize = sizeof(T) / 2;
char* flipP = reinterpret_cast<char*>(&flip);
for (std::size_t i = 0; i < halfSize; i++)
{
std::swap(flipP[i], flipP[sizeof(T) - i - 1]);
}
return flip;
}
}; };
@ -150,6 +167,18 @@ inline Int32 ByteOrder::flipBytes(Int32 value)
} }
inline float ByteOrder::flipBytes(float value)
{
return flip(value);
}
inline double ByteOrder::flipBytes(double value)
{
return flip(value);
}
#if defined(POCO_HAVE_INT64) #if defined(POCO_HAVE_INT64)
inline UInt64 ByteOrder::flipBytes(UInt64 value) inline UInt64 ByteOrder::flipBytes(UInt64 value)
{ {

View File

@ -22,6 +22,7 @@
#include "Poco/Configurable.h" #include "Poco/Configurable.h"
#include "Poco/Mutex.h" #include "Poco/Mutex.h"
#include "Poco/RefCountedObject.h" #include "Poco/RefCountedObject.h"
#include "Poco/AutoPtr.h"
namespace Poco { namespace Poco {
@ -38,6 +39,8 @@ class Foundation_API Channel: public Configurable, public RefCountedObject
/// of getProperty() and setProperty(). /// of getProperty() and setProperty().
{ {
public: public:
using Ptr = AutoPtr<Channel>;
Channel(); Channel();
/// Creates the channel and initializes /// Creates the channel and initializes
/// the reference count to one. /// the reference count to one.

View File

@ -25,6 +25,8 @@
#if defined(_WIN32) #if defined(_WIN32)
#define POCO_LIBRARY_API __declspec(dllexport) #define POCO_LIBRARY_API __declspec(dllexport)
#elif defined(__GNUC__) && (__GNUC__ >= 4)
#define POCO_LIBRARY_API __attribute__ ((visibility ("default")))
#else #else
#define POCO_LIBRARY_API #define POCO_LIBRARY_API
#endif #endif
@ -94,6 +96,10 @@ extern "C" \
pManifest->insert(new Poco::MetaObject<cls, _Base>(#cls)); pManifest->insert(new Poco::MetaObject<cls, _Base>(#cls));
#define POCO_EXPORT_INTERFACE(cls, itf) \
pManifest->insert(new Poco::MetaObject<cls, _Base>(itf));
#define POCO_EXPORT_SINGLETON(cls) \ #define POCO_EXPORT_SINGLETON(cls) \
pManifest->insert(new Poco::MetaSingleton<cls, _Base>(#cls)); pManifest->insert(new Poco::MetaSingleton<cls, _Base>(#cls));

View File

@ -132,10 +132,10 @@ public:
virtual ~ClassLoader() virtual ~ClassLoader()
/// Destroys the ClassLoader. /// Destroys the ClassLoader.
{ {
for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it) for (auto& p: _map)
{ {
delete it->second.pLibrary; delete p.second.pLibrary;
delete it->second.pManifest; delete p.second.pManifest;
} }
} }
@ -247,9 +247,9 @@ public:
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it) for (const auto& p: _map)
{ {
const Manif* pManif = it->second.pManifest; const Manif* pManif = p.second.pManifest;
typename Manif::Iterator itm = pManif->find(className); typename Manif::Iterator itm = pManif->find(className);
if (itm != pManif->end()) if (itm != pManif->end())
return *itm; return *itm;

View File

@ -28,7 +28,7 @@ class Foundation_API Clock
/// A Clock stores a monotonic* clock value /// A Clock stores a monotonic* clock value
/// with (theoretical) microseconds resolution. /// with (theoretical) microseconds resolution.
/// Clocks can be compared with each other /// Clocks can be compared with each other
/// and simple arithmetics are supported. /// and simple arithmetic is supported.
/// ///
/// [*] Note that Clock values are only monotonic if /// [*] Note that Clock values are only monotonic if
/// the operating system provides a monotonic clock. /// the operating system provides a monotonic clock.
@ -108,7 +108,7 @@ public:
static ClockDiff resolution(); static ClockDiff resolution();
/// Returns the resolution in units per second. /// Returns the resolution in units per second.
/// Since the Clock clas has microsecond resolution, /// Since the Clock class has microsecond resolution,
/// the returned value is always 1000000. /// the returned value is always 1000000.
static ClockDiff accuracy(); static ClockDiff accuracy();

View File

@ -18,16 +18,6 @@
#define Foundation_Config_INCLUDED #define Foundation_Config_INCLUDED
// Define to enable Windows Unicode (UTF-8) support
// NOTE: As of POCO C++ Libraries release 1.6.0, compiling POCO
// without POCO_WIN32_UTF8 defined on Windows is deprecated.
#define POCO_WIN32_UTF8
// Define to enable C++11 support
// #define POCO_ENABLE_CPP11
// Define to disable implicit linking // Define to disable implicit linking
// #define POCO_NO_AUTOMATIC_LIBS // #define POCO_NO_AUTOMATIC_LIBS

View File

@ -43,6 +43,8 @@ class Foundation_API ConsoleChannel: public Channel
/// same stream. /// same stream.
{ {
public: public:
using Ptr = AutoPtr<ConsoleChannel>;
ConsoleChannel(); ConsoleChannel();
/// Creates the channel and attaches std::clog. /// Creates the channel and attaches std::clog.

View File

@ -46,34 +46,34 @@ public:
~CountingStreamBuf(); ~CountingStreamBuf();
/// Destroys the CountingStream. /// Destroys the CountingStream.
int chars() const; std::streamsize chars() const;
/// Returns the total number of characters. /// Returns the total number of characters.
int lines() const; std::streamsize lines() const;
/// Returns the total number of lines. /// Returns the total number of lines.
int pos() const; std::streamsize pos() const;
/// Returns the number of characters on the current line. /// Returns the number of characters on the current line.
void reset(); void reset();
/// Resets all counters. /// Resets all counters.
void setCurrentLineNumber(int line); void setCurrentLineNumber(std::streamsize line);
/// Sets the current line number. /// Sets the current line number.
/// ///
/// This is mainly useful when parsing C/C++ /// This is mainly useful when parsing C/C++
/// preprocessed source code containing #line directives. /// preprocessed source code containing #line directives.
int getCurrentLineNumber() const; std::streamsize getCurrentLineNumber() const;
/// Returns the current line number (same as lines()). /// Returns the current line number (same as lines()).
void addChars(int chars); void addChars(std::streamsize chars);
/// Add to the total number of characters. /// Add to the total number of characters.
void addLines(int lines); void addLines(std::streamsize lines);
/// Add to the total number of lines. /// Add to the total number of lines.
void addPos(int pos); void addPos(std::streamsize pos);
/// Add to the number of characters on the current line. /// Add to the number of characters on the current line.
protected: protected:
@ -83,9 +83,9 @@ protected:
private: private:
std::istream* _pIstr; std::istream* _pIstr;
std::ostream* _pOstr; std::ostream* _pOstr;
int _chars; std::streamsize _chars;
int _lines; std::streamsize _lines;
int _pos; std::streamsize _pos;
}; };
@ -110,34 +110,34 @@ public:
~CountingIOS(); ~CountingIOS();
/// Destroys the stream. /// Destroys the stream.
int chars() const; std::streamsize chars() const;
/// Returns the total number of characters. /// Returns the total number of characters.
int lines() const; std::streamsize lines() const;
/// Returns the total number of lines. /// Returns the total number of lines.
int pos() const; std::streamsize pos() const;
/// Returns the number of characters on the current line. /// Returns the number of characters on the current line.
void reset(); void reset();
/// Resets all counters. /// Resets all counters.
void setCurrentLineNumber(int line); void setCurrentLineNumber(std::streamsize line);
/// Sets the current line number. /// Sets the current line number.
/// ///
/// This is mainly useful when parsing C/C++ /// This is mainly useful when parsing C/C++
/// preprocessed source code containing #line directives. /// preprocessed source code containing #line directives.
int getCurrentLineNumber() const; std::streamsize getCurrentLineNumber() const;
/// Returns the current line number (same as lines()). /// Returns the current line number (same as lines()).
void addChars(int chars); void addChars(std::streamsize chars);
/// Add to the total number of characters. /// Add to the total number of characters.
void addLines(int lines); void addLines(std::streamsize lines);
/// Add to the total number of lines. /// Add to the total number of lines.
void addPos(int pos); void addPos(std::streamsize pos);
/// Add to the number of characters on the current line. /// Add to the number of characters on the current line.
CountingStreamBuf* rdbuf(); CountingStreamBuf* rdbuf();
@ -183,49 +183,49 @@ public:
// //
// inlines // inlines
// //
inline int CountingStreamBuf::chars() const inline std::streamsize CountingStreamBuf::chars() const
{ {
return _chars; return _chars;
} }
inline int CountingStreamBuf::lines() const inline std::streamsize CountingStreamBuf::lines() const
{ {
return _lines; return _lines;
} }
inline int CountingStreamBuf::pos() const inline std::streamsize CountingStreamBuf::pos() const
{ {
return _pos; return _pos;
} }
inline int CountingStreamBuf::getCurrentLineNumber() const inline std::streamsize CountingStreamBuf::getCurrentLineNumber() const
{ {
return _lines; return _lines;
} }
inline int CountingIOS::chars() const inline std::streamsize CountingIOS::chars() const
{ {
return _buf.chars(); return _buf.chars();
} }
inline int CountingIOS::lines() const inline std::streamsize CountingIOS::lines() const
{ {
return _buf.lines(); return _buf.lines();
} }
inline int CountingIOS::pos() const inline std::streamsize CountingIOS::pos() const
{ {
return _buf.pos(); return _buf.pos();
} }
inline int CountingIOS::getCurrentLineNumber() const inline std::streamsize CountingIOS::getCurrentLineNumber() const
{ {
return _buf.getCurrentLineNumber(); return _buf.getCurrentLineNumber();
} }

View File

@ -107,9 +107,11 @@ public:
/// * day is from 1 to 31. /// * day is from 1 to 31.
/// * hour is from 0 to 23. /// * hour is from 0 to 23.
/// * minute is from 0 to 59. /// * minute is from 0 to 59.
/// * second is from 0 to 60 (allowing leap seconds). /// * second is from 0 to 60.
/// * millisecond is from 0 to 999. /// * millisecond is from 0 to 999.
/// * microsecond is from 0 to 999. /// * microsecond is from 0 to 999.
///
/// Throws an InvalidArgumentException if an argument date is out of range.
DateTime(double julianDay); DateTime(double julianDay);
/// Creates a DateTime for the given Julian day. /// Creates a DateTime for the given Julian day.
@ -141,9 +143,11 @@ public:
/// * day is from 1 to 31. /// * day is from 1 to 31.
/// * hour is from 0 to 23. /// * hour is from 0 to 23.
/// * minute is from 0 to 59. /// * minute is from 0 to 59.
/// * second is from 0 to 60 (allowing leap seconds). /// * second is from 0 to 60.
/// * millisecond is from 0 to 999. /// * millisecond is from 0 to 999.
/// * microsecond is from 0 to 999. /// * microsecond is from 0 to 999.
///
/// Throws an InvalidArgumentException if an argument date is out of range.
void swap(DateTime& dateTime); void swap(DateTime& dateTime);
/// Swaps the DateTime with another one. /// Swaps the DateTime with another one.
@ -164,11 +168,11 @@ public:
/// on a Saturday, week 1 will be the week starting on Monday, January 3. /// on a Saturday, week 1 will be the week starting on Monday, January 3.
/// January 1 and 2 will fall within week 0 (or the last week of the previous year). /// January 1 and 2 will fall within week 0 (or the last week of the previous year).
/// ///
/// For 2007, which starts on a Monday, week 1 will be the week startung on Monday, January 1. /// For 2007, which starts on a Monday, week 1 will be the week starting on Monday, January 1.
/// There will be no week 0 in 2007. /// There will be no week 0 in 2007.
int day() const; int day() const;
/// Returns the day witin the month (1 to 31). /// Returns the day within the month (1 to 31).
int dayOfWeek() const; int dayOfWeek() const;
/// Returns the weekday (0 to 6, where /// Returns the weekday (0 to 6, where
@ -254,7 +258,7 @@ protected:
/// Computes the Julian day for an UTC time. /// Computes the Julian day for an UTC time.
static double toJulianDay(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0); static double toJulianDay(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0);
/// Computes the Julian day for a gregorian calendar date and time. /// Computes the Julian day for a Gregorian calendar date and time.
/// See <http://vsg.cape.com/~pbaum/date/jdimp.htm>, section 2.3.1 for the algorithm. /// See <http://vsg.cape.com/~pbaum/date/jdimp.htm>, section 2.3.1 for the algorithm.
static Timestamp::UtcTimeVal toUtcTime(double julianDay); static Timestamp::UtcTimeVal toUtcTime(double julianDay);
@ -287,6 +291,21 @@ private:
// //
// inlines // inlines
// //
inline double DateTime::toJulianDay(Timestamp::UtcTimeVal utcTime)
{
double utcDays = double(utcTime)/864000000000.0;
return utcDays + 2299160.5; // first day of Gregorian reform (Oct 15 1582)
}
inline Timestamp::UtcTimeVal DateTime::toUtcTime(double julianDay)
{
return Timestamp::UtcTimeVal((julianDay - 2299160.5)*864000000000.0);
}
inline Timestamp DateTime::timestamp() const inline Timestamp DateTime::timestamp() const
{ {
return Timestamp::fromUtcTime(_utcTime); return Timestamp::fromUtcTime(_utcTime);

View File

@ -101,7 +101,7 @@ public:
static int parseDayOfWeek(std::string::const_iterator& it, const std::string::const_iterator& end); static int parseDayOfWeek(std::string::const_iterator& it, const std::string::const_iterator& end);
/// Tries to interpret the given range as a weekday name. The range must be at least /// Tries to interpret the given range as a weekday name. The range must be at least
/// three characters long. /// three characters long.
/// Returns the weekday number (0 .. 6, where 0 = Synday, 1 = Monday, etc.) if the /// Returns the weekday number (0 .. 6, where 0 = Sunday, 1 = Monday, etc.) if the
/// weekday name is valid. Otherwise throws a SyntaxException. /// weekday name is valid. Otherwise throws a SyntaxException.
protected: protected:

View File

@ -35,10 +35,10 @@ class DefaultStrategy: public NotificationStrategy<TArgs, TDelegate>
/// order in which they have been registered. /// order in which they have been registered.
{ {
public: public:
typedef TDelegate* DelegateHandle; using DelegateHandle = TDelegate*;
typedef SharedPtr<TDelegate> DelegatePtr; using DelegatePtr = SharedPtr<TDelegate>;
typedef std::vector<DelegatePtr> Delegates; using Delegates = std::vector<DelegatePtr>;
typedef typename Delegates::iterator Iterator; using Iterator = typename Delegates::iterator;
public: public:
DefaultStrategy() DefaultStrategy()
@ -132,10 +132,10 @@ class DefaultStrategy<void,TDelegate>: public NotificationStrategy<void, TDelega
/// order in which they have been registered. /// order in which they have been registered.
{ {
public: public:
typedef TDelegate* DelegateHandle; using DelegateHandle = TDelegate*;
typedef SharedPtr<TDelegate> DelegatePtr; using DelegatePtr = SharedPtr<TDelegate>;
typedef std::vector<DelegatePtr> Delegates; using Delegates = std::vector<DelegatePtr>;
typedef typename Delegates::iterator Iterator; using Iterator = typename Delegates::iterator;
public: public:
DefaultStrategy() DefaultStrategy()

View File

@ -36,7 +36,7 @@ class Foundation_API DigestEngine
/// digest. /// digest.
{ {
public: public:
typedef std::vector<unsigned char> Digest; using Digest = std::vector<unsigned char>;
DigestEngine(); DigestEngine();
virtual ~DigestEngine(); virtual ~DigestEngine();

View File

@ -31,8 +31,8 @@ namespace Poco {
class Foundation_API TraverseBase class Foundation_API TraverseBase
{ {
public: public:
typedef std::stack<DirectoryIterator> Stack; using Stack = std::stack<DirectoryIterator>;
typedef std::function<UInt16(const Stack&)> DepthFun; using DepthFun = std::function<UInt16(const Stack&)>;
enum enum
{ {

View File

@ -33,7 +33,7 @@ class Pair
/// Pair allows to define a pair of values. /// Pair allows to define a pair of values.
{ {
public: public:
typedef typename std::pair<K, Var> Data; using Data = typename std::pair<K, Var>;
Pair(): _data() Pair(): _data()
/// Creates an empty Pair /// Creates an empty Pair
@ -96,7 +96,7 @@ public:
std::string toString() std::string toString()
{ {
std::string str; std::string str;
Var(*this).convert<std::string>(str); Var(*this).template convert<std::string>(str);
return str; return str;
} }

View File

@ -62,16 +62,12 @@ public:
assignMap(val); assignMap(val);
} }
#ifdef POCO_ENABLE_CPP11
template <typename T> template <typename T>
Struct(const OrderedMap<K, T>& val) Struct(const OrderedMap<K, T>& val)
{ {
assignMap(val); assignMap(val);
} }
#endif // POCO_ENABLE_CPP11
virtual ~Struct() virtual ~Struct()
/// Destroys the Struct. /// Destroys the Struct.
{ {
@ -171,18 +167,24 @@ public:
_data.erase(it); _data.erase(it);
} }
inline void clear()
/// Remove all elements from the struct
{
_data.clear();
}
inline void swap(Struct& other)
/// Swap content of Struct with another Struct
{
_data.swap(other._data);
}
inline bool empty() const inline bool empty() const
/// Returns true if the Struct doesn't contain any members /// Returns true if the Struct doesn't contain any members
{ {
return _data.empty(); return _data.empty();
} }
inline void clear()
/// Clears the Struct contents
{
_data.clear();
}
SizeType size() const SizeType size() const
/// Returns the number of members the Struct contains /// Returns the number of members the Struct contains
{ {
@ -199,10 +201,35 @@ public:
return keys; return keys;
} }
inline Var getVar(const K& key) const
/// Returns the var value of the element with the given name.
/// Throws a NotFoundException if the key does not exist.
{
ConstIterator it = find(key);
if(it == end())
{
throw NotFoundException("Key not found in Struct");
}
return it->second;
}
template<typename DefT = Var>
inline Var getVar(const K& key, const DefT& defaultValue) const
/// Returns the var value of the element with the given name.
/// or defaultValue if none is found.
{
ConstIterator it = find(key);
if(it == end())
{
return defaultValue;
}
return it->second;
}
std::string toString() const std::string toString() const
{ {
std::string str; std::string str;
Var(*this).convert<std::string>(str); Var(*this).template convert<std::string>(str);
return str; return str;
} }
@ -593,9 +620,6 @@ private:
}; };
#ifdef POCO_ENABLE_CPP11
template <> template <>
class VarHolderImpl<Struct<std::string, Poco::OrderedMap<std::string, Var>, Poco::OrderedSet<std::string>>> : public VarHolder class VarHolderImpl<Struct<std::string, Poco::OrderedMap<std::string, Var>, Poco::OrderedSet<std::string>>> : public VarHolder
{ {
@ -968,17 +992,12 @@ private:
}; };
#endif // POCO_ENABLE_CPP11
} // namespace Dynamic } // namespace Dynamic
typedef Dynamic::Struct<std::string> DynamicStruct; typedef Dynamic::Struct<std::string> DynamicStruct;
#ifdef POCO_ENABLE_CPP11
typedef Dynamic::Struct<std::string, Poco::OrderedMap<std::string, Dynamic::Var>, Poco::OrderedSet<std::string>> OrderedDynamicStruct; typedef Dynamic::Struct<std::string, Poco::OrderedMap<std::string, Dynamic::Var>, Poco::OrderedSet<std::string>> OrderedDynamicStruct;
#endif // POCO_ENABLE_CPP11
} // namespace Poco } // namespace Poco

View File

@ -81,9 +81,9 @@ class Foundation_API Var
/// VarHolderImpl is available. For supported types, see VarHolder documentation. /// VarHolderImpl is available. For supported types, see VarHolder documentation.
{ {
public: public:
typedef SharedPtr<Var> Ptr; using Ptr = SharedPtr<Var>;
typedef Poco::Dynamic::VarIterator Iterator; using Iterator = Poco::Dynamic::VarIterator;
typedef const VarIterator ConstIterator; using ConstIterator = const VarIterator;
Var(); Var();
/// Creates an empty Var. /// Creates an empty Var.
@ -798,8 +798,7 @@ inline bool Var::isEmpty() const
inline bool Var::isArray() const inline bool Var::isArray() const
{ {
if (isEmpty() || if (isEmpty() || isString()) return false;
isString()) return false;
VarHolder* pHolder = content(); VarHolder* pHolder = content();
return pHolder ? pHolder->isArray() : false; return pHolder ? pHolder->isArray() : false;
@ -2231,6 +2230,110 @@ inline bool operator >= (const long& other, const Var& da)
} }
inline unsigned long operator + (const unsigned long& other, const Var& da)
/// Addition operator for adding Var to unsigned long
{
return other + da.convert<unsigned long>();
}
inline unsigned long operator - (const unsigned long& other, const Var& da)
/// Subtraction operator for subtracting Var from unsigned long
{
return other - da.convert<unsigned long>();
}
inline unsigned long operator * (const unsigned long& other, const Var& da)
/// Multiplication operator for multiplying Var with unsigned long
{
return other * da.convert<unsigned long>();
}
inline unsigned long operator / (const unsigned long& other, const Var& da)
/// Division operator for dividing Var with unsigned long
{
return other / da.convert<unsigned long>();
}
inline unsigned long operator += (unsigned long& other, const Var& da)
/// Addition assignment operator for adding Var to unsigned long
{
return other += da.convert<unsigned long>();
}
inline unsigned long operator -= (unsigned long& other, const Var& da)
/// Subtraction assignment operator for subtracting Var from unsigned long
{
return other -= da.convert<unsigned long>();
}
inline unsigned long operator *= (unsigned long& other, const Var& da)
/// Multiplication assignment operator for multiplying Var with unsigned long
{
return other *= da.convert<unsigned long>();
}
inline unsigned long operator /= (unsigned long& other, const Var& da)
/// Division assignment operator for dividing Var with unsigned long
{
return other /= da.convert<unsigned long>();
}
inline bool operator == (const unsigned long& other, const Var& da)
/// Equality operator for comparing Var with unsigned long
{
if (da.isEmpty()) return false;
return other == da.convert<unsigned long>();
}
inline bool operator != (const unsigned long& other, const Var& da)
/// Inequality operator for comparing Var with unsigned long
{
if (da.isEmpty()) return true;
return other != da.convert<unsigned long>();
}
inline bool operator < (const unsigned long& other, const Var& da)
/// Less than operator for comparing Var with unsigned long
{
if (da.isEmpty()) return false;
return other < da.convert<unsigned long>();
}
inline bool operator <= (const unsigned long& other, const Var& da)
/// Less than or equal operator for comparing Var with unsigned long
{
if (da.isEmpty()) return false;
return other <= da.convert<unsigned long>();
}
inline bool operator > (const unsigned long& other, const Var& da)
/// Greater than operator for comparing Var with unsigned long
{
if (da.isEmpty()) return false;
return other > da.convert<unsigned long>();
}
inline bool operator >= (const unsigned long& other, const Var& da)
/// Greater than or equal operator for comparing Var with unsigned long
{
if (da.isEmpty()) return false;
return other >= da.convert<unsigned long>();
}
#endif // POCO_LONG_IS_64_BIT #endif // POCO_LONG_IS_64_BIT

View File

@ -670,6 +670,7 @@ inline bool VarHolder::isDateTime() const
return false; return false;
} }
inline std::size_t VarHolder::size() const inline std::size_t VarHolder::size() const
{ {
return 1u; return 1u;

View File

@ -45,9 +45,9 @@ public:
/// Destroys the DynamicFactory and deletes the instantiators for /// Destroys the DynamicFactory and deletes the instantiators for
/// all registered classes. /// all registered classes.
{ {
for (typename FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it) for (auto& p: _map)
{ {
delete it->second; delete p.second;
} }
} }

View File

@ -44,11 +44,21 @@ class Foundation_API Event: private EventImpl
/// for an event to become signalled. /// for an event to become signalled.
{ {
public: public:
Event(bool autoReset = true); enum EventType
/// Creates the event. If autoReset is true, {
EVENT_MANUALRESET, /// Manual reset event
EVENT_AUTORESET /// Auto-reset event
};
explicit Event(EventType type = EVENT_AUTORESET);
/// Creates the event. If type is EVENT_AUTORESET,
/// the event is automatically reset after /// the event is automatically reset after
/// a wait() successfully returns. /// a wait() successfully returns.
//@ deprecated
explicit Event(bool autoReset);
/// Please use Event::Event(EventType) instead.
~Event(); ~Event();
/// Destroys the event. /// Destroys the event.

View File

@ -33,6 +33,8 @@ class Foundation_API EventChannel: public Channel
/// the logging framework. /// the logging framework.
{ {
public: public:
using Ptr = AutoPtr<EventChannel>;
Poco::BasicEvent<const Message> messageLogged; Poco::BasicEvent<const Message> messageLogged;
/// Fired when a message is logged by calling the log() method. /// Fired when a message is logged by calling the log() method.

View File

@ -35,6 +35,8 @@ class Foundation_API EventLogChannel: public Channel
/// containing the message definition resources can be found in $PATH. /// containing the message definition resources can be found in $PATH.
{ {
public: public:
using Ptr = AutoPtr<EventLogChannel>;
EventLogChannel(); EventLogChannel();
/// Creates the EventLogChannel. /// Creates the EventLogChannel.
/// The name of the current application (or more correctly, /// The name of the current application (or more correctly,
@ -85,11 +87,7 @@ protected:
static int getType(const Message& msg); static int getType(const Message& msg);
static int getCategory(const Message& msg); static int getCategory(const Message& msg);
void setUpRegistry() const; void setUpRegistry() const;
#if defined(POCO_WIN32_UTF8)
static std::wstring findLibrary(const wchar_t* name); static std::wstring findLibrary(const wchar_t* name);
#else
static std::string findLibrary(const char* name);
#endif
private: private:
std::string _name; std::string _name;

View File

@ -43,19 +43,19 @@ public:
Exception(const Exception& exc); Exception(const Exception& exc);
/// Copy constructor. /// Copy constructor.
~Exception() throw(); ~Exception() noexcept;
/// Destroys the exception and deletes the nested exception. /// Destroys the exception and deletes the nested exception.
Exception& operator = (const Exception& exc); Exception& operator = (const Exception& exc);
/// Assignment operator. /// Assignment operator.
virtual const char* name() const throw(); virtual const char* name() const noexcept;
/// Returns a static string describing the exception. /// Returns a static string describing the exception.
virtual const char* className() const throw(); virtual const char* className() const noexcept;
/// Returns the name of the exception class. /// Returns the name of the exception class.
virtual const char* what() const throw(); virtual const char* what() const noexcept;
/// Returns a static string describing the exception. /// Returns a static string describing the exception.
/// ///
/// Same as name(), but for compatibility with std::exception. /// Same as name(), but for compatibility with std::exception.
@ -146,10 +146,10 @@ inline int Exception::code() const
CLS(const std::string& msg, const std::string& arg, int code = CODE); \ CLS(const std::string& msg, const std::string& arg, int code = CODE); \
CLS(const std::string& msg, const Poco::Exception& exc, int code = CODE); \ CLS(const std::string& msg, const Poco::Exception& exc, int code = CODE); \
CLS(const CLS& exc); \ CLS(const CLS& exc); \
~CLS() throw(); \ ~CLS() noexcept; \
CLS& operator = (const CLS& exc); \ CLS& operator = (const CLS& exc); \
const char* name() const throw(); \ const char* name() const noexcept; \
const char* className() const throw(); \ const char* className() const noexcept; \
Poco::Exception* clone() const; \ Poco::Exception* clone() const; \
void rethrow() const; \ void rethrow() const; \
}; };
@ -173,7 +173,7 @@ inline int Exception::code() const
CLS::CLS(const CLS& exc): BASE(exc) \ CLS::CLS(const CLS& exc): BASE(exc) \
{ \ { \
} \ } \
CLS::~CLS() throw() \ CLS::~CLS() noexcept \
{ \ { \
} \ } \
CLS& CLS::operator = (const CLS& exc) \ CLS& CLS::operator = (const CLS& exc) \
@ -181,11 +181,11 @@ inline int Exception::code() const
BASE::operator = (exc); \ BASE::operator = (exc); \
return *this; \ return *this; \
} \ } \
const char* CLS::name() const throw() \ const char* CLS::name() const noexcept \
{ \ { \
return NAME; \ return NAME; \
} \ } \
const char* CLS::className() const throw() \ const char* CLS::className() const noexcept \
{ \ { \
return typeid(*this).name(); \ return typeid(*this).name(); \
} \ } \

View File

@ -39,7 +39,7 @@ class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey
/// but also limits the size of the cache (per default: 1024). /// but also limits the size of the cache (per default: 1024).
{ {
public: public:
ExpireLRUCache(long cacheSize = 1024, Timestamp::TimeDiff expire = 600000): ExpireLRUCache(std::size_t cacheSize = 1024, Timestamp::TimeDiff expire = 600000):
AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>(StrategyCollection<TKey, TValue>()) AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>(StrategyCollection<TKey, TValue>())
{ {
this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize)); this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize));

View File

@ -23,14 +23,12 @@
#include <vector> #include <vector>
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) #if defined(POCO_OS_FAMILY_WINDOWS)
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
#include "File_WINCE.h" #include "File_WINCE.h"
#else #else
#include "Poco/File_WIN32U.h" #include "Poco/File_WIN32U.h"
#endif #endif
#elif defined(POCO_OS_FAMILY_WINDOWS)
#include "Poco/File_WIN32.h"
#elif defined(POCO_VXWORKS) #elif defined(POCO_VXWORKS)
#include "Poco/File_VX.h" #include "Poco/File_VX.h"
#elif defined(POCO_OS_FAMILY_UNIX) #elif defined(POCO_OS_FAMILY_UNIX)
@ -51,8 +49,7 @@ class Foundation_API File: private FileImpl
/// platform-specific limitations regarding maximum length /// platform-specific limitations regarding maximum length
/// of the entire path and its components apply. /// of the entire path and its components apply.
/// ///
/// On Windows, if compiled with UTF-8 support (POCO_WIN32_UTF8) /// On Windows, the implementation tries to work around the rather low
/// the implementation tries to work around the rather low
/// 260 characters MAX_PATH limit by adding the "\\?\" prefix if /// 260 characters MAX_PATH limit by adding the "\\?\" prefix if
/// a path is absolute and exceeds MAX_PATH characters in length. /// a path is absolute and exceeds MAX_PATH characters in length.
/// Note that various limitations regarding usage of the "\\?\" /// Note that various limitations regarding usage of the "\\?\"

View File

@ -44,8 +44,7 @@ class Foundation_API FileIOS: public virtual std::ios
/// Use an InputLineEndingConverter or OutputLineEndingConverter /// Use an InputLineEndingConverter or OutputLineEndingConverter
/// if you require CR-LF translation. /// if you require CR-LF translation.
/// ///
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd, /// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled.
/// UTF-8 encoded Unicode paths are correctly handled.
{ {
public: public:
FileIOS(std::ios::openmode defaultMode); FileIOS(std::ios::openmode defaultMode);
@ -86,8 +85,7 @@ class Foundation_API FileInputStream: public FileIOS, public std::istream
/// was specified. /// was specified.
/// Use an InputLineEndingConverter if you require CR-LF translation. /// Use an InputLineEndingConverter if you require CR-LF translation.
/// ///
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd, /// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled.
/// UTF-8 encoded Unicode paths are correctly handled.
{ {
public: public:
FileInputStream(); FileInputStream();
@ -117,8 +115,7 @@ class Foundation_API FileOutputStream: public FileIOS, public std::ostream
/// was specified. /// was specified.
/// Use an OutputLineEndingConverter if you require CR-LF translation. /// Use an OutputLineEndingConverter if you require CR-LF translation.
/// ///
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd, /// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled.
/// UTF-8 encoded Unicode paths are correctly handled.
{ {
public: public:
FileOutputStream(); FileOutputStream();
@ -154,8 +151,7 @@ class Foundation_API FileStream: public FileIOS, public std::iostream
/// read position and the write position simultaneously to the /// read position and the write position simultaneously to the
/// same value. /// same value.
/// ///
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd, /// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled.
/// UTF-8 encoded Unicode paths are correctly handled.
{ {
public: public:
FileStream(); FileStream();

View File

@ -27,8 +27,8 @@ namespace Poco {
class FileImpl class FileImpl
{ {
protected: protected:
enum Options
enum Options { {
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01 OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
}; };

View File

@ -28,8 +28,8 @@ namespace Poco {
class Foundation_API FileImpl class Foundation_API FileImpl
{ {
protected: protected:
enum Options
enum Options { {
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01 OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
}; };

View File

@ -28,8 +28,8 @@ namespace Poco {
class Foundation_API FileImpl class Foundation_API FileImpl
{ {
protected: protected:
enum Options
enum Options { {
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01 OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
}; };

View File

@ -21,6 +21,7 @@
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
#include "Poco/Any.h" #include "Poco/Any.h"
#include <vector> #include <vector>
#include <type_traits>
namespace Poco { namespace Poco {
@ -80,11 +81,13 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
/// * h argument is short (d, i), unsigned short (o, u, x, X) or float (e, E, f, g, G) /// * h argument is short (d, i), unsigned short (o, u, x, X) or float (e, E, f, g, G)
/// * ? argument is any signed or unsigned int, short, long, or 64-bit integer (d, i, o, x, X) /// * ? argument is any signed or unsigned int, short, long, or 64-bit integer (d, i, o, x, X)
/// ///
/// The width argument is a nonnegative decimal integer controlling the minimum number of characters printed. /// The width argument is a nonnegative decimal integer or '*' with an additional nonnegative integer value
/// preceding the value to be formated, controlling the minimum number of characters printed.
/// If the number of characters in the output value is less than the specified width, blanks or /// If the number of characters in the output value is less than the specified width, blanks or
/// leading zeros are added, according to the specified flags (-, +, 0). /// leading zeros are added, according to the specified flags (-, +, 0).
/// ///
/// Precision is a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters /// Precision is a nonnegative decimal integer or '*' with an additional nonnegative integer value preceding
/// the value to be formated, preceded by a period (.), which specifies the number of characters
/// to be printed, the number of decimal places, or the number of significant digits. /// to be printed, the number of decimal places, or the number of significant digits.
/// ///
/// Throws an InvalidArgumentException if an argument index is out of range. /// Throws an InvalidArgumentException if an argument index is out of range.
@ -102,36 +105,47 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
/// std::string s1 = format("The answer to life, the universe, and everything is %d", 42); /// std::string s1 = format("The answer to life, the universe, and everything is %d", 42);
/// std::string s2 = format("second: %[1]d, first: %[0]d", 1, 2); /// std::string s2 = format("second: %[1]d, first: %[0]d", 1, 2);
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2); void Foundation_API format(std::string& result, const char *fmt, const std::vector<Any>& values);
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); /// Supports a variable number of arguments and is used by
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); /// all other variants of format().
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value);
/// Appends the formatted string to result.
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2);
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3);
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
void Foundation_API format(std::string& result, const std::string& fmt, const std::vector<Any>& values); void Foundation_API format(std::string& result, const std::string& fmt, const std::vector<Any>& values);
/// Supports a variable number of arguments and is used by /// Supports a variable number of arguments and is used by
/// all other variants of format(). /// all other variants of format().
template <
typename T,
typename... Args>
void format(std::string &result, const std::string &fmt, T arg1, Args... args)
/// Appends the formatted string to result.
{
std::vector<Any> values;
values.reserve(sizeof...(Args) + 1);
values.emplace_back(arg1);
values.insert(values.end(), { args... });
format(result, fmt, values);
}
template <
typename FMT,
typename T,
typename... Args,
typename std::enable_if<std::is_const<typename std::remove_reference<FMT>::type>::value, int>::type = 0>
std::string format(FMT &fmt, T arg1, Args... args)
/// Returns the formatted string.
{
std::vector<Any> values;
values.reserve(sizeof...(Args) + 1);
values.emplace_back(arg1);
values.insert(values.end(), { args... });
std::string result;
format(result, fmt, values);
return result;
}
} // namespace Poco } // namespace Poco

View File

@ -20,6 +20,7 @@
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
#include "Poco/Configurable.h" #include "Poco/Configurable.h"
#include "Poco/AutoPtr.h"
#include "Poco/RefCountedObject.h" #include "Poco/RefCountedObject.h"
@ -40,9 +41,9 @@ class Foundation_API Formatter: public Configurable, public RefCountedObject
/// A useful implementation should at least take the Message's /// A useful implementation should at least take the Message's
/// Time, Priority and Text fields and put them into a string. /// Time, Priority and Text fields and put them into a string.
/// ///
/// The Formatter class supports the Configurable /// The Formatter class supports the Configurable interface,
/// interface, so the behaviour of certain formatters /// so the behaviour of certain formatters is configurable.
/// is configurable. /// It also supports reference counting based garbage collection.
/// ///
/// Trivial implementations of of getProperty() and /// Trivial implementations of of getProperty() and
/// setProperty() are provided. /// setProperty() are provided.
@ -50,6 +51,8 @@ class Foundation_API Formatter: public Configurable, public RefCountedObject
/// Subclasses must at least provide a format() method. /// Subclasses must at least provide a format() method.
{ {
public: public:
using Ptr = AutoPtr<Formatter>;
Formatter(); Formatter();
/// Creates the formatter. /// Creates the formatter.

View File

@ -20,6 +20,8 @@
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
#include "Poco/Channel.h" #include "Poco/Channel.h"
#include "Poco/Formatter.h"
#include "Poco/AutoPtr.h"
namespace Poco { namespace Poco {
@ -34,30 +36,32 @@ class Foundation_API FormattingChannel: public Channel
/// to the destination channel. /// to the destination channel.
{ {
public: public:
using Ptr = AutoPtr<FormattingChannel>;
FormattingChannel(); FormattingChannel();
/// Creates a FormattingChannel. /// Creates a FormattingChannel.
FormattingChannel(Formatter* pFormatter); FormattingChannel(Formatter::Ptr pFormatter);
/// Creates a FormattingChannel and attaches a Formatter. /// Creates a FormattingChannel and attaches a Formatter.
FormattingChannel(Formatter* pFormatter, Channel* pChannel); FormattingChannel(Formatter::Ptr pFormatter, Channel::Ptr pChannel);
/// Creates a FormattingChannel and attaches a Formatter /// Creates a FormattingChannel and attaches a Formatter
/// and a Channel. /// and a Channel.
void setFormatter(Formatter* pFormatter); void setFormatter(Formatter::Ptr pFormatter);
/// Sets the Formatter used to format the messages /// Sets the Formatter used to format the messages
/// before they are passed on. If null, the message /// before they are passed on. If null, the message
/// is passed on unmodified. /// is passed on unmodified.
Formatter* getFormatter() const; Formatter::Ptr getFormatter() const;
/// Returns the Formatter used to format messages, /// Returns the Formatter used to format messages,
/// which may be null. /// which may be null.
void setChannel(Channel* pChannel); void setChannel(Channel::Ptr pChannel);
/// Sets the destination channel to which the formatted /// Sets the destination channel to which the formatted
/// messages are passed on. /// messages are passed on.
Channel* getChannel() const; Channel::Ptr getChannel() const;
/// Returns the channel to which the formatted /// Returns the channel to which the formatted
/// messages are passed on. /// messages are passed on.
@ -85,8 +89,8 @@ protected:
~FormattingChannel(); ~FormattingChannel();
private: private:
Formatter* _pFormatter; Formatter::Ptr _pFormatter;
Channel* _pChannel; Channel::Ptr _pChannel;
}; };

View File

@ -114,12 +114,8 @@
// Cleanup inconsistencies // Cleanup inconsistencies
// //
#ifdef POCO_OS_FAMILY_WINDOWS #ifdef POCO_OS_FAMILY_WINDOWS
#if defined(POCO_WIN32_UTF8) && defined(POCO_NO_WSTRING) #if defined(POCO_NO_WSTRING)
#error POCO_WIN32_UTF8 and POCO_NO_WSTRING are mutually exclusive. #error POCO_NO_WSTRING is not supported on Windows.
#endif
#else
#ifdef POCO_WIN32_UTF8
#undef POCO_WIN32_UTF8
#endif #endif
#endif #endif

View File

@ -78,7 +78,7 @@ public:
static void glob(const std::string& pathPattern, std::set<std::string>& files, int options = 0); static void glob(const std::string& pathPattern, std::set<std::string>& files, int options = 0);
/// Creates a set of files that match the given pathPattern. /// Creates a set of files that match the given pathPattern.
/// ///
/// The path may be give in either Unix, Windows or VMS syntax and /// The path may be give in either Unix or Windows syntax and
/// is automatically expanded by calling Path::expand(). /// is automatically expanded by calling Path::expand().
/// ///
/// The pattern may contain wildcard expressions even in intermediate /// The pattern may contain wildcard expressions even in intermediate
@ -93,7 +93,7 @@ public:
static void glob(const char* pathPattern, std::set<std::string>& files, int options = 0); static void glob(const char* pathPattern, std::set<std::string>& files, int options = 0);
/// Creates a set of files that match the given pathPattern. /// Creates a set of files that match the given pathPattern.
/// ///
/// The path may be give in either Unix, Windows or VMS syntax and /// The path may be give in either Unix or Windows syntax and
/// is automatically expanded by calling Path::expand(). /// is automatically expanded by calling Path::expand().
/// ///
/// The pattern may contain wildcard expressions even in intermediate /// The pattern may contain wildcard expressions even in intermediate

View File

@ -28,7 +28,7 @@ namespace Poco {
template <class Engine> template <class Engine>
class HMACEngine: public DigestEngine class HMACEngine: public DigestEngine
/// This class implementes the HMAC message /// This class implements the HMAC message
/// authentication code algorithm, as specified /// authentication code algorithm, as specified
/// in RFC 2104. The underlying DigestEngine /// in RFC 2104. The underlying DigestEngine
/// (MD5Engine, SHA1Engine, etc.) must be given as /// (MD5Engine, SHA1Engine, etc.) must be given as
@ -80,8 +80,7 @@ public:
const DigestEngine::Digest& d = _engine.digest(); const DigestEngine::Digest& d = _engine.digest();
char db[DIGEST_SIZE]; char db[DIGEST_SIZE];
char* pdb = db; char* pdb = db;
for (DigestEngine::Digest::const_iterator it = d.begin(); it != d.end(); ++it) for (auto v: d) *pdb++ = v;
*pdb++ = *it;
_engine.reset(); _engine.reset();
_engine.update(_opad, BLOCK_SIZE); _engine.update(_opad, BLOCK_SIZE);
_engine.update(db, DIGEST_SIZE); _engine.update(db, DIGEST_SIZE);

View File

@ -35,7 +35,7 @@ class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue>, TM
/// An LRUCache implements Least Recently Used caching. The default size for a cache is 1024 entries. /// An LRUCache implements Least Recently Used caching. The default size for a cache is 1024 entries.
{ {
public: public:
LRUCache(long size = 1024): LRUCache(std::size_t size = 1024):
AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue>, TMutex, TEventMutex>(LRUStrategy<TKey, TValue>(size)) AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue>, TMutex, TEventMutex>(LRUStrategy<TKey, TValue>(size))
{ {
} }

View File

@ -35,7 +35,7 @@ class LinearHashTable
/// This class implements a linear hash table. /// This class implements a linear hash table.
/// ///
/// In a linear hash table, the available address space /// In a linear hash table, the available address space
/// grows or shrinks dynamically. A linar hash table thus /// grows or shrinks dynamically. A linear hash table thus
/// supports any number of insertions or deletions without /// supports any number of insertions or deletions without
/// lookup or insertion performance deterioration. /// lookup or insertion performance deterioration.
/// ///
@ -279,15 +279,15 @@ public:
/// Returns an iterator pointing to the first entry, if one exists. /// Returns an iterator pointing to the first entry, if one exists.
{ {
BucketVecIterator it(_buckets.begin()); BucketVecIterator it(_buckets.begin());
BucketVecIterator end(_buckets.end()); BucketVecIterator itEnd(_buckets.end());
while (it != end && it->empty()) while (it != itEnd && it->empty())
{ {
++it; ++it;
} }
if (it == end) if (it == itEnd)
return this->end(); return end();
else else
return ConstIterator(it, end, it->begin()); return ConstIterator(it, itEnd, it->begin());
} }
ConstIterator end() const ConstIterator end() const
@ -300,15 +300,15 @@ public:
/// Returns an iterator pointing to the first entry, if one exists. /// Returns an iterator pointing to the first entry, if one exists.
{ {
BucketVecIterator it(_buckets.begin()); BucketVecIterator it(_buckets.begin());
BucketVecIterator end(_buckets.end()); BucketVecIterator itEnd(_buckets.end());
while (it != end && it->empty()) while (it != itEnd && it->empty())
{ {
++it; ++it;
} }
if (it == end) if (it == itEnd)
return this->end(); return end();
else else
return Iterator(it, end, it->begin()); return Iterator(it, itEnd, it->begin());
} }
Iterator end() Iterator end()
@ -398,8 +398,8 @@ public:
void clear() void clear()
/// Erases all elements. /// Erases all elements.
{ {
LinearHashTable empty; LinearHashTable emptyTable;
swap(empty); swap(emptyTable);
} }
std::size_t size() const std::size_t size() const

View File

@ -2,7 +2,7 @@
// ListMap.h // ListMap.h
// //
// Library: Foundation // Library: Foundation
// Package: Hashing // Package: Core
// Module: ListMap // Module: ListMap
// //
// Definition of the ListMap class. // Definition of the ListMap class.
@ -21,14 +21,14 @@
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
#include "Poco/String.h" #include "Poco/String.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <list> #include <vector>
#include <utility> #include <utility>
namespace Poco { namespace Poco {
template <class Key, class Mapped, class Container = std::list<std::pair<Key, Mapped> >, bool CaseSensitive = false > template <class Key, class Mapped, class Container = std::vector<std::pair<Key, Mapped>>, bool CaseSensitive = false>
class ListMap class ListMap
/// This class implements a multimap in terms of a sequential container. /// This class implements a multimap in terms of a sequential container.
/// The use for this type of associative container is wherever automatic /// The use for this type of associative container is wherever automatic
@ -39,29 +39,39 @@ class ListMap
/// header entry reordering. /// header entry reordering.
{ {
public: public:
typedef Key KeyType; using KeyType = Key;
typedef Mapped MappedType; using MappedType = Mapped;
typedef Mapped& Reference; using Reference = Mapped&;
typedef const Mapped& ConstReference; using ConstReference = const Mapped&;
typedef Mapped* Pointer; using Pointer = Mapped*;
typedef const Mapped* ConstPointer; using ConstPointer = const Mapped*;
typedef typename Container::value_type ValueType; using ValueType = typename Container::value_type;
typedef typename Container::size_type SizeType; using SizeType = typename Container::size_type;
typedef typename Container::iterator Iterator; using Iterator = typename Container::iterator;
typedef typename Container::const_iterator ConstIterator; using ConstIterator = typename Container::const_iterator;
ListMap() ListMap()
/// Creates an empty ListMap. /// Creates an empty ListMap.
{ {
} }
ListMap(std::size_t initialReserve): explicit ListMap(std::size_t initialReserve):
_list(initialReserve) _container(initialReserve)
/// Creates the ListMap with room for initialReserve entries. /// Creates the ListMap with room for initialReserve entries.
{ {
} }
ListMap(const ListMap& other):
_container(other._container)
{
}
ListMap(ListMap&& other) noexcept:
_container(std::move(other._container))
{
}
ListMap& operator = (const ListMap& map) ListMap& operator = (const ListMap& map)
/// Assigns another ListMap. /// Assigns another ListMap.
{ {
@ -70,34 +80,41 @@ public:
return *this; return *this;
} }
ListMap& operator = (ListMap&& map) noexcept
/// Assigns another ListMap.
{
_container = std::move(map._container);
return *this;
}
void swap(ListMap& map) void swap(ListMap& map)
/// Swaps the ListMap with another one. /// Swaps the ListMap with another one.
{ {
_list.swap(map._list); _container.swap(map._container);
} }
ConstIterator begin() const ConstIterator begin() const
/// Returns the beginning of the map. /// Returns the beginning of the map.
{ {
return _list.begin(); return _container.begin();
} }
ConstIterator end() const ConstIterator end() const
/// Returns the end of the map. /// Returns the end of the map.
{ {
return _list.end(); return _container.end();
} }
Iterator begin() Iterator begin()
/// Returns the beginning of the map. /// Returns the beginning of the map.
{ {
return _list.begin(); return _container.begin();
} }
Iterator end() Iterator end()
/// Returns the end of the map. /// Returns the end of the map.
{ {
return _list.end(); return _container.end();
} }
ConstIterator find(const KeyType& key) const ConstIterator find(const KeyType& key) const
@ -106,8 +123,8 @@ public:
/// or iterator pointing to the end if entry is /// or iterator pointing to the end if entry is
/// not found. /// not found.
{ {
typename Container::const_iterator it = _list.begin(); typename Container::const_iterator it = _container.begin();
typename Container::const_iterator itEnd = _list.end(); typename Container::const_iterator itEnd = _container.end();
for(; it != itEnd; ++it) for(; it != itEnd; ++it)
{ {
if (isEqual(it->first, key)) return it; if (isEqual(it->first, key)) return it;
@ -121,8 +138,8 @@ public:
/// or iterator pointing to the end if entry is /// or iterator pointing to the end if entry is
/// not found. /// not found.
{ {
typename Container::iterator it = _list.begin(); typename Container::iterator it = _container.begin();
typename Container::iterator itEnd = _list.end(); typename Container::iterator itEnd = _container.end();
for(; it != itEnd; ++it) for(; it != itEnd; ++it)
{ {
if (isEqual(it->first, key)) return it; if (isEqual(it->first, key)) return it;
@ -138,13 +155,13 @@ public:
/// Returns iterator pointing to the newly inserted value /// Returns iterator pointing to the newly inserted value
{ {
Iterator it = find(val.first); Iterator it = find(val.first);
while (it != _list.end() && isEqual(it->first, val.first)) ++it; while (it != _container.end() && isEqual(it->first, val.first)) ++it;
return _list.insert(it, val); return _container.insert(it, val);
} }
void erase(Iterator it) void erase(Iterator it)
{ {
_list.erase(it); _container.erase(it);
} }
SizeType erase(const KeyType& key) SizeType erase(const KeyType& key)
@ -152,12 +169,12 @@ public:
SizeType count = 0; SizeType count = 0;
Iterator it = find(key); Iterator it = find(key);
bool removed = false; bool removed = false;
while (it != _list.end()) while (it != _container.end())
{ {
if (isEqual(it->first, key)) if (isEqual(it->first, key))
{ {
++count; ++count;
it = _list.erase(it); it = _container.erase(it);
removed = true; removed = true;
} }
else else
@ -171,23 +188,23 @@ public:
void clear() void clear()
{ {
_list.clear(); _container.clear();
} }
std::size_t size() const std::size_t size() const
{ {
return _list.size(); return _container.size();
} }
bool empty() const bool empty() const
{ {
return _list.empty(); return _container.empty();
} }
ConstReference operator [] (const KeyType& key) const ConstReference operator [] (const KeyType& key) const
{ {
ConstIterator it = find(key); ConstIterator it = find(key);
if (it != _list.end()) if (it != _container.end())
return it->second; return it->second;
else else
throw NotFoundException(); throw NotFoundException();
@ -196,8 +213,10 @@ public:
Reference operator [] (const KeyType& key) Reference operator [] (const KeyType& key)
{ {
Iterator it = find(key); Iterator it = find(key);
if (it != _list.end()) if (it != _container.end())
{
return it->second; return it->second;
}
else else
{ {
ValueType value(key, Mapped()); ValueType value(key, Mapped());
@ -236,7 +255,7 @@ private:
return isEqual(std::string(s1), std::string(s2)); return isEqual(std::string(s1), std::string(s2));
} }
Container _list; Container _container;
}; };

Some files were not shown because too many files have changed in this diff Show More