1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-11-25 10:37:18 +01:00

Update POCO to 1.11.0

This commit is contained in:
Sandu Liviu Catalin
2021-08-22 18:07:06 +03:00
parent 151077c799
commit 7a3d92d1d1
450 changed files with 25219 additions and 6528 deletions

View File

@@ -19,7 +19,7 @@
#include "Poco/KeyValueArgs.h"
#include "Poco/ValidArgs.h"
#include "Poco/ValidArgs.h"
#include "Poco/Mutex.h"
#include "Poco/Exception.h"
#include "Poco/FIFOEvent.h"
@@ -34,9 +34,9 @@
namespace Poco {
template <class TKey, class TValue, class TStrategy, class TMutex = FastMutex, class TEventMutex = FastMutex>
template <class TKey, class TValue, class TStrategy, class TMutex = FastMutex, class TEventMutex = FastMutex>
class AbstractCache
/// An AbstractCache is the interface of all caches.
/// An AbstractCache is the interface of all caches.
{
public:
FIFOEvent<const KeyValueArgs<TKey, TValue>, TEventMutex> Add;
@@ -83,7 +83,7 @@ public:
void update(const TKey& key, const TValue& val)
/// Adds the key value pair to the cache. Note that adding a NULL SharedPtr will fail!
/// If for the key already an entry exists, it will be overwritten.
/// The difference to add is that no remove or add events are thrown in this case,
/// The difference to add is that no remove or add events are thrown in this case,
/// just a simply silent update is performed
/// If the key does not exist the behavior is equal to add, ie. an add event is thrown
{
@@ -103,7 +103,7 @@ public:
void update(const TKey& key, SharedPtr<TValue > val)
/// Adds the key value pair to the cache. Note that adding a NULL SharedPtr will fail!
/// If for the key already an entry exists, it will be overwritten.
/// The difference to add is that no remove or add events are thrown in this case,
/// The difference to add is that no remove or add events are thrown in this case,
/// just an Update is thrown
/// If the key does not exist the behavior is equal to add, ie. an add event is thrown
{
@@ -176,6 +176,23 @@ public:
return result;
}
template <typename Fn>
void forEach(Fn&& fn) const
/// Iterates over all key-value pairs in the
/// cache, using a functor or lambda expression.
///
/// The given functor must take the key and value
/// as parameters. Note that the value is passed
/// as the actual value (or reference),
/// not a Poco::SharedPtr.
{
typename TMutex::ScopedLock lock(_mutex);
for (const auto& p: _data)
{
fn(p.first, *p.second);
}
}
protected:
mutable FIFOEvent<ValidArgs<TKey>> IsValid;
mutable FIFOEvent<KeySet> Replace;
@@ -214,7 +231,7 @@ protected:
KeyValueArgs<TKey, TValue> args(key, val);
Add.notify(this, args);
_data.insert(std::make_pair(key, SharedPtr<TValue>(new TValue(val))));
doReplace();
}
@@ -228,7 +245,7 @@ protected:
KeyValueArgs<TKey, TValue> args(key, *val);
Add.notify(this, args);
_data.insert(std::make_pair(key, val));
doReplace();
}
@@ -248,7 +265,7 @@ protected:
Update.notify(this, args);
it->second = SharedPtr<TValue>(new TValue(val));
}
doReplace();
}
@@ -268,11 +285,11 @@ protected:
Update.notify(this, args);
it->second = val;
}
doReplace();
}
void doRemove(Iterator it)
void doRemove(Iterator it)
/// Removes an entry from the cache. If the entry is not found
/// the remove is ignored.
{
@@ -300,7 +317,7 @@ protected:
return result;
}
SharedPtr<TValue> doGet(const TKey& key)
SharedPtr<TValue> doGet(const TKey& key)
/// Returns a SharedPtr of the cache entry, returns 0 if for
/// the key no value was found
{
@@ -308,7 +325,7 @@ protected:
SharedPtr<TValue> result;
if (it != _data.end())
{
{
// inform all strategies that a read-access to an element happens
Get.notify(this, key);
// ask all strategies if the key is valid

View File

@@ -38,7 +38,7 @@ public:
virtual void notify(Notification* pNf) const = 0;
virtual bool equals(const AbstractObserver& observer) const = 0;
virtual bool accepts(Notification* pNf) const = 0;
virtual bool accepts(Notification* pNf, const char* pName = 0) const = 0;
virtual AbstractObserver* clone() const = 0;
virtual void disable() = 0;
};

View File

@@ -159,7 +159,7 @@ public:
if (newCapacity > _capacity)
{
T* ptr = new T[newCapacity];
if (preserveContent)
if (preserveContent && _ptr)
{
std::memcpy(ptr, _ptr, _used * sizeof(T));
}
@@ -191,7 +191,7 @@ public:
if (newCapacity > 0)
{
ptr = new T[newCapacity];
if (preserveContent)
if (preserveContent && _ptr)
{
std::size_t newSz = _used < newCapacity ? _used : newCapacity;
std::memcpy(ptr, _ptr, newSz * sizeof(T));
@@ -266,10 +266,11 @@ public:
{
if (_used == other._used)
{
if (std::memcmp(_ptr, other._ptr, _used * sizeof(T)) == 0)
if (_ptr && other._ptr && std::memcmp(_ptr, other._ptr, _used * sizeof(T)) == 0)
{
return true;
}
else return _used == 0;
}
return false;
}

View File

@@ -116,7 +116,7 @@ public:
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Pair<std::string>);
@@ -131,7 +131,7 @@ public:
{
throw BadCastException("Cannot cast Pair type to Int16");
}
void convert(Int32& val) const
{
throw BadCastException("Cannot cast Pair type to Int32");
@@ -151,7 +151,7 @@ public:
{
throw BadCastException("Cannot cast Pair type to UInt16");
}
void convert(UInt32& val) const
{
throw BadCastException("Cannot cast Pair type to UInt32");
@@ -189,9 +189,9 @@ public:
val.append("{ ");
Var key(_val.first());
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, _val.second());
val.append(" }");
val.append(" }");
}
void convert(Poco::DateTime&) const
@@ -213,7 +213,7 @@ public:
{
return cloneHolder(pVarHolder, _val);
}
const Pair<std::string>& value() const
{
return _val;
@@ -265,7 +265,7 @@ public:
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(Pair<int>);
@@ -280,7 +280,7 @@ public:
{
throw BadCastException("Cannot cast Pair type to Int16");
}
void convert(Int32& val) const
{
throw BadCastException("Cannot cast Pair type to Int32");
@@ -300,7 +300,7 @@ public:
{
throw BadCastException("Cannot cast Pair type to UInt16");
}
void convert(UInt32& val) const
{
throw BadCastException("Cannot cast Pair type to UInt32");
@@ -338,9 +338,9 @@ public:
val.append("{ ");
Var key(_val.first());
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, _val.second());
val.append(" }");
val.append(" }");
}
void convert(Poco::DateTime&) const
@@ -362,7 +362,7 @@ public:
{
return cloneHolder(pVarHolder, _val);
}
const Pair<int>& value() const
{
return _val;

View File

@@ -172,7 +172,7 @@ public:
{
_data.clear();
}
inline void swap(Struct& other)
/// Swap content of Struct with another Struct
{
@@ -264,7 +264,7 @@ public:
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(ValueType);
@@ -279,7 +279,7 @@ public:
{
throw BadCastException("Cannot cast Struct type to Int16");
}
void convert(Int32&) const
{
throw BadCastException("Cannot cast Struct type to Int32");
@@ -299,7 +299,7 @@ public:
{
throw BadCastException("Cannot cast Struct type to UInt16");
}
void convert(UInt32&) const
{
throw BadCastException("Cannot cast Struct type to UInt32");
@@ -339,7 +339,7 @@ public:
{
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, it->second);
++it;
}
@@ -348,7 +348,7 @@ public:
val.append(", ");
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, it->second);
}
val.append(" }");
@@ -373,7 +373,7 @@ public:
{
return cloneHolder(pVarHolder, _val);
}
const ValueType& value() const
{
return _val;
@@ -413,7 +413,7 @@ public:
{
return false;
}
std::size_t size() const
{
return _val.size();
@@ -525,7 +525,7 @@ public:
{
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, it->second);
++it;
}
@@ -534,7 +534,7 @@ public:
val.append(", ");
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, it->second);
}
val.append(" }");
@@ -711,7 +711,7 @@ public:
{
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, it->second);
++it;
}
@@ -720,7 +720,7 @@ public:
val.append(", ");
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, it->second);
}
val.append(" }");
@@ -897,7 +897,7 @@ public:
{
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, it->second);
++it;
}
@@ -906,7 +906,7 @@ public:
val.append(", ");
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(" : ");
val.append(": ");
Impl::appendJSONValue(val, it->second);
}
val.append(" }");

View File

@@ -523,6 +523,9 @@ public:
bool isDateTime() const;
/// Returns true if stored value represents a date/time.
bool isUUID() const;
/// Returns true if stored value is a Poco::UUID.
std::size_t size() const;
/// Returns the size of this Var.
/// This function returns 0 when Var is empty, 1 for POD or the size (i.e. length)
@@ -737,7 +740,7 @@ inline const std::type_info& Var::type() const
inline Var::ConstIterator Var::begin() const
{
if (isEmpty()) return ConstIterator(const_cast<Var*>(this), true);
if (size() == 0) return ConstIterator(const_cast<Var*>(this), true);
return ConstIterator(const_cast<Var*>(this), false);
}
@@ -749,7 +752,7 @@ inline Var::ConstIterator Var::end() const
inline Var::Iterator Var::begin()
{
if (isEmpty()) return Iterator(const_cast<Var*>(this), true);
if (size() == 0) return Iterator(const_cast<Var*>(this), true);
return Iterator(const_cast<Var*>(this), false);
}
@@ -896,6 +899,13 @@ inline bool Var::isDateTime() const
}
inline bool Var::isUUID() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isUUID() : false;
}
inline std::size_t Var::size() const
{
VarHolder* pHolder = content();

View File

@@ -31,6 +31,7 @@
#include "Poco/UnicodeConverter.h"
#include "Poco/UTFString.h"
#include "Poco/UTF8String.h"
#include "Poco/UUID.h"
#include "Poco/Any.h"
#include "Poco/Exception.h"
#include <vector>
@@ -135,47 +136,51 @@ public:
/// (typeid) for the stored content.
virtual void convert(Int8& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(Int16& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(Int32& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(Int64& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(UInt8& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(UInt16& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(UInt32& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(UInt64& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(DateTime& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(LocalDateTime& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(Timestamp& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(UUID& val) const;
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
#ifndef POCO_INT64_IS_LONG
@@ -189,96 +194,100 @@ public:
#else
virtual void convert(long long& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to suport the conversion.
virtual void convert(unsigned long long & val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to suport the conversion.
#endif
virtual void convert(bool& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(float& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(double& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(char& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(std::string& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual void convert(Poco::UTF16String& val) const;
/// Throws BadCastException. Must be overriden in a type
/// Throws BadCastException. Must be overridden in a type
/// specialization in order to support the conversion.
virtual bool isArray() const;
/// Returns true.
virtual bool isVector() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isList() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isDeque() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isStruct() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isOrdered() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isInteger() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isSigned() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isNumeric() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isBoolean() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isString() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isDate() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isTime() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isDateTime() const;
/// Returns false. Must be properly overriden in a type
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual bool isUUID() const;
/// Returns false. Must be properly overridden in a type
/// specialization in order to support the diagnostic.
virtual std::size_t size() const;
/// Returns 1 iff Var is not empty or this function overriden.
/// Returns 1 iff Var is not empty or this function overridden.
protected:
VarHolder();
@@ -519,8 +528,16 @@ inline void VarHolder::convert(Timestamp& /*val*/) const
throw BadCastException("Can not convert to Timestamp");
}
inline void VarHolder::convert(UUID& /*val*/) const
{
throw BadCastException("Can not convert to UUID");
}
#ifndef POCO_INT64_IS_LONG
inline void VarHolder::convert(long& val) const
{
Int32 tmp;
@@ -536,8 +553,10 @@ inline void VarHolder::convert(unsigned long& val) const
val = tmp;
}
#else
inline void VarHolder::convert(long long& /*val*/) const
{
throw BadCastException("Can not convert to long long");
@@ -549,8 +568,10 @@ inline void VarHolder::convert(unsigned long long& /*val*/) const
throw BadCastException("Can not convert to unsigned long long");
}
#endif
inline void VarHolder::convert(bool& /*val*/) const
{
throw BadCastException("Can not convert to bool");
@@ -671,6 +692,12 @@ inline bool VarHolder::isDateTime() const
}
inline bool VarHolder::isUUID() const
{
return false;
}
inline std::size_t VarHolder::size() const
{
return 1u;
@@ -1026,7 +1053,6 @@ public:
return std::numeric_limits<Int16>::is_specialized;
}
bool isString() const
{
return false;
@@ -2750,6 +2776,11 @@ public:
ts = tmp.timestamp();
}
void convert(UUID& uuid) const
{
uuid.parse(_val);
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
{
return cloneHolder(pVarHolder, _val);
@@ -3917,6 +3948,11 @@ public:
return true;
}
bool isUUID() const
{
return false;
}
private:
VarHolderImpl();
VarHolderImpl(const VarHolderImpl&);
@@ -4047,6 +4083,11 @@ public:
return true;
}
bool isUUID() const
{
return false;
}
private:
VarHolderImpl();
VarHolderImpl(const VarHolderImpl&);
@@ -4177,6 +4218,11 @@ public:
return true;
}
bool isUUID() const
{
return false;
}
private:
VarHolderImpl();
VarHolderImpl(const VarHolderImpl&);
@@ -4186,6 +4232,102 @@ private:
};
template <>
class VarHolderImpl<UUID>: public VarHolder
{
public:
VarHolderImpl(const UUID& val): _val(val)
{
}
~VarHolderImpl()
{
}
const std::type_info& type() const
{
return typeid(UUID);
}
void convert(std::string& val) const
{
val = _val.toString();
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
{
return cloneHolder(pVarHolder, _val);
}
const UUID& value() const
{
return _val;
}
bool isArray() const
{
return false;
}
bool isStruct() const
{
return false;
}
bool isInteger() const
{
return false;
}
bool isSigned() const
{
return false;
}
bool isNumeric() const
{
return false;
}
bool isBoolean() const
{
return false;
}
bool isString() const
{
return false;
}
bool isDate() const
{
return false;
}
bool isTime() const
{
return false;
}
bool isDateTime() const
{
return false;
}
bool isUUID() const
{
return true;
}
private:
VarHolderImpl();
VarHolderImpl(const VarHolderImpl&);
VarHolderImpl& operator = (const VarHolderImpl&);
Poco::UUID _val;
};
typedef std::vector<Var> Vector;
typedef std::deque<Var> Deque;
typedef std::list<Var> List;

View File

@@ -31,35 +31,71 @@ class FPEnvironmentImpl
protected:
enum RoundingModeImpl
{
#if defined(FE_DOWNWARD)
FP_ROUND_DOWNWARD_IMPL = FE_DOWNWARD,
#else
FP_ROUND_DOWNWARD_IMPL = 0,
#endif
#if defined(FE_UPWARD)
FP_ROUND_UPWARD_IMPL = FE_UPWARD,
#else
FP_ROUND_UPWARD_IMPL = 0,
#endif
#if defined(FE_TONEAREST)
FP_ROUND_TONEAREST_IMPL = FE_TONEAREST,
#else
FP_ROUND_TONEAREST_IMPL = 0,
#endif
#if defined(FE_TOWARDZERO)
FP_ROUND_TOWARDZERO_IMPL = FE_TOWARDZERO
#else
FP_ROUND_TOWARDZERO_IMPL = 0
#endif
};
enum FlagImpl
{
#if defined(FE_DIVBYZERO)
FP_DIVIDE_BY_ZERO_IMPL = FE_DIVBYZERO,
#else
FP_DIVIDE_BY_ZERO_IMPL = 0,
#endif
#if defined(FE_INEXACT)
FP_INEXACT_IMPL = FE_INEXACT,
#else
FP_INEXACT_IMPL = 0,
#endif
#if defined(FE_OVERFLOW)
FP_OVERFLOW_IMPL = FE_OVERFLOW,
#else
FP_OVERFLOW_IMPL = 0,
#endif
#if defined(FE_UNDERFLOW)
FP_UNDERFLOW_IMPL = FE_UNDERFLOW,
#else
FP_UNDERFLOW_IMPL = 0,
#endif
#if defined(FE_INVALID)
FP_INVALID_IMPL = FE_INVALID
#else
FP_INVALID_IMPL = 0
#endif
};
FPEnvironmentImpl();
FPEnvironmentImpl(const FPEnvironmentImpl& env);
~FPEnvironmentImpl();
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
void keepCurrentImpl();
void keepCurrentImpl();
static void clearFlagsImpl();
static bool isFlagImpl(FlagImpl flag);
static bool isFlagImpl(FlagImpl flag);
static void setRoundingModeImpl(RoundingModeImpl mode);
static RoundingModeImpl getRoundingModeImpl();
static bool isInfiniteImpl(float value);
static bool isInfiniteImpl(float value);
static bool isInfiniteImpl(double value);
static bool isInfiniteImpl(long double value);
static bool isNaNImpl(float value);
static bool isNaNImpl(float value);
static bool isNaNImpl(double value);
static bool isNaNImpl(long double value);
static float copySignImpl(float target, float source);
static float copySignImpl(float target, float source);
static double copySignImpl(double target, double source);
static long double copySignImpl(long double target, long double source);
@@ -73,37 +109,61 @@ private:
//
inline bool FPEnvironmentImpl::isInfiniteImpl(float value)
{
#if POCO_OS == POCO_OS_AIX
return ::isinf(value) != 0;
#else
return std::isinf(value) != 0;
#endif
}
inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
{
#if POCO_OS == POCO_OS_AIX
return ::isinf(value) != 0;
#else
return std::isinf(value) != 0;
#endif
}
inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
{
#if POCO_OS == POCO_OS_AIX
return ::isinf((double) value) != 0;
#else
return std::isinf((double) value) != 0;
#endif
}
inline bool FPEnvironmentImpl::isNaNImpl(float value)
{
#if POCO_OS == POCO_OS_AIX
return ::isnan(value) != 0;
#else
return std::isnan(value) != 0;
#endif
}
inline bool FPEnvironmentImpl::isNaNImpl(double value)
{
#if POCO_OS == POCO_OS_AIX
return ::isnan(value) != 0;
#else
return std::isnan(value) != 0;
#endif
}
inline bool FPEnvironmentImpl::isNaNImpl(long double value)
{
#if POCO_OS == POCO_OS_AIX
return ::isnan((double) value) != 0;
#else
return std::isnan((double) value) != 0;
#endif
}

View File

@@ -27,7 +27,7 @@ namespace Poco {
class FileImpl
{
protected:
enum Options
enum Options
{
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
};
@@ -65,6 +65,7 @@ protected:
FileSizeImpl totalSpaceImpl() const;
FileSizeImpl usableSpaceImpl() const;
FileSizeImpl freeSpaceImpl() const;
static void handleLastErrorImpl(int err, const std::string& path);
static void handleLastErrorImpl(const std::string& path);
private:

View File

@@ -45,7 +45,7 @@ public:
MemoryPool(std::size_t blockSize, int preAlloc = 0, int maxAlloc = 0);
/// Creates a MemoryPool for blocks with the given blockSize.
/// The number of blocks given in preAlloc are preallocated.
~MemoryPool();
void* get();
@@ -54,16 +54,16 @@ public:
///
/// If maxAlloc blocks are already allocated, an
/// OutOfMemoryException is thrown.
void release(void* ptr);
/// Releases a memory block and returns it to the pool.
std::size_t blockSize() const;
/// Returns the block size.
int allocated() const;
/// Returns the number of allocated blocks.
int available() const;
/// Returns the number of available blocks in the pool.
@@ -71,16 +71,16 @@ private:
MemoryPool();
MemoryPool(const MemoryPool&);
MemoryPool& operator = (const MemoryPool&);
void clear();
enum
{
BLOCK_RESERVE = 128
};
typedef std::vector<char*> BlockVec;
std::size_t _blockSize;
int _maxAlloc;
int _allocated;
@@ -94,7 +94,7 @@ private:
//
// Macro defining the default initial size of any
// FastMemoryPool; can be overriden by specifying
// FastMemoryPool; can be overridden by specifying
// FastMemoryPool pre-alloc at runtime.
#define POCO_FAST_MEMORY_POOL_PREALLOC 1000

View File

@@ -94,9 +94,9 @@ public:
return pObs && pObs->_pObject == _pObject && pObs->_method == _method;
}
bool accepts(Notification* pNf) const
bool accepts(Notification* pNf, const char* pName = 0) const
{
return dynamic_cast<N*>(pNf) != 0;
return dynamic_cast<N*>(pNf) && (!pName || pNf->name() == pName);
}
AbstractObserver* clone() const

View File

@@ -84,7 +84,7 @@ public:
Nullable(C&& value):
/// Creates a Nullable by moving the given value.
_value(value),
_value(std::forward<C>(value)),
_isNull(false),
_null()
{

View File

@@ -47,7 +47,7 @@ public:
{
return new C;
}
bool validateObject(P pObject)
/// Checks whether the object is still valid
/// and can be reused.
@@ -60,14 +60,14 @@ public:
{
return true;
}
void activateObject(P pObject)
/// Called before an object is handed out by the pool.
/// Also called for newly created objects, before
/// they are given out for the first time.
{
}
void deactivateObject(P pObject)
/// Called after an object has been given back to the
/// pool and the object is still valid (a prior call
@@ -77,7 +77,7 @@ public:
/// must not throw an exception.
{
}
void destroyObject(P pObject)
/// Destroy an object.
///
@@ -97,20 +97,20 @@ public:
{
return new C;
}
bool validateObject(Poco::AutoPtr<C> pObject)
{
return true;
}
void activateObject(Poco::AutoPtr<C> pObject)
{
}
void deactivateObject(Poco::AutoPtr<C> pObject)
{
}
void destroyObject(Poco::AutoPtr<C> pObject)
{
}
@@ -125,20 +125,20 @@ public:
{
return new C;
}
bool validateObject(Poco::SharedPtr<C> pObject)
{
return true;
}
void activateObject(Poco::SharedPtr<C> pObject)
{
}
void deactivateObject(Poco::SharedPtr<C> pObject)
{
}
void destroyObject(Poco::SharedPtr<C> pObject)
{
}
@@ -177,7 +177,7 @@ public:
{
poco_assert (capacity <= peakCapacity);
}
ObjectPool(const F& factory, std::size_t capacity, std::size_t peakCapacity):
/// Creates a new ObjectPool with the given PoolableObjectFactory,
/// capacity and peak capacity. The PoolableObjectFactory must have
@@ -189,7 +189,7 @@ public:
{
poco_assert (capacity <= peakCapacity);
}
~ObjectPool()
/// Destroys the ObjectPool.
{
@@ -205,7 +205,7 @@ public:
poco_unexpected();
}
}
P borrowObject(long timeoutMilliseconds = 0)
/// Obtains an object from the pool, or creates a new object if
/// possible.
@@ -217,22 +217,15 @@ public:
{
Poco::FastMutex::ScopedLock lock(_mutex);
if (!_pool.empty())
{
P pObject = _pool.back();
_pool.pop_back();
return activateObject(pObject);
}
if (_size >= _peakCapacity)
if (_size >= _peakCapacity && _pool.empty())
{
if (timeoutMilliseconds == 0)
{
return 0;
}
while (_size >= _peakCapacity)
while (_size >= _peakCapacity && _pool.empty())
{
if ( !_availableCondition.tryWait(_mutex, timeoutMilliseconds))
if (!_availableCondition.tryWait(_mutex, timeoutMilliseconds))
{
// timeout
return 0;
@@ -240,10 +233,19 @@ public:
}
}
if (!_pool.empty())
{
P pObject = _pool.back();
_pool.pop_back();
return activateObject(pObject);
}
// _size < _peakCapacity
P pObject = _factory.createObject();
activateObject(pObject);
_size++;
return pObject;
}
@@ -260,6 +262,7 @@ public:
try
{
_pool.push_back(pObject);
_availableCondition.signal();
return;
}
catch (...)
@@ -276,19 +279,19 @@ public:
{
return _capacity;
}
std::size_t peakCapacity() const
{
return _peakCapacity;
}
std::size_t size() const
{
Poco::FastMutex::ScopedLock lock(_mutex);
return _size;
}
std::size_t available() const
{
Poco::FastMutex::ScopedLock lock(_mutex);
@@ -310,12 +313,12 @@ protected:
}
return pObject;
}
private:
ObjectPool();
ObjectPool(const ObjectPool&);
ObjectPool& operator = (const ObjectPool&);
F _factory;
std::size_t _capacity;
std::size_t _peakCapacity;

View File

@@ -92,9 +92,9 @@ public:
return pObs && pObs->_pObject == _pObject && pObs->_method == _method;
}
bool accepts(Notification* pNf) const
bool accepts(Notification* pNf, const char* pName = 0) const
{
return dynamic_cast<N*>(pNf) != 0;
return dynamic_cast<N*>(pNf) && (!pName || pNf->name() == pName);
}
AbstractObserver* clone() const

View File

@@ -69,7 +69,7 @@ public:
Optional(C&& value):
/// Creates a Optional by moving the given value.
_value(value),
_value(std::forward<C>(value)),
_isSpecified(true)
{
}

View File

@@ -45,6 +45,7 @@ class Foundation_API PatternFormatter: public Formatter
/// * %I - message thread identifier (numeric)
/// * %N - node or host name
/// * %U - message source file path (empty string if not set)
/// * %O - message source file filename (empty string if not set)
/// * %u - message source line number (0 if not set)
/// * %w - message date/time abbreviated weekday (Mon, Tue, ...)
/// * %W - message date/time full weekday (Monday, Tuesday, ...)
@@ -143,6 +144,8 @@ private:
void parsePriorityNames();
static const std::string DEFAULT_PRIORITY_NAMES;
std::vector<PatternAction> _patternActions;
bool _localTime;
std::string _pattern;

View File

@@ -135,6 +135,7 @@
#define POCO_ARCH_AARCH64 0x0f
#define POCO_ARCH_ARM64 0x0f // same as POCO_ARCH_AARCH64
#define POCO_ARCH_RISCV64 0x10
#define POCO_ARCH_RISCV32 0x11
#if defined(__ALPHA) || defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA)
@@ -225,9 +226,14 @@
#elif defined(__AARCH64EB__)
#define POCO_ARCH POCO_ARCH_AARCH64
#define POCO_ARCH_BIG_ENDIAN 1
#elif defined(__riscv) && (__riscv_xlen == 64)
#define POCO_ARCH POCO_ARCH_RISCV64
#define POCO_ARCH_LITTLE_ENDIAN 1
#elif defined(__riscv)
#if (__riscv_xlen == 64)
#define POCO_ARCH POCO_ARCH_RISCV64
#define POCO_ARCH_LITTLE_ENDIAN 1
#elif(__riscv_xlen == 32)
#define POCO_ARCH POCO_ARCH_RISCV32
#define POCO_ARCH_LITTLE_ENDIAN 1
#endif
#endif
@@ -237,6 +243,7 @@
#define POCO_COMPILER_MSVC
#elif defined (__GNUC__)
#define POCO_COMPILER_GCC
// MinGW defines __GNUC__ so GCC and MinGW can coexist
#if defined (__MINGW32__) || defined (__MINGW64__)
#define POCO_COMPILER_MINGW
#endif

View File

@@ -22,10 +22,6 @@
#include "Poco/UnWindows.h"
#if defined(_MSC_VER) && !defined(POCO_MSVC_SECURE_WARNINGS) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE
#endif
// Verify that we're built with the multithreaded
// versions of the runtime libraries
@@ -78,7 +74,6 @@
#pragma warning(disable:4351) // new behavior: elements of array '...' will be default initialized
#pragma warning(disable:4355) // 'this' : used in base member initializer list
#pragma warning(disable:4675) // resolved overload was found by argument-dependent lookup
#pragma warning(disable:4996) // VC++ 8.0 deprecation warnings
#endif

View File

@@ -480,7 +480,7 @@ SharedPtr<T> makeShared(Args&&... args)
template <typename T>
SharedPtr<T, ReferenceCounter, ReleaseArrayPolicy<T>> makeSharedArray(std::size_t size)
{
return new SharedPtr<T, ReferenceCounter, ReleaseArrayPolicy<T>>(new T[size]);
return SharedPtr<T, ReferenceCounter, ReleaseArrayPolicy<T>>(new T[size]);
}

View File

@@ -55,11 +55,11 @@
//
// In this scenario, std::ios::init() is called twice
// (the first time by the MyIOS constructor, the second
// time by the std::istream constructor), resulting in
// two locale objects being allocated, the pointer second
// one overwriting the pointer to the first one and thus
// time by the std::istream constructor), resulting in
// two locale objects being allocated, the pointer second
// one overwriting the pointer to the first one and thus
// causing a memory leak.
//
//
// The workaround is to call init() only once for each
// stream object - by the istream, ostream or iostream
// constructor, and not calling init() in ios-derived
@@ -77,6 +77,9 @@
# define POCO_IOS_INIT_HACK 1
// QNX with Dinkumware but not GNU C++ Library
# elif defined(__QNX__) && !defined(__GLIBCPP__)
# define POCO_IOS_INIT_HACK 1
// Linux with Clang libc++
# elif defined(__linux) && defined(_LIBCPP_VERSION)
# define POCO_IOS_INIT_HACK 1
# endif
#endif

View File

@@ -58,7 +58,7 @@ S trimRight(const S& str)
/// Returns a copy of str with all trailing
/// whitespace removed.
{
int pos = int(str.size()) - 1;
std::ptrdiff_t pos = static_cast<std::ptrdiff_t>(str.size()) - 1;
while (pos >= 0 && Ascii::isSpace(str[pos])) --pos;
return S(str, 0, pos + 1);
@@ -69,7 +69,7 @@ template <class S>
S& trimRightInPlace(S& str)
/// Removes all trailing whitespace in str.
{
int pos = int(str.size()) - 1;
std::ptrdiff_t pos = static_cast<std::ptrdiff_t>(str.size()) - 1;
while (pos >= 0 && Ascii::isSpace(str[pos])) --pos;
str.resize(pos + 1);
@@ -83,8 +83,8 @@ S trim(const S& str)
/// Returns a copy of str with all leading and
/// trailing whitespace removed.
{
int first = 0;
int last = int(str.size()) - 1;
std::ptrdiff_t first = 0;
std::ptrdiff_t last = static_cast<std::ptrdiff_t>(str.size()) - 1;
while (first <= last && Ascii::isSpace(str[first])) ++first;
while (last >= first && Ascii::isSpace(str[last])) --last;
@@ -97,8 +97,8 @@ template <class S>
S& trimInPlace(S& str)
/// Removes all leading and trailing whitespace in str.
{
int first = 0;
int last = int(str.size()) - 1;
std::ptrdiff_t first = 0;
std::ptrdiff_t last = static_cast<std::ptrdiff_t>(str.size()) - 1;
while (first <= last && Ascii::isSpace(str[first])) ++first;
while (last >= first && Ascii::isSpace(str[last])) --last;

View File

@@ -41,7 +41,7 @@ class Foundation_API ThreadPool
/// Threads in a thread pool are re-used once they become
/// available again.
/// The thread pool always keeps a minimum number of threads
/// running. If the demans for threads increases, additional
/// running. If the demand for threads increases, additional
/// threads are created. Once the demand for threads sinks
/// again, no-longer used threads are stopped and removed
/// from the pool.
@@ -72,8 +72,8 @@ public:
~ThreadPool();
/// Currently running threads will remain active
/// until they complete.
/// until they complete.
void addCapacity(int n);
/// Increases (or decreases, if n is negative)
/// the maximum number of threads.
@@ -126,7 +126,7 @@ public:
/// If used, this method should be the last action before
/// the thread pool is deleted.
///
/// Note: If a thread fails to stop within 10 seconds
/// Note: If a thread fails to stop within 10 seconds
/// (due to a programming error, for example), the
/// underlying thread object will not be deleted and
/// this method will return anyway. This allows for a

View File

@@ -287,7 +287,7 @@ public:
/// such as in a Windows path containing a drive letter, a dot segment (./)
/// is prepended in accordance with section 3.3 of RFC 3986.
void getPathSegments(std::vector<std::string>& segments);
void getPathSegments(std::vector<std::string>& segments) const;
/// Places the single path segments (delimited by slashes) into the
/// given vector.

View File

@@ -35,7 +35,7 @@
// Ax: alpha releases
// Bx: beta releases
//
#define POCO_VERSION 0x010A0100
#define POCO_VERSION 0x010B0000
#endif // Foundation_Version_INCLUDED