1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-09-19 02:37:18 +02:00

Update POCO library.

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

View File

@@ -38,7 +38,7 @@ public:
int convert(int ch, unsigned char* bytes, int length) const;
int queryConvert(const unsigned char* bytes, int length) const;
int sequenceLength(const unsigned char* bytes, int length) const;
private:
static const char* _names[];
static const CharacterMap _charMap;

View File

@@ -24,7 +24,7 @@
namespace Poco {
template <class TArgs>
template <class TArgs>
class AbstractDelegate
/// Base class for Delegate and Expire.
{
@@ -37,7 +37,7 @@ public:
{
}
virtual ~AbstractDelegate()
virtual ~AbstractDelegate()
{
}
@@ -54,7 +54,7 @@ public:
virtual void disable() = 0;
/// Disables the delegate, which is done prior to removal.
virtual const AbstractDelegate* unwrap() const
/// Returns the unwrapped delegate. Must be overridden by decorators
/// like Expire.
@@ -64,7 +64,7 @@ public:
};
template <>
template <>
class AbstractDelegate<void>
/// Base class for Delegate and Expire.
{
@@ -77,7 +77,7 @@ public:
{
}
virtual ~AbstractDelegate()
virtual ~AbstractDelegate()
{
}
@@ -94,7 +94,7 @@ public:
virtual void disable() = 0;
/// Disables the delegate, which is done prior to removal.
virtual const AbstractDelegate* unwrap() const
/// Returns the unwrapped delegate. Must be overridden by decorators
/// like Expire.

View File

@@ -33,7 +33,7 @@ public:
AbstractObserver();
AbstractObserver(const AbstractObserver& observer);
virtual ~AbstractObserver();
AbstractObserver& operator = (const AbstractObserver& observer);
virtual void notify(Notification* pNf) const = 0;

View File

@@ -25,7 +25,7 @@
namespace Poco {
template <class TArgs>
template <class TArgs>
class AbstractPriorityDelegate: public AbstractDelegate<TArgs>
/// Base class for PriorityDelegate and PriorityExpire.
///
@@ -43,7 +43,7 @@ public:
{
}
virtual ~AbstractPriorityDelegate()
virtual ~AbstractPriorityDelegate()
{
}

View File

@@ -27,9 +27,9 @@
namespace Poco {
template <class TKey, class TValue>
template <class TKey, class TValue>
class AbstractStrategy
/// An AbstractStrategy is the interface for all strategies.
/// An AbstractStrategy is the interface for all strategies.
{
public:
AbstractStrategy()
@@ -46,7 +46,7 @@ public:
onRemove(pSender,args.key());
onAdd(pSender, args);
}
virtual void onAdd(const void* pSender, const KeyValueArgs <TKey, TValue>& key) = 0;
/// Adds the key to the strategy.
/// If for the key already an entry exists, an exception will be thrown.

View File

@@ -55,7 +55,7 @@ public:
~AccessExpirationDecorator()
{
}
const Poco::Timespan& getTimeout() const
{
return _span;

View File

@@ -26,23 +26,23 @@ namespace Poco {
template <
class TKey,
class TValue,
class TMutex = FastMutex,
class TKey,
class TValue,
class TMutex = FastMutex,
class TEventMutex = FastMutex
>
>
class AccessExpireCache: public AbstractCache<TKey, TValue, AccessExpireStrategy<TKey, TValue>, TMutex, TEventMutex>
/// An AccessExpireCache caches entries for a fixed time period (per default 10 minutes).
/// Entries expire when they are not accessed with get() during this time period. Each access resets
/// the start time for expiration.
/// Be careful when using an AccessExpireCache. A cache is often used
/// like cache.has(x) followed by cache.get x). Note that it could happen
/// like cache.has(x) followed by cache.get(x). Note that it could happen
/// that the "has" call works, then the current execution thread gets descheduled, time passes,
/// the entry gets invalid, thus leading to an empty SharedPtr being returned
/// the entry gets invalid, thus leading to an empty SharedPtr being returned
/// when "get" is invoked.
{
public:
AccessExpireCache(Timestamp::TimeDiff expire = 600000):
AccessExpireCache(Timestamp::TimeDiff expire = 600000):
AbstractCache<TKey, TValue, AccessExpireStrategy<TKey, TValue>, TMutex, TEventMutex>(AccessExpireStrategy<TKey, TValue>(expire))
{
}

View File

@@ -27,10 +27,10 @@
namespace Poco {
template <
template <
class TKey,
class TValue,
class TMutex = FastMutex,
class TMutex = FastMutex,
class TEventMutex = FastMutex
>
class AccessExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>

View File

@@ -21,6 +21,7 @@
#include "Poco/Foundation.h"
#include "Poco/Runnable.h"
#include "Poco/Thread.h"
#include "Poco/Event.h"
#include "Poco/ActiveStarter.h"
#include "Poco/ActiveRunnable.h"
#include "Poco/NotificationQueue.h"
@@ -35,7 +36,7 @@ class Foundation_API ActiveDispatcher: protected Runnable
///
/// An active object, which is an ordinary object
/// containing ActiveMethod members, executes all
/// active methods in their own thread.
/// active methods in their own thread.
/// This behavior does not fit the "classic"
/// definition of an active object, which serializes
/// the execution of active methods (in other words,
@@ -44,7 +45,7 @@ class Foundation_API ActiveDispatcher: protected Runnable
///
/// Using this class as a base class, the serializing
/// behavior for active objects can be implemented.
///
///
/// The following example shows how this is done:
///
/// class ActiveObject: public ActiveDispatcher
@@ -86,7 +87,7 @@ public:
void cancel();
/// Cancels all queued methods.
protected:
void run();
void stop();

View File

@@ -83,7 +83,7 @@ public:
{
poco_check_ptr (pOwner);
}
ActiveResultType operator () (const ArgType& arg)
/// Invokes the ActiveMethod.
{
@@ -92,7 +92,7 @@ public:
StarterType::start(_pOwner, pRunnable);
return result;
}
ActiveMethod(const ActiveMethod& other):
_pOwner(other._pOwner),
_method(other._method)
@@ -106,7 +106,7 @@ public:
return *this;
}
void swap(ActiveMethod& other)
void swap(ActiveMethod& other) noexcept
{
std::swap(_pOwner, other._pOwner);
std::swap(_method, other._method);
@@ -175,7 +175,7 @@ public:
{
poco_check_ptr (pOwner);
}
ActiveResultType operator () (void)
/// Invokes the ActiveMethod.
{
@@ -184,7 +184,7 @@ public:
StarterType::start(_pOwner, pRunnable);
return result;
}
ActiveMethod(const ActiveMethod& other):
_pOwner(other._pOwner),
_method(other._method)
@@ -198,7 +198,7 @@ public:
return *this;
}
void swap(ActiveMethod& other)
void swap(ActiveMethod& other) noexcept
{
std::swap(_pOwner, other._pOwner);
std::swap(_method, other._method);

View File

@@ -33,7 +33,7 @@ template <class ResultType>
class ActiveResultHolder: public RefCountedObject
/// This class holds the result of an asynchronous method
/// invocation. It is used to pass the result from the
/// execution thread back to the invocation thread.
/// execution thread back to the invocation thread.
/// The class uses reference counting for memory management.
/// Do not use this class directly, use ActiveResult instead.
{
@@ -45,26 +45,26 @@ public:
/// Creates an ActiveResultHolder.
{
}
ResultType& data()
/// Returns a reference to the actual result.
{
poco_check_ptr(_pData);
return *_pData;
}
void data(ResultType* pData)
{
delete _pData;
_pData = pData;
}
void wait()
/// Pauses the caller until the result becomes available.
{
_event.wait();
}
bool tryWait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Returns true if the result became
@@ -72,7 +72,7 @@ public:
{
return _event.tryWait(milliseconds);
}
void wait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Throws a TimeoutException if the
@@ -80,20 +80,20 @@ public:
{
_event.wait(milliseconds);
}
void notify()
/// Notifies the invoking thread that the result became available.
{
_event.set();
}
bool failed() const
/// Returns true if the active method failed (and threw an exception).
/// Information about the exception can be obtained by calling error().
{
return _pExc != 0;
}
std::string error() const
/// If the active method threw an exception, a textual representation
/// of the exception is returned. An empty string is returned if the
@@ -104,21 +104,21 @@ public:
else
return std::string();
}
Exception* exception() const
/// If the active method threw an exception, a clone of the exception
/// object is returned, otherwise null.
{
return _pExc;
}
void error(const Exception& exc)
/// Sets the exception.
{
delete _pExc;
_pExc = exc.clone();
}
void error(const std::string& msg)
/// Sets the exception.
{
@@ -151,13 +151,13 @@ public:
/// Creates an ActiveResultHolder.
{
}
void wait()
/// Pauses the caller until the result becomes available.
{
_event.wait();
}
bool tryWait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Returns true if the result became
@@ -165,7 +165,7 @@ public:
{
return _event.tryWait(milliseconds);
}
void wait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Throws a TimeoutException if the
@@ -173,20 +173,20 @@ public:
{
_event.wait(milliseconds);
}
void notify()
/// Notifies the invoking thread that the result became available.
{
_event.set();
}
bool failed() const
/// Returns true if the active method failed (and threw an exception).
/// Information about the exception can be obtained by calling error().
{
return _pExc != 0;
}
std::string error() const
/// If the active method threw an exception, a textual representation
/// of the exception is returned. An empty string is returned if the
@@ -197,21 +197,21 @@ public:
else
return std::string();
}
Exception* exception() const
/// If the active method threw an exception, a clone of the exception
/// object is returned, otherwise null.
{
return _pExc;
}
void error(const Exception& exc)
/// Sets the exception.
{
delete _pExc;
_pExc = exc.clone();
}
void error(const std::string& msg)
/// Sets the exception.
{
@@ -234,8 +234,8 @@ private:
template <class RT>
class ActiveResult
/// This class holds the result of an asynchronous method
/// invocation (see class ActiveMethod). It is used to pass the
/// result from the execution thread back to the invocation thread.
/// invocation (see class ActiveMethod). It is used to pass the
/// result from the execution thread back to the invocation thread.
{
public:
typedef RT ResultType;
@@ -247,20 +247,20 @@ public:
{
poco_check_ptr (pHolder);
}
ActiveResult(const ActiveResult& result)
/// Copy constructor.
{
_pHolder = result._pHolder;
_pHolder->duplicate();
}
~ActiveResult()
/// Destroys the result.
{
_pHolder->release();
}
ActiveResult& operator = (const ActiveResult& result)
/// Assignment operator.
{
@@ -268,30 +268,30 @@ public:
swap(tmp);
return *this;
}
void swap(ActiveResult& result)
void swap(ActiveResult& result) noexcept
{
using std::swap;
swap(_pHolder, result._pHolder);
}
ResultType& data() const
/// Returns a reference to the result data.
{
return _pHolder->data();
}
void data(ResultType* pValue)
{
_pHolder->data(pValue);
}
void wait()
/// Pauses the caller until the result becomes available.
{
_pHolder->wait();
}
bool tryWait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Returns true if the result became
@@ -299,7 +299,7 @@ public:
{
return _pHolder->tryWait(milliseconds);
}
void wait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Throws a TimeoutException if the
@@ -307,20 +307,20 @@ public:
{
_pHolder->wait(milliseconds);
}
bool available() const
/// Returns true if a result is available.
{
return _pHolder->tryWait(0);
}
bool failed() const
/// Returns true if the active method failed (and threw an exception).
/// Information about the exception can be obtained by calling error().
{
return _pHolder->failed();
}
std::string error() const
/// If the active method threw an exception, a textual representation
/// of the exception is returned. An empty string is returned if the
@@ -342,14 +342,14 @@ public:
{
_pHolder->notify();
}
ResultType& data()
/// Returns a non-const reference to the result data. For internal
/// use only.
{
return _pHolder->data();
}
void error(const std::string& msg)
/// Sets the failed flag and the exception message.
{
@@ -361,7 +361,7 @@ public:
{
_pHolder->error(exc);
}
private:
ActiveResult();
@@ -373,8 +373,8 @@ private:
template <>
class ActiveResult<void>
/// This class holds the result of an asynchronous method
/// invocation (see class ActiveMethod). It is used to pass the
/// result from the execution thread back to the invocation thread.
/// invocation (see class ActiveMethod). It is used to pass the
/// result from the execution thread back to the invocation thread.
{
public:
typedef ActiveResultHolder<void> ActiveResultHolderType;
@@ -385,20 +385,20 @@ public:
{
poco_check_ptr (pHolder);
}
ActiveResult(const ActiveResult& result)
/// Copy constructor.
{
_pHolder = result._pHolder;
_pHolder->duplicate();
}
~ActiveResult()
/// Destroys the result.
{
_pHolder->release();
}
ActiveResult& operator = (const ActiveResult& result)
/// Assignment operator.
{
@@ -406,19 +406,19 @@ public:
swap(tmp);
return *this;
}
void swap(ActiveResult& result)
void swap(ActiveResult& result) noexcept
{
using std::swap;
swap(_pHolder, result._pHolder);
}
void wait()
/// Pauses the caller until the result becomes available.
{
_pHolder->wait();
}
bool tryWait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Returns true if the result became
@@ -426,7 +426,7 @@ public:
{
return _pHolder->tryWait(milliseconds);
}
void wait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Throws a TimeoutException if the
@@ -434,20 +434,20 @@ public:
{
_pHolder->wait(milliseconds);
}
bool available() const
/// Returns true if a result is available.
{
return _pHolder->tryWait(0);
}
bool failed() const
/// Returns true if the active method failed (and threw an exception).
/// Information about the exception can be obtained by calling error().
{
return _pHolder->failed();
}
std::string error() const
/// If the active method threw an exception, a textual representation
/// of the exception is returned. An empty string is returned if the
@@ -469,7 +469,7 @@ public:
{
_pHolder->notify();
}
void error(const std::string& msg)
/// Sets the failed flag and the exception message.
{
@@ -481,7 +481,7 @@ public:
{
_pHolder->error(exc);
}
private:
ActiveResult();

View File

@@ -28,7 +28,7 @@ namespace Poco {
template <class OwnerType>
class ActiveStarter
/// The default implementation of the StarterType
/// The default implementation of the StarterType
/// policy for ActiveMethod. It starts the method
/// in its own thread, obtained from the default
/// thread pool.

View File

@@ -42,24 +42,24 @@ class Activity: public Runnable
/// be stopped at any time. However, to make stopping
/// an activity work, the method implementing the
/// activity has to check periodically whether it
/// has been requested to stop, and if so, return.
/// has been requested to stop, and if so, return.
/// Activities are stopped before the object they belong to is
/// destroyed. Methods implementing activities cannot have arguments
/// or return values.
/// or return values.
///
/// Activity objects are used as follows:
///
/// class ActiveObject
/// {
/// public:
/// ActiveObject():
/// ActiveObject():
/// _activity(this, &ActiveObject::runActivity)
/// {
/// ...
/// }
///
///
/// ...
///
///
/// protected:
/// void runActivity()
/// {
@@ -88,7 +88,7 @@ public:
{
poco_check_ptr (pOwner);
}
~Activity()
/// Stops and destroys the activity.
{
@@ -102,7 +102,7 @@ public:
poco_unexpected();
}
}
void start()
/// Starts the activity by acquiring a
/// thread for it from the default thread pool.
@@ -113,7 +113,7 @@ public:
void start(ThreadPool& pool)
{
FastMutex::ScopedLock lock(_mutex);
if (!_running)
{
_done.reset();
@@ -130,19 +130,20 @@ public:
}
}
}
void stop()
/// Requests to stop the activity.
{
_stopped = true;
}
void wait()
/// Waits for the activity to complete.
{
if (_running)
{
_done.wait();
_running = false;
}
}
@@ -154,15 +155,16 @@ public:
if (_running)
{
_done.wait(milliseconds);
_running = false;
}
}
bool isStopped() const
/// Returns true if the activity has been requested to stop.
{
return _stopped;
}
bool isRunning() const
/// Returns true if the activity is running.
{
@@ -178,14 +180,12 @@ protected:
}
catch (...)
{
_running = false;
_done.set();
throw;
}
_running = false;
_done.set();
}
private:
Activity();
Activity(const Activity&);

View File

@@ -23,12 +23,13 @@
#include <cstring>
#define poco_any_assert(cond) do { if (!(cond)) std::abort(); } while (0)
namespace Poco {
class Any;
namespace Dynamic {
class Var;
@@ -38,7 +39,14 @@ template <class T> class VarHolderImpl;
}
#ifndef POCO_NO_SOO
template <class T, std::size_t S>
struct TypeSizeLE:
std::integral_constant<bool, (sizeof(T) <= S)>{};
template <class T, std::size_t S>
struct TypeSizeGT:
std::integral_constant<bool, (sizeof(T) > S)>{};
template <typename PlaceholderT, unsigned int SizeV = POCO_SMALL_OBJECT_SIZE>
@@ -51,21 +59,48 @@ union Placeholder
/// (i.e. there will be no heap-allocation). The local buffer size is one byte
/// larger - [POCO_SMALL_OBJECT_SIZE + 1], additional byte value indicating
/// where the object was allocated (0 => heap, 1 => local).
///
/// Important: for SOO builds, only same-type (or trivial both-empty no-op)
/// swap operation is allowed.
{
public:
struct Size
{
static const unsigned int value = SizeV;
enum { value = SizeV };
};
Placeholder()
Placeholder(const Placeholder&) = delete;
Placeholder(Placeholder&&) = delete;
Placeholder& operator=(const Placeholder&) = delete;
Placeholder& operator=(Placeholder&&) = delete;
#ifndef POCO_NO_SOO
Placeholder(): pHolder(0)
{
erase();
std::memset(holder, 0, sizeof(Placeholder));
}
~Placeholder()
{
destruct(false);
}
void swap(Placeholder& other) noexcept
{
if (!isEmpty() || !other.isEmpty())
std::swap(holder, other.holder);
}
void erase()
{
std::memset(holder, 0, sizeof(Placeholder));
destruct(true);
}
bool isEmpty() const
{
static char buf[SizeV+1] = {};
return 0 == std::memcmp(holder, buf, SizeV+1);
}
bool isLocal() const
@@ -73,9 +108,24 @@ public:
return holder[SizeV] != 0;
}
void setLocal(bool local) const
template<typename T, typename V,
typename std::enable_if<TypeSizeLE<T, Placeholder::Size::value>::value>::type* = nullptr>
PlaceholderT* assign(const V& value)
{
holder[SizeV] = local ? 1 : 0;
erase();
new (reinterpret_cast<PlaceholderT*>(holder)) T(value);
setLocal(true);
return reinterpret_cast<PlaceholderT*>(holder);
}
template<typename T, typename V,
typename std::enable_if<TypeSizeGT<T, Placeholder::Size::value>::value>::type* = nullptr>
PlaceholderT* assign(const V& value)
{
erase();
pHolder = new T(value);
setLocal(false);
return pHolder;
}
PlaceholderT* content() const
@@ -86,40 +136,67 @@ public:
return pHolder;
}
// MSVC71,80 won't extend friendship to nested class (Any::Holder)
#if !defined(POCO_MSVC_VERSION) || (defined(POCO_MSVC_VERSION) && (POCO_MSVC_VERSION > 80))
private:
#endif
typedef typename std::aligned_storage<SizeV + 1>::type AlignerType;
typedef typename std::aligned_storage<SizeV+1>::type AlignerType;
PlaceholderT* pHolder;
mutable char holder[SizeV + 1];
AlignerType aligner;
friend class Any;
friend class Dynamic::Var;
friend class Dynamic::VarHolder;
template <class> friend class Dynamic::VarHolderImpl;
};
#else // !POCO_NO_SOO
template <typename PlaceholderT>
union Placeholder
/// ValueHolder union (used by Poco::Any and Poco::Dynamic::Var for small
/// object optimization, when enabled).
///
/// If Holder<Type> fits into POCO_SMALL_OBJECT_SIZE bytes of storage,
/// it will be placement-new-allocated into the local buffer
/// (i.e. there will be no heap-allocation). The local buffer size is one byte
/// larger - [POCO_SMALL_OBJECT_SIZE + 1], additional byte value indicating
/// where the object was allocated (0 => heap, 1 => local).
{
public:
Placeholder ()
void setLocal(bool local) const
{
holder[SizeV] = local ? 1 : 0;
}
void destruct(bool clear)
{
if (!isEmpty())
{
if (!isLocal())
delete pHolder;
else
reinterpret_cast<PlaceholderT*>(holder)->~PlaceholderT();
if (clear) std::memset(holder, 0, sizeof(Placeholder));
}
}
mutable unsigned char holder[SizeV+1];
AlignerType aligner;
#else // POCO_NO_SOO
Placeholder(): pHolder(0)
{
}
~Placeholder()
{
delete pHolder;
}
void swap(Placeholder& other) noexcept
{
std::swap(pHolder, other.pHolder);
}
void erase()
{
delete pHolder;
pHolder = 0;
}
bool isEmpty() const
{
return 0 == pHolder;
}
bool isLocal() const
{
return false;
}
template <typename T, typename V>
PlaceholderT* assign(const V& value)
{
erase();
return pHolder = new T(value);
}
PlaceholderT* content() const
@@ -127,25 +204,14 @@ public:
return pHolder;
}
// MSVC71,80 won't extend friendship to nested class (Any::Holder)
#if !defined(POCO_MSVC_VERSION) || (defined(POCO_MSVC_VERSION) && (POCO_MSVC_VERSION > 80))
private:
#endif
#endif // POCO_NO_SOO
PlaceholderT* pHolder;
friend class Any;
friend class Dynamic::Var;
friend class Dynamic::VarHolder;
template <class> friend class Dynamic::VarHolderImpl;
};
#endif // POCO_NO_SOO
class Any
/// An Any class represents a general type and is capable of storing any type, supporting type-safe extraction
/// Any class represents a general type and is capable of storing any type, supporting type-safe extraction
/// of the internally stored data.
///
/// Code taken from the Boost 1.33.1 library. Original copyright by Kevlin Henney. Modified for Poco
@@ -156,8 +222,6 @@ class Any
{
public:
#ifndef POCO_NO_SOO
Any()
/// Creates an empty any type.
{
@@ -185,41 +249,31 @@ public:
/// Destructor. If Any is locally held, calls ValueHolder destructor;
/// otherwise, deletes the placeholder from the heap.
{
if (!empty())
{
if (_valueHolder.isLocal())
destruct();
else
delete content();
}
}
Any& swap(Any& other)
Any& swap(Any& other) noexcept
/// Swaps the content of the two Anys.
///
/// When small object optimization is enabled, swap only
/// has no-throw guarantee when both (*this and other)
/// objects are allocated on the heap.
/// If an exception occurs during swapping, the program
/// execution is aborted.
{
if (this == &other) return *this;
if (!_valueHolder.isLocal() && !other._valueHolder.isLocal())
{
std::swap(_valueHolder.pHolder, other._valueHolder.pHolder);
_valueHolder.swap(other._valueHolder);
}
else
{
Any tmp(*this);
try
{
if (_valueHolder.isLocal()) destruct();
Any tmp(*this);
construct(other);
other = tmp;
}
catch (...)
{
construct(tmp);
throw;
std::abort();
}
}
@@ -252,11 +306,10 @@ public:
bool empty() const
/// Returns true if the Any is empty.
{
char buf[POCO_SMALL_OBJECT_SIZE] = { 0 };
return 0 == std::memcmp(_valueHolder.holder, buf, POCO_SMALL_OBJECT_SIZE);
return _valueHolder.isEmpty();
}
const std::type_info & type() const
const std::type_info& type() const
/// Returns the type information of the stored content.
/// If the Any is empty typeid(void) is returned.
/// It is recommended to always query an Any for its type info before
@@ -265,6 +318,14 @@ public:
return empty() ? typeid(void) : content()->type();
}
bool local() const
/// Returns true if data is held locally (ie. not allocated on the heap).
/// If POCO_NO_SOO is defined, it always return false.
/// The main purpose of this function is use for testing.
{
return _valueHolder.isLocal();
}
private:
class ValueHolder
{
@@ -283,28 +344,20 @@ private:
{
}
virtual const std::type_info & type() const
virtual const std::type_info& type() const
{
return typeid(ValueType);
}
virtual void clone(Placeholder<ValueHolder>* pPlaceholder) const
{
if ((sizeof(Holder<ValueType>) <= POCO_SMALL_OBJECT_SIZE))
{
new ((ValueHolder*) pPlaceholder->holder) Holder(_held);
pPlaceholder->setLocal(true);
}
else
{
pPlaceholder->pHolder = new Holder(_held);
pPlaceholder->setLocal(false);
}
pPlaceholder->assign<Holder<ValueType>, ValueType>(_held);
}
ValueType _held;
private:
Holder & operator = (const Holder &);
};
@@ -316,16 +369,7 @@ private:
template<typename ValueType>
void construct(const ValueType& value)
{
if (sizeof(Holder<ValueType>) <= Placeholder<ValueType>::Size::value)
{
new (reinterpret_cast<ValueHolder*>(_valueHolder.holder)) Holder<ValueType>(value);
_valueHolder.setLocal(true);
}
else
{
_valueHolder.pHolder = new Holder<ValueType>(value);
_valueHolder.setLocal(false);
}
_valueHolder.assign<Holder<ValueType>, ValueType>(value);
}
void construct(const Any& other)
@@ -336,130 +380,8 @@ private:
_valueHolder.erase();
}
void destruct()
{
content()->~ValueHolder();
}
Placeholder<ValueHolder> _valueHolder;
#else // if POCO_NO_SOO
Any(): _pHolder(0)
/// Creates an empty any type.
{
}
template <typename ValueType>
Any(const ValueType& value):
_pHolder(new Holder<ValueType>(value))
/// Creates an any which stores the init parameter inside.
///
/// Example:
/// Any a(13);
/// Any a(string("12345"));
{
}
Any(const Any& other):
_pHolder(other._pHolder ? other._pHolder->clone() : 0)
/// Copy constructor, works with both empty and initialized Any values.
{
}
~Any()
{
delete _pHolder;
}
Any& swap(Any& rhs)
/// Swaps the content of the two Anys.
{
std::swap(_pHolder, rhs._pHolder);
return *this;
}
template <typename ValueType>
Any& operator = (const ValueType& rhs)
/// Assignment operator for all types != Any.
///
/// Example:
/// Any a = 13;
/// Any a = string("12345");
{
Any(rhs).swap(*this);
return *this;
}
Any& operator = (const Any& rhs)
/// Assignment operator for Any.
{
Any(rhs).swap(*this);
return *this;
}
bool empty() const
/// Returns true if the Any is empty.
{
return !_pHolder;
}
const std::type_info& type() const
/// Returns the type information of the stored content.
/// If the Any is empty typeid(void) is returned.
/// It is recommended to always query an Any for its type info before
/// trying to extract data via an AnyCast/RefAnyCast.
{
return _pHolder ? _pHolder->type() : typeid(void);
}
private:
class ValueHolder
{
public:
virtual ~ValueHolder() = default;
virtual const std::type_info& type() const = 0;
virtual ValueHolder* clone() const = 0;
};
template <typename ValueType>
class Holder: public ValueHolder
{
public:
Holder(const ValueType& value):
_held(value)
{
}
virtual const std::type_info& type() const
{
return typeid(ValueType);
}
virtual ValueHolder* clone() const
{
return new Holder(_held);
}
ValueType _held;
private:
Holder & operator = (const Holder &);
};
ValueHolder* content() const
{
return _pHolder;
}
private:
ValueHolder* _pHolder;
#endif // POCO_NO_SOO
template <typename ValueType>
friend ValueType* AnyCast(Any*);
@@ -522,10 +444,10 @@ ValueType AnyCast(Any& operand)
if (!result)
{
std::string s = "RefAnyCast: Failed to convert between Any types ";
if (operand._pHolder)
if (operand.content())
{
s.append(1, '(');
s.append(operand._pHolder->type().name());
s.append(operand.content()->type().name());
s.append(" => ");
s.append(typeid(ValueType).name());
s.append(1, ')');
@@ -564,10 +486,10 @@ const ValueType& RefAnyCast(const Any & operand)
if (!result)
{
std::string s = "RefAnyCast: Failed to convert between Any types ";
if (operand._pHolder)
if (operand.content())
{
s.append(1, '(');
s.append(operand._pHolder->type().name());
s.append(operand.content()->type().name());
s.append(" => ");
s.append(typeid(ValueType).name());
s.append(1, ')');
@@ -589,10 +511,10 @@ ValueType& RefAnyCast(Any& operand)
if (!result)
{
std::string s = "RefAnyCast: Failed to convert between Any types ";
if (operand._pHolder)
if (operand.content())
{
s.append(1, '(');
s.append(operand._pHolder->type().name());
s.append(operand.content()->type().name());
s.append(" => ");
s.append(typeid(ValueType).name());
s.append(1, ')');

View File

@@ -32,7 +32,7 @@ class ArchiveCompressor;
class Foundation_API ArchiveStrategy
/// The ArchiveStrategy is used by FileChannel
/// The ArchiveStrategy is used by FileChannel
/// to rename a rotated log file for archiving.
///
/// Archived files can be automatically compressed,
@@ -42,22 +42,25 @@ public:
ArchiveStrategy();
virtual ~ArchiveStrategy();
virtual LogFile* open(LogFile* pFile) = 0;
/// Open a new log file and return it.
virtual LogFile* archive(LogFile* pFile) = 0;
/// Renames the given log file for archiving
/// and creates and returns a new log file.
/// The given LogFile object is deleted.
void compress(bool flag = true);
/// Enables or disables compression of archived files.
/// Enables or disables compression of archived files.
protected:
void moveFile(const std::string& oldName, const std::string& newName);
bool exists(const std::string& name);
private:
ArchiveStrategy(const ArchiveStrategy&);
ArchiveStrategy& operator = (const ArchiveStrategy&);
bool _compress;
ArchiveCompressor* _pCompressor;
};
@@ -71,6 +74,8 @@ class Foundation_API ArchiveByNumberStrategy: public ArchiveStrategy
public:
ArchiveByNumberStrategy();
~ArchiveByNumberStrategy();
LogFile* open(LogFile* pFile);
LogFile* archive(LogFile* pFile);
};
@@ -84,11 +89,16 @@ public:
ArchiveByTimestampStrategy()
{
}
~ArchiveByTimestampStrategy()
{
}
LogFile* open(LogFile* pFile)
{
return pFile;
}
LogFile* archive(LogFile* pFile)
/// Archives the file by appending the current timestamp to the
/// file name. If the new file name exists, additionally a monotonic
@@ -99,7 +109,7 @@ public:
std::string archPath = path;
archPath.append(".");
DateTimeFormatter::append(archPath, DT().timestamp(), "%Y%m%d%H%M%S%i");
if (exists(archPath)) archiveByNumber(archPath);
else moveFile(path, archPath);
@@ -121,7 +131,7 @@ private:
NumberFormatter::append(path, ++n);
}
while (exists(path));
while (n >= 0)
{
std::string oldPath = basePath;

View File

@@ -34,11 +34,11 @@ namespace Poco {
template<class T, std::size_t N>
class Array
/// STL container like C-style array replacement class.
///
class Array
/// STL container like C-style array replacement class.
///
/// 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:
typedef T value_type;
@@ -60,7 +60,7 @@ public:
}
iterator end()
{
{
return elems+N;
}
@@ -83,7 +83,7 @@ public:
}
reverse_iterator rend()
{
{
return reverse_iterator(begin());
}
@@ -92,26 +92,26 @@ public:
return const_reverse_iterator(begin());
}
reference operator[](size_type i)
reference operator[](size_type i)
/// Element access without range check. If the index is not small than the given size, the behavior is undefined.
{
poco_assert( i < N && "out of range" );
{
poco_assert_dbg(i < N && "out of range");
return elems[i];
}
const_reference operator[](size_type i) const
const_reference operator[](size_type i) const
/// Element access without range check. If the index is not small than the given size, the behavior is undefined.
{
poco_assert( i < N && "out of range" );
return elems[i];
{
poco_assert_dbg(i < N && "out of range");
return elems[i];
}
reference at(size_type i)
/// Element access with range check. Throws Poco::InvalidArgumentException if the index is over range.
{
{
if(i>=size())
throw Poco::InvalidArgumentException("Array::at() range check failed: index is over range");
return elems[i];
return elems[i];
}
const_reference at(size_type i) const
@@ -119,71 +119,71 @@ public:
{
if(i>=size())
throw Poco::InvalidArgumentException("Array::at() range check failed: index is over range");
return elems[i];
return elems[i];
}
reference front()
{
return elems[0];
}
const_reference front() const
reference front()
{
return elems[0];
}
reference back()
{
return elems[N-1];
const_reference front() const
{
return elems[0];
}
const_reference back() const
{
return elems[N-1];
reference back()
{
return elems[N-1];
}
const_reference back() const
{
return elems[N-1];
}
static size_type size()
{
return N;
return N;
}
static bool empty()
{
return false;
{
return false;
}
static size_type max_size()
{
return N;
{
return N;
}
enum { static_size = N };
void swap (Array<T,N>& y)
void swap (Array<T,N>& y) noexcept
{
std::swap_ranges(begin(),end(),y.begin());
}
const T* data() const
/// Direct access to data (read-only)
{
return elems;
{
return elems;
}
T* data()
{
{
return elems;
}
T* c_array()
{
{
/// Use array as C array (direct read/write access to data)
return elems;
}
template <typename Other>
Array<T,N>& operator= (const Array<Other,N>& rhs)
/// Assignment with type conversion
/// Assignment with type conversion
{
std::copy(rhs.begin(),rhs.end(), begin());
return *this;
@@ -196,7 +196,7 @@ 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.
};
@@ -204,49 +204,49 @@ public:
// comparisons
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::equal(x.begin(), x.end(), y.begin());
}
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());
}
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);
}
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;
}
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);
}
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);
}
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) noexcept
/// global swap()
{
x.swap(y);

View File

@@ -55,7 +55,7 @@ public:
ACP_GRAPH = 0x0100,
ACP_PRINT = 0x0200
};
static int properties(int ch);
/// Return the ASCII character properties for the
/// character with the given ASCII value.
@@ -65,44 +65,44 @@ public:
static bool hasSomeProperties(int ch, int properties);
/// Returns true if the given character is
/// within the ASCII range and has at least one of
/// within the ASCII range and has at least one of
/// the given properties.
static bool hasProperties(int ch, int properties);
/// Returns true if the given character is
/// within the ASCII range and has all of
/// within the ASCII range and has all of
/// the given properties.
static bool isAscii(int ch);
/// Returns true iff the given character code is within
/// the ASCII range (0 .. 127).
static bool isSpace(int ch);
/// Returns true iff the given character is a whitespace.
static bool isDigit(int ch);
/// Returns true iff the given character is a digit.
static bool isHexDigit(int ch);
/// Returns true iff the given character is a hexadecimal digit.
static bool isPunct(int ch);
/// Returns true iff the given character is a punctuation character.
static bool isAlpha(int ch);
/// Returns true iff the given character is an alphabetic character.
/// Returns true iff the given character is an alphabetic character.
static bool isAlphaNumeric(int ch);
/// Returns true iff the given character is an alphabetic character.
/// Returns true iff the given character is an alphabetic character.
static bool isLower(int ch);
/// Returns true iff the given character is a lowercase alphabetic
/// character.
static bool isUpper(int ch);
/// Returns true iff the given character is an uppercase alphabetic
/// character.
static bool isPrintable(int ch);
/// Returns true iff the given character is printable.
@@ -115,7 +115,7 @@ public:
/// If the given character is a lowercase character,
/// return its uppercase counterpart, otherwise return
/// the character.
private:
static const int CHARACTER_PROPERTIES[128];
};
@@ -126,7 +126,7 @@ private:
//
inline int Ascii::properties(int ch)
{
if (isAscii(ch))
if (isAscii(ch))
return CHARACTER_PROPERTIES[ch];
else
return 0;

View File

@@ -25,6 +25,7 @@
#include "Poco/Runnable.h"
#include "Poco/AutoPtr.h"
#include "Poco/NotificationQueue.h"
#include <atomic>
namespace Poco {
@@ -110,6 +111,7 @@ private:
NotificationQueue _queue;
std::size_t _queueSize = 0;
std::size_t _dropCount = 0;
std::atomic<bool> _closed;
};

View File

@@ -194,7 +194,7 @@ public:
return assign<Other>(ptr);
}
void swap(AutoPtr& ptr)
void swap(AutoPtr& ptr) noexcept
{
std::swap(_ptr, ptr._ptr);
}
@@ -398,7 +398,7 @@ private:
template <class C>
inline void swap(AutoPtr<C>& p1, AutoPtr<C>& p2)
inline void swap(AutoPtr<C>& p1, AutoPtr<C>& p2) noexcept
{
p1.swap(p2);
}

View File

@@ -27,10 +27,10 @@ namespace Poco {
template <class C>
class AutoReleasePool
/// An AutoReleasePool implements simple garbage collection for
/// An AutoReleasePool implements simple garbage collection for
/// reference-counted objects.
/// 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.
///
/// Note: The correct way to add an object hold by an AutoPtr<> to
@@ -46,14 +46,14 @@ public:
/// Creates the AutoReleasePool.
{
}
~AutoReleasePool()
/// Destroys the AutoReleasePool and releases
/// all objects it currently holds.
{
release();
}
void add(C* pObject)
/// Adds the given object to the AutoReleasePool.
/// The object's reference count is not modified
@@ -61,7 +61,7 @@ public:
if (pObject)
_list.push_back(pObject);
}
void release()
/// Releases all objects the AutoReleasePool currently holds
/// by calling each object's release() method.
@@ -72,10 +72,10 @@ public:
_list.pop_front();
}
}
private:
typedef std::list<C*> ObjectList;
ObjectList _list;
};

View File

@@ -30,8 +30,8 @@ class Foundation_API Base32DecoderBuf: public UnbufferedStreamBuf
/// This streambuf base32-decodes all data read
/// from the istream connected to it.
///
/// Note: For performance reasons, the characters
/// are read directly from the given istream's
/// Note: For performance reasons, the characters
/// are read directly from the given istream's
/// underlying streambuf, so the state
/// of the istream will not reflect that of
/// its streambuf.
@@ -39,7 +39,7 @@ class Foundation_API Base32DecoderBuf: public UnbufferedStreamBuf
public:
Base32DecoderBuf(std::istream& istr);
~Base32DecoderBuf();
private:
int readFromDevice();
int readOne();
@@ -48,10 +48,10 @@ private:
int _groupLength;
int _groupIndex;
std::streambuf& _buf;
static unsigned char IN_ENCODING[256];
static bool IN_ENCODING_INIT;
private:
Base32DecoderBuf(const Base32DecoderBuf&);
Base32DecoderBuf& operator = (const Base32DecoderBuf&);
@@ -71,7 +71,7 @@ public:
protected:
Base32DecoderBuf _buf;
private:
Base32DecoderIOS(const Base32DecoderIOS&);
Base32DecoderIOS& operator = (const Base32DecoderIOS&);
@@ -84,8 +84,8 @@ class Foundation_API Base32Decoder: public Base32DecoderIOS, public std::istream
///
/// The class implements RFC 4648 - https://tools.ietf.org/html/rfc4648
///
/// Note: For performance reasons, the characters
/// are read directly from the given istream's
/// Note: For performance reasons, the characters
/// are read directly from the given istream's
/// underlying streambuf, so the state
/// of the istream will not reflect that of
/// its streambuf.

View File

@@ -39,7 +39,7 @@ class Foundation_API Base32EncoderBuf: public UnbufferedStreamBuf
public:
Base32EncoderBuf(std::ostream& ostr, bool padding = true);
~Base32EncoderBuf();
int close();
/// Closes the stream buffer.
@@ -50,9 +50,9 @@ private:
int _groupLength;
std::streambuf& _buf;
bool _doPadding;
static const unsigned char OUT_ENCODING[32];
friend class Base32DecoderBuf;
Base32EncoderBuf(const Base32EncoderBuf&);

View File

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

View File

@@ -59,7 +59,7 @@ public:
void setLineLength(int lineLength);
/// Specify the line length.
///
/// After the given number of characters have been written,
/// After the given number of characters have been written,
/// a newline character will be written.
///
/// Specify 0 for an unlimited line length.

View File

@@ -27,13 +27,13 @@
namespace Poco {
template <class TArgs, class TMutex = FastMutex>
class BasicEvent: public AbstractEvent <
template <class TArgs, class TMutex = FastMutex>
class BasicEvent: public AbstractEvent <
TArgs, DefaultStrategy<TArgs, AbstractDelegate<TArgs>>,
AbstractDelegate<TArgs>,
TMutex
>
/// A BasicEvent uses the DefaultStrategy which
/// A BasicEvent uses the DefaultStrategy which
/// invokes delegates in the order they have been registered.
///
/// Please see the AbstractEvent class template documentation

View File

@@ -34,6 +34,21 @@ class Buffer
///
/// This class is useful everywhere where a temporary buffer
/// is needed.
///
/// Note: A Buffer has both a size and a capacity, similar to
/// std::vector and std::string. However, upon creation of the
/// Buffer, the size always equals the capacity (provided via the
/// length argument of the constructor), as the Buffer is meant
/// to be filled by directly writing to its contents,
/// i.e., by passing the pointer to the first element
/// of the buffer obtained via begin() to a function expecting
/// a pointer to a buffer.
///
/// Therefore, calling append() on a newly created Buffer will
/// always expand the buffer size and capacity.
/// If you need to create a Buffer and want to write data to it
/// by calling append(), the correct steps are to first create
/// the Buffer, then call resize(0), and then call append().
{
public:
Buffer(std::size_t length):
@@ -248,7 +263,7 @@ public:
return _capacity * sizeof(T);
}
void swap(Buffer& other)
void swap(Buffer& other) noexcept
/// Swaps the buffer with another one.
{
using std::swap;

View File

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

View File

@@ -29,9 +29,9 @@
namespace Poco {
template <typename ch, typename tr, typename ba = BufferAllocator<ch>>
template <typename ch, typename tr, typename ba = BufferAllocator<ch>>
class BasicBufferedBidirectionalStreamBuf: public std::basic_streambuf<ch, tr>
/// This is an implementation of a buffered bidirectional
/// This is an implementation of a buffered bidirectional
/// streambuf that greatly simplifies the implementation of
/// custom streambufs of various kinds.
/// Derived classes only have to override the methods
@@ -68,13 +68,13 @@ public:
Allocator::deallocate(_pReadBuffer, _bufsize);
Allocator::deallocate(_pWriteBuffer, _bufsize);
}
virtual int_type overflow(int_type c)
{
if (!(_mode & IOS::out)) return char_traits::eof();
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
if (c != char_traits::eof())
if (c != char_traits::eof())
{
*this->pptr() = char_traits::to_char_type(c);
this->pbump(1);
@@ -101,12 +101,12 @@ public:
this->setg(_pReadBuffer + (4 - putback), _pReadBuffer + 4, _pReadBuffer + 4 + n);
// return next character
return char_traits::to_int_type(*this->gptr());
return char_traits::to_int_type(*this->gptr());
}
virtual int sync()
{
if (this->pptr() && this->pptr() > this->pbase())
if (this->pptr() && this->pptr() > this->pbase())
{
if (flushBuffer() == -1) return -1;
}
@@ -123,7 +123,7 @@ protected:
{
return _mode;
}
void resetBuffers()
{
this->setg(_pReadBuffer + 4, _pReadBuffer + 4, _pReadBuffer + 4);
@@ -144,7 +144,7 @@ private:
int flushBuffer()
{
int n = int(this->pptr() - this->pbase());
if (writeToDevice(this->pbase(), n) == n)
if (writeToDevice(this->pbase(), n) == n)
{
this->pbump(-n);
return n;
@@ -169,7 +169,7 @@ private:
// instantiation - to avoid duplicate symbols due to multiple
// instantiations in different libraries.
//
#if defined(_MSC_VER) && defined(POCO_DLL) && !defined(Foundation_EXPORTS)
#if defined(_MSC_VER) && defined(POCO_DLL) && !defined(Foundation_EXPORTS)
template class Foundation_API BasicBufferedBidirectionalStreamBuf<char, std::char_traits<char>>;
#endif
typedef BasicBufferedBidirectionalStreamBuf<char, std::char_traits<char>> BufferedBidirectionalStreamBuf;

View File

@@ -29,7 +29,7 @@
namespace Poco {
template <typename ch, typename tr, typename ba = BufferAllocator<ch>>
template <typename ch, typename tr, typename ba = BufferAllocator<ch>>
class BasicBufferedStreamBuf: public std::basic_streambuf<ch, tr>
/// This is an implementation of a buffered streambuf
/// that greatly simplifies the implementation of
@@ -59,7 +59,7 @@ public:
_pBuffer(Allocator::allocate(_bufsize)),
_mode(mode)
{
this->setg(_pBuffer + 4, _pBuffer + 4, _pBuffer + 4);
this->setg(_pBuffer + 4, _pBuffer + 4, _pBuffer + 4);
this->setp(_pBuffer, _pBuffer + _bufsize);
}
@@ -68,7 +68,7 @@ public:
try
{
Allocator::deallocate(_pBuffer, _bufsize);
}
}
catch (...)
{
poco_unexpected();
@@ -80,7 +80,7 @@ public:
if (!(_mode & IOS::out)) return char_traits::eof();
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
if (c != char_traits::eof())
if (c != char_traits::eof())
{
*this->pptr() = char_traits::to_char_type(c);
this->pbump(1);
@@ -107,12 +107,12 @@ public:
this->setg(_pBuffer + (4 - putback), _pBuffer + 4, _pBuffer + 4 + n);
// return next character
return char_traits::to_int_type(*this->gptr());
return char_traits::to_int_type(*this->gptr());
}
virtual int sync()
{
if (this->pptr() && this->pptr() > this->pbase())
if (this->pptr() && this->pptr() > this->pbase())
{
if (flushBuffer() == -1) return -1;
}
@@ -124,7 +124,7 @@ protected:
{
_mode = mode;
}
openmode getMode() const
{
return _mode;
@@ -144,7 +144,7 @@ private:
int flushBuffer()
{
int n = int(this->pptr() - this->pbase());
if (writeToDevice(this->pbase(), n) == n)
if (writeToDevice(this->pbase(), n) == n)
{
this->pbump(-n);
return n;

View File

@@ -32,26 +32,26 @@ namespace Poco {
class Foundation_API Bugcheck
/// This class provides some static methods that are
/// used by the
/// poco_assert_dbg(), poco_assert(), poco_check_ptr(),
/// poco_bugcheck() and poco_unexpected() macros.
/// poco_assert_dbg(), poco_assert(), poco_check_ptr(),
/// poco_bugcheck() and poco_unexpected() macros.
/// You should not invoke these methods
/// directly. Use the macros instead, as they
/// automatically provide useful context information.
{
public:
static void assertion(const char* cond, const char* file, int line, const char* text = 0);
[[noreturn]] static void assertion(const char* cond, const char* file, int line, const char* text = 0);
/// An assertion failed. Break into the debugger, if
/// possible, then throw an AssertionViolationException.
static void nullPointer(const char* ptr, const char* file, int line);
[[noreturn]] static void nullPointer(const char* ptr, const char* file, int line);
/// An null pointer was encountered. Break into the debugger, if
/// possible, then throw an NullPointerException.
static void bugcheck(const char* file, int line);
[[noreturn]] static void bugcheck(const char* file, int line);
/// An internal error was encountered. Break into the debugger, if
/// possible, then throw an BugcheckException.
static void bugcheck(const char* msg, const char* file, int line);
[[noreturn]] static void bugcheck(const char* msg, const char* file, int line);
/// An internal error was encountered. Break into the debugger, if
/// possible, then throw an BugcheckException.
@@ -186,7 +186,7 @@ struct POCO_STATIC_ASSERTION_FAILURE<true>
};
template <int x>
template <int x>
struct poco_static_assert_test
{
};

View File

@@ -119,7 +119,7 @@ private:
#if (POCO_MSVC_VERSION > 71)
#define POCO_HAVE_MSC_BYTESWAP 1
#endif
#elif defined(__clang__)
#elif defined(__clang__)
#if __has_builtin(__builtin_bswap32)
#define POCO_HAVE_GCC_BYTESWAP 1
#endif

View File

@@ -46,29 +46,29 @@ public:
/// the reference count to one.
virtual void open();
/// Does whatever is necessary to open the channel.
/// Does whatever is necessary to open the channel.
/// The default implementation does nothing.
virtual void close();
/// Does whatever is necessary to close the channel.
/// The default implementation does nothing.
virtual void log(const Message& msg) = 0;
/// Logs the given message to the channel. Must be
/// overridden by subclasses.
///
/// If the channel has not been opened yet, the log()
/// method will open it.
void setProperty(const std::string& name, const std::string& value);
/// Throws a PropertyNotSupportedException.
std::string getProperty(const std::string& name) const;
/// Throws a PropertyNotSupportedException.
protected:
virtual ~Channel();
private:
Channel(const Channel&);
Channel& operator = (const Channel&);

View File

@@ -28,15 +28,15 @@ class Foundation_API Checksum
/// This class calculates CRC-32 or Adler-32 checksums
/// for arbitrary data.
///
/// A cyclic redundancy check (CRC) is a type of hash function, which is used to produce a
/// small, fixed-size checksum of a larger block of data, such as a packet of network
/// A cyclic redundancy check (CRC) is a type of hash function, which is used to produce a
/// small, fixed-size checksum of a larger block of data, such as a packet of network
/// traffic or a computer file. CRC-32 is one of the most commonly used CRC algorithms.
///
/// Adler-32 is a checksum algorithm which was invented by Mark Adler.
/// It is almost as reliable as a 32-bit cyclic redundancy check for protecting against
/// accidental modification of data, such as distortions occurring during a transmission,
/// Adler-32 is a checksum algorithm which was invented by Mark Adler.
/// It is almost as reliable as a 32-bit cyclic redundancy check for protecting against
/// accidental modification of data, such as distortions occurring during a transmission,
/// but is significantly faster to calculate in software.
{
public:
enum Type

View File

@@ -40,7 +40,7 @@ extern "C"
bool POCO_LIBRARY_API pocoBuildManifest(Poco::ManifestBase* pManifest);
void POCO_LIBRARY_API pocoInitializeLibrary();
void POCO_LIBRARY_API pocoUninitializeLibrary();
}
}
//

View File

@@ -140,7 +140,7 @@ public:
}
void loadLibrary(const std::string& path, const std::string& manifest)
/// Loads a library from the given path, using the given manifest.
/// Loads a library from the given path, using the given manifest.
/// Does nothing if the library is already loaded.
/// Throws a LibraryLoadException if the library
/// cannot be loaded or does not have a Manifest.
@@ -208,9 +208,9 @@ public:
{
loadLibrary(path, "");
}
void unloadLibrary(const std::string& path)
/// Unloads the given library.
/// Unloads the given library.
/// Be extremely cautious when unloading shared libraries.
/// If objects from the library are still referenced somewhere,
/// a total crash is very likely.
@@ -256,7 +256,7 @@ public:
}
return 0;
}
const Meta& classFor(const std::string& className) const
/// Returns a reference to the MetaObject for the given
/// class. Throws a NotFoundException if the class
@@ -268,7 +268,7 @@ public:
else
throw NotFoundException(className);
}
Base* create(const std::string& className) const
/// Creates an instance of the given class.
/// Throws a NotFoundException if the class
@@ -276,7 +276,7 @@ public:
{
return classFor(className).create();
}
Base& instance(const std::string& className) const
/// Returns a reference to the sole instance of
/// the given class. The class must be a singleton,
@@ -286,7 +286,7 @@ public:
{
return classFor(className).instance();
}
bool canCreate(const std::string& className) const
/// Returns true if create() can create new instances
/// of the class.
@@ -307,7 +307,7 @@ public:
{
return classFor(className).isAutoDelete(pObject);
}
const Manif* findManifest(const std::string& path) const
/// Returns a pointer to the Manifest for the given
/// library, or a null pointer if the library has not been loaded.
@@ -320,7 +320,7 @@ public:
else
return 0;
}
const Manif& manifestFor(const std::string& path) const
/// Returns a reference to the Manifest for the given library
/// Throws a NotFoundException if the library has not been loaded.

View File

@@ -35,8 +35,8 @@ class Foundation_API Clock
/// The monotonic() function can be used to check whether
/// the system's clock is monotonic.
///
/// Monotonic Clock is available on Windows, Linux, OS X
/// and on POSIX platforms supporting clock_gettime() with CLOCK_MONOTONIC.
/// Monotonic Clock is available on Windows, Linux, OS X
/// and on POSIX platforms supporting clock_gettime() with CLOCK_MONOTONIC.
///
/// Clock values are relative to a system-dependent epoch time
/// (usually the system's startup time) and have no relation
@@ -54,22 +54,22 @@ public:
Clock();
/// Creates a Clock with the current system clock value.
Clock(ClockVal tv);
/// Creates a Clock from the given clock value.
Clock(const Clock& other);
/// Copy constructor.
~Clock();
/// Destroys the Clock.
Clock& operator = (const Clock& other);
Clock& operator = (ClockVal tv);
void swap(Clock& clock);
void swap(Clock& clock) noexcept;
/// Swaps the Clock with another one.
void update();
/// Updates the Clock with the current system clock.
@@ -79,13 +79,13 @@ public:
bool operator >= (const Clock& ts) const;
bool operator < (const Clock& ts) const;
bool operator <= (const Clock& ts) const;
Clock operator + (ClockDiff d) const;
Clock operator - (ClockDiff d) const;
ClockDiff operator - (const Clock& ts) const;
Clock& operator += (ClockDiff d);
Clock& operator -= (ClockDiff d);
ClockVal microseconds() const;
/// Returns the clock value expressed in microseconds
/// since the system-specific epoch time (usually system
@@ -97,23 +97,23 @@ public:
/// startup).
///
/// Same as microseconds().
ClockDiff elapsed() const;
/// Returns the time elapsed since the time denoted by
/// the Clock instance. Equivalent to Clock() - *this.
bool isElapsed(ClockDiff interval) const;
/// Returns true iff the given interval has passed
/// since the time denoted by the Clock instance.
static ClockDiff resolution();
/// Returns the resolution in units per second.
/// Since the Clock class has microsecond resolution,
/// the returned value is always 1000000.
static ClockDiff accuracy();
/// Returns the system's clock accuracy in microseconds.
static bool monotonic();
/// Returns true iff the system's clock is monotonic.
@@ -220,7 +220,7 @@ inline Clock::ClockDiff Clock::resolution()
}
inline void swap(Clock& s1, Clock& s2)
inline void swap(Clock& s1, Clock& s2) noexcept
{
s1.swap(s2);
}

View File

@@ -30,8 +30,8 @@ namespace Poco {
class Foundation_API Condition
/// A Condition is a synchronization object used to block a thread
/// until a particular condition is met.
/// A Condition is a synchronization object used to block a thread
/// until a particular condition is met.
/// A Condition object is always used in conjunction with
/// a Mutex (or FastMutex) object.
///
@@ -43,16 +43,16 @@ class Foundation_API Condition
public:
Condition();
/// Creates the Condition.
~Condition();
/// Destroys the Condition.
template <class Mtx>
void wait(Mtx& mutex)
/// Unlocks the mutex (which must be locked upon calling
/// wait()) and waits until the Condition is signalled.
///
/// The given mutex will be locked again upon
/// The given mutex will be locked again upon
/// leaving the function, even in case of an exception.
{
ScopedUnlock<Mtx> unlock(mutex, false);
@@ -64,13 +64,13 @@ public:
}
event.wait();
}
template <class Mtx>
void wait(Mtx& mutex, long milliseconds)
/// Unlocks the mutex (which must be locked upon calling
/// wait()) and waits for the given time until the Condition is signalled.
///
/// The given mutex will be locked again upon successfully leaving the
/// The given mutex will be locked again upon successfully leaving the
/// function, even in case of an exception.
///
/// Throws a TimeoutException if the Condition is not signalled
@@ -79,13 +79,13 @@ public:
if (!tryWait(mutex, milliseconds))
throw TimeoutException();
}
template <class Mtx>
bool tryWait(Mtx& mutex, long milliseconds)
/// Unlocks the mutex (which must be locked upon calling
/// tryWait()) and waits for the given time until the Condition is signalled.
///
/// The given mutex will be locked again upon leaving the
/// The given mutex will be locked again upon leaving the
/// function, even in case of an exception.
///
/// Returns true if the Condition has been signalled
@@ -106,7 +106,7 @@ public:
}
return true;
}
void signal();
/// Signals the Condition and allows one waiting thread
/// to continue execution.
@@ -119,13 +119,13 @@ protected:
void enqueue(Event& event);
void dequeue();
void dequeue(Event& event);
private:
Condition(const Condition&);
Condition& operator = (const Condition&);
typedef std::deque<Event*> WaitQueue;
FastMutex _mutex;
WaitQueue _waitQueue;
};

View File

@@ -52,6 +52,11 @@
#define POCO_THREAD_STACK_SIZE 0
#endif
// Defined to desired max thread name length
#ifndef POCO_MAX_THREAD_NAME_LEN
#define POCO_MAX_THREAD_NAME_LEN 15
#endif
// Define to override system-provided
// minimum thread priority value on POSIX
@@ -71,24 +76,15 @@
// cases when value holder fits into POCO_SMALL_OBJECT_SIZE
// (see below).
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!! NOTE: Any/Dynamic::Var SOO will NOT work reliably !!!
// !!! without C++11 (std::aligned_storage in particular). !!!
// !!! Only comment this out if your compiler has support !!!
// !!! for std::aligned_storage. !!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
#ifndef POCO_ENABLE_SOO
#define POCO_NO_SOO
#endif
// #define POCO_NO_SOO
// Small object size in bytes. When assigned to Any or Var,
// objects larger than this value will be alocated on the heap,
// while those smaller will be placement new-ed into an
// internal buffer.
#if !defined(POCO_SMALL_OBJECT_SIZE) && !defined(POCO_NO_SOO)
#define POCO_SMALL_OBJECT_SIZE 32
// internal stack-auto-allocated buffer.
#if !defined(POCO_SMALL_OBJECT_SIZE)
#define POCO_SMALL_OBJECT_SIZE 64
#endif
@@ -96,7 +92,7 @@
// on platforms with no inotify.
// #define POCO_NO_INOTIFY
// Define to force the use of PollingDirectoryWatcher
// Define to force the use of PollingDirectoryWatcher
// #define POCO_DW_FORCE_POLLING
@@ -151,6 +147,20 @@
// #define POCO_NET_NO_IPv6
// No UNIX socket support
// Define to disable unix sockets
// #define POCO_NET_NO_UNIX_SOCKET
// Define to nonzero to enable move semantics
// on classes where it introduces a new state.
// For explanation, see:
// https://github.com/pocoproject/poco/wiki/Move-Semantics-in-POCO
#ifndef POCO_NEW_STATE_ON_MOVE
// #define POCO_NEW_STATE_ON_MOVE 1
#endif
// Windows CE has no locale support
#if defined(_WIN32_WCE)
#define POCO_NO_LOCALE
@@ -185,7 +195,7 @@
// empty or other value:
// Do not link any OpenSSL libraries automatically. You will have to edit the
// Visual C++ project files for Crypto and NetSSL_OpenSSL.
#ifndef POCO_EXTERNAL_OPENSSL
#if !defined(POCO_EXTERNAL_OPENSSL) && defined(POCO_EXTERNAL_OPENSSL_SLPRO)
#define POCO_EXTERNAL_OPENSSL POCO_EXTERNAL_OPENSSL_SLPRO
#endif

View File

@@ -48,15 +48,15 @@ class Foundation_API Configurable
public:
Configurable();
/// Creates the Configurable.
virtual ~Configurable();
/// Destroys the Configurable.
virtual void setProperty(const std::string& name, const std::string& value) = 0;
/// Sets the property with the given name to the given value.
/// If a property with the given name is not supported, a
/// PropertyNotSupportedException is thrown.
virtual std::string getProperty(const std::string& name) const = 0;
/// Returns the value of the property with the given name.
/// If a property with the given name is not supported, a

View File

@@ -34,7 +34,7 @@ class Foundation_API ConsoleChannel: public Channel
/// by a newline.
///
/// Chain this channel to a FormattingChannel with an
/// appropriate Formatter to control what is contained
/// appropriate Formatter to control what is contained
/// in the text.
///
/// Similar to StreamChannel, except that a static
@@ -47,13 +47,13 @@ public:
ConsoleChannel();
/// Creates the channel and attaches std::clog.
ConsoleChannel(std::ostream& str);
/// Creates the channel using the given stream.
void log(const Message& msg);
/// Logs the given message to the channel's stream.
protected:
~ConsoleChannel();
@@ -77,7 +77,7 @@ class Foundation_API ColorConsoleChannel: public Channel
/// property to true (default). Furthermore, colors can be
/// configured by setting the following properties
/// (default values are given in parenthesis):
///
///
/// * traceColor (gray)
/// * debugColor (gray)
/// * informationColor (default)
@@ -88,7 +88,7 @@ class Foundation_API ColorConsoleChannel: public Channel
/// * fatalColor (lightRed)
///
/// The following color values are supported:
///
///
/// * default
/// * black
/// * red
@@ -108,7 +108,7 @@ class Foundation_API ColorConsoleChannel: public Channel
/// * white
///
/// Chain this channel to a FormattingChannel with an
/// appropriate Formatter to control what is contained
/// appropriate Formatter to control what is contained
/// in the text.
///
/// Similar to StreamChannel, except that a static
@@ -116,19 +116,19 @@ class Foundation_API ColorConsoleChannel: public Channel
/// console channels concurrently writing to the
/// same stream.
{
public:
public:
ColorConsoleChannel();
/// Creates the channel and attaches std::clog.
ColorConsoleChannel(std::ostream& str);
/// Creates the channel using the given stream.
void log(const Message& msg);
/// Logs the given message to the channel's stream.
void setProperty(const std::string& name, const std::string& value);
/// Sets the property with the given name.
///
/// Sets the property with the given name.
///
/// The following properties are supported:
/// * enableColors: Enable or disable colors.
/// * traceColor: Specify color for trace messages.
@@ -147,7 +147,7 @@ public:
/// See setProperty() for a description of the supported
/// properties.
protected:
protected:
enum Color
{
CC_DEFAULT = 0x0027,

View File

@@ -34,7 +34,7 @@ class Foundation_API CountingStreamBuf: public UnbufferedStreamBuf
public:
CountingStreamBuf();
/// Creates an unconnected CountingStreamBuf.
CountingStreamBuf(std::istream& istr);
/// Creates the CountingStreamBuf and connects it
/// to the given input stream.
@@ -45,34 +45,34 @@ public:
~CountingStreamBuf();
/// Destroys the CountingStream.
std::streamsize chars() const;
/// Returns the total number of characters.
std::streamsize lines() const;
/// Returns the total number of lines.
std::streamsize pos() const;
/// Returns the number of characters on the current line.
void reset();
/// Resets all counters.
void setCurrentLineNumber(std::streamsize line);
/// Sets the current line number.
///
/// This is mainly useful when parsing C/C++
/// preprocessed source code containing #line directives.
std::streamsize getCurrentLineNumber() const;
/// Returns the current line number (same as lines()).
void addChars(std::streamsize chars);
/// Add to the total number of characters.
void addLines(std::streamsize lines);
/// Add to the total number of lines.
void addPos(std::streamsize pos);
/// Add to the number of characters on the current line.
@@ -127,16 +127,16 @@ public:
///
/// This is mainly useful when parsing C/C++
/// preprocessed source code containing #line directives.
std::streamsize getCurrentLineNumber() const;
/// Returns the current line number (same as lines()).
void addChars(std::streamsize chars);
/// Add to the total number of characters.
void addLines(std::streamsize lines);
/// Add to the total number of lines.
void addPos(std::streamsize pos);
/// Add to the number of characters on the current line.
@@ -170,7 +170,7 @@ class Foundation_API CountingOutputStream: public CountingIOS, public std::ostre
public:
CountingOutputStream();
/// Creates an unconnected CountingOutputStream.
CountingOutputStream(std::ostream& ostr);
/// Creates the CountingOutputStream and connects it
/// to the given output stream.

View File

@@ -36,7 +36,7 @@ public:
~DataURIStreamFactory();
/// Destroys the DataURIStreamFactory.
std::istream* open(const URI& uri);
/// Creates an input stream returning decoded data from the given data URI.
///

View File

@@ -37,7 +37,7 @@ class Foundation_API DateTime
/// UTC, Julian day and Gregorian calendar dates.
///
/// The date and time stored in a DateTime is always in UTC
/// (Coordinated Universal Time) and thus independent of the
/// (Coordinated Universal Time) and thus independent of the
/// timezone in effect on the system.
///
/// Conversion calculations are based on algorithms
@@ -45,7 +45,7 @@ class Foundation_API DateTime
/// http://vsg.cape.com/~pbaum/date/date0.htm
///
/// Internally, this class stores a date/time in two
/// forms (UTC and broken down) for performance reasons. Only use
/// forms (UTC and broken down) for performance reasons. Only use
/// this class for conversions between date/time representations.
/// Use the Timestamp class for everything else.
///
@@ -77,7 +77,7 @@ public:
NOVEMBER,
DECEMBER
};
enum DaysOfWeek
/// Symbolic names for week day numbers (0 to 6).
{
@@ -99,7 +99,7 @@ public:
DateTime(const Timestamp& timestamp);
/// Creates a DateTime for the date and time given in
/// a Timestamp.
DateTime(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0);
/// Creates a DateTime for the given Gregorian date and time.
/// * year is from 0 to 9999.
@@ -129,7 +129,7 @@ public:
DateTime& operator = (const DateTime& dateTime);
/// Assigns another DateTime.
DateTime& operator = (const Timestamp& timestamp);
/// Assigns a Timestamp.
@@ -149,66 +149,66 @@ public:
///
/// Throws an InvalidArgumentException if an argument date is out of range.
void swap(DateTime& dateTime);
void swap(DateTime& dateTime) noexcept;
/// Swaps the DateTime with another one.
int year() const;
/// Returns the year.
int month() const;
/// Returns the month (1 to 12).
int week(int firstDayOfWeek = MONDAY) const;
/// Returns the week number within the year.
/// FirstDayOfWeek should be either SUNDAY (0) or MONDAY (1).
/// The returned week number will be from 0 to 53. Week number 1 is the week
/// The returned week number will be from 0 to 53. Week number 1 is the week
/// containing January 4. This is in accordance to ISO 8601.
///
///
/// The following example assumes that firstDayOfWeek is MONDAY. For 2005, which started
/// 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).
///
/// 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.
int day() const;
/// Returns the day within the month (1 to 31).
int dayOfWeek() const;
/// Returns the weekday (0 to 6, where
/// 0 = Sunday, 1 = Monday, ..., 6 = Saturday).
int dayOfYear() const;
/// Returns the number of the day in the year.
/// January 1 is 1, February 1 is 32, etc.
int hour() const;
/// Returns the hour (0 to 23).
int hourAMPM() const;
/// Returns the hour (0 to 12).
bool isAM() const;
/// Returns true if hour < 12;
bool isPM() const;
/// Returns true if hour >= 12.
int minute() const;
/// Returns the minute (0 to 59).
int second() const;
/// Returns the second (0 to 59).
int millisecond() const;
/// Returns the millisecond (0 to 999)
int microsecond() const;
/// Returns the microsecond (0 to 999)
double julianDay() const;
/// Returns the julian day for the date and time.
Timestamp timestamp() const;
/// Returns the date and time expressed as a Timestamp.
@@ -217,12 +217,12 @@ public:
/// time. UTC base time is midnight, October 15, 1582.
/// Resolution is 100 nanoseconds.
bool operator == (const DateTime& dateTime) const;
bool operator != (const DateTime& dateTime) const;
bool operator < (const DateTime& dateTime) const;
bool operator <= (const DateTime& dateTime) const;
bool operator > (const DateTime& dateTime) const;
bool operator >= (const DateTime& dateTime) const;
bool operator == (const DateTime& dateTime) const;
bool operator != (const DateTime& dateTime) const;
bool operator < (const DateTime& dateTime) const;
bool operator <= (const DateTime& dateTime) const;
bool operator > (const DateTime& dateTime) const;
bool operator >= (const DateTime& dateTime) const;
DateTime operator + (const Timespan& span) const;
DateTime operator - (const Timespan& span) const;
@@ -256,14 +256,14 @@ public:
protected:
static double toJulianDay(Timestamp::UtcTimeVal utcTime);
/// 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);
/// 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.
static Timestamp::UtcTimeVal toUtcTime(double julianDay);
/// Computes the UTC time for a Julian day.
void computeGregorian(double julianDay);
/// Computes the Gregorian date for the given Julian day.
/// See <http://vsg.cape.com/~pbaum/date/injdimp.htm>, section 3.3.1 for the algorithm.
@@ -323,19 +323,19 @@ inline int DateTime::year() const
return _year;
}
inline int DateTime::month() const
{
return _month;
}
inline int DateTime::day() const
{
return _day;
}
inline int DateTime::hour() const
{
return _hour;
@@ -364,19 +364,19 @@ inline bool DateTime::isPM() const
return _hour >= 12;
}
inline int DateTime::minute() const
{
return _minute;
}
inline int DateTime::second() const
{
return _second;
}
inline int DateTime::millisecond() const
{
return _millisecond;
@@ -395,13 +395,13 @@ inline bool DateTime::operator == (const DateTime& dateTime) const
}
inline bool DateTime::operator != (const DateTime& dateTime) const
inline bool DateTime::operator != (const DateTime& dateTime) const
{
return _utcTime != dateTime._utcTime;
}
inline bool DateTime::operator < (const DateTime& dateTime) const
inline bool DateTime::operator < (const DateTime& dateTime) const
{
return _utcTime < dateTime._utcTime;
}
@@ -419,7 +419,7 @@ inline bool DateTime::operator > (const DateTime& dateTime) const
}
inline bool DateTime::operator >= (const DateTime& dateTime) const
inline bool DateTime::operator >= (const DateTime& dateTime) const
{
return _utcTime >= dateTime._utcTime;
}
@@ -431,7 +431,7 @@ inline bool DateTime::isLeapYear(int year)
}
inline void swap(DateTime& d1, DateTime& d2)
inline void swap(DateTime& d1, DateTime& d2) noexcept
{
d1.swap(d2);
}

View File

@@ -33,7 +33,7 @@ public:
static const std::string ISO8601_FORMAT;
/// The date/time format defined in the ISO 8601 standard.
///
/// Examples:
/// Examples:
/// 2005-01-01T12:00:00+01:00
/// 2005-01-01T11:00:00Z
@@ -41,21 +41,21 @@ public:
/// The date/time format defined in the ISO 8601 standard,
/// with fractional seconds.
///
/// Examples:
/// Examples:
/// 2005-01-01T12:00:00.000000+01:00
/// 2005-01-01T11:00:00.000000Z
static const std::string RFC822_FORMAT;
/// The date/time format defined in RFC 822 (obsoleted by RFC 1123).
///
/// Examples:
/// Examples:
/// Sat, 1 Jan 05 12:00:00 +0100
/// Sat, 1 Jan 05 11:00:00 GMT
static const std::string RFC1123_FORMAT;
/// The date/time format defined in RFC 1123 (obsoletes RFC 822).
///
/// Examples:
/// Examples:
/// Sat, 1 Jan 2005 12:00:00 +0100
/// Sat, 1 Jan 2005 11:00:00 GMT
@@ -63,28 +63,28 @@ public:
/// The date/time format defined in the HTTP specification (RFC 2616),
/// which is basically a variant of RFC 1036 with a zero-padded day field.
///
/// Examples:
/// Examples:
/// Sat, 01 Jan 2005 12:00:00 +0100
/// Sat, 01 Jan 2005 11:00:00 GMT
static const std::string RFC850_FORMAT;
/// The date/time format defined in RFC 850 (obsoleted by RFC 1036).
///
/// Examples:
/// Examples:
/// Saturday, 1-Jan-05 12:00:00 +0100
/// Saturday, 1-Jan-05 11:00:00 GMT
static const std::string RFC1036_FORMAT;
/// The date/time format defined in RFC 1036 (obsoletes RFC 850).
///
/// Examples:
/// Examples:
/// Saturday, 1 Jan 05 12:00:00 +0100
/// Saturday, 1 Jan 05 11:00:00 GMT
static const std::string ASCTIME_FORMAT;
/// The date/time format produced by the ANSI C asctime() function.
///
/// Example:
/// Example:
/// Sat Jan 1 12:00:00 2005
static const std::string SORTABLE_FORMAT;
@@ -97,9 +97,9 @@ public:
// names used by formatter and parser
static const std::string WEEKDAY_NAMES[7];
/// English names of week days (Sunday, Monday, Tuesday, ...).
static const std::string MONTH_NAMES[12];
/// English names of months (January, February, ...).
/// English names of months (January, February, ...).
};

View File

@@ -31,7 +31,7 @@ class Timespan;
class Foundation_API DateTimeFormatter
/// This class converts dates and times into strings, supporting a
/// This class converts dates and times into strings, supporting a
/// variety of standard and custom formats.
///
/// There are two kind of static member functions:
@@ -43,7 +43,7 @@ class Foundation_API DateTimeFormatter
public:
enum
{
UTC = 0xFFFF /// Special value for timeZoneDifferential denoting UTC.
UTC = 0xFFFF /// Special value for timeZoneDifferential denoting UTC.
};
static std::string format(const Timestamp& timestamp, const std::string& fmt, int timeZoneDifferential = UTC);
@@ -130,7 +130,7 @@ public:
/// Formats the given timezone differential in ISO format.
/// If timeZoneDifferential is UTC, "Z" is returned,
/// otherwise, +HH.MM (or -HH.MM) is returned.
static std::string tzdRFC(int timeZoneDifferential);
/// Formats the given timezone differential in RFC format.
/// If timeZoneDifferential is UTC, "GMT" is returned,
@@ -141,7 +141,7 @@ public:
/// and appends it to the given string.
/// If timeZoneDifferential is UTC, "Z" is returned,
/// otherwise, +HH.MM (or -HH.MM) is returned.
static void tzdRFC(std::string& str, int timeZoneDifferential);
/// Formats the given timezone differential in RFC format
/// and appends it to the given string.

View File

@@ -46,7 +46,7 @@ class Foundation_API DateTimeParser
/// two or four digits. Years 69-00 are interpreted in the 20th century
/// (1969-2000), years 01-68 in the 21th century (2001-2068).
///
/// Note that in the current implementation all characters other than format specifiers in
/// Note that in the current implementation all characters other than format specifiers in
/// the format string are ignored/not matched against the date/time string. This may
/// lead to non-error results even with nonsense input strings.
/// This may change in a future version to a more strict behavior.
@@ -66,13 +66,13 @@ public:
/// Throws a SyntaxException if the string cannot be successfully parsed.
/// Please see DateTimeFormatter::format() for a description of the format string.
/// Class DateTimeFormat defines format strings for various standard date/time formats.
static bool tryParse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
/// Parses a date and time in the given format from the given string.
/// Returns true if the string has been successfully parsed, false otherwise.
/// Please see DateTimeFormatter::format() for a description of the format string.
/// Class DateTimeFormat defines format strings for various standard date/time formats.
static void parse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
/// Parses a date and time from the given dateTime string. Before parsing, the method
/// examines the dateTime string for a known date/time format.
@@ -85,7 +85,7 @@ public:
/// examines the dateTime string for a known date/time format.
/// Please see DateTimeFormatter::format() for a description of the format string.
/// Class DateTimeFormat defines format strings for various standard date/time formats.
static bool tryParse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
/// Parses a date and time from the given dateTime string. Before parsing, the method
/// examines the dateTime string for a known date/time format.
@@ -94,16 +94,16 @@ public:
static int parseMonth(std::string::const_iterator& it, const std::string::const_iterator& end);
/// Tries to interpret the given range as a month name. The range must be at least
/// three characters long.
/// three characters long.
/// Returns the month number (1 .. 12) if the month name is valid. Otherwise throws
/// a SyntaxException.
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
/// three characters long.
/// three characters long.
/// Returns the weekday number (0 .. 6, where 0 = Sunday, 1 = Monday, etc.) if the
/// weekday name is valid. Otherwise throws a SyntaxException.
protected:
static int parseTZD(std::string::const_iterator& it, const std::string::const_iterator& end);
static int parseAMPM(std::string::const_iterator& it, const std::string::const_iterator& end, int hour);

View File

@@ -26,7 +26,7 @@
namespace Poco {
template <class TArgs, class TDelegate>
template <class TArgs, class TDelegate>
class DefaultStrategy: public NotificationStrategy<TArgs, TDelegate>
/// Default notification strategy.
///
@@ -81,7 +81,7 @@ public:
}
}
}
void remove(DelegateHandle delegateHandle)
{
for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it)

View File

@@ -57,7 +57,7 @@ public:
///
/// Please refer to the zlib documentation of deflateInit2() for a description
/// of the windowBits parameter.
DeflatingStreamBuf(std::ostream& ostr, StreamType type, int level);
/// Creates a DeflatingStreamBuf for compressing data passed
/// through and forwarding it to the given output stream.
@@ -68,12 +68,12 @@ public:
///
/// Please refer to the zlib documentation of deflateInit2() for a description
/// of the windowBits parameter.
~DeflatingStreamBuf();
/// Destroys the DeflatingStreamBuf.
int close();
/// Finishes up the stream.
/// Finishes up the stream.
///
/// Must be called when deflating to an output stream.
@@ -83,7 +83,7 @@ protected:
virtual int sync();
private:
enum
enum
{
STREAM_BUFFER_SIZE = 1024,
DEFLATE_BUFFER_SIZE = 32768
@@ -128,10 +128,10 @@ public:
~DeflatingIOS();
/// Destroys the DeflatingIOS.
DeflatingStreamBuf* rdbuf();
/// Returns a pointer to the underlying stream buffer.
protected:
DeflatingStreamBuf _buf;
};
@@ -163,9 +163,9 @@ public:
~DeflatingOutputStream();
/// Destroys the DeflatingOutputStream.
int close();
/// Finishes up the stream.
/// Finishes up the stream.
///
/// Must be called when deflating to an output stream.

View File

@@ -60,8 +60,11 @@ public:
/// The returned reference is valid until the next
/// time digest() is called, or the engine object is destroyed.
static std::string digestToHex(const Digest& bytes);
static std::string digestToHex(const Digest& bytes, std::size_t length = 0);
/// Converts a message digest into a string of hexadecimal numbers.
/// If length is greater than zero, the output is truncated to length
/// bytes. If size is greater than the length of untruncated output,
/// InvalidArgumentException is thrown.
static Digest digestFromHex(const std::string& digest);
/// Converts a string created by digestToHex back to its Digest presentation

View File

@@ -36,7 +36,7 @@ public:
DigestBuf(DigestEngine& eng);
DigestBuf(DigestEngine& eng, std::istream& istr);
DigestBuf(DigestEngine& eng, std::ostream& ostr);
~DigestBuf();
~DigestBuf();
int readFromDevice(char* buffer, std::streamsize length);
int writeToDevice(const char* buffer, std::streamsize length);
void close();
@@ -83,7 +83,7 @@ class Foundation_API DigestOutputStream: public DigestIOS, public std::ostream
/// all the data passing through it,
/// using a DigestEngine.
/// To ensure that all data has been incorporated
/// into the digest, call close() or flush() before
/// into the digest, call close() or flush() before
/// you obtain the digest from the digest engine.
{
public:

View File

@@ -40,19 +40,19 @@ class Foundation_API DirectoryIterator
/// even is the original iterator has been advanced
/// (all copies of an iterator share their state with
/// the original iterator)
/// * because of this you should only use the prefix
/// * because of this you should only use the prefix
/// increment operator
{
public:
DirectoryIterator();
/// Creates the end iterator.
DirectoryIterator(const std::string& path);
/// Creates a directory iterator for the given path.
DirectoryIterator(const DirectoryIterator& iterator);
/// Creates a directory iterator for the given path.
DirectoryIterator(const File& file);
/// Creates a directory iterator for the given file.
@@ -64,7 +64,7 @@ public:
const std::string& name() const;
/// Returns the current filename.
const Path& path() const;
/// Returns the current path.
@@ -72,18 +72,18 @@ public:
DirectoryIterator& operator = (const File& file);
DirectoryIterator& operator = (const Path& path);
DirectoryIterator& operator = (const std::string& path);
virtual DirectoryIterator& operator ++ (); // prefix
//@ deprecated
DirectoryIterator operator ++ (int); // postfix
/// Please use the prefix increment operator instead.
const File& operator * () const;
File& operator * ();
const File* operator -> () const;
File* operator -> ();
bool operator == (const DirectoryIterator& iterator) const;
bool operator != (const DirectoryIterator& iterator) const;
@@ -104,7 +104,7 @@ inline const std::string& DirectoryIterator::name() const
return _path.getFileName();
}
inline const Path& DirectoryIterator::path() const
{
return _path;

View File

@@ -30,13 +30,13 @@ class Foundation_API DirectoryIteratorImpl
public:
DirectoryIteratorImpl(const std::string& path);
~DirectoryIteratorImpl();
void duplicate();
void release();
const std::string& get() const;
const std::string& next();
private:
DIR* _pDir;
std::string _current;

View File

@@ -30,13 +30,13 @@ class Foundation_API DirectoryIteratorImpl
public:
DirectoryIteratorImpl(const std::string& path);
~DirectoryIteratorImpl();
void duplicate();
void release();
const std::string& get() const;
const std::string& next();
private:
HANDLE _fh;
WIN32_FIND_DATAW _fd;

View File

@@ -45,7 +45,7 @@ class Foundation_API DirectoryWatcher: protected Runnable
///
/// A thread will be created that watches the specified
/// directory for changes. Events are reported in the context
/// of this thread.
/// of this thread.
///
/// Note that changes to files in subdirectories of the watched
/// directory are not reported. Separate DirectoryWatcher objects
@@ -74,7 +74,7 @@ public:
{
DW_ITEM_ADDED = 1,
/// A new item has been created and added to the directory.
DW_ITEM_REMOVED = 2,
/// An item has been removed from the directory.
@@ -96,12 +96,12 @@ public:
DW_FILTER_DISABLE_ALL = 0
/// Disables all event types.
};
enum
{
DW_DEFAULT_SCAN_INTERVAL = 5 /// Default scan interval for platforms that don't provide a native notification mechanism.
};
struct DirectoryEvent
{
DirectoryEvent(const File& f, DirectoryEventType ev):
@@ -113,13 +113,13 @@ public:
const File& item; /// The directory or file that has been changed.
DirectoryEventType event; /// The kind of event.
};
BasicEvent<const DirectoryEvent> itemAdded;
/// Fired when a file or directory has been created or added to the directory.
BasicEvent<const DirectoryEvent> itemRemoved;
/// Fired when a file or directory has been removed from the directory.
BasicEvent<const DirectoryEvent> itemModified;
/// Fired when a file or directory has been modified.
@@ -128,10 +128,10 @@ public:
BasicEvent<const DirectoryEvent> itemMovedTo;
/// Fired when a file or directory has been moved. This event delivers the new name.
BasicEvent<const Exception> scanError;
/// Fired when an error occurs while scanning for changes.
DirectoryWatcher(const std::string& path, int eventMask = DW_FILTER_ENABLE_ALL, int scanInterval = DW_DEFAULT_SCAN_INTERVAL);
/// Creates a DirectoryWatcher for the directory given in path.
/// To enable only specific events, an eventMask can be specified by
@@ -139,7 +139,7 @@ public:
/// On platforms where no native filesystem notifications are available,
/// scanInterval specifies the interval in seconds between scans
/// of the directory.
DirectoryWatcher(const File& directory, int eventMask = DW_FILTER_ENABLE_ALL, int scanInterval = DW_DEFAULT_SCAN_INTERVAL);
/// Creates a DirectoryWatcher for the specified directory
/// To enable only specific events, an eventMask can be specified by
@@ -150,30 +150,30 @@ public:
~DirectoryWatcher();
/// Destroys the DirectoryWatcher.
void suspendEvents();
/// Suspends sending of events. Can be called multiple times, but every
/// call to suspendEvent() must be matched by a call to resumeEvents().
void resumeEvents();
/// Resumes events, after they have been suspended with a call to suspendEvents().
bool eventsSuspended() const;
/// Returns true iff events are suspended.
int eventMask() const;
/// Returns the value of the eventMask passed to the constructor.
int scanInterval() const;
/// Returns the scan interval in seconds.
const File& directory() const;
/// Returns the directory being watched.
bool supportsMoveEvents() const;
/// Returns true iff the platform supports DW_ITEM_MOVED_FROM/itemMovedFrom and
/// DW_ITEM_MOVED_TO/itemMovedTo events.
protected:
void init();
void stop();

View File

@@ -67,7 +67,7 @@ public:
{
}
Pair& swap(Pair& other)
Pair& swap(Pair& other) noexcept
/// Swaps the content of the two Pairs.
{
std::swap(_data, other._data);

View File

@@ -32,6 +32,37 @@ namespace Poco {
namespace Dynamic {
template <typename S, typename I = typename S::ConstIterator>
std::string structToString(const S& data, bool wrap = true)
/// Utility function for converting DynamicStruct to std::string.
/// Set wrap to false in order to prevent string values wrapping
/// (useful to prevent JSON fragments from being treated as strings).
{
std::string val;
val.append("{ ");
I it = data.begin();
I itEnd = data.end();
if (!data.empty())
{
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second, wrap);
++it;
}
for (; it != itEnd; ++it)
{
val.append(", ");
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second, wrap);
}
val.append(" }");
return val;
}
template <typename K, typename M = std::map<K, Var>, typename S = std::set<K>>
class Struct
/// Struct allows to define a named collection of Var objects.
@@ -173,7 +204,7 @@ public:
_data.clear();
}
inline void swap(Struct& other)
inline void swap(Struct& other) noexcept
/// Swap content of Struct with another Struct
{
_data.swap(other._data);
@@ -226,11 +257,20 @@ public:
return it->second;
}
std::string toString() const
std::string toString(bool wrap = true) const
/// Returns the DynamicStruct as string.
///
/// To prevent unwanted string wrapping
/// (eg. when a value is JSON string),
/// `wrap` should be false. Note, however,
/// that wrap argument is of a limited utility
/// because it applies to the entire Struct,
/// so it should not be relied on when mixed content
/// (ie. plain string, which should be wrapped,
/// and JSON-as-string entries, which shouldn't)
/// is held.
{
std::string str;
Var(*this).template convert<std::string>(str);
return str;
return structToString<Data, ConstIterator>(_data, wrap);
}
private:
@@ -332,26 +372,7 @@ public:
void convert(std::string& val) const
{
val.append("{ ");
ValueType::ConstIterator it = _val.begin();
ValueType::ConstIterator itEnd = _val.end();
if (!_val.empty())
{
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second);
++it;
}
for (; it != itEnd; ++it)
{
val.append(", ");
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second);
}
val.append(" }");
val = structToString(_val);
}
void convert(Poco::DateTime&) const
@@ -518,26 +539,7 @@ public:
void convert(std::string& val) const
{
val.append("{ ");
ValueType::ConstIterator it = _val.begin();
ValueType::ConstIterator itEnd = _val.end();
if (!_val.empty())
{
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second);
++it;
}
for (; it != itEnd; ++it)
{
val.append(", ");
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second);
}
val.append(" }");
val = structToString(_val);
}
void convert(Poco::DateTime&) const
@@ -704,26 +706,7 @@ public:
void convert(std::string& val) const
{
val.append("{ ");
ValueType::ConstIterator it = _val.begin();
ValueType::ConstIterator itEnd = _val.end();
if (!_val.empty())
{
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second);
++it;
}
for (; it != itEnd; ++it)
{
val.append(", ");
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second);
}
val.append(" }");
val = structToString(_val);
}
void convert(Poco::DateTime&) const
@@ -890,26 +873,7 @@ public:
void convert(std::string& val) const
{
val.append("{ ");
ValueType::ConstIterator it = _val.begin();
ValueType::ConstIterator itEnd = _val.end();
if (!_val.empty())
{
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second);
++it;
}
for (; it != itEnd; ++it)
{
val.append(", ");
Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second);
}
val.append(" }");
val = structToString(_val);
}
void convert(Poco::DateTime&) const

View File

@@ -91,15 +91,9 @@ public:
template <typename T>
Var(const T& val)
/// Creates the Var from the given value.
#ifdef POCO_NO_SOO
: _pHolder(new VarHolderImpl<T>(val))
{
}
#else
{
construct(val);
}
#endif
Var(const char* pVal);
// Convenience constructor for const char* which gets mapped to a std::string internally, i.e. pVal is deep-copied.
@@ -222,7 +216,7 @@ public:
else if (!pHolder)
throw InvalidAccessException("Can not extract empty value.");
else
throw BadCastException(format("Can not convert %s to %s.",
throw BadCastException(Poco::format("Can not convert %s to %s.",
std::string(pHolder->type().name()),
std::string(typeid(T).name())));
}
@@ -231,12 +225,8 @@ public:
Var& operator = (const T& other)
/// Assignment operator for assigning POD to Var
{
#ifdef POCO_NO_SOO
Var tmp(other);
swap(tmp);
#else
clear();
construct(other);
#endif
return *this;
}
@@ -612,79 +602,34 @@ private:
return pStr->operator[](n);
}
#ifdef POCO_NO_SOO
VarHolder* content() const
{
return _pHolder;
}
void destruct()
{
if (!isEmpty()) delete content();
}
VarHolder* _pHolder;
#else
VarHolder* content() const
{
return _placeholder.content();
}
void destruct()
{
}
template<typename ValueType>
void construct(const ValueType& value)
{
if (sizeof(VarHolderImpl<ValueType>) <= Placeholder<ValueType>::Size::value)
{
new (reinterpret_cast<VarHolder*>(_placeholder.holder)) VarHolderImpl<ValueType>(value);
_placeholder.setLocal(true);
}
else
{
_placeholder.pHolder = new VarHolderImpl<ValueType>(value);
_placeholder.setLocal(false);
}
_placeholder.assign<VarHolderImpl<ValueType>, ValueType>(value);
}
void construct(const char* value)
{
std::string val(value);
if (sizeof(VarHolderImpl<std::string>) <= Placeholder<std::string>::Size::value)
{
new (reinterpret_cast<VarHolder*>(_placeholder.holder)) VarHolderImpl<std::string>(val);
_placeholder.setLocal(true);
}
else
{
_placeholder.pHolder = new VarHolderImpl<std::string>(val);
_placeholder.setLocal(false);
}
_placeholder.assign<VarHolderImpl<std::string>, std::string>(val);
}
void construct(const Var& other)
{
if (!other.isEmpty())
other.content()->clone(&_placeholder);
else
_placeholder.erase();
}
void destruct()
{
if (!isEmpty())
{
if (_placeholder.isLocal())
content()->~VarHolder();
else
delete content();
}
}
Placeholder<VarHolder> _placeholder;
#endif // POCO_NO_SOO
};
@@ -699,24 +644,17 @@ private:
inline void Var::swap(Var& other)
{
#ifdef POCO_NO_SOO
std::swap(_pHolder, other._pHolder);
#else
if (this == &other) return;
if (!_placeholder.isLocal() && !other._placeholder.isLocal())
{
std::swap(_placeholder.pHolder, other._placeholder.pHolder);
_placeholder.swap(other._placeholder);
}
else
{
Var tmp(*this);
try
{
if (_placeholder.isLocal()) destruct();
construct(other);
other = tmp;
}
@@ -726,8 +664,6 @@ inline void Var::swap(Var& other)
throw;
}
}
#endif
}

View File

@@ -67,10 +67,12 @@ void Foundation_API appendJSONString(std::string& val, const Var& any);
/// regardless of the underlying type) and appends it to val.
void Foundation_API appendJSONValue(std::string& val, const Var& any);
void Foundation_API appendJSONValue(std::string& val, const Var& any, bool wrap = true);
/// Converts the any to a JSON value (if underlying type qualifies
/// as string - see isJSONString() - , it is wrapped into double quotes)
/// and appends it to val
/// as string - see isJSONString() - it is wrapped into double quotes)
/// and appends it to val.
/// Wrapping can be prevented (useful for appending JSON fragments) by setting
/// the wrap argument to false.
template <typename C>
@@ -295,32 +297,18 @@ protected:
template <typename T>
VarHolder* cloneHolder(Placeholder<VarHolder>* pVarHolder, const T& val) const
/// Instantiates value holder wrapper. If size of the wrapper is
/// larger than POCO_SMALL_OBJECT_SIZE, holder is instantiated on
/// Instantiates value holder wrapper.
///
/// Called from clone() member function of the implementation.
///
/// When the smal object optimization is enabled (POCO_NO_SOO not
/// defined), if size of the wrapper is larger than
/// POCO_SMALL_OBJECT_SIZE, holder is instantiated on
/// the heap, otherwise it is instantiated in-place (in the
/// pre-allocated buffer inside the holder).
///
/// Called from clone() member function of the implementation when
/// small object optimization is enabled.
{
#ifdef POCO_NO_SOO
(void)pVarHolder;
return new VarHolderImpl<T>(val);
#else
poco_check_ptr (pVarHolder);
if ((sizeof(VarHolderImpl<T>) <= Placeholder<T>::Size::value))
{
new ((VarHolder*) pVarHolder->holder) VarHolderImpl<T>(val);
pVarHolder->setLocal(true);
return (VarHolder*) pVarHolder->holder;
}
else
{
pVarHolder->pHolder = new VarHolderImpl<T>(val);
pVarHolder->setLocal(false);
return pVarHolder->pHolder;
}
#endif
return pVarHolder->assign<VarHolderImpl<T>, T>(val);
}
template <typename F, typename T>
@@ -420,41 +408,52 @@ protected:
}
private:
template <typename F, typename T>
void checkUpperLimit(const F& from) const
{
if ((sizeof(T) < sizeof(F)) &&
(from > static_cast<F>(std::numeric_limits<T>::max())))
{
throw RangeException("Value too large.");
}
else
if (from > std::numeric_limits<T>::max())
{
throw RangeException("Value too large.");
}
}
template <typename F, typename T>
void checkUpperLimitFloat(const F& from) const
{
if (from > std::numeric_limits<T>::max())
throw RangeException("Value too large.");
}
template <typename F, typename T>
void checkLowerLimitFloat(const F& from) const
{
if (from < -std::numeric_limits<T>::max())
throw RangeException("Value too small.");
}
template <typename F, typename T>
void checkLowerLimit(const F& from) const
{
if (from < std::numeric_limits<T>::min())
throw RangeException("Value too small.");
}
template <typename F, typename T>
void checkUpperLimitFloat(const F& from) const
{
if (std::is_floating_point<T>::value)
{
if (from > std::numeric_limits<T>::max())
throw RangeException("Value too large.");
}
else
{
// Avoid clang -Wimplicit-int-float-conversion warning with an explicit cast.
if (from > static_cast<F>(std::numeric_limits<T>::max()))
throw RangeException("Value too large.");
}
}
template <typename F, typename T>
void checkLowerLimitFloat(const F& from) const
{
if (std::is_floating_point<T>::value)
{
if (from < -std::numeric_limits<T>::max())
throw RangeException("Value too small.");
}
else
{
// Avoid clang -Wimplicit-int-float-conversion warning with an explicit cast.
if (from < static_cast<F>(std::numeric_limits<T>::min()))
throw RangeException("Value too small.");
}
}
};

View File

@@ -79,11 +79,11 @@ public:
/// Advances by one position and returns current position.
VarIterator operator ++ (int) const;
/// Advances by one position and returns copy of the iterator with
/// Advances by one position and returns copy of the iterator with
/// previous current position.
const VarIterator& operator -- () const;
/// Goes back by one position and returns copy of the iterator with
/// Goes back by one position and returns copy of the iterator with
/// previous current position.
VarIterator operator -- (int) const;
@@ -103,15 +103,15 @@ private:
VarIterator();
void increment() const;
/// Increments the iterator position by one.
/// Increments the iterator position by one.
/// Throws RangeException if position is out of range.
void decrement() const;
/// Decrements the iterator position by one.
/// Decrements the iterator position by one.
/// Throws RangeException if position is out of range.
void setPosition(std::size_t pos) const;
/// Sets the iterator position.
/// Sets the iterator position.
/// Throws RangeException if position is out of range.
Var* _pVar;

View File

@@ -31,8 +31,8 @@ class Foundation_API EnvironmentImpl
public:
typedef UInt8 NodeId[6]; /// Ethernet address.
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static void setImpl(const std::string& name, const std::string& value);
static std::string osNameImpl();
static std::string osDisplayNameImpl();
@@ -44,7 +44,7 @@ public:
private:
typedef std::map<std::string, std::string> StringMap;
static StringMap _map;
static FastMutex _mutex;
};

View File

@@ -31,8 +31,8 @@ class Foundation_API EnvironmentImpl
public:
typedef UInt8 NodeId[6]; /// Ethernet address.
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static void setImpl(const std::string& name, const std::string& value);
static std::string osNameImpl();
static std::string osDisplayNameImpl();
@@ -44,7 +44,7 @@ public:
private:
typedef std::map<std::string, std::string> StringMap;
static StringMap _map;
static FastMutex _mutex;
};

View File

@@ -29,10 +29,10 @@ class Foundation_API EnvironmentImpl
public:
typedef UInt8 NodeId[6]; /// Ethernet address.
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static void setImpl(const std::string& name, const std::string& value);
static std::string osNameImpl();
static std::string osNameImpl();
static std::string osDisplayNameImpl();
static std::string osVersionImpl();
static std::string osArchitectureImpl();

View File

@@ -29,27 +29,27 @@ class Foundation_API EnvironmentImpl
public:
typedef UInt8 NodeId[6]; /// Ethernet address.
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static void setImpl(const std::string& name, const std::string& value);
static std::string osNameImpl();
static std::string osNameImpl();
static std::string osDisplayNameImpl();
static std::string osVersionImpl();
static std::string osArchitectureImpl();
static std::string nodeNameImpl();
static void nodeIdImpl(NodeId& id);
static unsigned processorCountImpl();
private:
static bool envVar(const std::string& name, std::string* value);
static const std::string TEMP;
static const std::string TMP;
static const std::string HOMEPATH;
static const std::string COMPUTERNAME;
static const std::string OS;
static const std::string NUMBER_OF_PROCESSORS;
static const std::string PROCESSOR_ARCHITECTURE;
static const std::string PROCESSOR_ARCHITECTURE;
};

View File

@@ -32,7 +32,7 @@ class Foundation_API ErrorHandler
/// An unhandled exception that causes a thread to terminate is usually
/// silently ignored, since the class library cannot do anything meaningful
/// about it.
///
///
/// The Thread class provides the possibility to register a
/// global ErrorHandler that is invoked whenever a thread has
/// been terminated by an unhandled exception.
@@ -57,10 +57,10 @@ public:
/// be silently ignored.
///
/// The default implementation just breaks into the debugger.
virtual void exception(const std::exception& exc);
/// Called when a std::exception (or a subclass)
/// caused the thread to terminate.
/// caused the thread to terminate.
///
/// This method should not throw any exception - it would
/// be silently ignored.
@@ -76,16 +76,16 @@ public:
/// be silently ignored.
///
/// The default implementation just breaks into the debugger.
static void handle(const Exception& exc);
/// Invokes the currently registered ErrorHandler.
static void handle(const std::exception& exc);
/// Invokes the currently registered ErrorHandler.
static void handle();
/// Invokes the currently registered ErrorHandler.
static ErrorHandler* set(ErrorHandler* pHandler);
/// Registers the given handler as the current error handler.
///
@@ -95,10 +95,10 @@ public:
/// Returns a pointer to the currently registered
/// ErrorHandler.
protected:
protected:
static ErrorHandler* defaultHandler();
/// Returns the default ErrorHandler.
/// Returns the default ErrorHandler.
private:
static ErrorHandler* _pHandler;
static FastMutex _mutex;

View File

@@ -54,7 +54,7 @@ public:
/// Creates the event. If type is EVENT_AUTORESET,
/// the event is automatically reset after
/// a wait() successfully returns.
//@ deprecated
explicit Event(bool autoReset);
/// Please use Event::Event(EventType) instead.
@@ -64,7 +64,7 @@ public:
void set();
/// Signals the event. If autoReset is true,
/// only one thread waiting for the event
/// only one thread waiting for the event
/// can resume execution.
/// If autoReset is false, all waiting threads
/// can resume execution.
@@ -86,7 +86,7 @@ public:
void reset();
/// Resets the event to unsignalled state.
private:
Event(const Event&);
Event& operator = (const Event&);

View File

@@ -34,7 +34,7 @@ class Foundation_API EventArgs
{
public:
EventArgs();
virtual ~EventArgs();
};

View File

@@ -30,7 +30,7 @@ namespace Poco {
class Foundation_API EventChannel: public Channel
/// The EventChannel fires the messageLogged event for every log message
/// received. This can be used to hook custom log message processing into
/// the logging framework.
/// the logging framework.
{
public:
using Ptr = AutoPtr<EventChannel>;

View File

@@ -41,30 +41,30 @@ public:
/// Creates the EventLogChannel.
/// The name of the current application (or more correctly,
/// the name of its executable) is taken as event source name.
EventLogChannel(const std::string& name);
/// Creates the EventLogChannel with the given event source name.
EventLogChannel(const std::string& name, const std::string& host);
/// Creates an EventLogChannel with the given event source
/// name that routes messages to the given host.
void open();
/// Opens the EventLogChannel. If necessary, the
/// required registry entries to register a
/// message resource DLL are made.
void close();
/// Closes the EventLogChannel.
void log(const Message& msg);
/// Logs the given message to the Windows Event Log.
///
/// The message type and priority are mapped to
/// appropriate values for Event Log type and category.
void setProperty(const std::string& name, const std::string& value);
/// Sets or changes a configuration property.
/// Sets or changes a configuration property.
///
/// The following properties are supported:
///
@@ -73,7 +73,7 @@ public:
/// The default is "localhost".
/// * host: same as host.
/// * logfile: The name of the log file. The default is "Application".
std::string getProperty(const std::string& name) const;
/// Returns the value of the given property.

View File

@@ -22,6 +22,7 @@
#include "Poco/Exception.h"
#include <pthread.h>
#include <errno.h>
#include <atomic>
namespace Poco {
@@ -30,16 +31,16 @@ namespace Poco {
class Foundation_API EventImpl
{
protected:
EventImpl(bool autoReset);
EventImpl(bool autoReset);
~EventImpl();
void setImpl();
void waitImpl();
bool waitImpl(long milliseconds);
void resetImpl();
private:
bool _auto;
volatile bool _state;
bool _state;
pthread_mutex_t _mutex;
pthread_cond_t _cond;
};
@@ -50,7 +51,7 @@ private:
//
inline void EventImpl::setImpl()
{
if (pthread_mutex_lock(&_mutex))
if (pthread_mutex_lock(&_mutex))
throw SystemException("cannot signal event (lock)");
_state = true;
if (pthread_cond_broadcast(&_cond))
@@ -64,7 +65,7 @@ inline void EventImpl::setImpl()
inline void EventImpl::resetImpl()
{
if (pthread_mutex_lock(&_mutex))
if (pthread_mutex_lock(&_mutex))
throw SystemException("cannot reset event");
_state = false;
pthread_mutex_unlock(&_mutex);

View File

@@ -29,13 +29,13 @@ namespace Poco {
class Foundation_API EventImpl
{
protected:
EventImpl(bool autoReset);
EventImpl(bool autoReset);
~EventImpl();
void setImpl();
void waitImpl();
bool waitImpl(long milliseconds);
void resetImpl();
private:
bool _auto;
volatile bool _state;

View File

@@ -21,7 +21,7 @@
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include "Poco/UnWindows.h"
#include <atomic>
namespace Poco {
@@ -29,15 +29,15 @@ namespace Poco {
class Foundation_API EventImpl
{
protected:
EventImpl(bool autoReset);
EventImpl(bool autoReset);
~EventImpl();
void setImpl();
void waitImpl();
bool waitImpl(long milliseconds);
void resetImpl();
private:
HANDLE _event;
std::atomic<HANDLE> _event;
};

View File

@@ -42,7 +42,7 @@ public:
Exception(const Exception& exc);
/// Copy constructor.
~Exception() noexcept;
/// Destroys the exception and deletes the nested exception.
@@ -51,25 +51,25 @@ public:
virtual const char* name() const noexcept;
/// Returns a static string describing the exception.
virtual const char* className() const noexcept;
/// Returns the name of the exception class.
virtual const char* what() const noexcept;
/// Returns a static string describing the exception.
///
/// Same as name(), but for compatibility with std::exception.
const Exception* nested() const;
/// Returns a pointer to the nested exception, or
/// null if no nested exception exists.
const std::string& message() const;
/// Returns the message text.
int code() const;
/// Returns the exception code if defined.
std::string displayText() const;
/// Returns a string consisting of the
/// message name and the message text.
@@ -79,7 +79,7 @@ public:
///
/// The copy can later be thrown again by
/// invoking rethrow() on it.
virtual void rethrow() const;
/// (Re)Throws the exception.
///
@@ -96,7 +96,7 @@ protected:
void extendedMessage(const std::string& arg);
/// Sets the extended message for the exception.
private:
std::string _msg;
Exception* _pNested;

View File

@@ -64,7 +64,7 @@ public:
~ExpirationDecorator()
{
}
const Poco::Timestamp& getExpiration() const
{
return _expiresAt;

View File

@@ -28,12 +28,12 @@ namespace Poco {
template <class TArgs>
class Expire: public AbstractDelegate<TArgs>
/// Decorator for AbstractDelegate adding automatic
/// Decorator for AbstractDelegate adding automatic
/// expiration of registrations to AbstractDelegate's.
{
public:
Expire(const AbstractDelegate<TArgs>& p, Timestamp::TimeDiff expireMillisecs):
_pDelegate(p.clone()),
_pDelegate(p.clone()),
_expire(expireMillisecs*1000)
{
}
@@ -50,7 +50,7 @@ public:
{
delete _pDelegate;
}
Expire& operator = (const Expire& expire)
{
if (&expire != this)
@@ -81,7 +81,7 @@ public:
{
return new Expire(*this);
}
void disable()
{
_pDelegate->disable();
@@ -109,12 +109,12 @@ private:
template <>
class Expire<void>: public AbstractDelegate<void>
/// Decorator for AbstractDelegate adding automatic
/// Decorator for AbstractDelegate adding automatic
/// expiration of registrations to AbstractDelegate's.
{
public:
Expire(const AbstractDelegate<void>& p, Timestamp::TimeDiff expireMillisecs):
_pDelegate(p.clone()),
_pDelegate(p.clone()),
_expire(expireMillisecs*1000)
{
}
@@ -131,7 +131,7 @@ public:
{
delete _pDelegate;
}
Expire& operator = (const Expire& expire)
{
if (&expire != this)
@@ -162,7 +162,7 @@ public:
{
return new Expire(*this);
}
void disable()
{
_pDelegate->disable();

View File

@@ -26,11 +26,11 @@ namespace Poco {
template <
class TKey,
class TValue,
class TMutex = FastMutex,
class TKey,
class TValue,
class TMutex = FastMutex,
class TEventMutex = FastMutex
>
>
class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue>, TMutex, TEventMutex>
/// An ExpireCache caches entries for a fixed time period (per default 10 minutes).
/// Entries expire independently of the access pattern, i.e. after a constant time.
@@ -40,11 +40,11 @@ class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValu
/// Be careful when using an ExpireCache. A cache is often used
/// like cache.has(x) followed by cache.get x). Note that it could happen
/// that the "has" call works, then the current execution thread gets descheduled, time passes,
/// the entry gets invalid, thus leading to an empty SharedPtr being returned
/// the entry gets invalid, thus leading to an empty SharedPtr being returned
/// when "get" is invoked.
{
public:
ExpireCache(Timestamp::TimeDiff expire = 600000):
ExpireCache(Timestamp::TimeDiff expire = 600000):
AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue>, TMutex, TEventMutex>(ExpireStrategy<TKey, TValue>(expire))
{
}

View File

@@ -27,10 +27,10 @@
namespace Poco {
template <
template <
class TKey,
class TValue,
class TMutex = FastMutex,
class TMutex = FastMutex,
class TEventMutex = FastMutex
>
class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>

View File

@@ -31,7 +31,7 @@
namespace Poco {
template <
template <
class TKey,
class TValue
>
@@ -50,7 +50,7 @@ public:
/// Create an expire strategy. Note that the smallest allowed caching time is 25ms.
/// Anything lower than that is not useful with current operating systems.
{
if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms");
if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms");
}
~ExpireStrategy()

View File

@@ -41,7 +41,7 @@ class BasicFIFOBuffer
/// However, to achieve thread-safety in cases where multiple
/// member function calls are involved and have to be atomic,
/// the mutex must be locked externally.
///
///
/// Buffer size, as well as amount of unread data and
/// available space introspections are supported as well.
///
@@ -55,12 +55,12 @@ public:
/// Event indicating "writability" of the buffer,
/// triggered as follows:
///
/// * when buffer transitions from non-full to full,
/// Writable event observers are notified, with
/// * when buffer transitions from non-full to full,
/// Writable event observers are notified, with
/// false value as the argument
///
/// * when buffer transitions from full to non-full,
/// Writable event observers are notified, with
/// Writable event observers are notified, with
/// true value as the argument
mutable Poco::BasicEvent<bool> readable;
@@ -68,7 +68,7 @@ public:
/// triggered as follows:
///
/// * when buffer transitions from non-empty to empty,
/// Readable event observers are notified, with false
/// Readable event observers are notified, with false
/// value as the argument
///
/// * when FIFOBuffer transitions from empty to non-empty,
@@ -112,7 +112,7 @@ public:
/// Destroys the FIFOBuffer.
{
}
void resize(std::size_t newSize, bool preserveContent = true)
/// Resizes the buffer. If preserveContent is true,
/// the content of the old buffer is preserved.
@@ -126,22 +126,22 @@ public:
if (preserveContent && (newSize < _used))
throw InvalidAccessException("Can not resize FIFO without data loss.");
std::size_t usedBefore = _used;
_buffer.resize(newSize, preserveContent);
if (!preserveContent) _used = 0;
if (_notify) notify(usedBefore);
}
std::size_t peek(T* pBuffer, std::size_t length) const
/// Peeks into the data currently in the FIFO
/// without actually extracting it.
/// If length is zero, the return is immediate.
/// If length is greater than used length,
/// it is substituted with the the current FIFO
/// it is substituted with the the current FIFO
/// used length.
///
/// Returns the number of elements copied in the
///
/// Returns the number of elements copied in the
/// supplied buffer.
{
if (0 == length) return 0;
@@ -151,17 +151,17 @@ public:
std::memcpy(pBuffer, _buffer.begin() + _begin, length * sizeof(T));
return length;
}
std::size_t peek(Poco::Buffer<T>& buffer, std::size_t length = 0) const
/// Peeks into the data currently in the FIFO
/// without actually extracting it.
/// Resizes the supplied buffer to the size of
/// data written to it. If length is not
/// supplied by the caller or is greater than length
/// of currently used data, the current FIFO used
/// supplied by the caller or is greater than length
/// of currently used data, the current FIFO used
/// data length is substituted for it.
///
/// Returns the number of elements copied in the
///
/// Returns the number of elements copied in the
/// supplied buffer.
{
Mutex::ScopedLock lock(_mutex);
@@ -170,13 +170,13 @@ public:
buffer.resize(length);
return peek(buffer.begin(), length);
}
std::size_t read(T* pBuffer, std::size_t length)
/// Copies the data currently in the FIFO
/// into the supplied buffer, which must be
/// preallocated to at least the length size
/// before calling this function.
///
///
/// Returns the size of the copied data.
{
if (0 == length) return 0;
@@ -193,13 +193,13 @@ public:
return readLen;
}
std::size_t read(Poco::Buffer<T>& buffer, std::size_t length = 0)
/// Copies the data currently in the FIFO
/// into the supplied buffer.
/// Resizes the supplied buffer to the size of
/// data written to it.
///
///
/// Returns the size of the copied data.
{
Mutex::ScopedLock lock(_mutex);
@@ -219,20 +219,20 @@ public:
std::size_t write(const T* pBuffer, std::size_t length)
/// Writes data from supplied buffer to the FIFO buffer.
/// If there is no sufficient space for the whole
/// buffer to be written, data up to available
/// buffer to be written, data up to available
/// length is written.
/// The length of data to be written is determined from the
/// length argument. Function does nothing and returns zero
/// if length argument is equal to zero.
///
///
/// Returns the length of data written.
{
if (0 == length) return 0;
Mutex::ScopedLock lock(_mutex);
if (!isWritable()) return 0;
if (_buffer.size() - (_begin + _used) < length)
{
std::memmove(_buffer.begin(), begin(), _used * sizeof(T));
@@ -253,12 +253,12 @@ public:
std::size_t write(const Buffer<T>& buffer, std::size_t length = 0)
/// Writes data from supplied buffer to the FIFO buffer.
/// If there is no sufficient space for the whole
/// buffer to be written, data up to available
/// buffer to be written, data up to available
/// length is written.
/// The length of data to be written is determined from the
/// length argument or buffer size (when length argument is
/// default zero or greater than buffer size).
///
///
/// Returns the length of data written.
{
if (length == 0 || length > buffer.size())
@@ -272,13 +272,13 @@ public:
{
return _buffer.size();
}
std::size_t used() const
/// Returns the size of the used portion of the buffer.
{
return _used;
}
std::size_t available() const
/// Returns the size of the available portion of the buffer.
{
@@ -316,10 +316,10 @@ public:
if (0 == length) return;
Mutex::ScopedLock lock(_mutex);
if (length > available())
throw Poco::InvalidAccessException("Cannot extend buffer.");
if (!isWritable())
throw Poco::InvalidAccessException("Buffer not writable.");
@@ -331,14 +331,15 @@ public:
void advance(std::size_t length)
/// Advances buffer by length elements.
/// Should be called AFTER the data
/// Should be called AFTER the data
/// was copied into the buffer.
{
if (0 == length) return;
Mutex::ScopedLock lock(_mutex);
if (length > available())
throw Poco::InvalidAccessException("Cannot extend buffer.");
if (!isWritable())
throw Poco::InvalidAccessException("Buffer not writable.");
@@ -377,7 +378,7 @@ public:
T& operator [] (std::size_t index)
/// Returns value at index position.
/// Throws InvalidAccessException if index is larger than
/// Throws InvalidAccessException if index is larger than
/// the last valid (used) buffer position.
{
Mutex::ScopedLock lock(_mutex);
@@ -389,7 +390,7 @@ public:
const T& operator [] (std::size_t index) const
/// Returns value at index position.
/// Throws InvalidAccessException if index is larger than
/// Throws InvalidAccessException if index is larger than
/// the last valid (used) buffer position.
{
Mutex::ScopedLock lock(_mutex);
@@ -404,12 +405,12 @@ public:
{
return _buffer;
}
void setError(bool error = true)
/// Sets the error flag on the buffer and empties it.
/// If notifications are enabled, they will be triggered
/// If notifications are enabled, they will be triggered
/// if appropriate.
///
///
/// Setting error flag to true prevents reading and writing
/// to the buffer; to re-enable FIFOBuffer for reading/writing,
/// the error flag must be set to false.
@@ -418,8 +419,8 @@ public:
{
bool f = false;
Mutex::ScopedLock lock(_mutex);
if (error && isReadable() && _notify) readable.notify(this, f);
if (error && isWritable() && _notify) writable.notify(this, f);
if (isReadable() && _notify) readable.notify(this, f);
if (isWritable() && _notify) writable.notify(this, f);
_error = error;
_used = 0;
}
@@ -441,14 +442,14 @@ public:
void setEOF(bool eof = true)
/// Sets end-of-file flag on the buffer.
///
///
/// Setting EOF flag to true prevents writing to the
/// buffer; reading from the buffer will still be
/// allowed until all data present in the buffer at the
/// EOF set time is drained. After that, to re-enable
/// allowed until all data present in the buffer at the
/// EOF set time is drained. After that, to re-enable
/// FIFOBuffer for reading/writing, EOF must be
/// set to false.
///
///
/// Setting EOF flag to false clears EOF state if it
/// was previously set. If EOF was not set, it has no
/// effect.
@@ -523,7 +524,7 @@ private:
readable.notify(this, t);
else if (usedBefore > 0 && 0 == _used)
readable.notify(this, f);
if (usedBefore == _buffer.size() && _used < _buffer.size())
writable.notify(this, t);
else if (usedBefore < _buffer.size() && _used == _buffer.size())

View File

@@ -33,7 +33,7 @@ class Foundation_API FIFOBufferStreamBuf: public BufferedBidirectionalStreamBuf
/// FIFOBuffer is enabled for emtpy/non-empty/full state transitions notifications.
{
public:
FIFOBufferStreamBuf();
/// Creates a FIFOBufferStreamBuf.
@@ -60,7 +60,7 @@ protected:
int writeToDevice(const char* buffer, std::streamsize length);
private:
enum
enum
{
STREAM_BUFFER_SIZE = 1024
};
@@ -89,15 +89,15 @@ public:
explicit FIFOIOS(std::size_t length);
/// Creates a FIFOIOS of the given length.
~FIFOIOS();
/// Destroys the FIFOIOS.
///
/// Flushes the buffer.
FIFOBufferStreamBuf* rdbuf();
/// Returns a pointer to the internal FIFOBufferStreamBuf.
void close();
/// Flushes the stream.

View File

@@ -27,9 +27,9 @@ namespace Poco {
//@ deprecated
template <class TArgs, class TMutex = FastMutex>
class FIFOEvent: public AbstractEvent <
TArgs,
template <class TArgs, class TMutex = FastMutex>
class FIFOEvent: public AbstractEvent <
TArgs,
FIFOStrategy<TArgs, AbstractDelegate<TArgs>>,
AbstractDelegate<TArgs>,
TMutex

View File

@@ -25,9 +25,9 @@ namespace Poco {
//@ deprecated
template <class TArgs, class TDelegate>
template <class TArgs, class TDelegate>
class FIFOStrategy: public DefaultStrategy<TArgs, TDelegate>
/// Note: As of release 1.4.2, DefaultStrategy already
/// Note: As of release 1.4.2, DefaultStrategy already
/// implements FIFO behavior, so this class is provided
/// for backwards compatibility only.
{

View File

@@ -59,18 +59,18 @@ protected:
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);

View File

@@ -48,18 +48,18 @@ protected:
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);

View File

@@ -47,18 +47,18 @@ protected:
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);

View File

@@ -106,8 +106,8 @@ inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
{
if (_isnan(value) != 0) return false;
return _finite(value) == 0;
if (_isnan(static_cast<double>(value)) != 0) return false;
return _finite(static_cast<double>(value)) == 0;
}
@@ -125,7 +125,7 @@ inline bool FPEnvironmentImpl::isNaNImpl(double value)
inline bool FPEnvironmentImpl::isNaNImpl(long double value)
{
return _isnan(value) != 0;
return _isnan(static_cast<double>(value)) != 0;
}

View File

@@ -23,7 +23,7 @@
#include <vector>
#if defined(POCO_OS_FAMILY_WINDOWS)
#if defined(POCO_OS_FAMILY_WINDOWS)
#if defined(_WIN32_WCE)
#include "File_WINCE.h"
#else
@@ -103,7 +103,7 @@ public:
File& operator = (const Path& path);
/// Assignment operator.
void swap(File& file);
void swap(File& file) noexcept;
/// Swaps the file with another one.
const std::string& path() const;
@@ -312,7 +312,7 @@ inline bool File::operator >= (const File& file) const
}
inline void swap(File& f1, File& f2)
inline void swap(File& f1, File& f2) noexcept
{
f1.swap(f2);
}

View File

@@ -43,7 +43,7 @@ class Foundation_API FileChannel: public Channel
/// by a newline.
///
/// Chain this channel to a FormattingChannel with an
/// appropriate Formatter to control what is in the text.
/// appropriate Formatter to control what is in the text.
///
/// The FileChannel support log file rotation based
/// on log file size or time intervals.
@@ -66,7 +66,7 @@ class Foundation_API FileChannel: public Channel
/// * daily: the file is rotated daily
/// * weekly: the file is rotated every seven days
/// * monthly: the file is rotated every 30 days
/// * <n> minutes: the file is rotated every <n> minutes,
/// * <n> minutes: the file is rotated every <n> minutes,
/// where <n> is an integer greater than zero.
/// * <n> hours: the file is rotated every <n> hours, where
/// <n> is an integer greater than zero.
@@ -128,7 +128,7 @@ class Foundation_API FileChannel: public Channel
///
/// Archived log files can be automatically purged, either if
/// they reach a certain age, or if the number of archived
/// log files reaches a given maximum number. This is
/// log files reaches a given maximum number. This is
/// controlled by the purgeAge and purgeCount properties.
///
/// The purgeAge property can have the following values:
@@ -148,18 +148,18 @@ class Foundation_API FileChannel: public Channel
/// The flush property specifies whether each log message is flushed
/// immediately to the log file (which may hurt application performance,
/// but ensures that everything is in the log in case of a system crash),
// or whether it's allowed to stay in the system's file buffer for some time.
// or whether it's allowed to stay in the system's file buffer for some time.
/// Valid values are:
///
/// * true: Every essages is immediately flushed to the log file (default).
/// * false: Messages are not immediately flushed to the log file.
///
/// The rotateOnOpen property specifies whether an existing log file should be
/// The rotateOnOpen property specifies whether an existing log file should be
/// rotated (and archived) when the channel is opened. Valid values are:
///
/// * true: The log file is rotated (and archived) when the channel is opened.
/// * false: Log messages will be appended to an existing log file,
/// if it exists (unless other conditions for a rotation are met).
/// if it exists (unless other conditions for a rotation are met).
/// This is the default.
///
/// For a more lightweight file channel class, see SimpleFileChannel.
@@ -173,19 +173,19 @@ public:
void open();
/// Opens the FileChannel and creates the log file if necessary.
void close();
/// Closes the FileChannel.
void log(const Message& msg);
/// Logs the given message to the file.
void setProperty(const std::string& name, const std::string& value);
/// Sets the property with the given name.
///
/// Sets the property with the given name.
///
/// The following properties are supported:
/// * path: The log file's path.
/// * rotation: The log file's rotation mode. See the
/// * rotation: The log file's rotation mode. See the
/// FileChannel class for details.
/// * archive: The log file's archive mode. See the
/// FileChannel class for details.
@@ -203,7 +203,7 @@ public:
/// * flush: Specifies whether messages are immediately
/// flushed to the log file. See the FileChannel class
/// for details.
/// * rotateOnOpen: Specifies whether an existing log file should be
/// * rotateOnOpen: Specifies whether an existing log file should be
/// rotated and archived when the channel is opened.
std::string getProperty(const std::string& name) const;
@@ -211,9 +211,21 @@ public:
/// See setProperty() for a description of the supported
/// properties.
void setRotationStrategy(RotateStrategy* strategy);
/// Set a rotation strategy.
/// FileChannel will take ownership of the pointer
void setArchiveStrategy(ArchiveStrategy* strategy);
/// Set an archive strategy.
/// FileChannel will take ownership of the pointer
void setPurgeStrategy(PurgeStrategy* strategy);
/// Set a purge strategy.
/// FileChannel will take ownership of the pointer
Timestamp creationDate() const;
/// Returns the log file's creation date.
UInt64 size() const;
/// Returns the log file's current size in bytes.
@@ -232,6 +244,7 @@ public:
protected:
~FileChannel();
void setRotation(const std::string& rotation);
void setArchive(const std::string& archive);
void setCompress(const std::string& compress);
@@ -244,9 +257,11 @@ protected:
private:
bool setNoPurge(const std::string& value);
int extractDigit(const std::string& value, std::string::const_iterator* nextToDigit = NULL) const;
void setPurgeStrategy(PurgeStrategy* strategy);
Timespan::TimeDiff extractFactor(const std::string& value, std::string::const_iterator start) const;
RotateStrategy* createRotationStrategy(const std::string& rotation, const std::string& times) const;
ArchiveStrategy* createArchiveStrategy(const std::string& archive, const std::string& times) const;
std::string _path;
std::string _times;
std::string _rotation;

View File

@@ -49,14 +49,14 @@ class Foundation_API FileIOS: public virtual std::ios
public:
FileIOS(std::ios::openmode defaultMode);
/// Creates the basic stream.
~FileIOS();
/// Destroys the stream.
void open(const std::string& path, std::ios::openmode mode);
/// Opens the file specified by path, using the given mode.
///
/// Throws a FileException (or a similar exception) if the file
/// Throws a FileException (or a similar exception) if the file
/// does not exist or is not accessible for other reasons and
/// a new file cannot be created.
@@ -90,7 +90,7 @@ class Foundation_API FileInputStream: public FileIOS, public std::istream
public:
FileInputStream();
/// Creates an unopened FileInputStream.
FileInputStream(const std::string& path, std::ios::openmode mode = std::ios::in);
/// Creates the FileInputStream for the file given by path, using
/// the given mode.
@@ -98,7 +98,7 @@ public:
/// The std::ios::in flag is always set, regardless of the actual
/// value specified for mode.
///
/// Throws a FileNotFoundException (or a similar exception) if the file
/// Throws a FileNotFoundException (or a similar exception) if the file
/// does not exist or is not accessible for other reasons.
~FileInputStream();
@@ -120,15 +120,15 @@ class Foundation_API FileOutputStream: public FileIOS, public std::ostream
public:
FileOutputStream();
/// Creats an unopened FileOutputStream.
FileOutputStream(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::trunc);
/// Creates the FileOutputStream for the file given by path, using
/// the given mode.
///
/// The std::ios::out is always set, regardless of the actual
/// The std::ios::out is always set, regardless of the actual
/// value specified for mode.
///
/// Throws a FileException (or a similar exception) if the file
/// Throws a FileException (or a similar exception) if the file
/// does not exist or is not accessible for other reasons and
/// a new file cannot be created.
@@ -147,7 +147,7 @@ class Foundation_API FileStream: public FileIOS, public std::iostream
/// Use an InputLineEndingConverter or OutputLineEndingConverter
/// if you require CR-LF translation.
///
/// A seek (seekg() or seekp()) operation will always set the
/// A seek (seekg() or seekp()) operation will always set the
/// read position and the write position simultaneously to the
/// same value.
///
@@ -156,7 +156,7 @@ class Foundation_API FileStream: public FileIOS, public std::iostream
public:
FileStream();
/// Creats an unopened FileStream.
FileStream(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::in);
/// Creates the FileStream for the file given by path, using
/// the given mode.

View File

@@ -38,7 +38,7 @@ public:
~FileStreamFactory();
/// Destroys the FileStreamFactory.
std::istream* open(const URI& uri);
/// Creates and opens a file stream in binary mode for the given URI.
/// The URI must be either a file URI or a relative URI reference
@@ -46,7 +46,7 @@ public:
///
/// Throws an FileNotFound exception if the file cannot
/// be opened.
std::istream* open(const Path& path);
/// Creates and opens a file stream in binary mode for the given path.
///

View File

@@ -33,7 +33,7 @@ class Foundation_API FileStreamBuf: public BufferedBidirectionalStreamBuf
public:
FileStreamBuf();
/// Creates a FileStreamBuf.
~FileStreamBuf();
/// Destroys the FileStream.

View File

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

View File

@@ -106,17 +106,26 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
/// std::string s2 = format("second: %[1]d, first: %[0]d", 1, 2);
void Foundation_API format(std::string& result, const char *fmt, const std::vector<Any>& values);
/// Supports a variable number of arguments and is used by
/// all other variants of format().
/// Supports a variable number of arguments.
void Foundation_API format(std::string& result, const std::string& fmt, const std::vector<Any>& values);
/// Supports a variable number of arguments.
inline void formatAny(std::string& result, const std::string& fmt, const std::vector<Any>& values)
/// Supports a variable number of arguments and is used by
/// all other variants of format().
{
format(result, fmt, values);
}
inline void formatAny(std::string& result, const char *fmt, const std::vector<Any>& values)
/// Supports a variable number of arguments and is used by
/// all other variants of format().
{
format(result, fmt, values);
}
template <
typename T,
typename... Args>
template <typename T, typename... Args>
void format(std::string& result, const std::string& fmt, T arg1, Args... args)
/// Appends the formatted string to result.
{
@@ -124,13 +133,11 @@ void format(std::string& result, const std::string& fmt, T arg1, Args... args)
values.reserve(sizeof...(Args) + 1);
values.emplace_back(arg1);
values.insert(values.end(), { args... });
format(result, fmt, values);
formatAny(result, fmt, values);
}
template <
typename T,
typename... Args>
template <typename T, typename... Args>
void format(std::string& result, const char* fmt, T arg1, Args... args)
/// Appends the formatted string to result.
{
@@ -138,13 +145,11 @@ void format(std::string& result, const char* fmt, T arg1, Args... args)
values.reserve(sizeof...(Args) + 1);
values.emplace_back(arg1);
values.insert(values.end(), { args... });
format(result, fmt, values);
formatAny(result, fmt, values);
}
template <
typename T,
typename... Args>
template <typename T, typename... Args>
std::string format(const std::string& fmt, T arg1, Args... args)
/// Returns the formatted string.
{
@@ -153,14 +158,12 @@ std::string format(const std::string& fmt, T arg1, Args... args)
values.emplace_back(arg1);
values.insert(values.end(), { args... });
std::string result;
format(result, fmt, values);
formatAny(result, fmt, values);
return result;
}
template <
typename T,
typename... Args>
template <typename T, typename... Args>
std::string format(const char* fmt, T arg1, Args... args)
/// Returns the formatted string.
{
@@ -169,7 +172,7 @@ std::string format(const char* fmt, T arg1, Args... args)
values.emplace_back(arg1);
values.insert(values.end(), { args... });
std::string result;
format(result, fmt, values);
formatAny(result, fmt, values);
return result;
}

View File

@@ -44,8 +44,8 @@ class Foundation_API Formatter: public Configurable, public RefCountedObject
/// The Formatter class supports the Configurable interface,
/// so the behaviour of certain formatters 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.
///
/// Subclasses must at least provide a format() method.
@@ -55,14 +55,14 @@ public:
Formatter();
/// Creates the formatter.
virtual ~Formatter();
/// Destroys the formatter.
virtual void format(const Message& msg, std::string& text) = 0;
/// Formats the message and places the result in text.
/// Formats the message and places the result in text.
/// Subclasses must override this method.
void setProperty(const std::string& name, const std::string& value);
/// Throws a PropertyNotSupportedException.

View File

@@ -40,31 +40,31 @@ public:
FormattingChannel();
/// Creates a FormattingChannel.
FormattingChannel(Formatter::Ptr pFormatter);
/// Creates a FormattingChannel and attaches a Formatter.
FormattingChannel(Formatter::Ptr pFormatter, Channel::Ptr pChannel);
/// Creates a FormattingChannel and attaches a Formatter
/// and a Channel.
void setFormatter(Formatter::Ptr pFormatter);
/// Sets the Formatter used to format the messages
/// before they are passed on. If null, the message
/// is passed on unmodified.
Formatter::Ptr getFormatter() const;
/// Returns the Formatter used to format messages,
/// which may be null.
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.
Channel::Ptr getChannel() const;
/// Returns the channel to which the formatted
/// messages are passed on.
void log(const Message& msg);
/// Formats the given Message using the Formatter and
/// passes the formatted message on to the destination
@@ -81,7 +81,7 @@ public:
void open();
/// Opens the attached channel.
void close();
/// Closes the attached channel.

View File

@@ -26,9 +26,9 @@
namespace Poco {
template <class TArgs, bool hasSender = true, bool senderIsConst = true>
template <class TArgs, bool hasSender = true, bool senderIsConst = true>
class FunctionDelegate: public AbstractDelegate<TArgs>
/// Wraps a freestanding function or static member function
/// Wraps a freestanding function or static member function
/// for use as a Delegate.
{
public:
@@ -48,7 +48,7 @@ public:
~FunctionDelegate()
{
}
FunctionDelegate& operator = (const FunctionDelegate& delegate)
{
if (&delegate != this)
@@ -79,7 +79,7 @@ public:
{
return new FunctionDelegate(*this);
}
void disable()
{
Mutex::ScopedLock lock(_mutex);
@@ -95,7 +95,7 @@ private:
};
template <class TArgs>
template <class TArgs>
class FunctionDelegate<TArgs, true, false>: public AbstractDelegate<TArgs>
{
public:
@@ -115,7 +115,7 @@ public:
~FunctionDelegate()
{
}
FunctionDelegate& operator = (const FunctionDelegate& delegate)
{
if (&delegate != this)
@@ -162,7 +162,7 @@ private:
};
template <class TArgs, bool senderIsConst>
template <class TArgs, bool senderIsConst>
class FunctionDelegate<TArgs, false, senderIsConst>: public AbstractDelegate<TArgs>
{
public:
@@ -182,7 +182,7 @@ public:
~FunctionDelegate()
{
}
FunctionDelegate& operator = (const FunctionDelegate& delegate)
{
if (&delegate != this)
@@ -198,7 +198,7 @@ public:
if (_function)
{
(*_function)(arguments);
return true;
return true;
}
else return false;
}
@@ -229,9 +229,9 @@ private:
};
template <>
template <>
class FunctionDelegate<void, true, true>: public AbstractDelegate<void>
/// Wraps a freestanding function or static member function
/// Wraps a freestanding function or static member function
/// for use as a Delegate.
{
public:
@@ -251,7 +251,7 @@ public:
~FunctionDelegate()
{
}
FunctionDelegate& operator = (const FunctionDelegate& delegate)
{
if (&delegate != this)
@@ -282,7 +282,7 @@ public:
{
return new FunctionDelegate(*this);
}
void disable()
{
Mutex::ScopedLock lock(_mutex);
@@ -298,7 +298,7 @@ private:
};
template <>
template <>
class FunctionDelegate<void, true, false>: public AbstractDelegate<void>
{
public:
@@ -318,7 +318,7 @@ public:
~FunctionDelegate()
{
}
FunctionDelegate& operator = (const FunctionDelegate& delegate)
{
if (&delegate != this)
@@ -365,7 +365,7 @@ private:
};
template <bool senderIsConst>
template <bool senderIsConst>
class FunctionDelegate<void, false, senderIsConst>: public AbstractDelegate<void>
{
public:
@@ -385,7 +385,7 @@ public:
~FunctionDelegate()
{
}
FunctionDelegate& operator = (const FunctionDelegate& delegate)
{
if (&delegate != this)
@@ -401,7 +401,7 @@ public:
if (_function)
{
(*_function)();
return true;
return true;
}
else return false;
}

View File

@@ -26,9 +26,9 @@
namespace Poco {
template <class TArgs, bool useSender = true, bool senderIsConst = true>
template <class TArgs, bool useSender = true, bool senderIsConst = true>
class FunctionPriorityDelegate: public AbstractPriorityDelegate<TArgs>
/// Wraps a freestanding function or static member function
/// Wraps a freestanding function or static member function
/// for use as a PriorityDelegate.
{
public:
@@ -39,13 +39,13 @@ public:
_function(function)
{
}
FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate):
AbstractPriorityDelegate<TArgs>(delegate),
_function(delegate._function)
{
}
FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate)
{
if (&delegate != this)
@@ -97,7 +97,7 @@ private:
};
template <class TArgs>
template <class TArgs>
class FunctionPriorityDelegate<TArgs, true, false>: public AbstractPriorityDelegate<TArgs>
{
public:
@@ -108,13 +108,13 @@ public:
_function(function)
{
}
FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate):
AbstractPriorityDelegate<TArgs>(delegate),
_function(delegate._function)
{
}
FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate)
{
if (&delegate != this)
@@ -166,7 +166,7 @@ private:
};
template <class TArgs>
template <class TArgs>
class FunctionPriorityDelegate<TArgs, false>: public AbstractPriorityDelegate<TArgs>
{
public:
@@ -177,13 +177,13 @@ public:
_function(function)
{
}
FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate):
AbstractPriorityDelegate<TArgs>(delegate),
_function(delegate._function)
{
}
FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate)
{
if (&delegate != this)

View File

@@ -34,8 +34,8 @@ class Foundation_API Glob
/// as known from Unix shells.
///
/// In the pattern string, '*' matches any sequence of characters,
/// '?' matches any single character, [SET] matches any single character
/// in the specified set, [!SET] matches any character not in the
/// '?' matches any single character, [SET] matches any single character
/// in the specified set, [!SET] matches any character not in the
/// specified set.
///
/// A set is composed of characters or ranges; a range looks like
@@ -58,23 +58,23 @@ public:
GLOB_CASELESS = 0x04, /// ignore case when comparing characters
GLOB_DIRS_ONLY = 0x80 /// only glob for directories (for internal use only)
};
Glob(const std::string& pattern, int options = 0);
/// Creates the Glob, using the given pattern. The pattern
/// must not be an empty string.
///
/// If the GLOB_DOT_SPECIAL option is specified, '*' and '?' do
/// If the GLOB_DOT_SPECIAL option is specified, '*' and '?' do
/// not match '.' at the beginning of a matched subject. This is useful for
/// making dot-files invisible in good old Unix-style.
~Glob();
/// Destroys the Glob.
bool match(const std::string& subject);
/// Matches the given subject against the glob pattern.
/// Returns true if the subject matches the pattern, false
/// otherwise.
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.
///
@@ -135,7 +135,7 @@ protected:
bool matchSet(TextIterator& itp, const TextIterator& endp, int c);
static void collect(const Path& pathPattern, const Path& base, const Path& current, const std::string& pattern, std::set<std::string>& files, int options);
static bool isDirectory(const Path& path, bool followSymlink);
private:
std::string _pattern;
int _options;

View File

@@ -31,7 +31,7 @@ class HMACEngine: public DigestEngine
/// This class implements the HMAC message
/// authentication code algorithm, as specified
/// in RFC 2104. The underlying DigestEngine
/// (MD5Engine, SHA1Engine, etc.) must be given as
/// (MD5Engine, SHA1Engine, etc.) must be given as
/// template argument.
/// Since the HMACEngine is a DigestEngine, it can
/// be used with the DigestStream class to create
@@ -43,19 +43,19 @@ public:
BLOCK_SIZE = Engine::BLOCK_SIZE,
DIGEST_SIZE = Engine::DIGEST_SIZE
};
HMACEngine(const std::string& passphrase)
{
init(passphrase.data(), passphrase.length());
}
HMACEngine(const char* passphrase, std::size_t length)
{
poco_check_ptr (passphrase);
init(passphrase, length);
}
~HMACEngine()
{
std::memset(_ipad, 0, BLOCK_SIZE);
@@ -63,21 +63,22 @@ public:
delete [] _ipad;
delete [] _opad;
}
std::size_t digestLength() const
{
return DIGEST_SIZE;
}
void reset()
{
_engine.reset();
_engine.update(_ipad, BLOCK_SIZE);
}
const DigestEngine::Digest& digest()
{
const DigestEngine::Digest& d = _engine.digest();
poco_assert (d.size() == DIGEST_SIZE);
char db[DIGEST_SIZE];
char* pdb = db;
for (auto v: d) *pdb++ = v;
@@ -122,7 +123,7 @@ protected:
}
reset();
}
void updateImpl(const void* data, std::size_t length)
{
_engine.update(data, length);

View File

@@ -10,6 +10,9 @@
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// hashRange Copyright 2005-2014 Daniel James.
// (Extracted from Boost 1.75.0 lib and adapted for poco on 2021-03-31)
//
// SPDX-License-Identifier: BSL-1.0
//
@@ -19,9 +22,17 @@
#include "Poco/Foundation.h"
#include "Poco/Types.h"
#include <cstddef>
#if defined(_MSC_VER)
# define POCO_HASH_ROTL32(x, r) _rotl(x,r)
#else
# define POCO_HASH_ROTL32(x, r) (x << r) | (x >> (32 - r))
#endif
namespace Poco {
@@ -53,49 +64,133 @@ struct Hash
//
inline std::size_t hash(Int8 n)
{
return static_cast<std::size_t>(n)*2654435761U;
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(UInt8 n)
{
return static_cast<std::size_t>(n)*2654435761U;
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(Int16 n)
{
return static_cast<std::size_t>(n)*2654435761U;
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(UInt16 n)
{
return static_cast<std::size_t>(n)*2654435761U;
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(Int32 n)
{
return static_cast<std::size_t>(n)*2654435761U;
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(UInt32 n)
{
return static_cast<std::size_t>(n)*2654435761U;
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(Int64 n)
{
return static_cast<std::size_t>(n)*2654435761U;
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(UInt64 n)
{
return static_cast<std::size_t>(n)*2654435761U;
return static_cast<std::size_t>(n)*2654435761U;
}
namespace Impl {
template <typename SizeT>
inline void hashCombine(SizeT& seed, SizeT value)
{
seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2);
}
inline void hashCombine(Poco::UInt32& h1, Poco::UInt32 k1)
{
const uint32_t c1 = 0xcc9e2d51;
const uint32_t c2 = 0x1b873593;
k1 *= c1;
k1 = POCO_HASH_ROTL32(k1,15);
k1 *= c2;
h1 ^= k1;
h1 = POCO_HASH_ROTL32(h1,13);
h1 = h1*5+0xe6546b64;
}
#if defined(POCO_PTR_IS_64_BIT) && !(defined(__GNUC__) && ULONG_MAX == 0xffffffff)
inline void hashCombine(Poco::UInt64& h, Poco::UInt64 k)
{
const Poco::UInt64 m = UINT64_C(0xc6a4a7935bd1e995);
const int r = 47;
k *= m;
k ^= k >> r;
k *= m;
h ^= k;
h *= m;
// Completely arbitrary number, to
// prevent zeros from hashing to 0.
h += 0xe6546b64;
}
#endif // POCO_PTR_IS_64_BIT
} // namespace Impl
template <class T>
inline void hashCombine(std::size_t& seed, T const& v)
{
Hash<T> hasher;
Impl::hashCombine(seed, hasher(v));
}
template <class It>
inline std::size_t hashRange(It first, It last)
{
std::size_t seed = 0;
for(; first != last; ++first)
{
hashCombine<typename std::iterator_traits<It>::value_type>(seed, *first);
}
return seed;
}
template <class It>
inline void hashRange(std::size_t& seed, It first, It last)
{
for(; first != last; ++first)
{
hashCombine<typename std::iterator_traits<It>::value_type>(seed, *first);
}
}

View File

@@ -33,13 +33,13 @@ struct HashMapEntry
{
Key first;
Value second;
HashMapEntry():
first(),
second()
{
}
HashMapEntry(const Key& key):
first(key),
second()
@@ -51,7 +51,7 @@ struct HashMapEntry
second(value)
{
}
bool operator == (const HashMapEntry& entry) const
{
return first == entry.first;
@@ -91,27 +91,27 @@ public:
typedef const Mapped& ConstReference;
typedef Mapped* Pointer;
typedef const Mapped* ConstPointer;
typedef HashMapEntry<Key, Mapped> ValueType;
typedef std::pair<KeyType, MappedType> PairType;
typedef HashMapEntryHash<ValueType, HashFunc> HashType;
typedef LinearHashTable<ValueType, HashType> HashTable;
typedef typename HashTable::Iterator Iterator;
typedef typename HashTable::ConstIterator ConstIterator;
HashMap()
/// Creates an empty HashMap.
{
}
HashMap(std::size_t initialReserve):
_table(initialReserve)
/// Creates the HashMap with room for initialReserve entries.
{
}
HashMap& operator = (const HashMap& map)
/// Assigns another HashMap.
{
@@ -119,33 +119,33 @@ public:
swap(tmp);
return *this;
}
void swap(HashMap& map)
void swap(HashMap& map) noexcept
/// Swaps the HashMap with another one.
{
_table.swap(map._table);
}
ConstIterator begin() const
{
return _table.begin();
}
ConstIterator end() const
{
return _table.end();
}
Iterator begin()
{
return _table.begin();
}
Iterator end()
{
return _table.end();
}
ConstIterator find(const KeyType& key) const
{
ValueType value(key);
@@ -174,18 +174,18 @@ public:
{
return _table.insert(value);
}
void erase(Iterator it)
{
_table.erase(it);
}
void erase(const KeyType& key)
{
Iterator it = find(key);
_table.erase(it);
}
void clear()
{
_table.clear();

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