mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-11-21 19:27:09 +01:00
Update libraries and make it build on windows.
Still gets some warnings because compilers have changed. But should work.
This commit is contained in:
1 parent
520a5eacc5
commit
f2b7499f85
3038 files changed
+251668
-273857
No files matched your search
+15
-16
@@ -21,8 +21,7 @@
|
||||
#include "Poco/KeyValueArgs.h"
|
||||
#include "Poco/ValidArgs.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/FIFOEvent.h"
|
||||
#include "Poco/BasicEvent.h"
|
||||
#include "Poco/EventArgs.h"
|
||||
#include "Poco/Delegate.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
@@ -39,16 +38,16 @@ class AbstractCache
|
||||
/// An AbstractCache is the interface of all caches.
|
||||
{
|
||||
public:
|
||||
FIFOEvent<const KeyValueArgs<TKey, TValue>, TEventMutex> Add;
|
||||
FIFOEvent<const KeyValueArgs<TKey, TValue>, TEventMutex> Update;
|
||||
FIFOEvent<const TKey, TEventMutex> Remove;
|
||||
FIFOEvent<const TKey, TEventMutex> Get;
|
||||
FIFOEvent<const EventArgs, TEventMutex> Clear;
|
||||
BasicEvent<const KeyValueArgs<TKey, TValue>, TEventMutex> Add;
|
||||
BasicEvent<const KeyValueArgs<TKey, TValue>, TEventMutex> Update;
|
||||
BasicEvent<const TKey, TEventMutex> Remove;
|
||||
BasicEvent<const TKey, TEventMutex> Get;
|
||||
BasicEvent<const EventArgs, TEventMutex> Clear;
|
||||
|
||||
typedef std::map<TKey, SharedPtr<TValue>> DataHolder;
|
||||
typedef typename DataHolder::iterator Iterator;
|
||||
typedef typename DataHolder::const_iterator ConstIterator;
|
||||
typedef std::set<TKey> KeySet;
|
||||
using DataHolder = std::map<TKey, SharedPtr<TValue>>;
|
||||
using Iterator = typename DataHolder::iterator;
|
||||
using ConstIterator = typename DataHolder::const_iterator;
|
||||
using KeySet = std::set<TKey>;
|
||||
|
||||
AbstractCache()
|
||||
{
|
||||
@@ -72,6 +71,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
AbstractCache(const AbstractCache& aCache) = delete;
|
||||
AbstractCache& operator = (const AbstractCache& aCache) = delete;
|
||||
|
||||
void add(const TKey& key, const TValue& val)
|
||||
/// Adds the key value pair to the cache.
|
||||
/// If for the key already an entry exists, it will be overwritten.
|
||||
@@ -194,8 +196,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
mutable FIFOEvent<ValidArgs<TKey>> IsValid;
|
||||
mutable FIFOEvent<KeySet> Replace;
|
||||
mutable BasicEvent<ValidArgs<TKey>> IsValid;
|
||||
mutable BasicEvent<KeySet> Replace;
|
||||
|
||||
void initialize()
|
||||
/// Sets up event registration.
|
||||
@@ -371,9 +373,6 @@ protected:
|
||||
mutable DataHolder _data;
|
||||
mutable TMutex _mutex;
|
||||
|
||||
private:
|
||||
AbstractCache(const AbstractCache& aCache);
|
||||
AbstractCache& operator = (const AbstractCache& aCache);
|
||||
};
|
||||
|
||||
|
||||
|
||||
+2
-3
@@ -339,9 +339,8 @@ protected:
|
||||
}
|
||||
|
||||
NotifyAsyncParams params = par;
|
||||
TArgs retArgs(params.args);
|
||||
params.ptrStrat->notify(params.pSender, retArgs);
|
||||
return retArgs;
|
||||
params.ptrStrat->notify(params.pSender, params.args);
|
||||
return params.args;
|
||||
}
|
||||
|
||||
TStrategy _strategy; /// The strategy used to notify observers.
|
||||
|
||||
+31
-1
@@ -37,12 +37,42 @@ public:
|
||||
AbstractObserver& operator = (const AbstractObserver& observer);
|
||||
|
||||
virtual void notify(Notification* pNf) const = 0;
|
||||
|
||||
virtual bool equals(const AbstractObserver& observer) const = 0;
|
||||
virtual bool accepts(Notification* pNf, const char* pName = 0) const = 0;
|
||||
|
||||
POCO_DEPRECATED("use `Poco::Any accepts(Notification*)` instead")
|
||||
virtual bool accepts(Notification* pNf, const char* pName) const = 0;
|
||||
|
||||
virtual bool accepts(const Notification::Ptr& pNf) const = 0;
|
||||
|
||||
virtual AbstractObserver* clone() const = 0;
|
||||
|
||||
virtual void start();
|
||||
/// No-op.
|
||||
/// This method can be implemented by inheriting classes which require
|
||||
/// explicit start in order to begin processing notifications.
|
||||
|
||||
virtual void disable() = 0;
|
||||
|
||||
virtual int backlog() const;
|
||||
/// Returns number of queued messages that this Observer has.
|
||||
/// For non-active (synchronous) observers, always returns zero.
|
||||
};
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
|
||||
inline void AbstractObserver::start()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline int AbstractObserver::backlog() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/ThreadPool.h"
|
||||
#include "Poco/ActiveThreadPool.h"
|
||||
#include "Poco/ActiveRunnable.h"
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class ActiveStarter
|
||||
public:
|
||||
static void start(OwnerType* /*pOwner*/, ActiveRunnableBase::Ptr pRunnable)
|
||||
{
|
||||
ThreadPool::defaultPool().start(*pRunnable);
|
||||
ActiveThreadPool::defaultPool().start(*pRunnable);
|
||||
pRunnable->duplicate(); // The runnable will release itself.
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// ActiveThreadPool.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
// Module: ActiveThreadPool
|
||||
//
|
||||
// Definition of the ActiveThreadPool class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_ActiveThreadPool_INCLUDED
|
||||
#define Foundation_ActiveThreadPool_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include "Poco/Environment.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Runnable;
|
||||
class ActiveThreadPoolPrivate;
|
||||
|
||||
|
||||
class Foundation_API ActiveThreadPool
|
||||
/// A thread pool manages and recycles individual Poco::Thread objects
|
||||
/// to help reduce thread creation costs in programs that use threads.
|
||||
///
|
||||
/// The thread pool supports a task queue.
|
||||
/// When there are no idle threads, tasks are placed in the task queue to wait for execution.
|
||||
/// Use case for this pool is running many (more than os-max-thread-count) short live tasks
|
||||
{
|
||||
public:
|
||||
ActiveThreadPool(int capacity = static_cast<int>(Environment::processorCount()) + 1,
|
||||
int stackSize = POCO_THREAD_STACK_SIZE);
|
||||
/// Creates a thread pool with a maximum thread count of capacity.
|
||||
/// Threads are created with given stack size.
|
||||
|
||||
ActiveThreadPool(const std::string& name,
|
||||
int capacity = static_cast<int>(Environment::processorCount()) + 1,
|
||||
int stackSize = POCO_THREAD_STACK_SIZE);
|
||||
/// Creates a thread pool with the given name and a maximum thread count of capacity.
|
||||
/// Threads are created with given stack size.
|
||||
|
||||
~ActiveThreadPool();
|
||||
/// Currently running threads will remain active
|
||||
/// until they complete.
|
||||
|
||||
int capacity() const;
|
||||
/// Returns the capacity of threads.
|
||||
|
||||
int getStackSize() const;
|
||||
/// Returns the stack size used to create new threads.
|
||||
|
||||
int expiryTimeout() const;
|
||||
/// Returns the thread expiry timeout value in milliseconds.
|
||||
/// The default expiryTimeout is 30000 milliseconds (30 seconds).
|
||||
|
||||
void setExpiryTimeout(int expiryTimeout);
|
||||
/// Set the thread expiry timeout value in milliseconds.
|
||||
/// The default expiryTimeout is 30000 milliseconds (30 seconds).
|
||||
|
||||
void start(Runnable& target, int priority = 0);
|
||||
/// Obtains a thread and starts the target.
|
||||
|
||||
void joinAll();
|
||||
/// Waits for all threads to exit and removes all threads from the thread pool.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the name of the thread pool,
|
||||
/// or an empty string if no name has been
|
||||
/// specified in the constructor.
|
||||
|
||||
static ActiveThreadPool& defaultPool();
|
||||
/// Returns a reference to the default
|
||||
/// thread pool.
|
||||
|
||||
private:
|
||||
ActiveThreadPool(const ActiveThreadPool& pool);
|
||||
ActiveThreadPool& operator = (const ActiveThreadPool& pool);
|
||||
|
||||
private:
|
||||
std::unique_ptr<ActiveThreadPoolPrivate> _impl;
|
||||
};
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_ActiveThreadPool_INCLUDED
|
||||
@@ -180,9 +180,11 @@ protected:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
_running = false;
|
||||
_done.set();
|
||||
throw;
|
||||
}
|
||||
_running = false;
|
||||
_done.set();
|
||||
}
|
||||
|
||||
|
||||
+140
-60
@@ -18,18 +18,18 @@
|
||||
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/MetaProgramming.h"
|
||||
#include "Poco/Bugcheck.h"
|
||||
#include <algorithm>
|
||||
#include <typeinfo>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
#define poco_any_assert(cond) do { if (!(cond)) std::abort(); } while (0)
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
class Any;
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
namespace Dynamic {
|
||||
|
||||
class Var;
|
||||
@@ -39,6 +39,7 @@ template <class T> class VarHolderImpl;
|
||||
}
|
||||
|
||||
|
||||
#ifndef POCO_DOC
|
||||
template <class T, std::size_t S>
|
||||
struct TypeSizeLE:
|
||||
std::integral_constant<bool, (sizeof(T) <= S)>{};
|
||||
@@ -47,6 +48,7 @@ struct TypeSizeLE:
|
||||
template <class T, std::size_t S>
|
||||
struct TypeSizeGT:
|
||||
std::integral_constant<bool, (sizeof(T) > S)>{};
|
||||
#endif
|
||||
|
||||
|
||||
template <typename PlaceholderT, unsigned int SizeV = POCO_SMALL_OBJECT_SIZE>
|
||||
@@ -58,7 +60,7 @@ union Placeholder
|
||||
/// 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).
|
||||
/// where the object was allocated. See enum Allocation.
|
||||
///
|
||||
/// Important: for SOO builds, only same-type (or trivial both-empty no-op)
|
||||
/// swap operation is allowed.
|
||||
@@ -76,9 +78,12 @@ public:
|
||||
|
||||
#ifndef POCO_NO_SOO
|
||||
|
||||
Placeholder(): pHolder(0)
|
||||
Placeholder(): pHolder(nullptr)
|
||||
{
|
||||
std::memset(holder, 0, sizeof(Placeholder));
|
||||
// Forces to use optimised memset internally
|
||||
// https://travisdowns.github.io/blog/2020/01/20/zero.html
|
||||
std::fill(std::begin(holder), std::end(holder), static_cast<char>(0));
|
||||
setAllocation(Allocation::POCO_ANY_EMPTY);
|
||||
}
|
||||
|
||||
~Placeholder()
|
||||
@@ -99,32 +104,31 @@ public:
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
static char buf[SizeV+1] = {};
|
||||
return 0 == std::memcmp(holder, buf, SizeV+1);
|
||||
return holder[SizeV] == Allocation::POCO_ANY_EMPTY;
|
||||
}
|
||||
|
||||
bool isLocal() const
|
||||
{
|
||||
return holder[SizeV] != 0;
|
||||
return holder[SizeV] == Allocation::POCO_ANY_LOCAL;
|
||||
}
|
||||
|
||||
template<typename T, typename V,
|
||||
typename std::enable_if<TypeSizeLE<T, Placeholder::Size::value>::value>::type* = nullptr>
|
||||
typename std::enable_if_t<TypeSizeLE<T, Placeholder::Size::value>::value>* = nullptr>
|
||||
PlaceholderT* assign(const V& value)
|
||||
{
|
||||
erase();
|
||||
new (reinterpret_cast<PlaceholderT*>(holder)) T(value);
|
||||
setLocal(true);
|
||||
setAllocation(Allocation::POCO_ANY_LOCAL);
|
||||
return reinterpret_cast<PlaceholderT*>(holder);
|
||||
}
|
||||
|
||||
template<typename T, typename V,
|
||||
typename std::enable_if<TypeSizeGT<T, Placeholder::Size::value>::value>::type* = nullptr>
|
||||
typename std::enable_if_t<TypeSizeGT<T, Placeholder::Size::value>::value>* = nullptr>
|
||||
PlaceholderT* assign(const V& value)
|
||||
{
|
||||
erase();
|
||||
pHolder = new T(value);
|
||||
setLocal(false);
|
||||
setAllocation(Allocation::POCO_ANY_EXTERNAL);
|
||||
return pHolder;
|
||||
}
|
||||
|
||||
@@ -137,23 +141,56 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef typename std::aligned_storage<SizeV+1>::type AlignerType;
|
||||
using AlignerType = std::max_align_t;
|
||||
#ifndef POCO_DOC
|
||||
static_assert(
|
||||
sizeof(AlignerType) < SizeV,
|
||||
"Aligner type is bigger than the actual storage, so SizeV should be made bigger otherwise you simply waste unused memory."
|
||||
);
|
||||
#endif
|
||||
|
||||
void setLocal(bool local) const
|
||||
enum Allocation : unsigned char
|
||||
{
|
||||
holder[SizeV] = local ? 1 : 0;
|
||||
POCO_ANY_EMPTY = 0,
|
||||
POCO_ANY_LOCAL = 1,
|
||||
POCO_ANY_EXTERNAL = 2
|
||||
};
|
||||
|
||||
void setAllocation(Allocation alloc) const
|
||||
{
|
||||
holder[SizeV] = alloc;
|
||||
}
|
||||
|
||||
void destruct(bool clear)
|
||||
{
|
||||
if (!isEmpty())
|
||||
const auto allocation {holder[SizeV]};
|
||||
switch (allocation)
|
||||
{
|
||||
if (!isLocal())
|
||||
delete pHolder;
|
||||
else
|
||||
reinterpret_cast<PlaceholderT*>(holder)->~PlaceholderT();
|
||||
|
||||
if (clear) std::memset(holder, 0, sizeof(Placeholder));
|
||||
case Allocation::POCO_ANY_EMPTY:
|
||||
break;
|
||||
case Allocation::POCO_ANY_LOCAL:
|
||||
{
|
||||
// Do not deallocate, just explicitly call destructor
|
||||
auto* h { reinterpret_cast<PlaceholderT*>(holder) };
|
||||
h->~PlaceholderT();
|
||||
}
|
||||
break;
|
||||
case Allocation::POCO_ANY_EXTERNAL:
|
||||
{
|
||||
auto* h { pHolder };
|
||||
pHolder = nullptr;
|
||||
delete h;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
poco_bugcheck();
|
||||
break;
|
||||
}
|
||||
setAllocation(Allocation::POCO_ANY_EMPTY);
|
||||
if (clear)
|
||||
{
|
||||
// Force to use optimised memset internally
|
||||
std::fill(std::begin(holder), std::end(holder), static_cast<char>(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +199,7 @@ private:
|
||||
|
||||
#else // POCO_NO_SOO
|
||||
|
||||
Placeholder(): pHolder(0)
|
||||
Placeholder(): pHolder(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -179,12 +216,12 @@ private:
|
||||
void erase()
|
||||
{
|
||||
delete pHolder;
|
||||
pHolder = 0;
|
||||
pHolder = nullptr;
|
||||
}
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
return 0 == pHolder;
|
||||
return nullptr == pHolder;
|
||||
}
|
||||
|
||||
bool isLocal() const
|
||||
@@ -222,10 +259,8 @@ class Any
|
||||
{
|
||||
public:
|
||||
|
||||
Any()
|
||||
Any() = default;
|
||||
/// Creates an empty any type.
|
||||
{
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
Any(const ValueType & value)
|
||||
@@ -245,12 +280,19 @@ public:
|
||||
construct(other);
|
||||
}
|
||||
|
||||
~Any()
|
||||
/// Destructor. If Any is locally held, calls ValueHolder destructor;
|
||||
/// otherwise, deletes the placeholder from the heap.
|
||||
Any(Any&& other)
|
||||
/// Move constructor, works with both empty and initialized Any values.
|
||||
{
|
||||
construct(other);
|
||||
}
|
||||
|
||||
~Any() = default;
|
||||
/// Destructor.
|
||||
/// Small Object Optimization mode behavior:
|
||||
/// Invokes the Placeholder destructor, which calls the
|
||||
/// ValueHolder destructor explicitly (locally held Any), or
|
||||
/// deletes the ValueHolder heap memory (heap-allocated Any).
|
||||
|
||||
Any& swap(Any& other) noexcept
|
||||
/// Swaps the content of the two Anys.
|
||||
///
|
||||
@@ -295,11 +337,23 @@ public:
|
||||
Any& operator = (const Any& rhs)
|
||||
/// Assignment operator for Any.
|
||||
{
|
||||
if ((this != &rhs) && !rhs.empty())
|
||||
construct(rhs);
|
||||
else if ((this != &rhs) && rhs.empty())
|
||||
_valueHolder.erase();
|
||||
if (this != &rhs)
|
||||
{
|
||||
if (!rhs.empty())
|
||||
construct(rhs);
|
||||
else
|
||||
_valueHolder.erase();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Any& operator = (Any&& rhs)
|
||||
/// Move operator for Any.
|
||||
{
|
||||
if (!rhs.empty())
|
||||
construct(rhs);
|
||||
else
|
||||
_valueHolder.erase();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -344,21 +398,19 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
virtual const std::type_info& type() const
|
||||
Holder & operator = (const Holder &) = delete;
|
||||
|
||||
const std::type_info& type() const override
|
||||
{
|
||||
return typeid(ValueType);
|
||||
}
|
||||
|
||||
virtual void clone(Placeholder<ValueHolder>* pPlaceholder) const
|
||||
void clone(Placeholder<ValueHolder>* pPlaceholder) const override
|
||||
{
|
||||
pPlaceholder->assign<Holder<ValueType>, ValueType>(_held);
|
||||
}
|
||||
|
||||
ValueType _held;
|
||||
|
||||
private:
|
||||
|
||||
Holder & operator = (const Holder &);
|
||||
};
|
||||
|
||||
ValueHolder* content() const
|
||||
@@ -385,6 +437,9 @@ private:
|
||||
template <typename ValueType>
|
||||
friend ValueType* AnyCast(Any*);
|
||||
|
||||
template <typename ValueType>
|
||||
friend const ValueType* AnyCast(const Any*);
|
||||
|
||||
template <typename ValueType>
|
||||
friend ValueType* UnsafeAnyCast(Any*);
|
||||
|
||||
@@ -405,12 +460,12 @@ ValueType* AnyCast(Any* operand)
|
||||
/// to the stored value.
|
||||
///
|
||||
/// Example Usage:
|
||||
/// MyType* pTmp = AnyCast<MyType*>(pAny).
|
||||
/// Will return NULL if the cast fails, i.e. types don't match.
|
||||
/// MyType* pTmp = AnyCast<MyType>(pAny).
|
||||
/// Returns nullptr if the types don't match.
|
||||
{
|
||||
return operand && operand->type() == typeid(ValueType)
|
||||
? &static_cast<Any::Holder<ValueType>*>(operand->content())->_held
|
||||
: 0;
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -420,10 +475,12 @@ const ValueType* AnyCast(const Any* operand)
|
||||
/// to the stored value.
|
||||
///
|
||||
/// Example Usage:
|
||||
/// const MyType* pTmp = AnyCast<MyType*>(pAny).
|
||||
/// Will return NULL if the cast fails, i.e. types don't match.
|
||||
/// const MyType* pTmp = AnyCast<MyType>(pAny).
|
||||
/// Returns nullptr if the types don't match.
|
||||
{
|
||||
return AnyCast<ValueType>(const_cast<Any*>(operand));
|
||||
return operand && operand->type() == typeid(ValueType)
|
||||
? &static_cast<const Any::Holder<ValueType>*>(operand->content())->_held
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -438,18 +495,19 @@ ValueType AnyCast(Any& operand)
|
||||
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
|
||||
/// these cases.
|
||||
{
|
||||
typedef typename TypeWrapper<ValueType>::TYPE NonRef;
|
||||
using NonRef = typename TypeWrapper<ValueType>::TYPE;
|
||||
|
||||
NonRef* result = AnyCast<NonRef>(&operand);
|
||||
if (!result)
|
||||
{
|
||||
std::string s = "RefAnyCast: Failed to convert between Any types ";
|
||||
std::string s(__func__);
|
||||
s.append(": Failed to convert between Any types "s);
|
||||
if (operand.content())
|
||||
{
|
||||
s.append(1, '(');
|
||||
s.append(operand.content()->type().name());
|
||||
s.append(Poco::demangle(operand.content()->type().name()));
|
||||
s.append(" => ");
|
||||
s.append(typeid(ValueType).name());
|
||||
s.append(Poco::demangle<ValueType>());
|
||||
s.append(1, ')');
|
||||
}
|
||||
throw BadCastException(s);
|
||||
@@ -469,7 +527,7 @@ ValueType AnyCast(const Any& operand)
|
||||
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
|
||||
/// these cases.
|
||||
{
|
||||
typedef typename TypeWrapper<ValueType>::TYPE NonRef;
|
||||
using NonRef = typename TypeWrapper<ValueType>::TYPE;
|
||||
|
||||
return AnyCast<NonRef&>(const_cast<Any&>(operand));
|
||||
}
|
||||
@@ -485,13 +543,14 @@ const ValueType& RefAnyCast(const Any & operand)
|
||||
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
|
||||
if (!result)
|
||||
{
|
||||
std::string s = "RefAnyCast: Failed to convert between Any types ";
|
||||
std::string s(__func__);
|
||||
s.append(": Failed to convert between Any types "s);
|
||||
if (operand.content())
|
||||
{
|
||||
s.append(1, '(');
|
||||
s.append(operand.content()->type().name());
|
||||
s.append(Poco::demangle(operand.content()->type().name()));
|
||||
s.append(" => ");
|
||||
s.append(typeid(ValueType).name());
|
||||
s.append(Poco::demangle<ValueType>());
|
||||
s.append(1, ')');
|
||||
}
|
||||
throw BadCastException(s);
|
||||
@@ -510,13 +569,14 @@ ValueType& RefAnyCast(Any& operand)
|
||||
ValueType* result = AnyCast<ValueType>(&operand);
|
||||
if (!result)
|
||||
{
|
||||
std::string s = "RefAnyCast: Failed to convert between Any types ";
|
||||
std::string s(__func__);
|
||||
s.append(": Failed to convert between Any types "s);
|
||||
if (operand.content())
|
||||
{
|
||||
s.append(1, '(');
|
||||
s.append(operand.content()->type().name());
|
||||
s.append(Poco::demangle(operand.content()->type().name()));
|
||||
s.append(" => ");
|
||||
s.append(typeid(ValueType).name());
|
||||
s.append(Poco::demangle<ValueType>());
|
||||
s.append(1, ')');
|
||||
}
|
||||
throw BadCastException(s);
|
||||
@@ -549,6 +609,26 @@ const ValueType* UnsafeAnyCast(const Any* operand)
|
||||
}
|
||||
|
||||
|
||||
template <typename ValueType>
|
||||
bool AnyHoldsNullPtr(const Any& any)
|
||||
/// Returns true if any holds a null pointer.
|
||||
/// Fails to compile if `ValueType` is not a pointer.
|
||||
{
|
||||
poco_static_assert_ptr(ValueType);
|
||||
return (AnyCast<ValueType>(any) == nullptr);
|
||||
}
|
||||
|
||||
|
||||
template <typename ValueType>
|
||||
bool AnyHoldsNullPtr(const Any* pAny)
|
||||
/// Returns true if the Any pointed to holds a null pointer.
|
||||
/// Returns false if `pAny` is a null pointer.
|
||||
{
|
||||
if (!pAny) return false;
|
||||
return (AnyHoldsNullPtr<ValueType>(*pAny));
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
|
||||
+19
-3
@@ -23,6 +23,9 @@
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/DateTimeFormatter.h"
|
||||
#include "Poco/NumberFormatter.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/Condition.h"
|
||||
#include <atomic>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -44,12 +47,14 @@ public:
|
||||
|
||||
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 close();
|
||||
|
||||
void compress(bool flag = true);
|
||||
/// Enables or disables compression of archived files.
|
||||
|
||||
@@ -57,12 +62,23 @@ protected:
|
||||
void moveFile(const std::string& oldName, const std::string& newName);
|
||||
bool exists(const std::string& name);
|
||||
|
||||
Poco::FastMutex _rotateMutex;
|
||||
|
||||
// Log rotation must wait until all of the compression tasks complete
|
||||
int _compressingCount;
|
||||
Poco::Condition _compressingComplete;
|
||||
|
||||
private:
|
||||
|
||||
friend class ArchiveCompressor;
|
||||
|
||||
ArchiveStrategy(const ArchiveStrategy&);
|
||||
ArchiveStrategy& operator = (const ArchiveStrategy&);
|
||||
|
||||
bool _compress;
|
||||
ArchiveCompressor* _pCompressor;
|
||||
void compressFile(const std::string& path);
|
||||
|
||||
std::atomic<bool> _compress;
|
||||
std::atomic<ArchiveCompressor*> _pCompressor;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -208,7 +208,7 @@ inline bool Ascii::isPrintable(int ch)
|
||||
inline int Ascii::toLower(int ch)
|
||||
{
|
||||
if (isUpper(ch))
|
||||
return ch + 32;
|
||||
return ch | 0x20;
|
||||
else
|
||||
return ch;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ inline int Ascii::toLower(int ch)
|
||||
inline int Ascii::toUpper(int ch)
|
||||
{
|
||||
if (isLower(ch))
|
||||
return ch - 32;
|
||||
return ch & ~0x20;
|
||||
else
|
||||
return ch;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// AsyncNotificationCenter.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Notifications
|
||||
// Module: AsyncNotificationCenter
|
||||
//
|
||||
// Definition of the AsyncNotificationCenter class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Aleph ONE Software Engineering d.o.o.,
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_AsyncNotificationCenter_INCLUDED
|
||||
#define Foundation_AsyncNotificationCenter_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/NotificationCenter.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include "Poco/Stopwatch.h"
|
||||
#include "Poco/Debugger.h"
|
||||
#include "Poco/ErrorHandler.h"
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/RunnableAdapter.h"
|
||||
#include "Poco/NotificationQueue.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API AsyncNotificationCenter: public NotificationCenter
|
||||
/// AsyncNotificationCenter decouples posting of notifications
|
||||
/// from notifying subscribers by calling observers' notification
|
||||
/// handler in a dedicated thread.
|
||||
{
|
||||
public:
|
||||
AsyncNotificationCenter();
|
||||
/// Creates the AsyncNotificationCenter and starts the notifying thread.
|
||||
|
||||
~AsyncNotificationCenter();
|
||||
/// Stops the notifying thread and destroys the AsyncNotificationCenter.
|
||||
|
||||
AsyncNotificationCenter& operator = (const AsyncNotificationCenter&) = delete;
|
||||
AsyncNotificationCenter(const AsyncNotificationCenter&) = delete;
|
||||
AsyncNotificationCenter& operator = (AsyncNotificationCenter&&) = delete;
|
||||
AsyncNotificationCenter(AsyncNotificationCenter&&) = delete;
|
||||
|
||||
virtual void postNotification(Notification::Ptr pNotification);
|
||||
/// Enqueues notification into the notification queue.
|
||||
|
||||
virtual int backlog() const;
|
||||
/// Returns the numbner of notifications in the notification queue.
|
||||
|
||||
private:
|
||||
void start();
|
||||
void stop();
|
||||
void dequeue();
|
||||
|
||||
using Adapter = RunnableAdapter<AsyncNotificationCenter>;
|
||||
|
||||
Thread _thread;
|
||||
NotificationQueue _nq;
|
||||
Adapter _ra;
|
||||
std::atomic<bool> _started;
|
||||
std::atomic<bool> _done;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_AsyncNotificationCenter_INCLUDED
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
//
|
||||
// AsyncObserver.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Notifications
|
||||
// Module: AsyncObserver
|
||||
//
|
||||
// Definition of the AsyncObserver class template.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// Aleph ONE Software Engineering d.o.o.,
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_AsyncObserver_INCLUDED
|
||||
#define Foundation_AsyncObserver_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/NObserver.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include "Poco/Stopwatch.h"
|
||||
#include "Poco/Debugger.h"
|
||||
#include "Poco/ErrorHandler.h"
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/RunnableAdapter.h"
|
||||
#include "Poco/NotificationQueue.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template <class C, class N>
|
||||
class AsyncObserver: public NObserver<C, N>
|
||||
/// AsyncObserver notifies subscribers in a dedicated thread (as opposed
|
||||
/// to (N)Observer classes, which notify subscribers synchronously).
|
||||
/// In order to become active and process notifications, the start()
|
||||
/// method must be called.
|
||||
///
|
||||
/// This class is meant to be used with the NotificationCenter only.
|
||||
/// Notification processing thread can be started only once, and copying
|
||||
/// should be done before `start()` is called.
|
||||
{
|
||||
public:
|
||||
using Type = AsyncObserver<C, N>;
|
||||
using Matcher = typename NObserver<C, N>::Matcher;
|
||||
using Handler = typename NObserver<C, N>::Handler;
|
||||
using NotificationPtr = typename NObserver<C, N>::NotificationPtr;
|
||||
|
||||
AsyncObserver() = delete;
|
||||
|
||||
AsyncObserver(C& object, Handler handler, Matcher matcher = nullptr):
|
||||
NObserver<C, N>(object, handler, matcher),
|
||||
_ra(*this, &AsyncObserver::dequeue),
|
||||
_started(false),
|
||||
_done(false)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncObserver(const AsyncObserver& observer):
|
||||
NObserver<C, N>(observer),
|
||||
_ra(*this, &AsyncObserver::dequeue),
|
||||
_started(false),
|
||||
_done(false)
|
||||
{
|
||||
poco_assert(observer._nq.size() == 0);
|
||||
}
|
||||
|
||||
~AsyncObserver()
|
||||
{
|
||||
disable();
|
||||
}
|
||||
|
||||
AsyncObserver& operator = (const AsyncObserver& observer)
|
||||
{
|
||||
if (&observer != this)
|
||||
{
|
||||
poco_assert(observer._nq.size() == 0);
|
||||
setObject(observer._pObject);
|
||||
setHandler(observer._handler);
|
||||
setMatcher(observer._matcher);
|
||||
_started = false;
|
||||
_done =false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual void notify(Notification* pNf) const
|
||||
{
|
||||
_nq.enqueueNotification(NotificationPtr(static_cast<N*>(pNf), true));
|
||||
}
|
||||
|
||||
virtual AbstractObserver* clone() const
|
||||
{
|
||||
return new AsyncObserver(*this);
|
||||
}
|
||||
|
||||
virtual void start()
|
||||
{
|
||||
Poco::ScopedLock l(this->mutex());
|
||||
if (_started)
|
||||
{
|
||||
throw Poco::InvalidAccessException(
|
||||
Poco::format("thread already started %s", poco_src_loc));
|
||||
}
|
||||
|
||||
_thread.start(_ra);
|
||||
Poco::Stopwatch sw;
|
||||
sw.start();
|
||||
while (!_started)
|
||||
{
|
||||
if (sw.elapsedSeconds() > 5)
|
||||
throw Poco::TimeoutException(poco_src_loc);
|
||||
Thread::sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void disable()
|
||||
{
|
||||
if (!_started.exchange(false)) return;
|
||||
_nq.wakeUpAll();
|
||||
while (!_done) Thread::sleep(100);
|
||||
_thread.join();
|
||||
NObserver<C, N>::disable();
|
||||
}
|
||||
|
||||
virtual int backlog() const
|
||||
{
|
||||
return _nq.size();
|
||||
}
|
||||
|
||||
private:
|
||||
void dequeue()
|
||||
{
|
||||
Notification::Ptr pNf;
|
||||
_started = true;
|
||||
_done = false;
|
||||
while ((pNf = _nq.waitDequeueNotification()))
|
||||
{
|
||||
try
|
||||
{
|
||||
this->handle(pNf.unsafeCast<N>());
|
||||
}
|
||||
catch (Poco::Exception& ex)
|
||||
{
|
||||
Poco::ErrorHandler::handle(ex);
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
Poco::ErrorHandler::handle(ex);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Poco::ErrorHandler::handle();
|
||||
}
|
||||
}
|
||||
_done = true;
|
||||
_started = false;
|
||||
}
|
||||
|
||||
using Adapter = RunnableAdapter<AsyncObserver<C, N>>;
|
||||
|
||||
Thread _thread;
|
||||
mutable NotificationQueue _nq;
|
||||
Adapter _ra;
|
||||
std::atomic<bool> _started;
|
||||
std::atomic<bool> _done;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_AsyncObserver_INCLUDED
|
||||
+6
-17
@@ -110,34 +110,23 @@ public:
|
||||
{
|
||||
if (_ptr != ptr)
|
||||
{
|
||||
if (_ptr) _ptr->release();
|
||||
_ptr = ptr;
|
||||
if (shared && _ptr) _ptr->duplicate();
|
||||
if (shared && ptr) ptr->duplicate();
|
||||
std::swap(_ptr, ptr);
|
||||
if (ptr) ptr->release();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
AutoPtr& assign(const AutoPtr& ptr)
|
||||
{
|
||||
if (&ptr != this)
|
||||
{
|
||||
if (_ptr) _ptr->release();
|
||||
_ptr = ptr._ptr;
|
||||
if (_ptr) _ptr->duplicate();
|
||||
}
|
||||
return *this;
|
||||
return assign(ptr._ptr, true);
|
||||
}
|
||||
|
||||
template <class Other>
|
||||
AutoPtr& assign(const AutoPtr<Other>& ptr)
|
||||
{
|
||||
if (ptr.get() != _ptr)
|
||||
{
|
||||
if (_ptr) _ptr->release();
|
||||
_ptr = const_cast<Other*>(ptr.get());
|
||||
if (_ptr) _ptr->duplicate();
|
||||
}
|
||||
return *this;
|
||||
C* nptr = const_cast<Other*>(ptr.get());
|
||||
return assign(nptr, true);
|
||||
}
|
||||
|
||||
void reset()
|
||||
|
||||
@@ -117,6 +117,9 @@ public:
|
||||
void readRaw(char* buffer, std::streamsize length);
|
||||
/// Reads length bytes of raw data into buffer.
|
||||
|
||||
void readCString(std::string& value);
|
||||
/// Reads zero-terminated C-string into value.
|
||||
|
||||
void readBOM();
|
||||
/// Reads a byte-order mark from the stream and configures
|
||||
/// the reader for the encountered byte order.
|
||||
|
||||
@@ -55,6 +55,8 @@ public:
|
||||
LITTLE_ENDIAN_BYTE_ORDER = 3 /// little-endian byte-order
|
||||
};
|
||||
|
||||
static const std::streamsize DEFAULT_MAX_CSTR_LENGTH { 1024 };
|
||||
|
||||
BinaryWriter(std::ostream& ostr, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
||||
/// Creates the BinaryWriter.
|
||||
|
||||
@@ -132,6 +134,9 @@ public:
|
||||
void writeRaw(const char* buffer, std::streamsize length);
|
||||
/// Writes length raw bytes from the given buffer to the stream.
|
||||
|
||||
void writeCString(const char* cString, std::streamsize maxLength = DEFAULT_MAX_CSTR_LENGTH);
|
||||
/// Writes zero-terminated C-string.
|
||||
|
||||
void writeBOM();
|
||||
/// Writes a byte-order mark to the stream. A byte order mark is
|
||||
/// a 16-bit integer with a value of 0xFEFF, written in host byte-order.
|
||||
|
||||
@@ -43,15 +43,15 @@ class BasicBufferedBidirectionalStreamBuf: public std::basic_streambuf<ch, tr>
|
||||
/// for implementing an iostream.
|
||||
{
|
||||
protected:
|
||||
typedef std::basic_streambuf<ch, tr> Base;
|
||||
typedef std::basic_ios<ch, tr> IOS;
|
||||
typedef ch char_type;
|
||||
typedef tr char_traits;
|
||||
typedef ba Allocator;
|
||||
typedef typename Base::int_type int_type;
|
||||
typedef typename Base::pos_type pos_type;
|
||||
typedef typename Base::off_type off_type;
|
||||
typedef typename IOS::openmode openmode;
|
||||
using Base = std::basic_streambuf<ch, tr>;
|
||||
using IOS = std::basic_ios<ch, tr>;
|
||||
using char_type = ch;
|
||||
using char_traits = tr;
|
||||
using Allocator = ba;
|
||||
using int_type = typename Base::int_type;
|
||||
using pos_type = typename Base::pos_type;
|
||||
using off_type = typename Base::off_type;
|
||||
using openmode = typename IOS::openmode;
|
||||
|
||||
public:
|
||||
BasicBufferedBidirectionalStreamBuf(std::streamsize bufferSize, openmode mode):
|
||||
@@ -69,6 +69,9 @@ public:
|
||||
Allocator::deallocate(_pWriteBuffer, _bufsize);
|
||||
}
|
||||
|
||||
BasicBufferedBidirectionalStreamBuf(const BasicBufferedBidirectionalStreamBuf&) = delete;
|
||||
BasicBufferedBidirectionalStreamBuf& operator = (const BasicBufferedBidirectionalStreamBuf&) = delete;
|
||||
|
||||
virtual int_type overflow(int_type c)
|
||||
{
|
||||
if (!(_mode & IOS::out)) return char_traits::eof();
|
||||
@@ -130,6 +133,22 @@ protected:
|
||||
this->setp(_pWriteBuffer, _pWriteBuffer + _bufsize);
|
||||
}
|
||||
|
||||
virtual bool resizeBuffer(std::streamsize bufferSize)
|
||||
{
|
||||
if (_bufsize != bufferSize)
|
||||
{
|
||||
Allocator::deallocate(_pReadBuffer, _bufsize);
|
||||
Allocator::deallocate(_pWriteBuffer, _bufsize);
|
||||
|
||||
_bufsize = bufferSize;
|
||||
_pReadBuffer = Allocator::allocate(_bufsize);
|
||||
_pWriteBuffer = Allocator::allocate(_bufsize);
|
||||
}
|
||||
resetBuffers();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual int readFromDevice(char_type* /*buffer*/, std::streamsize /*length*/)
|
||||
{
|
||||
@@ -152,28 +171,24 @@ private:
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::streamsize _bufsize;
|
||||
char_type* _pReadBuffer;
|
||||
char_type* _pWriteBuffer;
|
||||
openmode _mode;
|
||||
|
||||
BasicBufferedBidirectionalStreamBuf(const BasicBufferedBidirectionalStreamBuf&);
|
||||
BasicBufferedBidirectionalStreamBuf& operator = (const BasicBufferedBidirectionalStreamBuf&);
|
||||
std::streamsize _bufsize {0};
|
||||
char_type* _pReadBuffer {nullptr};
|
||||
char_type* _pWriteBuffer {nullptr};
|
||||
openmode _mode {0};
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// We provide an instantiation for char.
|
||||
//
|
||||
// Visual C++ needs a workaround - explicitly importing the template
|
||||
// instantiation - to avoid duplicate symbols due to multiple
|
||||
// instantiations in different libraries.
|
||||
//
|
||||
#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;
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
extern template class BasicBufferedBidirectionalStreamBuf<char, std::char_traits<char>>;
|
||||
#else
|
||||
extern template class Foundation_API BasicBufferedBidirectionalStreamBuf<char, std::char_traits<char>>;
|
||||
#endif
|
||||
|
||||
using BufferedBidirectionalStreamBuf = BasicBufferedBidirectionalStreamBuf<char, std::char_traits<char>>;
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
+7
-8
@@ -160,18 +160,17 @@ private:
|
||||
BasicBufferedStreamBuf& operator = (const BasicBufferedStreamBuf&);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// We provide an instantiation for char.
|
||||
//
|
||||
// Visual C++ needs a workaround - explicitly importing the template
|
||||
// instantiation - to avoid duplicate symbols due to multiple
|
||||
// instantiations in different libraries.
|
||||
//
|
||||
#if defined(_MSC_VER) && defined(POCO_DLL) && !defined(Foundation_EXPORTS)
|
||||
template class Foundation_API BasicBufferedStreamBuf<char, std::char_traits<char>>;
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
extern template class BasicBufferedStreamBuf<char, std::char_traits<char>>;
|
||||
#else
|
||||
extern template class Foundation_API BasicBufferedStreamBuf<char, std::char_traits<char>>;
|
||||
#endif
|
||||
typedef BasicBufferedStreamBuf<char, std::char_traits<char>> BufferedStreamBuf;
|
||||
|
||||
using BufferedStreamBuf = BasicBufferedStreamBuf<char, std::char_traits<char>>;
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
+16
-42
@@ -39,38 +39,38 @@ class Foundation_API Bugcheck
|
||||
/// automatically provide useful context information.
|
||||
{
|
||||
public:
|
||||
[[noreturn]] 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, LineNumber line, const char* text = 0);
|
||||
/// An assertion failed. Break into the debugger, if
|
||||
/// possible, then throw an AssertionViolationException.
|
||||
|
||||
[[noreturn]] static void nullPointer(const char* ptr, const char* file, int line);
|
||||
[[noreturn]] static void nullPointer(const char* ptr, const char* file, LineNumber line);
|
||||
/// An null pointer was encountered. Break into the debugger, if
|
||||
/// possible, then throw an NullPointerException.
|
||||
|
||||
[[noreturn]] static void bugcheck(const char* file, int line);
|
||||
[[noreturn]] static void bugcheck(const char* file, LineNumber line);
|
||||
/// An internal error was encountered. Break into the debugger, if
|
||||
/// possible, then throw an BugcheckException.
|
||||
|
||||
[[noreturn]] static void bugcheck(const char* msg, const char* file, int line);
|
||||
[[noreturn]] static void bugcheck(const char* msg, const char* file, LineNumber line);
|
||||
/// An internal error was encountered. Break into the debugger, if
|
||||
/// possible, then throw an BugcheckException.
|
||||
|
||||
static void unexpected(const char* file, int line);
|
||||
static void unexpected(const char* file, LineNumber line);
|
||||
/// An exception was caught in a destructor. Break into debugger,
|
||||
/// if possible and report exception. Must only be called from
|
||||
/// within a catch () block as it rethrows the exception to
|
||||
/// determine its class.
|
||||
|
||||
static void debugger(const char* file, int line);
|
||||
static void debugger(const char* file, LineNumber line);
|
||||
/// An internal error was encountered. Break into the debugger, if
|
||||
/// possible.
|
||||
|
||||
static void debugger(const char* msg, const char* file, int line);
|
||||
static void debugger(const char* msg, const char* file, LineNumber line);
|
||||
/// An internal error was encountered. Break into the debugger, if
|
||||
/// possible.
|
||||
|
||||
protected:
|
||||
static std::string what(const char* msg, const char* file, int line, const char* text = 0);
|
||||
static std::string what(const char* msg, const char* file, LineNumber line, const char* text = 0);
|
||||
};
|
||||
|
||||
|
||||
@@ -165,42 +165,16 @@ protected:
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// poco_static_assert
|
||||
//
|
||||
// The following was ported from <boost/static_assert.hpp>
|
||||
//
|
||||
#define poco_static_assert(B) static_assert(B)
|
||||
|
||||
|
||||
template <bool x>
|
||||
struct POCO_STATIC_ASSERTION_FAILURE;
|
||||
|
||||
|
||||
template <>
|
||||
struct POCO_STATIC_ASSERTION_FAILURE<true>
|
||||
{
|
||||
enum
|
||||
{
|
||||
value = 1
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <int x>
|
||||
struct poco_static_assert_test
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4))
|
||||
#define poco_static_assert(B) \
|
||||
typedef char POCO_JOIN(poco_static_assert_typedef_, __LINE__) \
|
||||
[POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>::value]
|
||||
#else
|
||||
#define poco_static_assert(B) \
|
||||
typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>)> \
|
||||
POCO_JOIN(poco_static_assert_typedef_, __LINE__) POCO_UNUSED
|
||||
#endif
|
||||
#define poco_static_assert_ptr(T) \
|
||||
static_assert(std::is_pointer_v<T> || \
|
||||
std::is_same_v<T, std::nullptr_t> || \
|
||||
std::is_member_pointer_v<T> || \
|
||||
std::is_member_function_pointer_v<T> || \
|
||||
std::is_member_object_pointer_v<T>, \
|
||||
"not a pointer")
|
||||
|
||||
|
||||
#endif // Foundation_Bugcheck_INCLUDED
|
||||
+34
@@ -32,6 +32,8 @@ class Foundation_API ByteOrder
|
||||
/// integers of various sizes.
|
||||
{
|
||||
public:
|
||||
static Int8 flipBytes(Int8 value);
|
||||
static UInt8 flipBytes(UInt8 value);
|
||||
static Int16 flipBytes(Int16 value);
|
||||
static UInt16 flipBytes(UInt16 value);
|
||||
static Int32 flipBytes(Int32 value);
|
||||
@@ -43,6 +45,8 @@ public:
|
||||
static UInt64 flipBytes(UInt64 value);
|
||||
#endif
|
||||
|
||||
static Int8 toBigEndian(Int8 value);
|
||||
static UInt8 toBigEndian(UInt8 value);
|
||||
static Int16 toBigEndian(Int16 value);
|
||||
static UInt16 toBigEndian (UInt16 value);
|
||||
static Int32 toBigEndian(Int32 value);
|
||||
@@ -52,6 +56,8 @@ public:
|
||||
static UInt64 toBigEndian (UInt64 value);
|
||||
#endif
|
||||
|
||||
static Int8 fromBigEndian(Int8 value);
|
||||
static UInt8 fromBigEndian(UInt8 value);
|
||||
static Int16 fromBigEndian(Int16 value);
|
||||
static UInt16 fromBigEndian (UInt16 value);
|
||||
static Int32 fromBigEndian(Int32 value);
|
||||
@@ -61,6 +67,8 @@ public:
|
||||
static UInt64 fromBigEndian (UInt64 value);
|
||||
#endif
|
||||
|
||||
static Int8 toLittleEndian(Int8 value);
|
||||
static UInt8 toLittleEndian(UInt8 value);
|
||||
static Int16 toLittleEndian(Int16 value);
|
||||
static UInt16 toLittleEndian (UInt16 value);
|
||||
static Int32 toLittleEndian(Int32 value);
|
||||
@@ -70,6 +78,8 @@ public:
|
||||
static UInt64 toLittleEndian (UInt64 value);
|
||||
#endif
|
||||
|
||||
static Int8 fromLittleEndian(Int8 value);
|
||||
static UInt8 fromLittleEndian(UInt8 value);
|
||||
static Int16 fromLittleEndian(Int16 value);
|
||||
static UInt16 fromLittleEndian (UInt16 value);
|
||||
static Int32 fromLittleEndian(Int32 value);
|
||||
@@ -79,6 +89,8 @@ public:
|
||||
static UInt64 fromLittleEndian (UInt64 value);
|
||||
#endif
|
||||
|
||||
static Int8 toNetwork(Int8 value);
|
||||
static UInt8 toNetwork(UInt8 value);
|
||||
static Int16 toNetwork(Int16 value);
|
||||
static UInt16 toNetwork (UInt16 value);
|
||||
static Int32 toNetwork(Int32 value);
|
||||
@@ -88,6 +100,8 @@ public:
|
||||
static UInt64 toNetwork (UInt64 value);
|
||||
#endif
|
||||
|
||||
static Int8 fromNetwork(Int8 value);
|
||||
static UInt8 fromNetwork(UInt8 value);
|
||||
static Int16 fromNetwork(Int16 value);
|
||||
static UInt16 fromNetwork (UInt16 value);
|
||||
static Int32 fromNetwork(Int32 value);
|
||||
@@ -132,6 +146,18 @@ private:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline UInt8 ByteOrder::flipBytes(UInt8 value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
inline Int8 ByteOrder::flipBytes(Int8 value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
inline UInt16 ByteOrder::flipBytes(UInt16 value)
|
||||
{
|
||||
#if defined(POCO_HAVE_MSC_BYTESWAP)
|
||||
@@ -218,6 +244,8 @@ inline Int64 ByteOrder::flipBytes(Int64 value)
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
#define POCO_IMPLEMENT_BYTEORDER_NOOP(op) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int8) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt8) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int16) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt16) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int32) \
|
||||
@@ -225,6 +253,8 @@ inline Int64 ByteOrder::flipBytes(Int64 value)
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int64) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt64)
|
||||
#define POCO_IMPLEMENT_BYTEORDER_FLIP(op) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int8) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt8) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int16) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt16) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int32) \
|
||||
@@ -233,11 +263,15 @@ inline Int64 ByteOrder::flipBytes(Int64 value)
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt64)
|
||||
#else
|
||||
#define POCO_IMPLEMENT_BYTEORDER_NOOP(op) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int8) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt8) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int16) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt16) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int32) \
|
||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt32)
|
||||
#define POCO_IMPLEMENT_BYTEORDER_FLIP(op) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int8) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt8) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int16) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt16) \
|
||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int32) \
|
||||
|
||||
+8
-8
@@ -67,13 +67,13 @@ extern "C" \
|
||||
#define POCO_BEGIN_MANIFEST_IMPL(fnName, base) \
|
||||
bool fnName(Poco::ManifestBase* pManifest_) \
|
||||
{ \
|
||||
typedef base _Base; \
|
||||
typedef Poco::Manifest<_Base> _Manifest; \
|
||||
std::string requiredType(typeid(_Manifest).name()); \
|
||||
std::string actualType(pManifest_->className()); \
|
||||
using BaseType = base; \
|
||||
using ManifestType = Poco::Manifest<BaseType>; \
|
||||
const std::string requiredType(typeid(ManifestType).name()); \
|
||||
const std::string actualType(pManifest_->className()); \
|
||||
if (requiredType == actualType) \
|
||||
{ \
|
||||
Poco::Manifest<_Base>* pManifest = static_cast<_Manifest*>(pManifest_);
|
||||
Poco::Manifest<BaseType>* pManifest = static_cast<ManifestType*>(pManifest_);
|
||||
|
||||
|
||||
#define POCO_BEGIN_MANIFEST(base) \
|
||||
@@ -93,15 +93,15 @@ extern "C" \
|
||||
|
||||
|
||||
#define POCO_EXPORT_CLASS(cls) \
|
||||
pManifest->insert(new Poco::MetaObject<cls, _Base>(#cls));
|
||||
pManifest->insert(new Poco::MetaObject<cls, BaseType>(#cls));
|
||||
|
||||
|
||||
#define POCO_EXPORT_INTERFACE(cls, itf) \
|
||||
pManifest->insert(new Poco::MetaObject<cls, _Base>(itf));
|
||||
pManifest->insert(new Poco::MetaObject<cls, BaseType>(itf));
|
||||
|
||||
|
||||
#define POCO_EXPORT_SINGLETON(cls) \
|
||||
pManifest->insert(new Poco::MetaSingleton<cls, _Base>(#cls));
|
||||
pManifest->insert(new Poco::MetaSingleton<cls, BaseType>(#cls));
|
||||
|
||||
|
||||
#endif // Foundation_ClassLibrary_INCLUDED
|
||||
+1
-1
@@ -254,7 +254,7 @@ public:
|
||||
if (itm != pManif->end())
|
||||
return *itm;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const Meta& classFor(const std::string& className) const
|
||||
|
||||
+27
-36
@@ -42,7 +42,7 @@
|
||||
// #define POCO_NO_SHAREDMEMORY
|
||||
|
||||
|
||||
// Define if no <locale> header is available (such as on WinCE)
|
||||
// Define if no <locale> header is available
|
||||
// #define POCO_NO_LOCALE
|
||||
|
||||
|
||||
@@ -149,6 +149,10 @@
|
||||
|
||||
// No UNIX socket support
|
||||
// Define to disable unix sockets
|
||||
// UNIX local sockets are default-enabled on
|
||||
// all UNIX systems, on Windows if available
|
||||
// See Net/SocketDefs.h
|
||||
// See https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
|
||||
// #define POCO_NET_NO_UNIX_SOCKET
|
||||
|
||||
|
||||
@@ -161,52 +165,39 @@
|
||||
#endif
|
||||
|
||||
|
||||
// Windows CE has no locale support
|
||||
#if defined(_WIN32_WCE)
|
||||
#define POCO_NO_LOCALE
|
||||
#endif
|
||||
|
||||
|
||||
// Enable the poco_debug_* and poco_trace_* macros
|
||||
// even if the _DEBUG variable is not set.
|
||||
// This allows the use of these macros in a release version.
|
||||
// #define POCO_LOG_DEBUG
|
||||
|
||||
|
||||
// OpenSSL on Windows
|
||||
//
|
||||
// Poco has its own OpenSSL build system.
|
||||
// See <https://github.com/pocoproject/openssl/blob/master/README.md>
|
||||
// for details.
|
||||
//
|
||||
// These options are Windows only.
|
||||
//
|
||||
// To disable the use of Poco-provided OpenSSL binaries,
|
||||
// define POCO_EXTERNAL_OPENSSL.
|
||||
//
|
||||
// Possible values:
|
||||
// POCO_EXTERNAL_OPENSSL_SLPRO:
|
||||
// Automatically link OpenSSL libraries from OpenSSL Windows installer provided
|
||||
// by Shining Light Productions <http://slproweb.com/products/Win32OpenSSL.html>
|
||||
// The (global) library search path must be set accordingly.
|
||||
// POCO_EXTERNAL_OPENSSL_DEFAULT:
|
||||
// Automatically link OpenSSL libraries from standard OpenSSL Windows build.
|
||||
// The (global) library search path must be set accordingly.
|
||||
// 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.
|
||||
#if !defined(POCO_EXTERNAL_OPENSSL) && defined(POCO_EXTERNAL_OPENSSL_SLPRO)
|
||||
#define POCO_EXTERNAL_OPENSSL POCO_EXTERNAL_OPENSSL_SLPRO
|
||||
#endif
|
||||
|
||||
|
||||
// Define to prevent changing the suffix for shared libraries
|
||||
// to "d.so", "d.dll", etc. for _DEBUG builds in Poco::SharedLibrary.
|
||||
// #define POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX
|
||||
|
||||
// Enable usage of Poco::Mutex and Poco::FastMutex
|
||||
// as wrappers for std::recursive_mutex and std::mutex
|
||||
#ifndef POCO_ENABLE_STD_MUTEX
|
||||
// #define POCO_ENABLE_STD_MUTEX
|
||||
#endif
|
||||
|
||||
// Disarm POCO_DEPRECATED macro.
|
||||
// #define POCO_NO_DEPRECATED
|
||||
#ifndef POCO_HAVE_SENDFILE
|
||||
// #define POCO_HAVE_SENDFILE
|
||||
#endif
|
||||
|
||||
#define POCO_HAVE_CPP17_COMPILER (__cplusplus >= 201703L)
|
||||
|
||||
// Option to silence deprecation warnings.
|
||||
#ifndef POCO_SILENCE_DEPRECATED
|
||||
#define POCO_DEPRECATED(reason) [[deprecated(reason)]]
|
||||
#else
|
||||
#define POCO_DEPRECATED(reason)
|
||||
#endif
|
||||
|
||||
// Uncomment to explicitly disable SQLParser
|
||||
// #define POCO_DATA_NO_SQL_PARSER
|
||||
|
||||
// Uncomment to enable stack trace autogeneration in Exception
|
||||
//#define POCO_ENABLE_TRACE 1
|
||||
|
||||
#endif // Foundation_Config_INCLUDED
|
||||
+8
-1
@@ -52,7 +52,8 @@ class Foundation_API DateTime
|
||||
/// Notes:
|
||||
/// * Zero is a valid year (in accordance with ISO 8601 and astronomical year numbering)
|
||||
/// * Year zero (0) is a leap year
|
||||
/// * Negative years (years preceding 1 BC) are not supported
|
||||
/// * Minimum date/time that can be represented is 12:00:00 UTC Monday, 1 January 4713 BC
|
||||
/// (Julian Day 0, Gregorian -4713-11-24 12:00:00)
|
||||
///
|
||||
/// For more information, please see:
|
||||
/// * http://en.wikipedia.org/wiki/Gregorian_Calendar
|
||||
@@ -254,6 +255,12 @@ public:
|
||||
/// Returns true if all arguments are valid, false otherwise.
|
||||
|
||||
protected:
|
||||
void checkValid();
|
||||
/// Checks if the given date and time is valid (all arguments are within a proper range).
|
||||
/// Expects all members to be set.
|
||||
///
|
||||
/// Throws Poco::InvalidArgumentException if any of the arguments is not valid.
|
||||
|
||||
static double toJulianDay(Timestamp::UtcTimeVal utcTime);
|
||||
/// Computes the Julian day for an UTC time.
|
||||
|
||||
|
||||
@@ -19,16 +19,21 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include <unordered_set>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class RegularExpression;
|
||||
|
||||
|
||||
class Foundation_API DateTimeFormat
|
||||
/// Definition of date/time formats and various
|
||||
/// constants used by DateTimeFormatter and DateTimeParser.
|
||||
{
|
||||
public:
|
||||
|
||||
// predefined date formats
|
||||
static const std::string ISO8601_FORMAT;
|
||||
/// The date/time format defined in the ISO 8601 standard.
|
||||
@@ -37,6 +42,8 @@ public:
|
||||
/// 2005-01-01T12:00:00+01:00
|
||||
/// 2005-01-01T11:00:00Z
|
||||
|
||||
static const std::string ISO8601_REGEX;
|
||||
|
||||
static const std::string ISO8601_FRAC_FORMAT;
|
||||
/// The date/time format defined in the ISO 8601 standard,
|
||||
/// with fractional seconds.
|
||||
@@ -52,6 +59,8 @@ public:
|
||||
/// Sat, 1 Jan 05 12:00:00 +0100
|
||||
/// Sat, 1 Jan 05 11:00:00 GMT
|
||||
|
||||
static const std::string RFC822_REGEX;
|
||||
|
||||
static const std::string RFC1123_FORMAT;
|
||||
/// The date/time format defined in RFC 1123 (obsoletes RFC 822).
|
||||
///
|
||||
@@ -59,6 +68,8 @@ public:
|
||||
/// Sat, 1 Jan 2005 12:00:00 +0100
|
||||
/// Sat, 1 Jan 2005 11:00:00 GMT
|
||||
|
||||
static const std::string RFC1123_REGEX;
|
||||
|
||||
static const std::string HTTP_FORMAT;
|
||||
/// 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.
|
||||
@@ -67,6 +78,8 @@ public:
|
||||
/// Sat, 01 Jan 2005 12:00:00 +0100
|
||||
/// Sat, 01 Jan 2005 11:00:00 GMT
|
||||
|
||||
static const std::string HTTP_REGEX;
|
||||
|
||||
static const std::string RFC850_FORMAT;
|
||||
/// The date/time format defined in RFC 850 (obsoleted by RFC 1036).
|
||||
///
|
||||
@@ -74,6 +87,8 @@ public:
|
||||
/// Saturday, 1-Jan-05 12:00:00 +0100
|
||||
/// Saturday, 1-Jan-05 11:00:00 GMT
|
||||
|
||||
static const std::string RFC850_REGEX;
|
||||
|
||||
static const std::string RFC1036_FORMAT;
|
||||
/// The date/time format defined in RFC 1036 (obsoletes RFC 850).
|
||||
///
|
||||
@@ -81,18 +96,24 @@ public:
|
||||
/// Saturday, 1 Jan 05 12:00:00 +0100
|
||||
/// Saturday, 1 Jan 05 11:00:00 GMT
|
||||
|
||||
static const std::string RFC1036_REGEX;
|
||||
|
||||
static const std::string ASCTIME_FORMAT;
|
||||
/// The date/time format produced by the ANSI C asctime() function.
|
||||
///
|
||||
/// Example:
|
||||
/// Sat Jan 1 12:00:00 2005
|
||||
|
||||
static const std::string ASCTIME_REGEX;
|
||||
|
||||
static const std::string SORTABLE_FORMAT;
|
||||
/// A simple, sortable date/time format.
|
||||
///
|
||||
/// Example:
|
||||
/// 2005-01-01 12:00:00
|
||||
|
||||
static const std::string SORTABLE_REGEX;
|
||||
// ^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)$
|
||||
|
||||
// names used by formatter and parser
|
||||
static const std::string WEEKDAY_NAMES[7];
|
||||
@@ -100,6 +121,16 @@ public:
|
||||
|
||||
static const std::string MONTH_NAMES[12];
|
||||
/// English names of months (January, February, ...).
|
||||
|
||||
static bool hasFormat(const std::string& fmt);
|
||||
/// Returns true if fmt is a known standard format.
|
||||
|
||||
static bool isValid(const std::string& dateTime);
|
||||
/// Returns true if dateTime validates against at least one supported format.
|
||||
|
||||
private:
|
||||
typedef std::unordered_set<std::string> Formatlist;
|
||||
static Formatlist FORMAT_LIST;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -53,28 +53,34 @@ class Foundation_API DateTimeParser
|
||||
/// If more strict format validation of date/time strings is required, a regular
|
||||
/// expression could be used for initial validation, before passing the string
|
||||
/// to DateTimeParser.
|
||||
/// TODO: Correct description
|
||||
|
||||
{
|
||||
public:
|
||||
static void parse(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.
|
||||
/// Performs cleanup of the input string (trims spaces).
|
||||
/// 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 DateTime parse(const std::string& fmt, const std::string& str, int& timeZoneDifferential);
|
||||
/// Parses a date and time in the given format from the given string.
|
||||
/// Performs cleanup of the input string (trims spaces).
|
||||
/// 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.
|
||||
/// Performs cleanup of the input string (trims spaces).
|
||||
/// 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
|
||||
/// performs cleanup of the input string (trims spaces) when cleanup is true and
|
||||
/// examines the dateTime string for a known date/time format.
|
||||
/// Throws a SyntaxException if the string cannot be successfully parsed.
|
||||
/// Please see DateTimeFormatter::format() for a description of the format string.
|
||||
@@ -82,12 +88,14 @@ public:
|
||||
|
||||
static DateTime parse(const std::string& str, int& timeZoneDifferential);
|
||||
/// Parses a date and time from the given dateTime string. Before parsing, the method
|
||||
/// performs cleanup of the input string (trims spaces) and
|
||||
/// 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
|
||||
/// performs cleanup of the input string (trims spaces) and
|
||||
/// 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.
|
||||
|
||||
+22
-3
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include <string_view>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
/// Writes a message to the debugger log, if available, otherwise to
|
||||
/// standard error output.
|
||||
|
||||
static void message(const std::string& msg, const char* file, int line);
|
||||
static void message(const std::string& msg, const char* file, LineNumber line);
|
||||
/// Writes a message to the debugger log, if available, otherwise to
|
||||
/// standard error output.
|
||||
|
||||
@@ -56,15 +57,33 @@ public:
|
||||
static void enter(const std::string& msg);
|
||||
/// Writes a debug message to the debugger log and breaks into it.
|
||||
|
||||
static void enter(const std::string& msg, const char* file, int line);
|
||||
static void enter(const std::string& msg, const char* file, LineNumber line);
|
||||
/// Writes a debug message to the debugger log and breaks into it.
|
||||
|
||||
static void enter(const char* file, int line);
|
||||
static void enter(const char* file, LineNumber line);
|
||||
/// Writes a debug message to the debugger log and breaks into it.
|
||||
|
||||
static constexpr std::string_view sourceFile(const std::string_view& fileName)
|
||||
/// Utility function for reporting the source file name. The file path is
|
||||
/// truncated and only the source file name (with extension) is returned.
|
||||
///
|
||||
/// For full location reporting (including function name and line number),
|
||||
/// see `poco_src_loc` macro.
|
||||
{
|
||||
std::size_t pos = fileName.find_last_of("/\\");
|
||||
if (pos == std::string_view::npos) pos = 0;
|
||||
else if (fileName.length() > 1) ++pos;
|
||||
return std::string_view(fileName.substr(pos));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#define poco_src_loc std::string(Poco::Debugger::sourceFile(__FILE__)) \
|
||||
.append("::").append(__func__) \
|
||||
.append("():").append(std::to_string(__LINE__))
|
||||
|
||||
|
||||
#endif // Foundation_Debugger_INCLUDED
|
||||
@@ -147,6 +147,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
DefaultStrategy(DefaultStrategy&& s):
|
||||
_delegates(std::move(s._delegates))
|
||||
{
|
||||
}
|
||||
|
||||
~DefaultStrategy()
|
||||
{
|
||||
}
|
||||
@@ -201,6 +206,15 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
DefaultStrategy& operator = (DefaultStrategy&& s)
|
||||
{
|
||||
if (this != &s)
|
||||
{
|
||||
_delegates = std::move(s._delegates);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it)
|
||||
|
||||
+22
-14
@@ -22,11 +22,8 @@
|
||||
#include "Poco/BufferedStreamBuf.h"
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#if defined(POCO_UNBUNDLED)
|
||||
#include <zlib.h>
|
||||
#else
|
||||
#include "Poco/zlib.h"
|
||||
#endif
|
||||
|
||||
struct z_stream_s;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -47,6 +44,17 @@ public:
|
||||
STREAM_GZIP /// Create a gzip header, use CRC-32 checksum.
|
||||
};
|
||||
|
||||
enum CompressionLevel
|
||||
/// Constants for compression levels.
|
||||
/// Note to maintainers: These must be kept in sync with the constants
|
||||
/// defined by zlib.
|
||||
{
|
||||
DEFAULT_COMPRESSION = -1,
|
||||
NO_COMPRESSION = 0,
|
||||
BEST_SPEED = 1,
|
||||
BEST_COMPRESSION = 9
|
||||
};
|
||||
|
||||
DeflatingStreamBuf(std::istream& istr, StreamType type, int level);
|
||||
/// Creates a DeflatingStreamBuf for compressing data read
|
||||
/// from the given input stream.
|
||||
@@ -89,11 +97,11 @@ private:
|
||||
DEFLATE_BUFFER_SIZE = 32768
|
||||
};
|
||||
|
||||
std::istream* _pIstr;
|
||||
std::ostream* _pOstr;
|
||||
char* _buffer;
|
||||
z_stream _zstr;
|
||||
bool _eof;
|
||||
std::istream* _pIstr;
|
||||
std::ostream* _pOstr;
|
||||
char* _buffer;
|
||||
z_stream_s* _pZstr;
|
||||
bool _eof;
|
||||
};
|
||||
|
||||
|
||||
@@ -104,7 +112,7 @@ class Foundation_API DeflatingIOS: public virtual std::ios
|
||||
/// order of the stream buffer and base classes.
|
||||
{
|
||||
public:
|
||||
DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
||||
DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION);
|
||||
/// Creates a DeflatingIOS for compressing data passed
|
||||
/// through and forwarding it to the given output stream.
|
||||
|
||||
@@ -115,7 +123,7 @@ public:
|
||||
/// Please refer to the zlib documentation of deflateInit2() for a description
|
||||
/// of the windowBits parameter.
|
||||
|
||||
DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
||||
DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION);
|
||||
/// Creates a DeflatingIOS for compressing data read
|
||||
/// from the given input stream.
|
||||
|
||||
@@ -150,7 +158,7 @@ class Foundation_API DeflatingOutputStream: public std::ostream, public Deflatin
|
||||
/// ostr.close();
|
||||
{
|
||||
public:
|
||||
DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
||||
DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION);
|
||||
/// Creates a DeflatingOutputStream for compressing data passed
|
||||
/// through and forwarding it to the given output stream.
|
||||
|
||||
@@ -179,7 +187,7 @@ class Foundation_API DeflatingInputStream: public std::istream, public Deflating
|
||||
/// using zlib's deflate algorithm.
|
||||
{
|
||||
public:
|
||||
DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
||||
DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION);
|
||||
/// Creates a DeflatingIOS for compressing data read
|
||||
/// from the given input stream.
|
||||
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ public:
|
||||
|
||||
virtual DirectoryIterator& operator ++ (); // prefix
|
||||
|
||||
//@ deprecated
|
||||
POCO_DEPRECATED("")
|
||||
DirectoryIterator operator ++ (int); // postfix
|
||||
/// Please use the prefix increment operator instead.
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
const std::string& DirectoryIteratorImpl::get() const
|
||||
inline const std::string& DirectoryIteratorImpl::get() const
|
||||
{
|
||||
return _current;
|
||||
}
|
||||
|
||||
+25
-27
@@ -62,10 +62,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~Pair()
|
||||
virtual ~Pair() = default;
|
||||
/// Destroys the Pair.
|
||||
{
|
||||
}
|
||||
|
||||
Pair& swap(Pair& other) noexcept
|
||||
/// Swaps the content of the two Pairs.
|
||||
@@ -122,62 +120,62 @@ public:
|
||||
return typeid(Pair<std::string>);
|
||||
}
|
||||
|
||||
void convert(Int8& val) const
|
||||
void convert(Int8&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int8");
|
||||
}
|
||||
|
||||
void convert(Int16& val) const
|
||||
void convert(Int16&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int16");
|
||||
}
|
||||
|
||||
void convert(Int32& val) const
|
||||
void convert(Int32&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int32");
|
||||
}
|
||||
|
||||
void convert(Int64& val) const
|
||||
void convert(Int64&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int64");
|
||||
}
|
||||
|
||||
void convert(UInt8& val) const
|
||||
void convert(UInt8&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt8");
|
||||
}
|
||||
|
||||
void convert(UInt16& val) const
|
||||
void convert(UInt16&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt16");
|
||||
}
|
||||
|
||||
void convert(UInt32& val) const
|
||||
void convert(UInt32&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt32");
|
||||
}
|
||||
|
||||
void convert(UInt64& val) const
|
||||
void convert(UInt64&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt64");
|
||||
}
|
||||
|
||||
void convert(bool& val) const
|
||||
void convert(bool&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to bool");
|
||||
}
|
||||
|
||||
void convert(float& val) const
|
||||
void convert(float&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to float");
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
void convert(double&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to double");
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
void convert(char&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to char");
|
||||
}
|
||||
@@ -271,62 +269,62 @@ public:
|
||||
return typeid(Pair<int>);
|
||||
}
|
||||
|
||||
void convert(Int8& val) const
|
||||
void convert(Int8&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int8");
|
||||
}
|
||||
|
||||
void convert(Int16& val) const
|
||||
void convert(Int16&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int16");
|
||||
}
|
||||
|
||||
void convert(Int32& val) const
|
||||
void convert(Int32&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int32");
|
||||
}
|
||||
|
||||
void convert(Int64& val) const
|
||||
void convert(Int64&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int64");
|
||||
}
|
||||
|
||||
void convert(UInt8& val) const
|
||||
void convert(UInt8&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt8");
|
||||
}
|
||||
|
||||
void convert(UInt16& val) const
|
||||
void convert(UInt16&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt16");
|
||||
}
|
||||
|
||||
void convert(UInt32& val) const
|
||||
void convert(UInt32&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt32");
|
||||
}
|
||||
|
||||
void convert(UInt64& val) const
|
||||
void convert(UInt64&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt64");
|
||||
}
|
||||
|
||||
void convert(bool& val) const
|
||||
void convert(bool&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to bool");
|
||||
}
|
||||
|
||||
void convert(float& val) const
|
||||
void convert(float&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to float");
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
void convert(double&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to double");
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
void convert(char&) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to char");
|
||||
}
|
||||
|
||||
+21
-2
@@ -288,6 +288,25 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
|
||||
extern template class Struct<std::string>;
|
||||
extern template class Struct<int>;
|
||||
|
||||
extern template class Struct<std::string, Poco::OrderedMap<std::string, Var>, Poco::OrderedSet<std::string>>;
|
||||
extern template class Struct<int, OrderedMap<int, Var>, OrderedSet<int>>;
|
||||
|
||||
#else
|
||||
|
||||
extern template class Foundation_API Struct<std::string>;
|
||||
extern template class Foundation_API Struct<int>;
|
||||
|
||||
extern template class Foundation_API Struct<std::string, Poco::OrderedMap<std::string, Var>, Poco::OrderedSet<std::string>>;
|
||||
extern template class Foundation_API Struct<int, OrderedMap<int, Var>, OrderedSet<int>>;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template <>
|
||||
class VarHolderImpl<Struct<std::string, std::map<std::string, Var>, std::set<std::string>>>: public VarHolder
|
||||
{
|
||||
@@ -959,8 +978,8 @@ private:
|
||||
} // namespace Dynamic
|
||||
|
||||
|
||||
typedef Dynamic::Struct<std::string> DynamicStruct;
|
||||
typedef Dynamic::Struct<std::string, Poco::OrderedMap<std::string, Dynamic::Var>, Poco::OrderedSet<std::string>> OrderedDynamicStruct;
|
||||
using DynamicStruct = Dynamic::Struct<std::string>;
|
||||
using OrderedDynamicStruct = Dynamic::Struct<std::string, Poco::OrderedMap<std::string, Dynamic::Var>, Poco::OrderedSet<std::string>>;
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
+33
-32
@@ -210,7 +210,7 @@ public:
|
||||
|
||||
if (pHolder && pHolder->type() == typeid(T))
|
||||
{
|
||||
VarHolderImpl<T>* pHolderImpl = static_cast<VarHolderImpl<T>*>(pHolder);
|
||||
auto* pHolderImpl = static_cast<VarHolderImpl<T>*>(pHolder);
|
||||
return pHolderImpl->value();
|
||||
}
|
||||
else if (!pHolder)
|
||||
@@ -475,7 +475,12 @@ public:
|
||||
const std::type_info& type() const;
|
||||
/// Returns the type information of the stored content.
|
||||
|
||||
//@ deprecated
|
||||
std::string typeName(bool demangle = true) const;
|
||||
/// Returns the type name of the stored content.
|
||||
/// If demangling is available and emangle is true,
|
||||
/// the returnsed string will be demangled.
|
||||
|
||||
POCO_DEPRECATED("Use clear() instead")
|
||||
void empty();
|
||||
/// Empties Var.
|
||||
/// This function is deprecated and will be removed.
|
||||
@@ -521,23 +526,8 @@ public:
|
||||
/// This function returns 0 when Var is empty, 1 for POD or the size (i.e. length)
|
||||
/// for held container.
|
||||
|
||||
std::string toString() const
|
||||
std::string toString() const;
|
||||
/// Returns the stored value as string.
|
||||
{
|
||||
VarHolder* pHolder = content();
|
||||
|
||||
if (!pHolder)
|
||||
throw InvalidAccessException("Can not convert empty value.");
|
||||
|
||||
if (typeid(std::string) == pHolder->type())
|
||||
return extract<std::string>();
|
||||
else
|
||||
{
|
||||
std::string result;
|
||||
pHolder->convert(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static Var parse(const std::string& val);
|
||||
/// Parses the string which must be in JSON format
|
||||
@@ -617,17 +607,8 @@ private:
|
||||
_placeholder.assign<VarHolderImpl<ValueType>, ValueType>(value);
|
||||
}
|
||||
|
||||
void construct(const char* value)
|
||||
{
|
||||
std::string val(value);
|
||||
_placeholder.assign<VarHolderImpl<std::string>, std::string>(val);
|
||||
}
|
||||
|
||||
void construct(const Var& other)
|
||||
{
|
||||
if (!other.isEmpty())
|
||||
other.content()->clone(&_placeholder);
|
||||
}
|
||||
void construct(const char* value);
|
||||
void construct(const Var& other);
|
||||
|
||||
Placeholder<VarHolder> _placeholder;
|
||||
};
|
||||
@@ -642,6 +623,20 @@ private:
|
||||
/// Var members
|
||||
///
|
||||
|
||||
inline void Var::construct(const char* value)
|
||||
{
|
||||
std::string val(value);
|
||||
_placeholder.assign<VarHolderImpl<std::string>, std::string>(val);
|
||||
}
|
||||
|
||||
|
||||
inline void Var::construct(const Var& other)
|
||||
{
|
||||
if (!other.isEmpty())
|
||||
other.content()->clone(&_placeholder);
|
||||
}
|
||||
|
||||
|
||||
inline void Var::swap(Var& other)
|
||||
{
|
||||
if (this == &other) return;
|
||||
@@ -674,6 +669,13 @@ inline const std::type_info& Var::type() const
|
||||
}
|
||||
|
||||
|
||||
inline std::string Var::typeName(bool demangle) const
|
||||
{
|
||||
VarHolder* pHolder = content();
|
||||
return pHolder ? demangle ? Poco::demangle(pHolder->type().name()) : pHolder->type().name() : std::string();
|
||||
}
|
||||
|
||||
|
||||
inline Var::ConstIterator Var::begin() const
|
||||
{
|
||||
if (size() == 0) return ConstIterator(const_cast<Var*>(this), true);
|
||||
@@ -731,7 +733,7 @@ inline bool Var::operator ! () const
|
||||
|
||||
inline bool Var::isEmpty() const
|
||||
{
|
||||
return 0 == content();
|
||||
return nullptr == content();
|
||||
}
|
||||
|
||||
|
||||
@@ -2286,8 +2288,7 @@ inline bool operator >= (const unsigned long& other, const Var& da)
|
||||
} // namespace Dynamic
|
||||
|
||||
|
||||
//@ deprecated
|
||||
typedef Dynamic::Var DynamicAny;
|
||||
using DynamicAny POCO_DEPRECATED("") = Dynamic::Var;
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
+503
-118
@@ -33,16 +33,27 @@
|
||||
#include "Poco/UTF8String.h"
|
||||
#include "Poco/UUID.h"
|
||||
#include "Poco/Any.h"
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/Debugger.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <deque>
|
||||
#include <typeinfo>
|
||||
#include <type_traits>
|
||||
#include <string_view>
|
||||
#undef min
|
||||
#undef max
|
||||
#include <limits>
|
||||
|
||||
|
||||
#define POCO_VAR_RANGE_EXCEPTION(str, from) \
|
||||
throw RangeException(Poco::format("%v ((%s/%d) %s > (%s/%d) %s) @ %s.", \
|
||||
std::string_view(#str), Poco::demangle<F>(), numValDigits(from), std::to_string(from), \
|
||||
Poco::demangle<T>(), numTypeDigits<T>(), std::to_string(static_cast<T>(from)), \
|
||||
poco_src_loc))
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Dynamic {
|
||||
|
||||
@@ -120,12 +131,12 @@ class Foundation_API VarHolder
|
||||
/// throw BadCastException.
|
||||
{
|
||||
public:
|
||||
typedef Var ArrayValueType;
|
||||
using ArrayValueType = Var;
|
||||
|
||||
virtual ~VarHolder();
|
||||
/// Destroys the VarHolder.
|
||||
|
||||
virtual VarHolder* clone(Placeholder<VarHolder>* pHolder = 0) const = 0;
|
||||
virtual VarHolder* clone(Placeholder<VarHolder>* pHolder = nullptr) const = 0;
|
||||
/// Implementation must implement this function to
|
||||
/// deep-copy the VarHolder.
|
||||
/// If small object optimization is enabled (i.e. if
|
||||
@@ -311,148 +322,241 @@ protected:
|
||||
return pVarHolder->assign<VarHolderImpl<T>, T>(val);
|
||||
}
|
||||
|
||||
template <typename F, typename T>
|
||||
void convertToSmaller(const F& from, T& to) const
|
||||
/// This function is meant to convert signed numeric values from
|
||||
template <typename F, typename T,
|
||||
std::enable_if_t<(std::is_integral_v<F> && std::is_signed_v<F>) ||
|
||||
std::is_floating_point_v<F>, F>* = nullptr,
|
||||
std::enable_if_t<(std::is_integral_v<T> && std::is_signed_v<T>) ||
|
||||
std::is_floating_point_v<F>, T>* = nullptr>
|
||||
static void convertToSmaller(const F& from, T& to)
|
||||
/// Converts signed integral, as well as floating-point, values from
|
||||
/// larger to smaller type. It checks the upper and lower bound and
|
||||
/// if from value is within limits of type T (i.e. check calls do not throw),
|
||||
/// it is converted.
|
||||
{
|
||||
poco_static_assert (std::numeric_limits<F>::is_specialized);
|
||||
poco_static_assert (std::numeric_limits<T>::is_specialized);
|
||||
poco_static_assert (std::numeric_limits<F>::is_signed);
|
||||
poco_static_assert (std::numeric_limits<T>::is_signed);
|
||||
|
||||
if (std::numeric_limits<F>::is_integer)
|
||||
if constexpr((std::is_integral_v<F>) && (std::is_floating_point_v<T>))
|
||||
{
|
||||
checkUpperLimit<F,T>(from);
|
||||
checkLowerLimit<F,T>(from);
|
||||
if (isPrecisionLost<F, T>(from))
|
||||
POCO_VAR_RANGE_EXCEPTION ("Lost precision", from);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkUpperLimitFloat<F,T>(from);
|
||||
checkLowerLimitFloat<F,T>(from);
|
||||
}
|
||||
|
||||
checkUpperLimit<F,T>(from);
|
||||
checkLowerLimit<F,T>(from);
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
template <typename F, typename T>
|
||||
void convertToSmallerUnsigned(const F& from, T& to) const
|
||||
/// This function is meant for converting unsigned integral data types,
|
||||
/// from larger to smaller type. Since lower limit is always 0 for unsigned types,
|
||||
/// only the upper limit is checked, thus saving some cycles compared to the signed
|
||||
/// version of the function. If the value to be converted is smaller than
|
||||
/// the maximum value for the target type, the conversion is performed.
|
||||
template <typename F, typename T,
|
||||
std::enable_if_t<std::is_integral_v<F> && std::is_signed_v<T>, F>* = nullptr,
|
||||
std::enable_if_t<std::is_floating_point_v<T>, T>* = nullptr>
|
||||
static void convertToSmaller(const F& from, T& to)
|
||||
/// Converts signed integral values from integral to floating-point type. Checks for
|
||||
/// the loss of precision and if from value is within limits of type T (i.e. check calls do not throw),
|
||||
/// it is converted.
|
||||
{
|
||||
poco_static_assert (std::numeric_limits<F>::is_specialized);
|
||||
poco_static_assert (std::numeric_limits<T>::is_specialized);
|
||||
poco_static_assert (!std::numeric_limits<F>::is_signed);
|
||||
poco_static_assert (!std::numeric_limits<T>::is_signed);
|
||||
if (isPrecisionLost<F, T>(from))
|
||||
POCO_VAR_RANGE_EXCEPTION ("Lost precision", from);
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
template <typename F, typename T,
|
||||
std::enable_if_t<std::is_same_v<F, bool>>* = nullptr,
|
||||
std::enable_if_t<std::is_floating_point_v<T>, T>* = nullptr>
|
||||
static void convertToSmaller(const F& from, T& to)
|
||||
/// Converts boolean values to floating-point type.
|
||||
{
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
template <typename F, typename T,
|
||||
std::enable_if_t<std::is_integral_v<F> && !std::is_signed_v<F>, F>* = nullptr,
|
||||
std::enable_if_t<(std::is_integral_v<T> && !std::is_signed<T>::value) || std::is_floating_point<T>::value, T>* = nullptr>
|
||||
static void convertToSmallerUnsigned(const F& from, T& to)
|
||||
/// Converts unsigned integral data types from larger to smaller, as well as to floating-point, types.
|
||||
/// Since lower limit is always 0 for unsigned types, only the upper limit is checked, thus
|
||||
/// saving some cycles compared to the signed version of the function. If the
|
||||
/// value to be converted is smaller than the maximum value for the target type,
|
||||
/// the conversion is performed.
|
||||
{
|
||||
checkUpperLimit<F,T>(from);
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
template <typename F, typename T>
|
||||
void convertSignedToUnsigned(const F& from, T& to) const
|
||||
/// This function is meant for converting signed integral data types to
|
||||
/// unsigned data types. Negative values can not be converted and if one
|
||||
/// is encountered, RangeException is thrown.
|
||||
template <typename F, typename T,
|
||||
std::enable_if_t<std::is_integral_v<F> && std::is_signed_v<F>, F>* = nullptr,
|
||||
std::enable_if_t<std::is_integral_v<T> && !std::is_signed_v<T>, T>* = nullptr>
|
||||
static void convertSignedToUnsigned(const F& from, T& to)
|
||||
/// Converts signed integral data types to unsigned data types.
|
||||
/// Negative values can not be converted and if one is encountered, RangeException is thrown.
|
||||
/// If upper limit is within the target data type limits, the conversion is performed.
|
||||
{
|
||||
poco_static_assert (std::numeric_limits<F>::is_specialized);
|
||||
poco_static_assert (std::numeric_limits<T>::is_specialized);
|
||||
poco_static_assert (std::numeric_limits<F>::is_signed);
|
||||
poco_static_assert (!std::numeric_limits<T>::is_signed);
|
||||
|
||||
if (from < 0)
|
||||
throw RangeException("Value too small.");
|
||||
checkUpperLimit<F,T>(from);
|
||||
POCO_VAR_RANGE_EXCEPTION ("Value too small", from);
|
||||
checkUpperLimit<std::make_unsigned_t<F>,T>(from);
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
template <typename F, typename T>
|
||||
void convertSignedFloatToUnsigned(const F& from, T& to) const
|
||||
/// This function is meant for converting floating point data types to
|
||||
/// unsigned integral data types. Negative values can not be converted and if one
|
||||
/// is encountered, RangeException is thrown.
|
||||
template <typename F, typename T, std::enable_if_t<std::is_floating_point_v<F>, bool> = true,
|
||||
std::enable_if_t<std::is_integral_v<T> && !std::is_signed_v<T>, T>* = nullptr>
|
||||
static void convertSignedFloatToUnsigned(const F& from, T& to)
|
||||
/// Converts floating point data types to unsigned integral data types. Negative values
|
||||
/// can not be converted and if one is encountered, RangeException is thrown.
|
||||
/// If upper limit is within the target data type limits, the conversion is performed.
|
||||
{
|
||||
poco_static_assert (std::numeric_limits<F>::is_specialized);
|
||||
poco_static_assert (std::numeric_limits<T>::is_specialized);
|
||||
poco_static_assert (!std::numeric_limits<F>::is_integer);
|
||||
poco_static_assert (std::numeric_limits<T>::is_integer);
|
||||
poco_static_assert (!std::numeric_limits<T>::is_signed);
|
||||
|
||||
if (from < 0)
|
||||
throw RangeException("Value too small.");
|
||||
checkUpperLimitFloat<F,T>(from);
|
||||
POCO_VAR_RANGE_EXCEPTION ("Value too small", from);
|
||||
checkUpperLimit<F,T>(from);
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
template <typename F, typename T>
|
||||
void convertUnsignedToSigned(const F& from, T& to) const
|
||||
/// This function is meant for converting unsigned integral data types to
|
||||
/// signed integral data types. Negative values can not be converted and if one
|
||||
/// is encountered, RangeException is thrown.
|
||||
template <typename F, typename T,
|
||||
std::enable_if_t<std::is_integral_v<F> && !std::is_signed_v<F>, F>* = nullptr,
|
||||
std::enable_if_t<std::is_integral_v<T> && std::is_signed_v<T>, T>* = nullptr>
|
||||
static void convertUnsignedToSigned(const F& from, T& to)
|
||||
/// Converts unsigned integral data types to signed integral data types.
|
||||
/// If upper limit is within the target data type limits, the conversion is performed.
|
||||
{
|
||||
poco_static_assert (std::numeric_limits<F>::is_specialized);
|
||||
poco_static_assert (std::numeric_limits<T>::is_specialized);
|
||||
poco_static_assert (!std::numeric_limits<F>::is_signed);
|
||||
poco_static_assert (std::numeric_limits<T>::is_signed);
|
||||
|
||||
checkUpperLimit<F,T>(from);
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<std::is_signed_v<F> && std::is_signed_v<T> && (sizeof(F) <= sizeof(T))>* = nullptr>
|
||||
void convertToSigned(const F& from, T& to) const
|
||||
{
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<std::is_signed_v<F> && std::is_signed_v<T> && (sizeof(F) > sizeof(T))>* = nullptr>
|
||||
void convertToSigned(const F& from, T& to) const
|
||||
{
|
||||
convertToSmaller(from, to);
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<!std::is_signed_v<F> && std::is_signed_v<T>>* = nullptr>
|
||||
void convertToSigned(const F& from, T& to) const
|
||||
{
|
||||
convertUnsignedToSigned(from, to);
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<!std::is_signed_v<F> && !std::is_signed_v<T> && (sizeof(F) <= sizeof(T))>* = nullptr>
|
||||
void convertToUnsigned(const F& from, T& to) const
|
||||
{
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<!std::is_signed_v<F> && !std::is_signed_v<T> && (sizeof(F) > sizeof(T))>* = nullptr>
|
||||
void convertToUnsigned(const F& from, T& to) const
|
||||
{
|
||||
convertToSmallerUnsigned(from, to);
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<std::is_signed_v<F> && !std::is_signed_v<T>>* = nullptr>
|
||||
void convertToUnsigned(const F& from, T& to) const
|
||||
{
|
||||
convertSignedToUnsigned(from, to);
|
||||
}
|
||||
|
||||
template <typename F, typename T,
|
||||
std::enable_if_t<std::is_integral_v<F>, bool> = true,
|
||||
std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
|
||||
static void convertToFP(F& from, T& to)
|
||||
/// Converts unsigned integral data types to floating-point data types.
|
||||
/// If the number of significant digits used for the integer vaue exceeds the number
|
||||
/// of available digits in the floatinng-point destination (ie. if precision would be lost
|
||||
/// by casting the value), RangeException is thrown.
|
||||
{
|
||||
if (isPrecisionLost<F, T>(from))
|
||||
POCO_VAR_RANGE_EXCEPTION ("Lost precision", from);
|
||||
to = static_cast<T>(from);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
template <typename F, typename T>
|
||||
void checkUpperLimit(const F& from) const
|
||||
template <typename T>
|
||||
static constexpr T unpreserveSign(const T& value)
|
||||
{
|
||||
if (from > std::numeric_limits<T>::max())
|
||||
throw RangeException("Value too large.");
|
||||
}
|
||||
|
||||
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 constexpr (std::is_signed_v<T>)
|
||||
{
|
||||
if (from > std::numeric_limits<T>::max())
|
||||
throw RangeException("Value too large.");
|
||||
return (value < 0) ? -value : value;
|
||||
}
|
||||
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.");
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename F, typename T>
|
||||
void checkLowerLimitFloat(const F& from) const
|
||||
template <typename T, std::enable_if_t<std::is_same_v<T, bool>, bool> = true>
|
||||
static constexpr int numValDigits(const T& value)
|
||||
{
|
||||
if (std::is_floating_point<T>::value)
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <typename T, std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, bool>, bool> = true>
|
||||
static constexpr int numValDigits(const T& value)
|
||||
{
|
||||
using U = std::make_unsigned_t<T>;
|
||||
if (value == 0) return 0;
|
||||
int digitCount = 0;
|
||||
U locVal = static_cast<U>(unpreserveSign(value)); // to prevent sign preservation
|
||||
while (locVal >>= 1) ++digitCount;
|
||||
return digitCount;
|
||||
}
|
||||
|
||||
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
|
||||
static constexpr int numValDigits(T value)
|
||||
{
|
||||
return numValDigits<int64_t>(static_cast<int64_t>(value));
|
||||
}
|
||||
|
||||
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
|
||||
static constexpr int numTypeDigits()
|
||||
{
|
||||
return std::numeric_limits<T>::digits;
|
||||
}
|
||||
|
||||
template <typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
|
||||
static constexpr int numTypeDigits()
|
||||
{
|
||||
return numValDigits(std::numeric_limits<T>::max());
|
||||
}
|
||||
|
||||
template <typename F, typename T,
|
||||
std::enable_if_t<std::is_integral_v<F>, bool> = true,
|
||||
std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
|
||||
static bool isPrecisionLost(const F& from)
|
||||
// Checks for loss of precision in integral -> floating point conversion.
|
||||
{
|
||||
return numValDigits(from) > numTypeDigits<T>();
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<std::is_integral_v<F>, bool> = true>
|
||||
static void checkUpperLimit(const F& from)
|
||||
{
|
||||
if (from > static_cast<F>(std::numeric_limits<T>::max()))
|
||||
POCO_VAR_RANGE_EXCEPTION ("Value too big", from);
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<std::is_integral_v<F>, bool> = true>
|
||||
static void checkLowerLimit(const F& from)
|
||||
{
|
||||
if (from < static_cast<F>(std::numeric_limits<T>::min()))
|
||||
POCO_VAR_RANGE_EXCEPTION ("Value too small", from);
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<std::is_floating_point_v<F>, bool> = true>
|
||||
static void checkUpperLimit(const F& from)
|
||||
{
|
||||
if ((from > static_cast<F>(std::numeric_limits<T>::max())))
|
||||
POCO_VAR_RANGE_EXCEPTION ("Value too big", from);
|
||||
}
|
||||
|
||||
template <typename F, typename T, std::enable_if_t<std::is_floating_point_v<F>, bool> = true>
|
||||
static void checkLowerLimit(const F& from)
|
||||
{
|
||||
if constexpr(std::is_floating_point_v<T>)
|
||||
{
|
||||
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.");
|
||||
if (static_cast<F>(-std::numeric_limits<T>::max()) > from)
|
||||
POCO_VAR_RANGE_EXCEPTION ("Value too small", from);
|
||||
}
|
||||
else if (from < static_cast<F>(std::numeric_limits<T>::min()))
|
||||
POCO_VAR_RANGE_EXCEPTION ("Value too small", from);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -738,6 +842,287 @@ public:
|
||||
return typeid(T);
|
||||
}
|
||||
|
||||
void convert(Int8& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToSigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(Int16& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToSigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(Int32& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToSigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(Int64& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToSigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(UInt8& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToUnsigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(UInt16& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToUnsigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(UInt32& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToUnsigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(UInt64& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToUnsigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef POCO_INT64_IS_LONG
|
||||
|
||||
void convert(long long& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToSigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(unsigned long long& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
convertToUnsigned(std::underlying_type_t<T>(_val), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void convert(bool& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
val = (std::underlying_type_t<T>(_val) != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
val = static_cast<float>(_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
val = static_cast<double>(_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
val = static_cast<char>(_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(std::string& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
val = NumberFormatter::format(std::underlying_type_t<T>(_val));
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
void convert(Poco::UTF16String& val) const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
std::string str = NumberFormatter::format(std::underlying_type_t<T>(_val));
|
||||
Poco::UnicodeConverter::convert(str, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
VarHolder::convert(val);
|
||||
}
|
||||
}
|
||||
|
||||
bool isArray() const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VarHolder::isArray();
|
||||
}
|
||||
}
|
||||
|
||||
bool isStruct() const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VarHolder::isStruct();
|
||||
}
|
||||
}
|
||||
|
||||
bool isInteger() const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
return std::numeric_limits<std::underlying_type_t<T>>::is_integer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VarHolder::isInteger();
|
||||
}
|
||||
}
|
||||
|
||||
bool isSigned() const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
return std::numeric_limits<std::underlying_type_t<T>>::is_signed;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VarHolder::isSigned();
|
||||
}
|
||||
}
|
||||
|
||||
bool isNumeric() const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
return std::numeric_limits<std::underlying_type_t<T>>::is_specialized;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VarHolder::isNumeric();
|
||||
}
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VarHolder::isBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VarHolder::isString();
|
||||
}
|
||||
}
|
||||
|
||||
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
||||
{
|
||||
return cloneHolder(pVarHolder, _val);
|
||||
@@ -835,12 +1220,12 @@ public:
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
val = static_cast<float>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
val = static_cast<double>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
@@ -991,12 +1376,12 @@ public:
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
val = static_cast<float>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
val = static_cast<double>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
@@ -1144,12 +1529,12 @@ public:
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
val = static_cast<float>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
val = static_cast<double>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
@@ -1296,12 +1681,12 @@ public:
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
val = static_cast<float>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
val = static_cast<double>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
@@ -1463,12 +1848,12 @@ public:
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
val = static_cast<float>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
val = static_cast<double>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
@@ -1615,12 +2000,12 @@ public:
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
val = static_cast<float>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
val = static_cast<double>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
@@ -1767,12 +2152,12 @@ public:
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
val = static_cast<float>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
val = static_cast<double>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
@@ -1919,12 +2304,12 @@ public:
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
val = static_cast<float>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
val = static_cast<double>(_val);
|
||||
convertToFP(_val, val);
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
@@ -4327,10 +4712,10 @@ private:
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector<Var> Vector;
|
||||
typedef std::deque<Var> Deque;
|
||||
typedef std::list<Var> List;
|
||||
typedef Vector Array;
|
||||
using Vector = std::vector<Var>;
|
||||
using Deque = std::deque<Var>;
|
||||
using List = std::list<Var>;
|
||||
using Array = Vector;
|
||||
|
||||
|
||||
} } // namespace Poco::Dynamic
|
||||
|
||||
@@ -69,6 +69,18 @@ public:
|
||||
bool operator != (const VarIterator& other) const;
|
||||
/// Inequality operator.
|
||||
|
||||
bool operator < (const VarIterator& other) const;
|
||||
/// Less than operator.
|
||||
|
||||
bool operator > (const VarIterator& other) const;
|
||||
/// Greater than operator.
|
||||
|
||||
bool operator <= (const VarIterator& other) const;
|
||||
/// Less than or equal to operator.
|
||||
|
||||
bool operator >= (const VarIterator& other) const;
|
||||
/// Greater than or equal to operator.
|
||||
|
||||
Var& operator * () const;
|
||||
/// Returns value at the current position.
|
||||
|
||||
@@ -138,6 +150,30 @@ inline bool VarIterator::operator != (const VarIterator& other) const
|
||||
}
|
||||
|
||||
|
||||
inline bool VarIterator::operator < (const VarIterator& other) const
|
||||
{
|
||||
return _position < other._position;
|
||||
}
|
||||
|
||||
|
||||
inline bool VarIterator::operator > (const VarIterator& other) const
|
||||
{
|
||||
return _position > other._position;
|
||||
}
|
||||
|
||||
|
||||
inline bool VarIterator::operator <= (const VarIterator& other) const
|
||||
{
|
||||
return _position <= other._position;
|
||||
}
|
||||
|
||||
|
||||
inline bool VarIterator::operator >= (const VarIterator& other) const
|
||||
{
|
||||
return _position >= other._position;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Dynamic
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// VarVisitor.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Dynamic
|
||||
// Module: VarVisitor
|
||||
//
|
||||
// Definition of the VarVisitor class.
|
||||
//
|
||||
// Copyright (c) 2023, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_VarVisitor_INCLUDED
|
||||
#define Foundation_VarVisitor_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Dynamic/Var.h"
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Details {
|
||||
|
||||
|
||||
#ifndef POCO_DOC
|
||||
|
||||
|
||||
struct TypeInfoHash
|
||||
{
|
||||
inline std::size_t operator()(std::type_info const& t) const { return t.hash_code(); }
|
||||
};
|
||||
|
||||
|
||||
struct EqualRef
|
||||
{
|
||||
template <typename T>
|
||||
bool operator()(std::reference_wrapper<T> a, std::reference_wrapper<T> b) const
|
||||
{
|
||||
return a.get() == b.get();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
using TypeInfoRef = std::reference_wrapper<std::type_info const>;
|
||||
using HandlerCaller = std::function<void(const Poco::Dynamic::Var&)>;
|
||||
|
||||
|
||||
template <typename T>
|
||||
using HandlerPointer = void (*)(const T&);
|
||||
|
||||
|
||||
template <typename T>
|
||||
using Handler = std::function<void(const T&)>;
|
||||
|
||||
|
||||
#endif // POCO_DOC
|
||||
|
||||
|
||||
} // Details
|
||||
|
||||
|
||||
namespace Dynamic {
|
||||
|
||||
|
||||
class Foundation_API Visitor
|
||||
/// VarVisitor class.
|
||||
{
|
||||
std::unordered_map<Details::TypeInfoRef,
|
||||
Details::HandlerCaller,
|
||||
Details::TypeInfoHash,
|
||||
Details::EqualRef> _handlers;
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
bool addHandler(const Details::Handler<T>& f)
|
||||
/// Add handler for specific type T which holds in Var.
|
||||
/// This method is more safe, because it saves copy of handler : lambda or std::function.
|
||||
/// Returns true if handler was added.
|
||||
{
|
||||
auto result = _handlers.emplace(std::ref(typeid(T)),
|
||||
Details::HandlerCaller([handler = f](const Poco::Dynamic::Var& x)
|
||||
{
|
||||
handler(x.extract<T>());
|
||||
}));
|
||||
return result.second;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool addHandler(Details::HandlerPointer<T> f)
|
||||
/// Add handler for specific type T which holds in Var.
|
||||
/// This method is less safe, because it saves only copy of function pointer.
|
||||
/// Returns true if handler was added.
|
||||
{
|
||||
auto result = _handlers.emplace(std::ref(typeid(T)),
|
||||
Details::HandlerCaller([handlerPointer = f](const Poco::Dynamic::Var& x)
|
||||
{
|
||||
handlerPointer(x.extract<T>());
|
||||
}));
|
||||
return result.second;
|
||||
}
|
||||
|
||||
bool visit(const Poco::Dynamic::Var& x) const;
|
||||
/// Find handler for held type and if it exists call handler.
|
||||
/// Returns true if hanlder was found othrewise returns false.
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Dynamic
|
||||
|
||||
|
||||
#endif // Foundation_VarVisitor_INCLUDED
|
||||
@@ -1,59 +0,0 @@
|
||||
//
|
||||
// Environment_WINCE.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
// Module: Environment
|
||||
//
|
||||
// Definition of the EnvironmentImpl class for WINCE.
|
||||
//
|
||||
// Copyright (c) 2009-2010, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Environment_WINCE_INCLUDED
|
||||
#define Foundation_Environment_WINCE_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
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 void setImpl(const std::string& name, const std::string& value);
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Environment_WINCE_INCLUDED
|
||||
+3
@@ -43,6 +43,9 @@ public:
|
||||
static std::string getMessage(int errorCode);
|
||||
/// Utility function translating numeric error code to string.
|
||||
#endif
|
||||
|
||||
static std::string getLastMessage();
|
||||
/// Utility function returning the last error message.
|
||||
};
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public:
|
||||
/// the event is automatically reset after
|
||||
/// a wait() successfully returns.
|
||||
|
||||
//@ deprecated
|
||||
POCO_DEPRECATED("")
|
||||
explicit Event(bool autoReset);
|
||||
/// Please use Event::Event(EventType) instead.
|
||||
|
||||
|
||||
+2
-2
@@ -39,8 +39,8 @@ protected:
|
||||
void resetImpl();
|
||||
|
||||
private:
|
||||
bool _auto;
|
||||
bool _state;
|
||||
std::atomic<bool> _auto;
|
||||
std::atomic<bool> _state;
|
||||
pthread_mutex_t _mutex;
|
||||
pthread_cond_t _cond;
|
||||
};
|
||||
|
||||
@@ -103,6 +103,12 @@ private:
|
||||
int _code;
|
||||
};
|
||||
|
||||
#if defined(_HAS_EXCEPTIONS)
|
||||
// Size of Poco::Exception depends on the exception settings (like _HAS_EXCEPTIONS)
|
||||
// that might influence size of std::exception from which Poco::Exception is derived from.
|
||||
// It is expected that Poco libraries and application using Poco have the same settings.
|
||||
static_assert(_HAS_EXCEPTIONS != 0);
|
||||
#endif
|
||||
|
||||
//
|
||||
// inlines
|
||||
@@ -228,6 +234,7 @@ POCO_DECLARE_EXCEPTION(Foundation_API, PropertyNotSupportedException, RuntimeExc
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, PoolOverflowException, RuntimeException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, NoPermissionException, RuntimeException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, OutOfMemoryException, RuntimeException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, ResourceLimitException, RuntimeException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, DataException, RuntimeException)
|
||||
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, DataFormatException, DataException)
|
||||
@@ -246,6 +253,8 @@ POCO_DECLARE_EXCEPTION(Foundation_API, CreateFileException, FileException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, OpenFileException, FileException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, WriteFileException, FileException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, ReadFileException, FileException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, ExecuteFileException, FileException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, FileNotReadyException, FileException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, DirectoryNotEmptyException, FileException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, UnknownURISchemeException, RuntimeException)
|
||||
POCO_DECLARE_EXCEPTION(Foundation_API, TooManyURIRedirectsException, RuntimeException)
|
||||
|
||||
+1
-2
@@ -26,9 +26,8 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
//@ deprecated
|
||||
template <class TArgs, class TMutex = FastMutex>
|
||||
class FIFOEvent: public AbstractEvent <
|
||||
class POCO_DEPRECATED("use BasicEvent") FIFOEvent: public AbstractEvent <
|
||||
TArgs,
|
||||
FIFOStrategy<TArgs, AbstractDelegate<TArgs>>,
|
||||
AbstractDelegate<TArgs>,
|
||||
|
||||
+12
-2
@@ -24,9 +24,8 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
//@ deprecated
|
||||
template <class TArgs, class TDelegate>
|
||||
class FIFOStrategy: public DefaultStrategy<TArgs, TDelegate>
|
||||
class POCO_DEPRECATED("") FIFOStrategy: public DefaultStrategy<TArgs, TDelegate>
|
||||
/// Note: As of release 1.4.2, DefaultStrategy already
|
||||
/// implements FIFO behavior, so this class is provided
|
||||
/// for backwards compatibility only.
|
||||
@@ -41,6 +40,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
FIFOStrategy(FIFOStrategy&& s):
|
||||
DefaultStrategy<TArgs, TDelegate>(std::move(s))
|
||||
{
|
||||
}
|
||||
|
||||
~FIFOStrategy()
|
||||
{
|
||||
}
|
||||
@@ -50,6 +54,12 @@ public:
|
||||
DefaultStrategy<TArgs, TDelegate>::operator = (s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
FIFOStrategy& operator = (FIFOStrategy&& s)
|
||||
{
|
||||
DefaultStrategy<TArgs, TDelegate>::operator = (s);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class FPEnvironmentImpl
|
||||
class Foundation_API FPEnvironmentImpl
|
||||
{
|
||||
protected:
|
||||
enum RoundingModeImpl
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class FPEnvironmentImpl
|
||||
class Foundation_API FPEnvironmentImpl
|
||||
{
|
||||
protected:
|
||||
enum RoundingModeImpl
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class FPEnvironmentImpl
|
||||
class Foundation_API FPEnvironmentImpl
|
||||
{
|
||||
protected:
|
||||
enum RoundingModeImpl
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class FPEnvironmentImpl
|
||||
class Foundation_API FPEnvironmentImpl
|
||||
{
|
||||
protected:
|
||||
enum RoundingModeImpl
|
||||
|
||||
+17
-6
@@ -24,11 +24,7 @@
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "File_WINCE.h"
|
||||
#else
|
||||
#include "Poco/File_WIN32U.h"
|
||||
#endif
|
||||
#elif defined(POCO_VXWORKS)
|
||||
#include "Poco/File_VX.h"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
@@ -58,7 +54,7 @@ class Foundation_API File: private FileImpl
|
||||
/// use the forward slash ("/") as directory separator.
|
||||
{
|
||||
public:
|
||||
typedef FileSizeImpl FileSize;
|
||||
using FileSize = FileSizeImpl;
|
||||
|
||||
enum LinkType
|
||||
/// Type of link for linkTo().
|
||||
@@ -88,7 +84,7 @@ public:
|
||||
File(const File& file);
|
||||
/// Copy constructor.
|
||||
|
||||
virtual ~File();
|
||||
~File() override;
|
||||
/// Destroys the file.
|
||||
|
||||
File& operator = (const File& file);
|
||||
@@ -109,9 +105,24 @@ public:
|
||||
const std::string& path() const;
|
||||
/// Returns the path.
|
||||
|
||||
std::string absolutePath() const;
|
||||
/// Returns absolute path.
|
||||
/// Attempts to find the existing file
|
||||
/// using curent work directory and the PATH
|
||||
/// environment variable.
|
||||
/// If the file doesn't exist, returns empty string.
|
||||
|
||||
bool exists() const;
|
||||
/// Returns true iff the file exists.
|
||||
|
||||
bool existsAnywhere() const;
|
||||
/// If the file path is relative, searches
|
||||
/// for the file in the current working directory
|
||||
/// and the environment paths.
|
||||
/// If the file path is absolute, the
|
||||
/// functionality is identical to the
|
||||
/// exists() call.
|
||||
|
||||
bool canRead() const;
|
||||
/// Returns true iff the file is readable.
|
||||
|
||||
|
||||
+57
-8
@@ -47,19 +47,25 @@ class Foundation_API FileIOS: public virtual std::ios
|
||||
/// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled.
|
||||
{
|
||||
public:
|
||||
FileIOS(std::ios::openmode defaultMode);
|
||||
|
||||
using NativeHandle = FileStreamBuf::NativeHandle;
|
||||
|
||||
FileIOS();
|
||||
/// Creates the basic stream.
|
||||
|
||||
~FileIOS();
|
||||
~FileIOS() override;
|
||||
/// Destroys the stream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode);
|
||||
virtual 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.
|
||||
|
||||
void openHandle(NativeHandle handle, std::ios::openmode mode);
|
||||
/// Takes ownership of the handle.
|
||||
|
||||
void close();
|
||||
/// Closes the file stream.
|
||||
///
|
||||
@@ -70,9 +76,17 @@ public:
|
||||
FileStreamBuf* rdbuf();
|
||||
/// Returns a pointer to the underlying streambuf.
|
||||
|
||||
NativeHandle nativeHandle() const;
|
||||
/// Returns native file descriptor handle
|
||||
|
||||
UInt64 size() const;
|
||||
/// Returns file size
|
||||
|
||||
void flushToDisk();
|
||||
/// Forces buffered data to be written to the disk
|
||||
|
||||
protected:
|
||||
FileStreamBuf _buf;
|
||||
std::ios::openmode _defaultMode;
|
||||
};
|
||||
|
||||
|
||||
@@ -101,8 +115,16 @@ public:
|
||||
/// Throws a FileNotFoundException (or a similar exception) if the file
|
||||
/// does not exist or is not accessible for other reasons.
|
||||
|
||||
~FileInputStream();
|
||||
~FileInputStream() override;
|
||||
/// Destroys the stream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode = std::ios::in) override;
|
||||
/// Opens the file specified by path, using the given mode, which
|
||||
/// will always include std::ios::in (even if not specified).
|
||||
///
|
||||
/// 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.
|
||||
};
|
||||
|
||||
|
||||
@@ -131,9 +153,25 @@ public:
|
||||
/// 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.
|
||||
///
|
||||
/// NOTE: The default mode std::ios::out | std::ios::trunc is different from the default
|
||||
/// for std::ofstream, which is std::ios::out only. This is for backwards compatibility
|
||||
/// with earlier POCO versions.
|
||||
|
||||
~FileOutputStream();
|
||||
~FileOutputStream() override;
|
||||
/// Destroys the FileOutputStream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::trunc) override;
|
||||
/// Opens the file specified by path, using the given mode, which
|
||||
/// always includes std::ios::out, even if not specified.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// NOTE: The default mode std::ios::out | std::ios::trunc is different from the default
|
||||
/// for std::ostream, which is std::ios::out only. This is for backwards compatibility
|
||||
/// with earlier POCO versions.
|
||||
};
|
||||
|
||||
|
||||
@@ -160,9 +198,20 @@ public:
|
||||
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.
|
||||
///
|
||||
/// NOTE: The default mode std::ios::in | std::ios::out is different from the default
|
||||
/// for std::fstream, which is std::ios::out only. This is for backwards compatibility
|
||||
/// with earlier POCO versions.
|
||||
|
||||
~FileStream();
|
||||
~FileStream() override;
|
||||
/// Destroys the FileOutputStream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::in) override;
|
||||
/// Opens the file specified by path, using the given mode.
|
||||
///
|
||||
/// 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.
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
//
|
||||
// FileStreamRWLock.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
// Module: FileStreamRWLock
|
||||
//
|
||||
// Definition of the FileStreamRWLock class.
|
||||
//
|
||||
// Copyright (c) 2004-2024, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_FileStreamRWLock_INCLUDED
|
||||
#define Foundation_FileStreamRWLock_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include <atomic>
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/FileStreamRWLock_WIN32.h"
|
||||
#else
|
||||
#include "Poco/FileStreamRWLock_POSIX.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class ScopedFStreamRWLock;
|
||||
class ScopedFStreamReadRWLock;
|
||||
class ScopedFStreamWriteRWLock;
|
||||
|
||||
|
||||
class Foundation_API FileStreamRWLock: private FileStreamRWLockImpl
|
||||
/// A reader writer lock on the file region allows multiple concurrent
|
||||
/// process-readers or one exclusive process-writer.
|
||||
{
|
||||
public:
|
||||
using ScopedLock = ScopedFStreamRWLock;
|
||||
using ScopedReadLock = ScopedFStreamReadRWLock;
|
||||
using ScopedWriteLock = ScopedFStreamWriteRWLock;
|
||||
|
||||
FileStreamRWLock(const FileStream &fs, Poco::UInt64 offset, Poco::UInt64 size);
|
||||
/// Creates the Reader/Writer lock on the file region.
|
||||
/// offset - from start of the file
|
||||
/// size - size of the locker region
|
||||
|
||||
~FileStreamRWLock();
|
||||
/// Destroys the Reader/Writer lock on the file region.
|
||||
|
||||
void readLock();
|
||||
/// Acquires a read lock. If another process currently holds a write lock,
|
||||
/// waits until the write lock is released.
|
||||
|
||||
bool tryReadLock();
|
||||
/// Tries to acquire a read lock. Immediately returns true if successful, or
|
||||
/// false if another process currently holds a write lock.
|
||||
|
||||
void writeLock();
|
||||
/// Acquires a write lock on the file region. If one or more other processes currently hold
|
||||
/// locks, waits until all locks are released.
|
||||
|
||||
bool tryWriteLock();
|
||||
/// Tries to acquire a write lock on the file region. Immediately returns true if successful,
|
||||
/// or false if one or more other processes currently hold
|
||||
/// locks.
|
||||
|
||||
void unlock();
|
||||
/// Releases the read or write lock.
|
||||
|
||||
private:
|
||||
std::atomic_bool _locked = false;
|
||||
FileStreamRWLock(const FileStreamRWLock&);
|
||||
FileStreamRWLock& operator = (const FileStreamRWLock&);
|
||||
};
|
||||
|
||||
|
||||
class Foundation_API ScopedFStreamRWLock
|
||||
/// A variant of ScopedLock for reader/writer locks.
|
||||
{
|
||||
public:
|
||||
ScopedFStreamRWLock(FileStreamRWLock& rwl, bool write = false);
|
||||
~ScopedFStreamRWLock();
|
||||
|
||||
private:
|
||||
FileStreamRWLock& _rwl;
|
||||
|
||||
ScopedFStreamRWLock();
|
||||
ScopedFStreamRWLock(const ScopedFStreamRWLock&);
|
||||
ScopedFStreamRWLock& operator = (const ScopedFStreamRWLock&);
|
||||
};
|
||||
|
||||
|
||||
class Foundation_API ScopedFStreamReadRWLock : public ScopedFStreamRWLock
|
||||
/// A variant of ScopedLock for reader locks.
|
||||
{
|
||||
public:
|
||||
ScopedFStreamReadRWLock(FileStreamRWLock& rwl);
|
||||
~ScopedFStreamReadRWLock();
|
||||
};
|
||||
|
||||
|
||||
class Foundation_API ScopedFStreamWriteRWLock : public ScopedFStreamRWLock
|
||||
/// A variant of ScopedLock for writer locks.
|
||||
{
|
||||
public:
|
||||
ScopedFStreamWriteRWLock(FileStreamRWLock& rwl);
|
||||
~ScopedFStreamWriteRWLock();
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline void FileStreamRWLock::readLock()
|
||||
{
|
||||
readLockImpl();
|
||||
_locked = true;
|
||||
}
|
||||
|
||||
|
||||
inline bool FileStreamRWLock::tryReadLock()
|
||||
{
|
||||
bool locked = tryReadLockImpl();
|
||||
if (locked) _locked = true; // assign only if success lock
|
||||
return locked;
|
||||
}
|
||||
|
||||
|
||||
inline void FileStreamRWLock::writeLock()
|
||||
{
|
||||
writeLockImpl();
|
||||
_locked = true;
|
||||
}
|
||||
|
||||
|
||||
inline bool FileStreamRWLock::tryWriteLock()
|
||||
{
|
||||
bool locked = tryWriteLockImpl();
|
||||
if (locked) _locked = true; // assign only if success lock
|
||||
return locked;
|
||||
}
|
||||
|
||||
|
||||
inline void FileStreamRWLock::unlock()
|
||||
{
|
||||
unlockImpl();
|
||||
_locked = false;
|
||||
}
|
||||
|
||||
|
||||
inline ScopedFStreamRWLock::ScopedFStreamRWLock(FileStreamRWLock& rwl, bool write): _rwl(rwl)
|
||||
{
|
||||
if (write)
|
||||
_rwl.writeLock();
|
||||
else
|
||||
_rwl.readLock();
|
||||
}
|
||||
|
||||
|
||||
inline ScopedFStreamRWLock::~ScopedFStreamRWLock()
|
||||
{
|
||||
try
|
||||
{
|
||||
_rwl.unlock();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
poco_unexpected();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline ScopedFStreamReadRWLock::ScopedFStreamReadRWLock(FileStreamRWLock& rwl): ScopedFStreamRWLock(rwl, false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline ScopedFStreamReadRWLock::~ScopedFStreamReadRWLock()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline ScopedFStreamWriteRWLock::ScopedFStreamWriteRWLock(FileStreamRWLock& rwl): ScopedFStreamRWLock(rwl, true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline ScopedFStreamWriteRWLock::~ScopedFStreamWriteRWLock()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_FileStreamRWLock_INCLUDED
|
||||
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// FileStreamRWLock_POSIX.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
// Module: FileStreamRWLock
|
||||
//
|
||||
// Definition of the FileStreamRWLockImpl class for POSIX FileStream.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_FileStreamRWLock_POSIX_INCLUDED
|
||||
#define Foundation_FileStreamRWLock_POSIX_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include <fcntl.h>
|
||||
#include <cerrno>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API FileStreamRWLockImpl
|
||||
{
|
||||
protected:
|
||||
FileStreamRWLockImpl(const FileStream::NativeHandle &fd, Poco::UInt64 offset, Poco::UInt64 size);
|
||||
~FileStreamRWLockImpl();
|
||||
void readLockImpl();
|
||||
bool tryReadLockImpl();
|
||||
void writeLockImpl();
|
||||
bool tryWriteLockImpl();
|
||||
void unlockImpl();
|
||||
|
||||
private:
|
||||
FileStream::NativeHandle _fd;
|
||||
struct flock _flock;
|
||||
int _lockMode;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline void FileStreamRWLockImpl::readLockImpl()
|
||||
{
|
||||
_flock.l_type = F_RDLCK;
|
||||
_lockMode = F_SETLKW;
|
||||
int rc = fcntl(_fd, _lockMode, &_flock);
|
||||
if (rc == -1)
|
||||
throw SystemException("cannot lock reader lock", errno);
|
||||
}
|
||||
|
||||
|
||||
inline bool FileStreamRWLockImpl::tryReadLockImpl()
|
||||
{
|
||||
_flock.l_type = F_RDLCK;
|
||||
_lockMode = F_SETLK;
|
||||
int rc = fcntl(_fd, _lockMode, &_flock);
|
||||
if (rc == 0)
|
||||
return true;
|
||||
else if (errno == EAGAIN || errno == EACCES)
|
||||
return false;
|
||||
else
|
||||
throw SystemException("cannot lock try-reader lock", errno);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline void FileStreamRWLockImpl::writeLockImpl()
|
||||
{
|
||||
_flock.l_type = F_WRLCK;
|
||||
_lockMode = F_SETLKW;
|
||||
int rc = fcntl(_fd, _lockMode, &_flock);
|
||||
if (rc == -1)
|
||||
throw SystemException("cannot lock writer lock", errno);
|
||||
}
|
||||
|
||||
|
||||
inline bool FileStreamRWLockImpl::tryWriteLockImpl()
|
||||
{
|
||||
_flock.l_type = F_WRLCK;
|
||||
_lockMode = F_SETLK;
|
||||
int rc = fcntl(_fd, _lockMode, &_flock);
|
||||
if (rc != -1)
|
||||
return true;
|
||||
else if (errno == EAGAIN || errno == EACCES)
|
||||
return false;
|
||||
else
|
||||
throw SystemException("cannot lock writer lock", errno);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline void FileStreamRWLockImpl::unlockImpl()
|
||||
{
|
||||
_flock.l_type = F_UNLCK;
|
||||
_lockMode = F_SETLKW;
|
||||
int rc = fcntl(_fd, _lockMode, &_flock);
|
||||
if (rc == -1)
|
||||
throw SystemException("cannot unlock", errno);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_FileStreamRWLock_POSIX_INCLUDED
|
||||
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// FileStreamRWLock_WIN32.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
// Module: FileStreamRWLock
|
||||
//
|
||||
// Definition of the FileStreamRWLockImpl class for WIN32 FileStream.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_FileStreamRWLock_WIN32_INCLUDED
|
||||
#define Foundation_FileStreamRWLock_WIN32_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include <Windows.h>
|
||||
|
||||
namespace Poco {
|
||||
|
||||
struct LockMode
|
||||
{
|
||||
static constexpr DWORD READ = 0;
|
||||
static constexpr DWORD WRITE = LOCKFILE_EXCLUSIVE_LOCK;
|
||||
static constexpr DWORD TRY_READ = LOCKFILE_FAIL_IMMEDIATELY;
|
||||
static constexpr DWORD TRY_WRITE = (LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY);
|
||||
};
|
||||
|
||||
class Foundation_API FileStreamRWLockImpl
|
||||
{
|
||||
protected:
|
||||
FileStreamRWLockImpl(const FileStream::NativeHandle &fd, Poco::UInt64 offset, Poco::UInt64 size);
|
||||
~FileStreamRWLockImpl();
|
||||
void readLockImpl();
|
||||
bool tryReadLockImpl();
|
||||
void writeLockImpl();
|
||||
bool tryWriteLockImpl();
|
||||
void unlockImpl();
|
||||
|
||||
private:
|
||||
FileStream::NativeHandle _fd;
|
||||
OVERLAPPED _overlapped;
|
||||
LARGE_INTEGER _size;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline void FileStreamRWLockImpl::readLockImpl()
|
||||
{
|
||||
BOOL fSuccess = LockFileEx(_fd, LockMode::READ, 0, _size.LowPart, _size.HighPart, &_overlapped);
|
||||
if (!fSuccess)
|
||||
{
|
||||
throw SystemException("cannot lock reader lock", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool FileStreamRWLockImpl::tryReadLockImpl()
|
||||
{
|
||||
BOOL fSuccess = LockFileEx(_fd, LockMode::TRY_READ, 0, _size.LowPart, _size.HighPart, &_overlapped);
|
||||
if (fSuccess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto lastError = GetLastError();
|
||||
if (lastError == ERROR_IO_PENDING || lastError == ERROR_LOCK_VIOLATION)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw SystemException("cannot lock try-reader lock", lastError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void FileStreamRWLockImpl::writeLockImpl()
|
||||
{
|
||||
BOOL fSuccess = LockFileEx(_fd, LockMode::WRITE, 0, _size.LowPart, _size.HighPart, &_overlapped);
|
||||
if (!fSuccess)
|
||||
{
|
||||
throw SystemException("cannot lock writer lock", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool FileStreamRWLockImpl::tryWriteLockImpl()
|
||||
{
|
||||
BOOL fSuccess = LockFileEx(_fd, LockMode::TRY_WRITE, 0, _size.LowPart, _size.HighPart, &_overlapped);
|
||||
if (fSuccess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto lastError = GetLastError();
|
||||
if (lastError == ERROR_IO_PENDING || lastError == ERROR_LOCK_VIOLATION)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw SystemException("cannot lock try-writer lock", lastError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void FileStreamRWLockImpl::unlockImpl()
|
||||
{
|
||||
BOOL fSuccess = UnlockFileEx(_fd, 0, _size.LowPart, _size.HighPart, &_overlapped);
|
||||
if (!fSuccess)
|
||||
{
|
||||
throw SystemException("cannot unlock ", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_FileStreamRWLock_WIN32_INCLUDED
|
||||
+27
-7
@@ -31,38 +31,58 @@ class Foundation_API FileStreamBuf: public BufferedBidirectionalStreamBuf
|
||||
/// This stream buffer handles Fileio
|
||||
{
|
||||
public:
|
||||
using NativeHandle = int;
|
||||
|
||||
FileStreamBuf();
|
||||
/// Creates a FileStreamBuf.
|
||||
|
||||
~FileStreamBuf();
|
||||
~FileStreamBuf() override;
|
||||
/// Destroys the FileStream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode);
|
||||
/// Opens the given file in the given mode.
|
||||
|
||||
void openHandle(NativeHandle fd, std::ios::openmode mode);
|
||||
/// Take ownership of the given file descriptor.
|
||||
|
||||
bool close();
|
||||
/// Closes the File stream buffer. Returns true if successful,
|
||||
/// false otherwise.
|
||||
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
bool resizeBuffer(std::streamsize bufferSize) override;
|
||||
/// Resizes internal buffer. Minimum size is BUFFER_SIZE.
|
||||
/// Minimum is used when requested size is smaller.
|
||||
/// Buffer can be resized only when the file is not open.
|
||||
/// Returns true if resize succeeded.
|
||||
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out) override;
|
||||
/// Change position by offset, according to way and mode.
|
||||
|
||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out) override;
|
||||
/// Change to specified position, according to mode.
|
||||
|
||||
void flushToDisk();
|
||||
/// Forces buffered data to be written to the disk
|
||||
|
||||
NativeHandle nativeHandle() const;
|
||||
/// Returns native file descriptor handle
|
||||
|
||||
UInt64 size() const;
|
||||
/// Returns file size
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
BUFFER_SIZE = 4096
|
||||
};
|
||||
|
||||
int readFromDevice(char* buffer, std::streamsize length);
|
||||
int writeToDevice(const char* buffer, std::streamsize length);
|
||||
int readFromDevice(char* buffer, std::streamsize length) override;
|
||||
int writeToDevice(const char* buffer, std::streamsize length) override;
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
int _fd;
|
||||
std::streamoff _pos;
|
||||
NativeHandle _fd;
|
||||
std::streamoff _pos {0};
|
||||
};
|
||||
|
||||
|
||||
|
||||
+26
-7
@@ -25,11 +25,12 @@
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API FileStreamBuf: public BufferedBidirectionalStreamBuf
|
||||
/// This stream buffer handles Fileio
|
||||
{
|
||||
public:
|
||||
using NativeHandle = HANDLE;
|
||||
|
||||
FileStreamBuf();
|
||||
/// Creates a FileStreamBuf.
|
||||
|
||||
@@ -39,29 +40,47 @@ public:
|
||||
void open(const std::string& path, std::ios::openmode mode);
|
||||
/// Opens the given file in the given mode.
|
||||
|
||||
void openHandle(NativeHandle handle, std::ios::openmode mode);
|
||||
/// Take ownership of the given HANDLE.
|
||||
|
||||
bool close();
|
||||
/// Closes the File stream buffer. Returns true if successful,
|
||||
/// false otherwise.
|
||||
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
bool resizeBuffer(std::streamsize bufferSize) override;
|
||||
/// Resizes internal buffer. Minimum size is BUFFER_SIZE.
|
||||
/// Minimum is used when requested size is smaller.
|
||||
/// Buffer can be resized only when the file is not open.
|
||||
/// Returns true if resize succeeded.
|
||||
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out) override;
|
||||
/// change position by offset, according to way and mode
|
||||
|
||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out) override;
|
||||
/// change to specified position, according to mode
|
||||
|
||||
void flushToDisk();
|
||||
/// Forces buffered data to be written to the disk
|
||||
|
||||
NativeHandle nativeHandle() const;
|
||||
/// Returns native file descriptor handle
|
||||
|
||||
Poco::UInt64 size() const;
|
||||
/// Returns file size
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
BUFFER_SIZE = 4096
|
||||
};
|
||||
|
||||
int readFromDevice(char* buffer, std::streamsize length);
|
||||
int writeToDevice(const char* buffer, std::streamsize length);
|
||||
int readFromDevice(char* buffer, std::streamsize length) override;
|
||||
int writeToDevice(const char* buffer, std::streamsize length) override;
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
HANDLE _handle;
|
||||
UInt64 _pos;
|
||||
NativeHandle _handle;
|
||||
UInt64 _pos {0};
|
||||
};
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -32,7 +33,7 @@ protected:
|
||||
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
|
||||
};
|
||||
|
||||
typedef UInt64 FileSizeImpl;
|
||||
using FileSizeImpl = UInt64;
|
||||
|
||||
FileImpl();
|
||||
FileImpl(const std::string& path);
|
||||
@@ -40,10 +41,11 @@ protected:
|
||||
void swapImpl(FileImpl& file);
|
||||
void setPathImpl(const std::string& path);
|
||||
const std::string& getPathImpl() const;
|
||||
std::string getExecutablePathImpl() const;
|
||||
bool existsImpl() const;
|
||||
bool canReadImpl() const;
|
||||
bool canWriteImpl() const;
|
||||
bool canExecuteImpl() const;
|
||||
bool canExecuteImpl(const std::string& absolutePath) const;
|
||||
bool isFileImpl() const;
|
||||
bool isDirectoryImpl() const;
|
||||
bool isLinkImpl() const;
|
||||
|
||||
+4
-3
@@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
#include "Poco/Timestamp.h"
|
||||
|
||||
namespace Poco {
|
||||
|
||||
@@ -32,7 +32,7 @@ protected:
|
||||
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
|
||||
};
|
||||
|
||||
typedef UInt64 FileSizeImpl;
|
||||
using FileSizeImpl = UInt64;
|
||||
|
||||
FileImpl();
|
||||
FileImpl(const std::string& path);
|
||||
@@ -40,10 +40,11 @@ protected:
|
||||
void swapImpl(FileImpl& file);
|
||||
void setPathImpl(const std::string& path);
|
||||
const std::string& getPathImpl() const;
|
||||
std::string getExecutablePathImpl() const;
|
||||
bool existsImpl() const;
|
||||
bool canReadImpl() const;
|
||||
bool canWriteImpl() const;
|
||||
bool canExecuteImpl() const;
|
||||
bool canExecuteImpl(const std::string& absolutePath) const;
|
||||
bool isFileImpl() const;
|
||||
bool isDirectoryImpl() const;
|
||||
bool isLinkImpl() const;
|
||||
|
||||
+3
-2
@@ -33,7 +33,7 @@ protected:
|
||||
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
|
||||
};
|
||||
|
||||
typedef UInt64 FileSizeImpl;
|
||||
using FileSizeImpl = UInt64;
|
||||
|
||||
FileImpl();
|
||||
FileImpl(const std::string& path);
|
||||
@@ -41,10 +41,11 @@ protected:
|
||||
void swapImpl(FileImpl& file);
|
||||
void setPathImpl(const std::string& path);
|
||||
const std::string& getPathImpl() const;
|
||||
std::string getExecutablePathImpl() const;
|
||||
bool existsImpl() const;
|
||||
bool canReadImpl() const;
|
||||
bool canWriteImpl() const;
|
||||
bool canExecuteImpl() const;
|
||||
bool canExecuteImpl(const std::string& absolutePath) const;
|
||||
bool isFileImpl() const;
|
||||
bool isDirectoryImpl() const;
|
||||
bool isLinkImpl() const;
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
//
|
||||
// File_WIN32U.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
// Module: File
|
||||
//
|
||||
// Definition of the Unicode FileImpl class for WIN32.
|
||||
//
|
||||
// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_File_WINCE_INCLUDED
|
||||
#define Foundation_File_WINCE_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API FileImpl
|
||||
{
|
||||
protected:
|
||||
|
||||
enum Options {
|
||||
OPT_FAIL_ON_OVERWRITE_IMPL = 0x01
|
||||
};
|
||||
|
||||
typedef UInt64 FileSizeImpl;
|
||||
|
||||
FileImpl();
|
||||
FileImpl(const std::string& path);
|
||||
virtual ~FileImpl();
|
||||
void swapImpl(FileImpl& file);
|
||||
void setPathImpl(const std::string& path);
|
||||
const std::string& getPathImpl() const;
|
||||
bool existsImpl() const;
|
||||
bool canReadImpl() const;
|
||||
bool canWriteImpl() const;
|
||||
bool canExecuteImpl() const;
|
||||
bool isFileImpl() const;
|
||||
bool isDirectoryImpl() const;
|
||||
bool isLinkImpl() const;
|
||||
bool isDeviceImpl() const;
|
||||
bool isHiddenImpl() const;
|
||||
Timestamp createdImpl() const;
|
||||
Timestamp getLastModifiedImpl() const;
|
||||
void setLastModifiedImpl(const Timestamp& ts);
|
||||
FileSizeImpl getSizeImpl() const;
|
||||
void setSizeImpl(FileSizeImpl size);
|
||||
void setWriteableImpl(bool flag = true);
|
||||
void setExecutableImpl(bool flag = true);
|
||||
void copyToImpl(const std::string& path, int options = 0) const;
|
||||
void renameToImpl(const std::string& path, int options = 0);
|
||||
void linkToImpl(const std::string& path, int type) const;
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
FileSizeImpl totalSpaceImpl() const;
|
||||
FileSizeImpl usableSpaceImpl() const;
|
||||
FileSizeImpl freeSpaceImpl() const;
|
||||
static void handleLastErrorImpl(const std::string& path);
|
||||
static void convertPath(const std::string& utf8Path, std::wstring& utf16Path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
std::wstring _upath;
|
||||
|
||||
friend class FileHandle;
|
||||
friend class DirectoryIteratorImpl;
|
||||
friend class FileStreamBuf;
|
||||
friend class LogFileImpl;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const std::string& FileImpl::getPathImpl() const
|
||||
{
|
||||
return _path;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_File_WINCE_INCLUDED
|
||||
+3
-2
@@ -63,6 +63,7 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
|
||||
/// * E signed floating-point value in the form [-]d.ddddE[<sign>]dd[d]
|
||||
/// * f signed floating-point value in the form [-]dddd.dddd
|
||||
/// * s std::string
|
||||
/// * v std::string_view
|
||||
/// * z std::size_t
|
||||
///
|
||||
/// The following flags are supported:
|
||||
@@ -115,14 +116,14 @@ inline void formatAny(std::string& result, const std::string& fmt, const std::ve
|
||||
/// Supports a variable number of arguments and is used by
|
||||
/// all other variants of format().
|
||||
{
|
||||
format(result, fmt, values);
|
||||
Poco::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);
|
||||
Poco::format(result, fmt, values);
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
|
||||
+17
-19
@@ -44,7 +44,7 @@
|
||||
// Foundation_API functions as being imported from a DLL, wheras this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if (defined(_WIN32) || defined(_WIN32_WCE)) && defined(POCO_DLL)
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
#if defined(Foundation_EXPORTS)
|
||||
#define Foundation_API __declspec(dllexport)
|
||||
#else
|
||||
@@ -91,6 +91,14 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Poco {
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
//
|
||||
// Include platform-specific definitions
|
||||
@@ -133,32 +141,22 @@
|
||||
#define POCO_DO_JOIN(X, Y) POCO_DO_JOIN2(X, Y)
|
||||
#define POCO_DO_JOIN2(X, Y) X##Y
|
||||
|
||||
//
|
||||
// MS Visual Studio can use type long for __LINE__ macro
|
||||
// when /ZI compilation flag is used - https://learn.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=msvc-170#zi-1
|
||||
// This breaks some poco interfaces, for ex. logger
|
||||
// We should fix type for line number
|
||||
namespace Poco {
|
||||
|
||||
//
|
||||
// POCO_DEPRECATED
|
||||
//
|
||||
// A macro expanding to a compiler-specific clause to
|
||||
// mark a class or function as deprecated.
|
||||
//
|
||||
#if defined(POCO_NO_DEPRECATED)
|
||||
#define POCO_DEPRECATED
|
||||
#elif defined(_GNUC_)
|
||||
#define POCO_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(__clang__)
|
||||
#define POCO_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define POCO_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define POCO_DEPRECATED
|
||||
#endif
|
||||
using LineNumber = decltype(__LINE__);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Pull in basic definitions
|
||||
//
|
||||
#include "Poco/Bugcheck.h"
|
||||
#include "Poco/Types.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
#endif // Foundation_Foundation_INCLUDED
|
||||
+2
-4
@@ -25,9 +25,8 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
//@ deprecated
|
||||
template <class T>
|
||||
struct HashFunction
|
||||
struct POCO_DEPRECATED("use Hash") HashFunction
|
||||
/// A generic hash function.
|
||||
{
|
||||
UInt32 operator () (T key, UInt32 maxValue) const
|
||||
@@ -38,9 +37,8 @@ struct HashFunction
|
||||
};
|
||||
|
||||
|
||||
//@ deprecated
|
||||
template <>
|
||||
struct HashFunction<std::string>
|
||||
struct POCO_DEPRECATED("use Hash") HashFunction<std::string>
|
||||
/// A generic hash function.
|
||||
{
|
||||
UInt32 operator () (const std::string& key, UInt32 maxValue) const
|
||||
|
||||
+13
-16
@@ -85,26 +85,23 @@ class HashMap
|
||||
/// A HashMap can be used just like a std::map.
|
||||
{
|
||||
public:
|
||||
typedef Key KeyType;
|
||||
typedef Mapped MappedType;
|
||||
typedef Mapped& Reference;
|
||||
typedef const Mapped& ConstReference;
|
||||
typedef Mapped* Pointer;
|
||||
typedef const Mapped* ConstPointer;
|
||||
using KeyType = Key;
|
||||
using MappedType = Mapped;
|
||||
using Reference = Mapped &;
|
||||
using ConstReference = const Mapped &;
|
||||
using Pointer = Mapped *;
|
||||
using ConstPointer = const Mapped *;
|
||||
|
||||
typedef HashMapEntry<Key, Mapped> ValueType;
|
||||
typedef std::pair<KeyType, MappedType> PairType;
|
||||
using ValueType = HashMapEntry<Key, Mapped>;
|
||||
using PairType = std::pair<KeyType, MappedType>;
|
||||
|
||||
typedef HashMapEntryHash<ValueType, HashFunc> HashType;
|
||||
typedef LinearHashTable<ValueType, HashType> HashTable;
|
||||
using HashType = HashMapEntryHash<ValueType, HashFunc>;
|
||||
using HashTable = LinearHashTable<ValueType, HashType>;
|
||||
|
||||
typedef typename HashTable::Iterator Iterator;
|
||||
typedef typename HashTable::ConstIterator ConstIterator;
|
||||
using Iterator = typename HashTable::Iterator;
|
||||
using ConstIterator = typename HashTable::ConstIterator;
|
||||
|
||||
HashMap()
|
||||
/// Creates an empty HashMap.
|
||||
{
|
||||
}
|
||||
HashMap() = default;
|
||||
|
||||
HashMap(std::size_t initialReserve):
|
||||
_table(initialReserve)
|
||||
|
||||
+1
-1
@@ -24,8 +24,8 @@
|
||||
|
||||
namespace Poco {
|
||||
|
||||
class POCO_DEPRECATED("") HashStatistic;
|
||||
|
||||
//@ deprecated
|
||||
class Foundation_API HashStatistic
|
||||
/// HashStatistic class bundles statistical information on the current state of a HashTable
|
||||
{
|
||||
|
||||
+1
-2
@@ -31,9 +31,8 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
//@ deprecated
|
||||
template <class Key, class Value, class KeyHashFunction = HashFunction<Key>>
|
||||
class HashTable
|
||||
class POCO_DEPRECATED("use LinearHashTable") HashTable
|
||||
/// A HashTable stores a key value pair that can be looked up via a hashed key.
|
||||
///
|
||||
/// Collision handling is done via overflow maps(!). With small hash tables performance of this
|
||||
|
||||
+8
-11
@@ -22,11 +22,8 @@
|
||||
#include "Poco/BufferedStreamBuf.h"
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#if defined(POCO_UNBUNDLED)
|
||||
#include <zlib.h>
|
||||
#else
|
||||
#include "Poco/zlib.h"
|
||||
#endif
|
||||
|
||||
struct z_stream_s;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -92,12 +89,12 @@ private:
|
||||
INFLATE_BUFFER_SIZE = 32768
|
||||
};
|
||||
|
||||
std::istream* _pIstr;
|
||||
std::ostream* _pOstr;
|
||||
char* _buffer;
|
||||
z_stream _zstr;
|
||||
bool _eof;
|
||||
bool _check;
|
||||
std::istream* _pIstr;
|
||||
std::ostream* _pOstr;
|
||||
char* _buffer;
|
||||
z_stream_s* _pZstr;
|
||||
bool _eof;
|
||||
bool _check;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// JSONFormatter.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
// Module: JSONFormatter
|
||||
//
|
||||
// Definition of the JSONFormatter class.
|
||||
//
|
||||
// Copyright (c) 2024, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_JSONFormatter_INCLUDED
|
||||
#define Foundation_JSONFormatter_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Formatter.h"
|
||||
#include "Poco/Message.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API JSONFormatter: public Formatter
|
||||
/// This formatter formats log messages as compact
|
||||
/// (no unnecessary whitespace) single-line JSON strings.
|
||||
///
|
||||
/// The following JSON schema is used:
|
||||
/// {
|
||||
/// "timestamp": "2024-09-26T13:41:23.324461Z",
|
||||
/// "source": "sample",
|
||||
/// "level": "information",
|
||||
/// "message": "This is a test message.",
|
||||
/// "thread": 12,
|
||||
/// "file": "source.cpp",
|
||||
/// "line": 456,
|
||||
/// "params": {
|
||||
/// "prop1": "value1"
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// The "file" and "line" properties will only be included if the log
|
||||
/// message contains a file name and line number.
|
||||
///
|
||||
/// The "params" object will only be included if custom parameters
|
||||
/// have been added to the Message.
|
||||
{
|
||||
public:
|
||||
using Ptr = AutoPtr<JSONFormatter>;
|
||||
|
||||
JSONFormatter() = default;
|
||||
/// Creates a JSONFormatter.
|
||||
|
||||
~JSONFormatter() = default;
|
||||
/// Destroys the JSONFormatter.
|
||||
|
||||
void format(const Message& msg, std::string& text);
|
||||
/// Formats the message as a JSON string.
|
||||
|
||||
void setProperty(const std::string& name, const std::string& value);
|
||||
/// Sets the property with the given name to the given value.
|
||||
///
|
||||
/// The following properties are supported:
|
||||
///
|
||||
/// * times: Specifies whether times are adjusted for local time
|
||||
/// or taken as they are in UTC. Supported values are "local" and "UTC".
|
||||
/// * thread: Specifies the value given for the thread. Can be
|
||||
/// "none" (excluded), "name" (thread name), "id" (POCO thread ID) or "osid"
|
||||
/// (operating system thread ID).
|
||||
///
|
||||
/// If any other property name is given, a PropertyNotSupported
|
||||
/// exception is thrown.
|
||||
|
||||
std::string getProperty(const std::string& name) const;
|
||||
/// Returns the value of the property with the given name or
|
||||
/// throws a PropertyNotSupported exception if the given
|
||||
/// name is not recognized.
|
||||
|
||||
static const std::string PROP_TIMES;
|
||||
static const std::string PROP_THREAD;
|
||||
|
||||
protected:
|
||||
std::string getThread(const Message& message) const;
|
||||
static const std::string& getPriorityName(int prio);
|
||||
|
||||
enum ThreadFormat
|
||||
{
|
||||
JSONF_THREAD_NONE = 0,
|
||||
JSONF_THREAD_NAME = 1,
|
||||
JSONF_THREAD_ID = 2,
|
||||
JSONF_THREAD_OS_ID = 3
|
||||
};
|
||||
|
||||
private:
|
||||
bool _localTime = false;
|
||||
ThreadFormat _threadFormat = JSONF_THREAD_ID;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_JSONFormatter_INCLUDED
|
||||
+7
-26
@@ -38,37 +38,18 @@ enum JSONOptions
|
||||
/// unicode characters will be escaped in the resulting
|
||||
/// string.
|
||||
|
||||
JSON_WRAP_STRINGS = 4
|
||||
JSON_WRAP_STRINGS = 4,
|
||||
/// If specified, the object will preserve the items
|
||||
/// insertion order. Otherwise, items will be sorted
|
||||
/// by keys.
|
||||
|
||||
JSON_LOWERCASE_HEX = 8
|
||||
/// If specified, all encoding happens with lowercase
|
||||
/// HEX characters instead of capitals
|
||||
};
|
||||
|
||||
|
||||
//@ deprecated
|
||||
void Foundation_API toJSON(const std::string& value, std::ostream& out, bool wrap = true);
|
||||
/// Formats string value into the supplied output stream by
|
||||
/// escaping control and ALL Unicode characters.
|
||||
/// If wrap is true, the resulting string is enclosed in double quotes.
|
||||
///
|
||||
/// This function is deprecated, please use
|
||||
///
|
||||
/// void Poco::toJSON(const std::string&, std::ostream&, int)
|
||||
|
||||
|
||||
//@ deprecated
|
||||
std::string Foundation_API toJSON(const std::string& value, bool wrap = true);
|
||||
/// Formats string value by escaping control and ALL Unicode characters.
|
||||
/// If wrap is true, the resulting string is enclosed in double quotes
|
||||
///
|
||||
/// Returns formatted string.
|
||||
///
|
||||
/// This function is deprecated, please use
|
||||
///
|
||||
/// std::string Poco::toJSON(const std::string&, int)
|
||||
|
||||
|
||||
void Foundation_API toJSON(const std::string& value, std::ostream& out, int options);
|
||||
void Foundation_API toJSON(const std::string& value, std::ostream& out, int options = Poco::JSON_WRAP_STRINGS);
|
||||
/// Formats string value into the supplied output stream by
|
||||
/// escaping control characters.
|
||||
/// If JSON_WRAP_STRINGS is in options, the resulting strings is enclosed in double quotes
|
||||
@@ -76,7 +57,7 @@ void Foundation_API toJSON(const std::string& value, std::ostream& out, int opti
|
||||
/// only the compulsory ones.
|
||||
|
||||
|
||||
std::string Foundation_API toJSON(const std::string& value, int options);
|
||||
std::string Foundation_API toJSON(const std::string& value, int options = Poco::JSON_WRAP_STRINGS);
|
||||
/// Formats string value by escaping control characters.
|
||||
/// If JSON_WRAP_STRINGS is in options, the resulting string is enclosed in double quotes
|
||||
/// If JSON_ESCAPE_UNICODE is in options, all unicode characters will be escaped, otherwise
|
||||
|
||||
+23
-26
@@ -20,10 +20,8 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Hash.h"
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
@@ -56,20 +54,26 @@ class LinearHashTable
|
||||
/// elements in a bucket should not exceed 3.
|
||||
{
|
||||
public:
|
||||
typedef Value ValueType;
|
||||
typedef Value& Reference;
|
||||
typedef const Value& ConstReference;
|
||||
typedef Value* Pointer;
|
||||
typedef const Value* ConstPointer;
|
||||
typedef HashFunc Hash;
|
||||
typedef std::vector<Value> Bucket;
|
||||
typedef std::vector<Bucket> BucketVec;
|
||||
typedef typename Bucket::iterator BucketIterator;
|
||||
typedef typename BucketVec::iterator BucketVecIterator;
|
||||
using ValueType = Value;
|
||||
using Reference = Value &;
|
||||
using ConstReference = const Value &;
|
||||
using Pointer = Value *;
|
||||
using ConstPointer = const Value *;
|
||||
using Hash = HashFunc;
|
||||
using Bucket = std::vector<Value>;
|
||||
using BucketVec = std::vector<Bucket>;
|
||||
using BucketIterator = typename Bucket::iterator;
|
||||
using BucketVecIterator = typename BucketVec::iterator;
|
||||
|
||||
class ConstIterator: public std::iterator<std::forward_iterator_tag, Value>
|
||||
class ConstIterator
|
||||
{
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using value_type = Value;
|
||||
using difference_type = ptrdiff_t;
|
||||
using pointer = Value*;
|
||||
using reference = Value&;
|
||||
|
||||
ConstIterator(): _initialized(false)
|
||||
{
|
||||
}
|
||||
@@ -171,9 +175,7 @@ public:
|
||||
class Iterator: public ConstIterator
|
||||
{
|
||||
public:
|
||||
Iterator()
|
||||
{
|
||||
}
|
||||
Iterator() = default;
|
||||
|
||||
Iterator(const BucketVecIterator& vecIt, const BucketVecIterator& endIt, const BucketIterator& buckIt):
|
||||
ConstIterator(vecIt, endIt, buckIt)
|
||||
@@ -233,10 +235,7 @@ public:
|
||||
friend class LinearHashTable;
|
||||
};
|
||||
|
||||
LinearHashTable(std::size_t initialReserve = 64):
|
||||
_split(0),
|
||||
_front(1),
|
||||
_size(0)
|
||||
LinearHashTable(std::size_t initialReserve = 64)
|
||||
/// Creates the LinearHashTable, using the given initialReserve.
|
||||
{
|
||||
_buckets.reserve(calcSize(initialReserve));
|
||||
@@ -252,10 +251,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~LinearHashTable()
|
||||
~LinearHashTable() = default;
|
||||
/// Destroys the LinearHashTable.
|
||||
{
|
||||
}
|
||||
|
||||
LinearHashTable& operator = (const LinearHashTable& table)
|
||||
/// Assigns another LinearHashTable.
|
||||
@@ -490,9 +487,9 @@ private:
|
||||
// Evil hack: _buckets must be mutable because both ConstIterator and Iterator hold
|
||||
// ordinary iterator's (not const_iterator's).
|
||||
mutable BucketVec _buckets;
|
||||
std::size_t _split;
|
||||
std::size_t _front;
|
||||
std::size_t _size;
|
||||
std::size_t _split{0};
|
||||
std::size_t _front{1};
|
||||
std::size_t _size{0};
|
||||
HashFunc _hash;
|
||||
};
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ public:
|
||||
/// * millisecond is from 0 to 999.
|
||||
/// * microsecond is from 0 to 999.
|
||||
|
||||
//@ deprecated
|
||||
LocalDateTime(int tzd, int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond);
|
||||
/// Creates a LocalDateTime for the given Gregorian date and time in the
|
||||
/// time zone denoted by the time zone differential in tzd.
|
||||
@@ -85,13 +84,11 @@ public:
|
||||
/// Creates a LocalDateTime from the UTC time given in dateTime,
|
||||
/// using the time zone differential of the current time zone.
|
||||
|
||||
//@ deprecated
|
||||
LocalDateTime(int tzd, const DateTime& dateTime);
|
||||
/// Creates a LocalDateTime from the UTC time given in dateTime,
|
||||
/// using the given time zone differential. Adjusts dateTime
|
||||
/// for the given time zone differential.
|
||||
|
||||
//@ deprecated
|
||||
LocalDateTime(int tzd, const DateTime& dateTime, bool adjust);
|
||||
/// Creates a LocalDateTime from the UTC time given in dateTime,
|
||||
/// using the given time zone differential. If adjust is true,
|
||||
@@ -100,7 +97,6 @@ public:
|
||||
LocalDateTime(double julianDay);
|
||||
/// Creates a LocalDateTime for the given Julian day in the local time zone.
|
||||
|
||||
//@ deprecated
|
||||
LocalDateTime(int tzd, double julianDay);
|
||||
/// Creates a LocalDateTime for the given Julian day in the time zone
|
||||
/// denoted by the time zone differential in tzd.
|
||||
@@ -131,7 +127,6 @@ public:
|
||||
/// * millisecond is from 0 to 999.
|
||||
/// * microsecond is from 0 to 999.
|
||||
|
||||
//@ deprecated
|
||||
LocalDateTime& assign(int tzd, int year, int month, int day, int hour, int minute, int second, int millisecond, int microseconds);
|
||||
/// Assigns a Gregorian local date and time in the time zone denoted by
|
||||
/// the time zone differential in tzd.
|
||||
@@ -145,7 +140,6 @@ public:
|
||||
/// * millisecond is from 0 to 999.
|
||||
/// * microsecond is from 0 to 999.
|
||||
|
||||
//@ deprecated
|
||||
LocalDateTime& assign(int tzd, double julianDay);
|
||||
/// Assigns a Julian day in the time zone denoted by the
|
||||
/// time zone differential in tzd.
|
||||
|
||||
+9
-37
@@ -17,21 +17,14 @@
|
||||
#ifndef Foundation_LogFile_INCLUDED
|
||||
#define Foundation_LogFile_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/LogFile_WIN32U.h"
|
||||
#else
|
||||
#include "Poco/LogFile_STD.h"
|
||||
#endif
|
||||
|
||||
#include "Poco/Timestamp.h"
|
||||
#include "Poco/FileStream.h"
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API LogFile: public LogFileImpl
|
||||
class Foundation_API LogFile
|
||||
/// This class is used by FileChannel to work
|
||||
/// with a log file.
|
||||
{
|
||||
@@ -55,36 +48,15 @@ public:
|
||||
|
||||
const std::string& path() const;
|
||||
/// Returns the path given in the constructor.
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
mutable Poco::FileOutputStream _str;
|
||||
Timestamp _creationDate;
|
||||
UInt64 _size;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline void LogFile::write(const std::string& text, bool flush)
|
||||
{
|
||||
writeImpl(text, flush);
|
||||
}
|
||||
|
||||
|
||||
inline UInt64 LogFile::size() const
|
||||
{
|
||||
return sizeImpl();
|
||||
}
|
||||
|
||||
|
||||
inline Timestamp LogFile::creationDate() const
|
||||
{
|
||||
return creationDateImpl();
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& LogFile::path() const
|
||||
{
|
||||
return pathImpl();
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
//
|
||||
// LogFile_STD.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
// Module: LogFile
|
||||
//
|
||||
// Definition of the LogFileImpl class using iostreams.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_LogFile_STD_INCLUDED
|
||||
#define Foundation_LogFile_STD_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#include "Poco/FileStream.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API LogFileImpl
|
||||
/// The implementation of LogFile for non-Windows platforms.
|
||||
/// The native filesystem APIs are used for
|
||||
/// total control over locking behavior.
|
||||
{
|
||||
public:
|
||||
LogFileImpl(const std::string& path);
|
||||
~LogFileImpl();
|
||||
void writeImpl(const std::string& text, bool flush);
|
||||
UInt64 sizeImpl() const;
|
||||
Timestamp creationDateImpl() const;
|
||||
const std::string& pathImpl() const;
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
mutable Poco::FileOutputStream _str;
|
||||
Timestamp _creationDate;
|
||||
UInt64 _size;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_LogFile_STD_INCLUDED
|
||||
@@ -1,54 +0,0 @@
|
||||
//
|
||||
// LogFile_WIN32U.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
// Module: LogFile
|
||||
//
|
||||
// Definition of the LogFileImpl class using the Windows file APIs.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_LogFile_WIN32U_INCLUDED
|
||||
#define Foundation_LogFile_WIN32U_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#include "Poco/UnWindows.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API LogFileImpl
|
||||
/// The implementation of LogFile for Windows.
|
||||
/// The native filesystem APIs are used for
|
||||
/// total control over locking behavior.
|
||||
{
|
||||
public:
|
||||
LogFileImpl(const std::string& path);
|
||||
~LogFileImpl();
|
||||
void writeImpl(const std::string& text, bool flush);
|
||||
UInt64 sizeImpl() const;
|
||||
Timestamp creationDateImpl() const;
|
||||
const std::string& pathImpl() const;
|
||||
|
||||
private:
|
||||
void createFile();
|
||||
|
||||
std::string _path;
|
||||
HANDLE _hFile;
|
||||
Timestamp _creationDate;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_LogFile_WIN32U_INCLUDED
|
||||
+30
-20
@@ -130,7 +130,7 @@ public:
|
||||
void log(const Exception& exc);
|
||||
/// Logs the given exception with priority PRIO_ERROR.
|
||||
|
||||
void log(const Exception& exc, const char* file, int line);
|
||||
void log(const Exception& exc, const char* file, LineNumber line);
|
||||
/// Logs the given exception with priority PRIO_ERROR.
|
||||
///
|
||||
/// File must be a static string, such as the value of
|
||||
@@ -142,8 +142,8 @@ public:
|
||||
/// creates a Message with priority PRIO_FATAL
|
||||
/// and the given message text and sends it
|
||||
/// to the attached channel.
|
||||
|
||||
void fatal(const std::string& msg, const char* file, int line);
|
||||
|
||||
void fatal(const std::string& msg, const char* file, LineNumber line);
|
||||
/// If the Logger's log level is at least PRIO_FATAL,
|
||||
/// creates a Message with priority PRIO_FATAL
|
||||
/// and the given message text and sends it
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
/// and the given message text and sends it
|
||||
/// to the attached channel.
|
||||
|
||||
void critical(const std::string& msg, const char* file, int line);
|
||||
void critical(const std::string& msg, const char* file, LineNumber line);
|
||||
/// If the Logger's log level is at least PRIO_CRITICAL,
|
||||
/// creates a Message with priority PRIO_CRITICAL
|
||||
/// and the given message text and sends it
|
||||
@@ -189,7 +189,7 @@ public:
|
||||
/// and the given message text and sends it
|
||||
/// to the attached channel.
|
||||
|
||||
void error(const std::string& msg, const char* file, int line);
|
||||
void error(const std::string& msg, const char* file, LineNumber line);
|
||||
/// If the Logger's log level is at least PRIO_ERROR,
|
||||
/// creates a Message with priority PRIO_ERROR
|
||||
/// and the given message text and sends it
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
/// and the given message text and sends it
|
||||
/// to the attached channel.
|
||||
|
||||
void warning(const std::string& msg, const char* file, int line);
|
||||
void warning(const std::string& msg, const char* file, LineNumber line);
|
||||
/// If the Logger's log level is at least PRIO_WARNING,
|
||||
/// creates a Message with priority PRIO_WARNING
|
||||
/// and the given message text and sends it
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
/// and the given message text and sends it
|
||||
/// to the attached channel.
|
||||
|
||||
void notice(const std::string& msg, const char* file, int line);
|
||||
void notice(const std::string& msg, const char* file, LineNumber line);
|
||||
/// If the Logger's log level is at least PRIO_NOTICE,
|
||||
/// creates a Message with priority PRIO_NOTICE
|
||||
/// and the given message text and sends it
|
||||
@@ -258,7 +258,7 @@ public:
|
||||
/// and the given message text and sends it
|
||||
/// to the attached channel.
|
||||
|
||||
void information(const std::string& msg, const char* file, int line);
|
||||
void information(const std::string& msg, const char* file, LineNumber line);
|
||||
/// If the Logger's log level is at least PRIO_INFORMATION,
|
||||
/// creates a Message with priority PRIO_INFORMATION
|
||||
/// and the given message text and sends it
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
/// and the given message text and sends it
|
||||
/// to the attached channel.
|
||||
|
||||
void debug(const std::string& msg, const char* file, int line);
|
||||
void debug(const std::string& msg, const char* file, LineNumber line);
|
||||
/// If the Logger's log level is at least PRIO_DEBUG,
|
||||
/// creates a Message with priority PRIO_DEBUG
|
||||
/// and the given message text and sends it
|
||||
@@ -304,7 +304,7 @@ public:
|
||||
/// and the given message text and sends it
|
||||
/// to the attached channel.
|
||||
|
||||
void trace(const std::string& msg, const char* file, int line);
|
||||
void trace(const std::string& msg, const char* file, LineNumber line);
|
||||
/// If the Logger's log level is at least PRIO_TRACE,
|
||||
/// creates a Message with priority PRIO_TRACE
|
||||
/// and the given message text and sends it
|
||||
@@ -462,7 +462,8 @@ protected:
|
||||
~Logger();
|
||||
|
||||
void log(const std::string& text, Message::Priority prio);
|
||||
void log(const std::string& text, Message::Priority prio, const char* file, int line);
|
||||
void logNPC(const std::string& text, Message::Priority prio);
|
||||
void log(const std::string& text, Message::Priority prio, const char* file, LineNumber line);
|
||||
|
||||
static std::string format(const std::string& fmt, int argc, std::string argv[]);
|
||||
static Logger& parent(const std::string& name);
|
||||
@@ -789,7 +790,16 @@ inline void Logger::log(const std::string& text, Message::Priority prio)
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::log(const std::string& text, Message::Priority prio, const char* file, int line)
|
||||
inline void Logger::logNPC(const std::string& text, Message::Priority prio)
|
||||
{
|
||||
if (_pChannel)
|
||||
{
|
||||
_pChannel->log(Message(_name, text, prio));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::log(const std::string& text, Message::Priority prio, const char* file, LineNumber line)
|
||||
{
|
||||
if (_level >= prio && _pChannel)
|
||||
{
|
||||
@@ -813,7 +823,7 @@ inline void Logger::fatal(const std::string& msg)
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::fatal(const std::string& msg, const char* file, int line)
|
||||
inline void Logger::fatal(const std::string& msg, const char* file, LineNumber line)
|
||||
{
|
||||
log(msg, Message::PRIO_FATAL, file, line);
|
||||
}
|
||||
@@ -826,7 +836,7 @@ inline void Logger::critical(const std::string& msg)
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::critical(const std::string& msg, const char* file, int line)
|
||||
inline void Logger::critical(const std::string& msg, const char* file, LineNumber line)
|
||||
{
|
||||
log(msg, Message::PRIO_CRITICAL, file, line);
|
||||
}
|
||||
@@ -838,7 +848,7 @@ inline void Logger::error(const std::string& msg)
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::error(const std::string& msg, const char* file, int line)
|
||||
inline void Logger::error(const std::string& msg, const char* file, LineNumber line)
|
||||
{
|
||||
log(msg, Message::PRIO_ERROR, file, line);
|
||||
}
|
||||
@@ -850,7 +860,7 @@ inline void Logger::warning(const std::string& msg)
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::warning(const std::string& msg, const char* file, int line)
|
||||
inline void Logger::warning(const std::string& msg, const char* file, LineNumber line)
|
||||
{
|
||||
log(msg, Message::PRIO_WARNING, file, line);
|
||||
}
|
||||
@@ -862,7 +872,7 @@ inline void Logger::notice(const std::string& msg)
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::notice(const std::string& msg, const char* file, int line)
|
||||
inline void Logger::notice(const std::string& msg, const char* file, LineNumber line)
|
||||
{
|
||||
log(msg, Message::PRIO_NOTICE, file, line);
|
||||
}
|
||||
@@ -874,7 +884,7 @@ inline void Logger::information(const std::string& msg)
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::information(const std::string& msg, const char* file, int line)
|
||||
inline void Logger::information(const std::string& msg, const char* file, LineNumber line)
|
||||
{
|
||||
log(msg, Message::PRIO_INFORMATION, file, line);
|
||||
}
|
||||
@@ -886,7 +896,7 @@ inline void Logger::debug(const std::string& msg)
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::debug(const std::string& msg, const char* file, int line)
|
||||
inline void Logger::debug(const std::string& msg, const char* file, LineNumber line)
|
||||
{
|
||||
log(msg, Message::PRIO_DEBUG, file, line);
|
||||
}
|
||||
@@ -898,7 +908,7 @@ inline void Logger::trace(const std::string& msg)
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::trace(const std::string& msg, const char* file, int line)
|
||||
inline void Logger::trace(const std::string& msg, const char* file, LineNumber line)
|
||||
{
|
||||
log(msg, Message::PRIO_TRACE, file, line);
|
||||
}
|
||||
|
||||
@@ -229,6 +229,7 @@ private:
|
||||
_memory.next = next;
|
||||
}
|
||||
|
||||
#ifndef POCO_DOC
|
||||
union
|
||||
/// Memory block storage.
|
||||
///
|
||||
@@ -242,6 +243,7 @@ private:
|
||||
char buffer[sizeof(T)];
|
||||
Block* next;
|
||||
} _memory;
|
||||
#endif
|
||||
|
||||
private:
|
||||
Block(const Block&);
|
||||
|
||||
@@ -140,6 +140,12 @@ public:
|
||||
|
||||
return newoff;
|
||||
}
|
||||
|
||||
virtual pos_type seekpos(pos_type pos, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
|
||||
{
|
||||
const off_type off = pos;
|
||||
return seekoff(off, std::ios::beg, which);
|
||||
}
|
||||
|
||||
virtual int sync()
|
||||
{
|
||||
|
||||
+6
-6
@@ -43,7 +43,7 @@ class Foundation_API Message
|
||||
/// caused the message.
|
||||
{
|
||||
public:
|
||||
typedef std::map<std::string, std::string> StringMap;
|
||||
using StringMap = std::map<std::string, std::string>;
|
||||
|
||||
enum Priority
|
||||
{
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
/// Creates a Message with the given source, text and priority.
|
||||
/// The thread and process ids are set.
|
||||
|
||||
Message(const std::string& source, const std::string& text, Priority prio, const char* file, int line);
|
||||
Message(const std::string& source, const std::string& text, Priority prio, const char* file, LineNumber line);
|
||||
/// Creates a Message with the given source, text, priority,
|
||||
/// source file path and line.
|
||||
///
|
||||
@@ -155,14 +155,14 @@ public:
|
||||
/// Returns the source file path of the code creating
|
||||
/// the message. May be 0 if not set.
|
||||
|
||||
void setSourceLine(int line);
|
||||
void setSourceLine(LineNumber line);
|
||||
/// Sets the source file line of the statement
|
||||
/// generating the log message.
|
||||
///
|
||||
/// This is usually the result of the __LINE__
|
||||
/// macro.
|
||||
|
||||
int getSourceLine() const;
|
||||
LineNumber getSourceLine() const;
|
||||
/// Returns the source file line of the statement
|
||||
/// generating the log message. May be 0
|
||||
/// if not set.
|
||||
@@ -211,7 +211,7 @@ private:
|
||||
std::string _thread;
|
||||
long _pid;
|
||||
const char* _file;
|
||||
int _line;
|
||||
LineNumber _line;
|
||||
StringMap* _pMap;
|
||||
};
|
||||
|
||||
@@ -271,7 +271,7 @@ inline const char* Message::getSourceFile() const
|
||||
}
|
||||
|
||||
|
||||
inline int Message::getSourceLine() const
|
||||
inline LineNumber Message::getSourceLine() const
|
||||
{
|
||||
return _line;
|
||||
}
|
||||
|
||||
+11
-7
@@ -24,18 +24,17 @@
|
||||
#include "Poco/Timestamp.h"
|
||||
#include <atomic>
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "Poco/Mutex_WINCE.h"
|
||||
#ifdef POCO_ENABLE_STD_MUTEX
|
||||
#include "Poco/Mutex_STD.h"
|
||||
#else
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/Mutex_WIN32.h"
|
||||
#endif
|
||||
#elif defined(POCO_VXWORKS)
|
||||
#include "Poco/Mutex_VX.h"
|
||||
#else
|
||||
#include "Poco/Mutex_POSIX.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -53,6 +52,7 @@ class Foundation_API Mutex: private MutexImpl
|
||||
{
|
||||
public:
|
||||
using ScopedLock = Poco::ScopedLock<Mutex>;
|
||||
using ScopedLockWithUnlock = Poco::ScopedLockWithUnlock<Mutex>;
|
||||
|
||||
Mutex();
|
||||
/// creates the Mutex.
|
||||
@@ -108,6 +108,7 @@ class Foundation_API FastMutex: private FastMutexImpl
|
||||
{
|
||||
public:
|
||||
using ScopedLock = Poco::ScopedLock<FastMutex>;
|
||||
using ScopedLockWithUnlock = Poco::ScopedLockWithUnlock<FastMutex>;
|
||||
|
||||
FastMutex();
|
||||
/// creates the Mutex.
|
||||
@@ -158,13 +159,15 @@ class Foundation_API SpinlockMutex
|
||||
///
|
||||
/// While in some cases (eg. locking small blocks of code)
|
||||
/// busy-waiting may be an optimal solution, in many scenarios
|
||||
/// spinlock may not be the right choice - it is up to the user to
|
||||
/// choose the proper mutex type for their particular case.
|
||||
/// spinlock may not be the right choice (especially on single-core
|
||||
/// systems) - it is up to the user to choose the proper mutex type
|
||||
/// for their particular case.
|
||||
///
|
||||
/// Works with the ScopedLock class.
|
||||
{
|
||||
public:
|
||||
using ScopedLock = Poco::ScopedLock<SpinlockMutex>;
|
||||
using ScopedLockWithUnlock = Poco::ScopedLockWithUnlock<SpinlockMutex>;
|
||||
|
||||
SpinlockMutex();
|
||||
/// Creates the SpinlockMutex.
|
||||
@@ -209,6 +212,7 @@ class Foundation_API NullMutex
|
||||
{
|
||||
public:
|
||||
using ScopedLock = Poco::ScopedLock<NullMutex>;
|
||||
using ScopedLockWithUnlock = Poco::ScopedLockWithUnlock<NullMutex>;
|
||||
|
||||
NullMutex()
|
||||
/// Creates the NullMutex.
|
||||
|
||||
+8
-6
@@ -20,8 +20,8 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Error.h"
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -56,8 +56,9 @@ protected:
|
||||
//
|
||||
inline void MutexImpl::lockImpl()
|
||||
{
|
||||
if (pthread_mutex_lock(&_mutex))
|
||||
throw SystemException("cannot lock mutex");
|
||||
int rc;
|
||||
if ((rc = pthread_mutex_lock(&_mutex)))
|
||||
throw SystemException("cannot lock mutex", Error::getMessage(rc));
|
||||
}
|
||||
|
||||
|
||||
@@ -69,14 +70,15 @@ inline bool MutexImpl::tryLockImpl()
|
||||
else if (rc == EBUSY)
|
||||
return false;
|
||||
else
|
||||
throw SystemException("cannot lock mutex");
|
||||
throw SystemException("cannot lock mutex", Error::getMessage(rc));
|
||||
}
|
||||
|
||||
|
||||
inline void MutexImpl::unlockImpl()
|
||||
{
|
||||
if (pthread_mutex_unlock(&_mutex))
|
||||
throw SystemException("cannot unlock mutex");
|
||||
int rc;
|
||||
if ((rc = pthread_mutex_unlock(&_mutex)))
|
||||
throw SystemException("cannot unlock mutex", Error::getMessage(rc));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// Mutex_STD.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
// Module: Mutex
|
||||
//
|
||||
// Definition of the MutexImpl and FastMutexImpl classes based on Standard library mutex and recursive mutes.
|
||||
//
|
||||
// Copyright (c) 2004-2023, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Mutex_STD_INCLUDED
|
||||
#define Foundation_Mutex_STD_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <mutex>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API MutexImpl
|
||||
{
|
||||
protected:
|
||||
MutexImpl();
|
||||
~MutexImpl();
|
||||
void lockImpl();
|
||||
bool tryLockImpl();
|
||||
bool tryLockImpl(long milliseconds);
|
||||
void unlockImpl();
|
||||
|
||||
private:
|
||||
std::recursive_mutex _mutex;
|
||||
};
|
||||
|
||||
|
||||
class Foundation_API FastMutexImpl
|
||||
{
|
||||
protected:
|
||||
FastMutexImpl();
|
||||
~FastMutexImpl();
|
||||
void lockImpl();
|
||||
bool tryLockImpl();
|
||||
bool tryLockImpl(long milliseconds);
|
||||
void unlockImpl();
|
||||
private:
|
||||
std::mutex _mutex;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline void MutexImpl::lockImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
_mutex.lock();
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
throw SystemException("cannot lock mutex", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool MutexImpl::tryLockImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _mutex.try_lock();
|
||||
}
|
||||
catch (std::exception &ex)
|
||||
{
|
||||
throw SystemException("cannot lock mutex", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void MutexImpl::unlockImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
_mutex.unlock();
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
throw SystemException("cannot unlock mutex");
|
||||
}
|
||||
}
|
||||
|
||||
inline void FastMutexImpl::lockImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
_mutex.lock();
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
throw SystemException("cannot lock mutex", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool FastMutexImpl::tryLockImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _mutex.try_lock();
|
||||
}
|
||||
catch (std::exception &ex)
|
||||
{
|
||||
throw SystemException("cannot lock mutex", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void FastMutexImpl::unlockImpl()
|
||||
{
|
||||
try
|
||||
{
|
||||
_mutex.unlock();
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
throw SystemException("cannot unlock mutex");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
#endif //Foundation_Mutex_STD_INCLUDED
|
||||
+3
-2
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Error.h"
|
||||
#include "Poco/UnWindows.h"
|
||||
|
||||
|
||||
@@ -55,7 +56,7 @@ inline void MutexImpl::lockImpl()
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw SystemException("cannot lock mutex");
|
||||
throw SystemException("cannot lock mutex", Error::getLastMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +70,7 @@ inline bool MutexImpl::tryLockImpl()
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
throw SystemException("cannot lock mutex");
|
||||
throw SystemException("cannot lock mutex", Error::getLastMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
//
|
||||
// Mutex_WIN32.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
// Module: Mutex
|
||||
//
|
||||
// Definition of the MutexImpl and FastMutexImpl classes for WIN32.
|
||||
//
|
||||
// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Mutex_WINCE_INCLUDED
|
||||
#define Foundation_Mutex_WINCE_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/UnWindows.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API MutexImpl
|
||||
{
|
||||
protected:
|
||||
MutexImpl();
|
||||
~MutexImpl();
|
||||
void lockImpl();
|
||||
bool tryLockImpl();
|
||||
bool tryLockImpl(long milliseconds);
|
||||
void unlockImpl();
|
||||
|
||||
private:
|
||||
HANDLE _mutex;
|
||||
};
|
||||
|
||||
|
||||
typedef MutexImpl FastMutexImpl;
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Mutex_WINCE_INCLUDED
|
||||
+65
-33
@@ -3,7 +3,7 @@
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Notifications
|
||||
// Module: NotificationCenter
|
||||
// Module: NObserver
|
||||
//
|
||||
// Definition of the NObserver class template.
|
||||
//
|
||||
@@ -37,25 +37,39 @@ class NObserver: public AbstractObserver
|
||||
/// to use this template class.
|
||||
///
|
||||
/// This class template is quite similar to the Observer class
|
||||
/// template. The only difference is that the NObserver
|
||||
/// expects the callback function to accept a const AutoPtr&
|
||||
/// instead of a plain pointer as argument, thus simplifying memory
|
||||
/// management.
|
||||
/// template. The differences are:
|
||||
///
|
||||
/// - NObserver expects the callback function to accept a const AutoPtr&
|
||||
/// instead of a plain pointer as argument, thus simplifying memory
|
||||
/// management.
|
||||
///
|
||||
/// - In addition to dispatching notifications based on the Notification runtime
|
||||
/// type, NObserver can also notify subscribers based on the Notification name.
|
||||
/// To enable this functionality, a matcher function must be provided.
|
||||
/// Null matcher means no matching is performed and all notificiations
|
||||
/// of the type subscribed to are dispatched.
|
||||
{
|
||||
public:
|
||||
typedef AutoPtr<N> NotificationPtr;
|
||||
typedef void (C::*Callback)(const NotificationPtr&);
|
||||
using Type = NObserver<C, N>;
|
||||
using NotificationPtr = AutoPtr<N>;
|
||||
using Callback = void (C::*)(const NotificationPtr&);
|
||||
using Handler = Callback;
|
||||
using Matcher = bool (C::*)(const std::string&) const;
|
||||
|
||||
NObserver(C& object, Callback method):
|
||||
NObserver() = delete;
|
||||
|
||||
NObserver(C& object, Handler method, Matcher matcher = nullptr):
|
||||
_pObject(&object),
|
||||
_method(method)
|
||||
_handler(method),
|
||||
_matcher(matcher)
|
||||
{
|
||||
}
|
||||
|
||||
NObserver(const NObserver& observer):
|
||||
AbstractObserver(observer),
|
||||
_pObject(observer._pObject),
|
||||
_method(observer._method)
|
||||
_handler(observer._handler),
|
||||
_matcher(observer._matcher)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -68,54 +82,72 @@ public:
|
||||
if (&observer != this)
|
||||
{
|
||||
_pObject = observer._pObject;
|
||||
_method = observer._method;
|
||||
_handler = observer._handler;
|
||||
_matcher = observer._matcher;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void notify(Notification* pNf) const
|
||||
virtual void notify(Notification* pNf) const
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_pObject)
|
||||
{
|
||||
N* pCastNf = dynamic_cast<N*>(pNf);
|
||||
if (pCastNf)
|
||||
{
|
||||
NotificationPtr ptr(pCastNf, true);
|
||||
(_pObject->*_method)(ptr);
|
||||
}
|
||||
}
|
||||
handle(NotificationPtr(static_cast<N*>(pNf), true));
|
||||
}
|
||||
|
||||
bool equals(const AbstractObserver& abstractObserver) const
|
||||
virtual bool equals(const AbstractObserver& abstractObserver) const
|
||||
{
|
||||
const NObserver* pObs = dynamic_cast<const NObserver*>(&abstractObserver);
|
||||
return pObs && pObs->_pObject == _pObject && pObs->_method == _method;
|
||||
return pObs && pObs->_pObject == _pObject && pObs->_handler == _handler && pObs->_matcher == _matcher;
|
||||
}
|
||||
|
||||
bool accepts(Notification* pNf, const char* pName = 0) const
|
||||
POCO_DEPRECATED("use `bool accepts(const Notification::Ptr&)` instead")
|
||||
virtual bool accepts(Notification* pNf, const char* pName) const
|
||||
{
|
||||
return dynamic_cast<N*>(pNf) && (!pName || pNf->name() == pName);
|
||||
return (!pName || pNf->name() == pName) && dynamic_cast<N*>(pNf) != nullptr;
|
||||
}
|
||||
|
||||
AbstractObserver* clone() const
|
||||
virtual bool accepts(const Notification::Ptr& pNf) const
|
||||
{
|
||||
return (match(pNf) && (pNf.template cast<N>() != nullptr));
|
||||
}
|
||||
|
||||
virtual AbstractObserver* clone() const
|
||||
{
|
||||
return new NObserver(*this);
|
||||
}
|
||||
|
||||
void disable()
|
||||
virtual void disable()
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
_pObject = 0;
|
||||
_pObject = nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void handle(const NotificationPtr& ptr) const
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_pObject)
|
||||
(_pObject->*_handler)(ptr);
|
||||
}
|
||||
|
||||
bool match(const Notification::Ptr& ptr) const
|
||||
{
|
||||
Mutex::ScopedLock l(_mutex);
|
||||
|
||||
return _pObject && (!_matcher || (_pObject->*_matcher)(ptr->name()));
|
||||
}
|
||||
|
||||
Mutex& mutex() const
|
||||
{
|
||||
return _mutex;
|
||||
}
|
||||
|
||||
private:
|
||||
NObserver();
|
||||
|
||||
C* _pObject;
|
||||
Callback _method;
|
||||
Callback _handler;
|
||||
Matcher _matcher;
|
||||
mutable Poco::Mutex _mutex;
|
||||
};
|
||||
|
||||
|
||||
+14
-4
@@ -17,12 +17,21 @@
|
||||
#ifndef Foundation_NamedEvent_UNIX_INCLUDED
|
||||
#define Foundation_NamedEvent_UNIX_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
#include <Poco/Platform.h>
|
||||
|
||||
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
|
||||
#include <semaphore.h>
|
||||
#define POCO_NAMED_EVENT_USE_POSIX_SEMAPHORES 1
|
||||
#define POCO_NAMED_EVENT_USE_SYS_V_SEMAPHORES 0
|
||||
#else
|
||||
#define POCO_NAMED_EVENT_USE_POSIX_SEMAPHORES 0
|
||||
#define POCO_NAMED_EVENT_USE_SYS_V_SEMAPHORES 1
|
||||
#endif
|
||||
|
||||
#if POCO_NAMED_EVENT_USE_POSIX_SEMAPHORES
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
namespace Poco {
|
||||
|
||||
@@ -39,10 +48,11 @@ private:
|
||||
std::string getFileName();
|
||||
|
||||
std::string _name;
|
||||
#if defined(sun) || defined(__APPLE__) || defined(__osf__) || defined(__QNX__) || defined(_AIX) || defined(__GNU__)
|
||||
sem_t* _sem;
|
||||
#if POCO_NAMED_EVENT_USE_POSIX_SEMAPHORES
|
||||
::sem_t* _sem;
|
||||
#else
|
||||
int _semid; // semaphore id
|
||||
bool _createdId; // semaphore id was created with this instance
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ class Foundation_API NamedMutex: private NamedMutexImpl
|
||||
{
|
||||
public:
|
||||
using ScopedLock = Poco::ScopedLock<NamedMutex>;
|
||||
using ScopedLockWithUnlock = Poco::ScopedLockWithUnlock<NamedMutex>;
|
||||
|
||||
NamedMutex(const std::string& name);
|
||||
/// creates the Mutex.
|
||||
|
||||
+82
-82
@@ -21,7 +21,7 @@
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Tuple.h"
|
||||
#include "Poco/TypeList.h"
|
||||
#include "Poco/DynamicAny.h"
|
||||
#include "Poco/Dynamic/Var.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
#include "Poco/Format.h"
|
||||
|
||||
@@ -265,12 +265,12 @@ struct NamedTuple: public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T1
|
||||
const std::string& n39 = "N1",
|
||||
typename TypeWrapper<T39>::CONSTTYPE& t39 = POCO_TYPEWRAPPER_DEFAULTVALUE(T39)):
|
||||
TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39),
|
||||
_pNames(0)
|
||||
_pNames(nullptr)
|
||||
{
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36,n37,n38,n39);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -329,7 +329,7 @@ struct NamedTuple: public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T1
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -722,7 +722,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36,n37,n38);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -780,7 +780,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -1166,7 +1166,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36,n37);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -1223,7 +1223,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -1602,7 +1602,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -1658,7 +1658,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -2030,7 +2030,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -2085,7 +2085,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -2450,7 +2450,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -2504,7 +2504,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -2862,7 +2862,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -2915,7 +2915,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -3266,7 +3266,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -3318,7 +3318,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -3662,7 +3662,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -3713,7 +3713,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -4050,7 +4050,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -4100,7 +4100,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -4430,7 +4430,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -4479,7 +4479,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -4802,7 +4802,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -4850,7 +4850,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -5166,7 +5166,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -5213,7 +5213,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -5522,7 +5522,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -5568,7 +5568,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -5870,7 +5870,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -5915,7 +5915,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -6210,7 +6210,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -6254,7 +6254,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -6542,7 +6542,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -6585,7 +6585,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -6866,7 +6866,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -6908,7 +6908,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -7182,7 +7182,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -7223,7 +7223,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -7490,7 +7490,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -7530,7 +7530,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -7790,7 +7790,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -7829,7 +7829,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -8082,7 +8082,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -8120,7 +8120,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -8366,7 +8366,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -8403,7 +8403,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -8642,7 +8642,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,Null
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -8678,7 +8678,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,Null
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -8911,7 +8911,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,NullType
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -8946,7 +8946,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,NullType
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -9172,7 +9172,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,NullTypeList
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -9206,7 +9206,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,NullTypeList
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -9425,7 +9425,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -9458,7 +9458,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -9669,7 +9669,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -9701,7 +9701,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -9906,7 +9906,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -9937,7 +9937,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -10134,7 +10134,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -10164,7 +10164,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -10355,7 +10355,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -10384,7 +10384,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -10568,7 +10568,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7,n8);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -10596,7 +10596,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -10773,7 +10773,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4,n5,n6,n7);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -10800,7 +10800,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -10968,7 +10968,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4,n5,n6);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -10994,7 +10994,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -11155,7 +11155,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4,n5);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -11180,7 +11180,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,T5,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -11336,7 +11336,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,NullTypeList>:
|
||||
init(n0,n1,n2,n3,n4);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -11360,7 +11360,7 @@ struct NamedTuple<T0,T1,T2,T3,T4,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -11508,7 +11508,7 @@ struct NamedTuple<T0,T1,T2,T3,NullTypeList>:
|
||||
init(n0,n1,n2,n3);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -11531,7 +11531,7 @@ struct NamedTuple<T0,T1,T2,T3,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -11673,7 +11673,7 @@ struct NamedTuple<T0,T1,T2,NullTypeList>:
|
||||
init(n0,n1,n2);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -11695,7 +11695,7 @@ struct NamedTuple<T0,T1,T2,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -11830,7 +11830,7 @@ struct NamedTuple<T0,T1,NullTypeList>:
|
||||
init(n0,n1);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -11851,7 +11851,7 @@ struct NamedTuple<T0,T1,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
@@ -11978,7 +11978,7 @@ struct NamedTuple<T0,NullTypeList>:
|
||||
init(n0);
|
||||
}
|
||||
|
||||
const DynamicAny get(const std::string& name) const
|
||||
const Dynamic::Var get(const std::string& name) const
|
||||
{
|
||||
NameVec::const_iterator it = _pNames->begin();
|
||||
NameVec::const_iterator itEnd = _pNames->end();
|
||||
@@ -11998,7 +11998,7 @@ struct NamedTuple<T0,NullTypeList>:
|
||||
throw NotFoundException("Name not found: " + name);
|
||||
}
|
||||
|
||||
const DynamicAny operator [] (const std::string& name) const
|
||||
const Dynamic::Var operator [] (const std::string& name) const
|
||||
{
|
||||
return get(name);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
void push(const std::string& info);
|
||||
/// Pushes a context (without line number and filename) onto the stack.
|
||||
|
||||
void push(const std::string& info, int line, const char* filename);
|
||||
void push(const std::string& info, LineNumber line, const char* filename);
|
||||
/// Pushes a context (including line number and filename)
|
||||
/// onto the stack. Filename must be a static string, such as the
|
||||
/// one produced by the __FILE__ preprocessor macro.
|
||||
@@ -89,9 +89,11 @@ public:
|
||||
/// to the given stream. The entries are delimited by
|
||||
/// a newline.
|
||||
|
||||
void dump(std::ostream& ostr, const std::string& delimiter) const;
|
||||
void dump(std::ostream& ostr, const std::string& delimiter, bool nameOnly = false) const;
|
||||
/// Dumps the stack (including line number and filenames)
|
||||
/// to the given stream.
|
||||
/// If nameOnly is false (default), the whole path to file is printed,
|
||||
/// otherwise only the file name.
|
||||
|
||||
void clear();
|
||||
/// Clears the NDC stack.
|
||||
@@ -104,7 +106,7 @@ private:
|
||||
{
|
||||
std::string info;
|
||||
const char* file;
|
||||
int line;
|
||||
LineNumber line;
|
||||
};
|
||||
typedef std::vector<Context> Stack;
|
||||
|
||||
@@ -124,7 +126,7 @@ public:
|
||||
NDCScope(const std::string& info);
|
||||
/// Pushes a context on the stack.
|
||||
|
||||
NDCScope(const std::string& info, int line, const char* filename);
|
||||
NDCScope(const std::string& info, LineNumber line, const char* filename);
|
||||
/// Pushes a context on the stack.
|
||||
|
||||
~NDCScope();
|
||||
@@ -141,7 +143,7 @@ inline NDCScope::NDCScope(const std::string& info)
|
||||
}
|
||||
|
||||
|
||||
inline NDCScope::NDCScope(const std::string& info, int line, const char* filename)
|
||||
inline NDCScope::NDCScope(const std::string& info, LineNumber line, const char* filename)
|
||||
{
|
||||
NestedDiagnosticContext::current().push(info, line, filename);
|
||||
}
|
||||
|
||||
+3
-1
@@ -22,6 +22,7 @@
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -37,7 +38,7 @@ class Foundation_API Notification: public RefCountedObject
|
||||
public:
|
||||
using Ptr = AutoPtr<Notification>;
|
||||
|
||||
Notification();
|
||||
Notification(const std::string& name = ""s);
|
||||
/// Creates the notification.
|
||||
|
||||
virtual std::string name() const;
|
||||
@@ -46,6 +47,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual ~Notification();
|
||||
std::unique_ptr<std::string> _pName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+21
-4
@@ -79,10 +79,11 @@ class Foundation_API NotificationCenter
|
||||
/// }
|
||||
{
|
||||
public:
|
||||
|
||||
NotificationCenter();
|
||||
/// Creates the NotificationCenter.
|
||||
|
||||
~NotificationCenter();
|
||||
virtual ~NotificationCenter();
|
||||
/// Destroys the NotificationCenter.
|
||||
|
||||
void addObserver(const AbstractObserver& observer);
|
||||
@@ -99,7 +100,7 @@ public:
|
||||
bool hasObserver(const AbstractObserver& observer) const;
|
||||
/// Returns true if the observer is registered with this NotificationCenter.
|
||||
|
||||
void postNotification(Notification::Ptr pNotification);
|
||||
virtual void postNotification(Notification::Ptr pNotification);
|
||||
/// Posts a notification to the NotificationCenter.
|
||||
/// The NotificationCenter then delivers the notification
|
||||
/// to all interested observers.
|
||||
@@ -120,13 +121,29 @@ public:
|
||||
std::size_t countObservers() const;
|
||||
/// Returns the number of registered observers.
|
||||
|
||||
virtual int backlog() const;
|
||||
/// Returns the sum of queued notifications
|
||||
/// for all observers (applies only to asynchronous observers,
|
||||
/// regular observers post notifications syncronously and
|
||||
/// never have a backlog).
|
||||
|
||||
static NotificationCenter& defaultCenter();
|
||||
/// Returns a reference to the default
|
||||
/// NotificationCenter.
|
||||
|
||||
protected:
|
||||
using AbstractObserverPtr = SharedPtr<AbstractObserver>;
|
||||
using ObserverList = std::vector<AbstractObserverPtr>;
|
||||
|
||||
Mutex& mutex()
|
||||
{
|
||||
return _mutex;
|
||||
}
|
||||
|
||||
ObserverList observersToNotify(const Notification::Ptr& pNotification) const;
|
||||
void notifyObservers(Notification::Ptr& pNotification);
|
||||
|
||||
private:
|
||||
typedef SharedPtr<AbstractObserver> AbstractObserverPtr;
|
||||
typedef std::vector<AbstractObserverPtr> ObserverList;
|
||||
|
||||
ObserverList _observers;
|
||||
mutable Mutex _mutex;
|
||||
|
||||
+41
-70
@@ -20,18 +20,13 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
enum NullType
|
||||
{
|
||||
NULL_GENERIC = 0
|
||||
};
|
||||
|
||||
using NullType = std::nullopt_t;
|
||||
|
||||
template <typename C>
|
||||
class Nullable
|
||||
@@ -58,88 +53,72 @@ class Nullable
|
||||
/// default construction.
|
||||
{
|
||||
public:
|
||||
Nullable():
|
||||
using Type = C;
|
||||
|
||||
Nullable()
|
||||
/// Creates an empty Nullable.
|
||||
_value(),
|
||||
_isNull(true),
|
||||
_null()
|
||||
{
|
||||
}
|
||||
|
||||
Nullable(const NullType&):
|
||||
Nullable(const NullType&)
|
||||
/// Creates an empty Nullable.
|
||||
_value(),
|
||||
_isNull(true),
|
||||
_null()
|
||||
{
|
||||
}
|
||||
|
||||
Nullable(const C& value):
|
||||
/// Creates a Nullable with the given value.
|
||||
_value(value),
|
||||
_isNull(false),
|
||||
_null()
|
||||
_optional(value)
|
||||
{
|
||||
}
|
||||
|
||||
Nullable(C&& value):
|
||||
/// Creates a Nullable by moving the given value.
|
||||
_value(std::forward<C>(value)),
|
||||
_isNull(false),
|
||||
_null()
|
||||
_optional(std::forward<C>(value))
|
||||
{
|
||||
}
|
||||
|
||||
Nullable(const Nullable& other):
|
||||
/// Creates a Nullable by copying another one.
|
||||
_value(other._value),
|
||||
_isNull(other._isNull),
|
||||
_null()
|
||||
_optional(other._optional)
|
||||
{
|
||||
}
|
||||
|
||||
Nullable(Nullable&& other) noexcept:
|
||||
/// Creates a Nullable by moving another one.
|
||||
_value(std::move(other._value)),
|
||||
_isNull(other._isNull),
|
||||
_null()
|
||||
_optional(std::move(other._optional))
|
||||
{
|
||||
other._isNull = true;
|
||||
other._optional.reset();
|
||||
}
|
||||
|
||||
~Nullable()
|
||||
~Nullable() = default;
|
||||
/// Destroys the Nullable.
|
||||
{
|
||||
}
|
||||
|
||||
Nullable& assign(const C& value)
|
||||
/// Assigns a value to the Nullable.
|
||||
{
|
||||
_value = value;
|
||||
_isNull = false;
|
||||
_optional.emplace(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Nullable& assign(C&& value)
|
||||
/// Assigns a value to the Nullable.
|
||||
{
|
||||
_value = std::move(value);
|
||||
_isNull = false;
|
||||
_optional.emplace(std::move(value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
Nullable& assign(const Nullable& other)
|
||||
/// Assigns another Nullable.
|
||||
{
|
||||
Nullable tmp(other);
|
||||
swap(tmp);
|
||||
if (&other != this)
|
||||
_optional = other._optional;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Nullable& assign(NullType)
|
||||
/// Sets value to null.
|
||||
{
|
||||
_isNull = true;
|
||||
_optional.reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -164,42 +143,39 @@ public:
|
||||
Nullable& operator = (Nullable&& other) noexcept
|
||||
/// Moves another Nullable.
|
||||
{
|
||||
_isNull = other._isNull;
|
||||
_value = std::move(other._value);
|
||||
other._isNull = true;
|
||||
_optional = std::move(other._optional);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Nullable& operator = (NullType)
|
||||
/// Assigns another Nullable.
|
||||
/// Assigns NullType.
|
||||
{
|
||||
_isNull = true;
|
||||
_optional.reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(Nullable& other) noexcept
|
||||
/// Swaps this Nullable with other.
|
||||
{
|
||||
std::swap(_value, other._value);
|
||||
std::swap(_isNull, other._isNull);
|
||||
std::swap(_optional, other._optional);
|
||||
}
|
||||
|
||||
bool operator == (const Nullable<C>& other) const
|
||||
/// Compares two Nullables for equality
|
||||
{
|
||||
return (_isNull && other._isNull) || (_isNull == other._isNull && _value == other._value);
|
||||
return _optional == other._optional;
|
||||
}
|
||||
|
||||
bool operator == (const C& value) const
|
||||
/// Compares Nullable with value for equality
|
||||
{
|
||||
return (!_isNull && _value == value);
|
||||
return (_optional.has_value() && _optional.value() == value);
|
||||
}
|
||||
|
||||
bool operator == (const NullType&) const
|
||||
/// Compares Nullable with NullData for equality
|
||||
{
|
||||
return _isNull;
|
||||
return !_optional.has_value();
|
||||
}
|
||||
|
||||
bool operator != (const C& value) const
|
||||
@@ -217,7 +193,7 @@ public:
|
||||
bool operator != (const NullType&) const
|
||||
/// Compares with NullData for non equality
|
||||
{
|
||||
return !_isNull;
|
||||
return _optional.has_value();
|
||||
}
|
||||
|
||||
bool operator < (const Nullable<C>& other) const
|
||||
@@ -225,14 +201,7 @@ public:
|
||||
/// value is smaler than the other object's value.
|
||||
/// Null value is smaller than a non-null value.
|
||||
{
|
||||
if (_isNull && other._isNull) return false;
|
||||
|
||||
if (!_isNull && !other._isNull)
|
||||
return (_value < other._value);
|
||||
|
||||
if (_isNull && !other._isNull) return true;
|
||||
|
||||
return false;
|
||||
return _optional < other._optional;
|
||||
}
|
||||
|
||||
bool operator > (const Nullable<C>& other) const
|
||||
@@ -248,8 +217,8 @@ public:
|
||||
///
|
||||
/// Throws a NullValueException if the Nullable is empty.
|
||||
{
|
||||
if (!_isNull)
|
||||
return _value;
|
||||
if (_optional.has_value())
|
||||
return _optional.value();
|
||||
else
|
||||
throw NullValueException();
|
||||
}
|
||||
@@ -259,8 +228,8 @@ public:
|
||||
///
|
||||
/// Throws a NullValueException if the Nullable is empty.
|
||||
{
|
||||
if (!_isNull)
|
||||
return _value;
|
||||
if (_optional.has_value())
|
||||
return _optional.value();
|
||||
else
|
||||
throw NullValueException();
|
||||
}
|
||||
@@ -269,22 +238,25 @@ public:
|
||||
/// Returns the Nullable's value, or the
|
||||
/// given default value if the Nullable is empty.
|
||||
{
|
||||
return _isNull ? deflt : _value;
|
||||
if (_optional.has_value())
|
||||
return _optional.value();
|
||||
|
||||
return deflt;
|
||||
}
|
||||
|
||||
operator C& ()
|
||||
explicit operator C& ()
|
||||
/// Get reference to the value
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
||||
operator const C& () const
|
||||
explicit operator const C& () const
|
||||
/// Get const reference to the value
|
||||
{
|
||||
return value();
|
||||
}
|
||||
|
||||
operator NullType& ()
|
||||
operator const NullType& () const
|
||||
/// Get reference to the value
|
||||
{
|
||||
return _null;
|
||||
@@ -293,19 +265,18 @@ public:
|
||||
bool isNull() const
|
||||
/// Returns true if the Nullable is empty.
|
||||
{
|
||||
return _isNull;
|
||||
return !_optional.has_value();
|
||||
}
|
||||
|
||||
void clear()
|
||||
/// Clears the Nullable.
|
||||
{
|
||||
_isNull = true;
|
||||
_optional.reset();
|
||||
}
|
||||
|
||||
private:
|
||||
C _value;
|
||||
bool _isNull;
|
||||
NullType _null;
|
||||
std::optional<C> _optional;
|
||||
static constexpr NullType _null {std::nullopt};
|
||||
};
|
||||
|
||||
|
||||
|
||||
+301
-139
@@ -43,6 +43,17 @@ public:
|
||||
FMT_ON_OFF
|
||||
};
|
||||
|
||||
enum class Options
|
||||
/// Options to control the format of the generated string.
|
||||
{
|
||||
DEFAULT = 0,
|
||||
/// formatHex defaults: No 0x prefix, uppercase hexadecimal values
|
||||
PREFIX = 1 << 0,
|
||||
/// formatHex: Prepend prefix 0x
|
||||
LOWERCASE = 1 << 1
|
||||
/// formatHex: Use lowercase letters for hexadecimal values
|
||||
};
|
||||
|
||||
static const unsigned NF_MAX_INT_STRING_LEN = 32; // increase for 64-bit binary formatting support
|
||||
static const unsigned NF_MAX_FLT_STRING_LEN = POCO_MAX_FLT_STRING_LEN;
|
||||
|
||||
@@ -59,18 +70,18 @@ public:
|
||||
/// right justified and zero-padded in a field
|
||||
/// having at least the specified width.
|
||||
|
||||
static std::string formatHex(int value, bool prefix = false);
|
||||
static std::string formatHex(int value, Options options = Options::DEFAULT);
|
||||
/// Formats an int value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static std::string formatHex(int value, int width, bool prefix = false);
|
||||
/// Formats a int value in hexadecimal notation,
|
||||
static std::string formatHex(int value, int width, Options options = Options::DEFAULT);
|
||||
/// Formats an int value in hexadecimal notation,
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static std::string format(unsigned value);
|
||||
@@ -86,17 +97,17 @@ public:
|
||||
/// right justified and zero-padded in a field having at
|
||||
/// least the specified width.
|
||||
|
||||
static std::string formatHex(unsigned value, bool prefix = false);
|
||||
static std::string formatHex(unsigned value, Options options = Options::DEFAULT);
|
||||
/// Formats an unsigned int value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string formatHex(unsigned value, int width, bool prefix = false);
|
||||
/// Formats a int value in hexadecimal notation,
|
||||
static std::string formatHex(unsigned value, int width, Options options = Options::DEFAULT);
|
||||
/// Formats an unsigned value in hexadecimal notation,
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string format(long value);
|
||||
/// Formats a long value in decimal notation.
|
||||
@@ -111,19 +122,17 @@ public:
|
||||
/// right justified and zero-padded in a field
|
||||
/// having at least the specified width.
|
||||
|
||||
static std::string formatHex(long value, bool prefix = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
static std::string formatHex(long value, Options options = Options::DEFAULT);
|
||||
/// Formats a long value in hexadecimal notation.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string formatHex(long value, int width, bool prefix = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
static std::string formatHex(long value, int width, Options options = Options::DEFAULT);
|
||||
/// Formats a long value in hexadecimal notation,
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string format(unsigned long value);
|
||||
/// Formats an unsigned long value in decimal notation.
|
||||
@@ -138,17 +147,17 @@ public:
|
||||
/// right justified and zero-padded
|
||||
/// in a field having at least the specified width.
|
||||
|
||||
static std::string formatHex(unsigned long value, bool prefix = false);
|
||||
static std::string formatHex(unsigned long value, Options options = Options::DEFAULT);
|
||||
/// Formats an unsigned long value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string formatHex(unsigned long value, int width, bool prefix = false);
|
||||
static std::string formatHex(unsigned long value, int width, Options options = Options::DEFAULT);
|
||||
/// Formats an unsigned long value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
#ifdef POCO_HAVE_INT64
|
||||
#ifdef POCO_INT64_IS_LONG
|
||||
@@ -165,18 +174,18 @@ public:
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
|
||||
static std::string formatHex(long long value, bool prefix = false);
|
||||
static std::string formatHex(long long value, Options options = Options::DEFAULT);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string formatHex(long long value, int width, bool prefix = false);
|
||||
static std::string formatHex(long long value, int width, Options options = Options::DEFAULT);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
/// The value is treated as unsigned.
|
||||
/// If prefix is true, "0x" prefix is prepended to the resulting string.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string format(unsigned long long value);
|
||||
/// Formats an unsigned 64-bit integer value in decimal notation.
|
||||
@@ -190,16 +199,18 @@ public:
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
|
||||
static std::string formatHex(unsigned long long value, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
static std::string formatHex(unsigned long long value, Options options = Options::DEFAULT);
|
||||
/// Formats an unsigned 64-bit value in hexadecimal notation.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string formatHex(unsigned long long value, int width, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
static std::string formatHex(unsigned long long value, int width, Options options = Options::DEFAULT);
|
||||
/// Formats an unsigned 64-bit value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width. If prefix is true, "0x" prefix is
|
||||
/// prepended to the resulting string.
|
||||
/// the specified width.
|
||||
/// The value is treated as unsigned.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
#else // ifndef POCO_INT64_IS_LONG
|
||||
|
||||
@@ -215,18 +226,18 @@ public:
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
|
||||
static std::string formatHex(Int64 value, bool prefix = false);
|
||||
static std::string formatHex(Int64 value, Options options = Options::DEFAULT);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string formatHex(Int64 value, int width, bool prefix = false);
|
||||
static std::string formatHex(Int64 value, int width, Options options = Options::DEFAULT);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
/// The value is treated as unsigned.
|
||||
/// If prefix is true, "0x" prefix is prepended to the resulting string.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string format(UInt64 value);
|
||||
/// Formats an unsigned 64-bit integer value in decimal notation.
|
||||
@@ -240,16 +251,18 @@ public:
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
|
||||
static std::string formatHex(UInt64 value, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
static std::string formatHex(UInt64 value, Options options = Options::DEFAULT);
|
||||
/// Formats an unsigned 64-bit integer in hexadecimal notation.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
static std::string formatHex(UInt64 value, int width, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
static std::string formatHex(UInt64 value, int width, Options options = Options::DEFAULT);
|
||||
/// Formats an unsigned 64-bit integer in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width. If prefix is true, "0x" prefix is
|
||||
/// prepended to the resulting string.
|
||||
/// the specified width.
|
||||
/// The value is treated as unsigned.
|
||||
/// Options (see NumberFormatter::Options) define the format of the
|
||||
/// generated string.
|
||||
|
||||
#endif // ifdef POCO_INT64_IS_LONG
|
||||
#endif // ifdef POCO_HAVE_INT64
|
||||
@@ -302,11 +315,11 @@ public:
|
||||
/// right justified and zero-padded in a field
|
||||
/// having at least the specified width.
|
||||
|
||||
static void appendHex(std::string& str, int value);
|
||||
static void appendHex(std::string& str, int value, bool lowercase = false);
|
||||
/// Formats an int value in hexadecimal notation.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static void appendHex(std::string& str, int value, int width);
|
||||
static void appendHex(std::string& str, int value, int width, bool lowercase = false);
|
||||
/// Formats a int value in hexadecimal notation,
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
@@ -325,10 +338,10 @@ public:
|
||||
/// right justified and zero-padded in a field having at
|
||||
/// least the specified width.
|
||||
|
||||
static void appendHex(std::string& str, unsigned value);
|
||||
static void appendHex(std::string& str, unsigned value, bool lowercase = false);
|
||||
/// Formats an unsigned int value in hexadecimal notation.
|
||||
|
||||
static void appendHex(std::string& str, unsigned value, int width);
|
||||
static void appendHex(std::string& str, unsigned value, int width, bool lowercase = false);
|
||||
/// Formats a int value in hexadecimal notation,
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
@@ -346,11 +359,11 @@ public:
|
||||
/// right justified and zero-padded in a field
|
||||
/// having at least the specified width.
|
||||
|
||||
static void appendHex(std::string& str, long value);
|
||||
static void appendHex(std::string& str, long value, bool lowercase = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static void appendHex(std::string& str, long value, int width);
|
||||
static void appendHex(std::string& str, long value, int width, bool lowercase = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
@@ -369,10 +382,10 @@ public:
|
||||
/// right justified and zero-padded
|
||||
/// in a field having at least the specified width.
|
||||
|
||||
static void appendHex(std::string& str, unsigned long value);
|
||||
static void appendHex(std::string& str, unsigned long value, bool lowercase = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation.
|
||||
|
||||
static void appendHex(std::string& str, unsigned long value, int width);
|
||||
static void appendHex(std::string& str, unsigned long value, int width, bool lowercase = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
@@ -392,11 +405,11 @@ public:
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
|
||||
static void appendHex(std::string& str, long long value);
|
||||
static void appendHex(std::string& str, long long value, bool lowercase = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static void appendHex(std::string& str, long long value, int width);
|
||||
static void appendHex(std::string& str, long long value, int width, bool lowercase = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
@@ -414,10 +427,10 @@ public:
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
|
||||
static void appendHex(std::string& str, unsigned long long value);
|
||||
static void appendHex(std::string& str, unsigned long long value, bool lowercase = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
|
||||
static void appendHex(std::string& str, unsigned long long value, int width);
|
||||
static void appendHex(std::string& str, unsigned long long value, int width, bool lowercase = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
@@ -436,11 +449,11 @@ public:
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
|
||||
static void appendHex(std::string& str, Int64 value);
|
||||
static void appendHex(std::string& str, Int64 value, bool lowercase = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static void appendHex(std::string& str, Int64 value, int width);
|
||||
static void appendHex(std::string& str, Int64 value, int width, bool lowercase = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
@@ -458,10 +471,10 @@ public:
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
|
||||
static void appendHex(std::string& str, UInt64 value);
|
||||
static void appendHex(std::string& str, UInt64 value, bool lowercase = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
|
||||
static void appendHex(std::string& str, UInt64 value, int width);
|
||||
static void appendHex(std::string& str, UInt64 value, int width, bool lowercase = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
@@ -500,7 +513,137 @@ public:
|
||||
/// sixteen (64-bit architectures) characters wide
|
||||
/// field in hexadecimal notation.
|
||||
|
||||
//
|
||||
// Deprecated functions
|
||||
//
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(int value, bool prefix);
|
||||
/// Formats an int value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(int value, int width, bool prefix);
|
||||
/// Formats an int value in hexadecimal notation,
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(unsigned value, bool prefix);
|
||||
/// Formats an unsigned int value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(unsigned value, int width, bool prefix);
|
||||
/// Formats an unsigned value in hexadecimal notation,
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(long value, bool prefix);
|
||||
/// Formats a long value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(long value, int width, bool prefix);
|
||||
/// Formats a long value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(unsigned long value, bool prefix);
|
||||
/// Formats an unsigned long value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(unsigned long value, int width, bool prefix);
|
||||
/// Formats an unsigned long value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
#ifdef POCO_HAVE_INT64
|
||||
#ifdef POCO_INT64_IS_LONG
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(long long value, bool prefix);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(long long value, int width, bool prefix);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
/// The value is treated as unsigned.
|
||||
/// If prefix is true, "0x" prefix is prepended to the resulting string.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(unsigned long long value, bool prefix);
|
||||
/// Formats an unsigned 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(unsigned long long value, int width, bool prefix);
|
||||
/// Formats an unsigned 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width. If prefix is true, "0x" prefix is
|
||||
/// prepended to the resulting string.
|
||||
|
||||
#else // ifndef POCO_INT64_IS_LONG
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(Int64 value, bool prefix);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(Int64 value, int width, bool prefix);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
/// The value is treated as unsigned.
|
||||
/// If prefix is true, "0x" prefix is prepended to the resulting string.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(UInt64 value, bool prefix);
|
||||
/// Formats an unsigned 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
POCO_DEPRECATED("use formatHex with options instead")
|
||||
static std::string formatHex(UInt64 value, int width, bool prefix);
|
||||
/// Formats an unsigned 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width. If prefix is true, "0x" prefix is
|
||||
/// prepended to the resulting string.
|
||||
|
||||
#endif // ifdef POCO_INT64_IS_LONG
|
||||
#endif // ifdef POCO_HAVE_INT64
|
||||
|
||||
private:
|
||||
|
||||
static bool isEnabled(NumberFormatter::Options options, NumberFormatter::Options opt);
|
||||
};
|
||||
|
||||
|
||||
@@ -508,6 +651,42 @@ private:
|
||||
// inlines
|
||||
//
|
||||
|
||||
|
||||
inline NumberFormatter::Options operator | (NumberFormatter::Options lhs, NumberFormatter::Options rhs)
|
||||
{
|
||||
using T = std::underlying_type_t<NumberFormatter::Options>;
|
||||
return static_cast<NumberFormatter::Options>(static_cast<T>(lhs) | static_cast<T>(rhs));
|
||||
}
|
||||
|
||||
|
||||
inline NumberFormatter::Options& operator |= (NumberFormatter::Options& lhs, NumberFormatter::Options rhs)
|
||||
{
|
||||
lhs = lhs | rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
||||
inline NumberFormatter::Options operator & (NumberFormatter::Options lhs, NumberFormatter::Options rhs)
|
||||
{
|
||||
using T = std::underlying_type_t<NumberFormatter::Options>;
|
||||
return static_cast<NumberFormatter::Options>(static_cast<T>(lhs) & static_cast<T>(rhs));
|
||||
}
|
||||
|
||||
|
||||
inline NumberFormatter::Options& operator &= (NumberFormatter::Options& lhs, NumberFormatter::Options rhs)
|
||||
{
|
||||
lhs = lhs & rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
||||
inline bool NumberFormatter::isEnabled(Options options, Options opt)
|
||||
{
|
||||
using T = std::underlying_type_t<Options>;
|
||||
return static_cast<T>(options & opt) != 0;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::format(int value)
|
||||
{
|
||||
std::string result;
|
||||
@@ -532,26 +711,22 @@ inline std::string NumberFormatter::format0(int value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(int value, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(int value, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix);
|
||||
return result;
|
||||
return formatHex(static_cast<unsigned int>(value), options);
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(int value, int width, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(int value, int width, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
return formatHex(static_cast<unsigned int>(value), width, options);
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::format(unsigned value)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result);
|
||||
intToStr(value, 10, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -559,7 +734,7 @@ inline std::string NumberFormatter::format(unsigned value)
|
||||
inline std::string NumberFormatter::format(unsigned value, int width)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result, false, width, ' ');
|
||||
intToStr(value, 10, result, false, width, ' ');
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -567,23 +742,23 @@ inline std::string NumberFormatter::format(unsigned value, int width)
|
||||
inline std::string NumberFormatter::format0(unsigned int value, int width)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result, false, width, '0');
|
||||
intToStr(value, 10, result, false, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned value, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(unsigned value, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix);
|
||||
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX),-1, ' ', 0, isEnabled(options, Options::LOWERCASE));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned value, int width, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(unsigned value, int width, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0');
|
||||
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), width, '0', 0, isEnabled(options, Options::LOWERCASE));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -612,26 +787,22 @@ inline std::string NumberFormatter::format0(long value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(long value, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(long value, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix);
|
||||
return result;
|
||||
return formatHex(static_cast<unsigned long>(value), options);
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(long value, int width, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(long value, int width, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
return formatHex(static_cast<unsigned long>(value), width, options);
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::format(unsigned long value)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result);
|
||||
intToStr(value, 10, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -639,7 +810,7 @@ inline std::string NumberFormatter::format(unsigned long value)
|
||||
inline std::string NumberFormatter::format(unsigned long value, int width)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result, false, width, ' ');
|
||||
intToStr(value, 10, result, false, width, ' ');
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -647,27 +818,26 @@ inline std::string NumberFormatter::format(unsigned long value, int width)
|
||||
inline std::string NumberFormatter::format0(unsigned long value, int width)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result, false, width, '0');
|
||||
intToStr(value, 10, result, false, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned long value, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(unsigned long value, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix);
|
||||
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), -1, ' ', 0, isEnabled(options, Options::LOWERCASE));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned long value, int width, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(unsigned long value, int width, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0');
|
||||
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), width, '0', 0, isEnabled(options, Options::LOWERCASE));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#ifdef POCO_HAVE_INT64
|
||||
#ifdef POCO_INT64_IS_LONG
|
||||
|
||||
@@ -696,26 +866,22 @@ inline std::string NumberFormatter::format0(long long value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(long long value, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(long long value, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix);
|
||||
return result;
|
||||
return formatHex(static_cast<unsigned long long>(value), options);
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(long long value, int width, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(long long value, int width, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
return formatHex(static_cast<unsigned long long>(value), width, options);
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::format(unsigned long long value)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result);
|
||||
intToStr(value, 10, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -723,7 +889,7 @@ inline std::string NumberFormatter::format(unsigned long long value)
|
||||
inline std::string NumberFormatter::format(unsigned long long value, int width)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result, false, width, ' ');
|
||||
intToStr(value, 10, result, false, width, ' ');
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -731,23 +897,23 @@ inline std::string NumberFormatter::format(unsigned long long value, int width)
|
||||
inline std::string NumberFormatter::format0(unsigned long long value, int width)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result, false, width, '0');
|
||||
intToStr(value, 10, result, false, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned long long value, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(unsigned long long value, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix);
|
||||
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), -1, ' ', 0, isEnabled(options, Options::LOWERCASE));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned long long value, int width, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(unsigned long long value, int width, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0');
|
||||
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), width, '0', 0, isEnabled(options, Options::LOWERCASE));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -779,26 +945,22 @@ inline std::string NumberFormatter::format0(Int64 value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(Int64 value, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(Int64 value, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix);
|
||||
return result;
|
||||
return formatHex(static_cast<UInt64>(value), options);
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(Int64 value, int width, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(long long value, int width, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
return formatHex(static_cast<UInt64>(value), width, options);
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::format(UInt64 value)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result);
|
||||
intToStr(value, 10, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -806,7 +968,7 @@ inline std::string NumberFormatter::format(UInt64 value)
|
||||
inline std::string NumberFormatter::format(UInt64 value, int width)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result, false, width, ' ');
|
||||
intToStr(value, 10, result, false, width, ' ');
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -814,23 +976,23 @@ inline std::string NumberFormatter::format(UInt64 value, int width)
|
||||
inline std::string NumberFormatter::format0(UInt64 value, int width)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 10, result, false, width, '0');
|
||||
intToStr(value, 10, result, false, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(UInt64 value, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(UInt64 value, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix);
|
||||
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), -1, ' ', 0, isEnabled(options, Options::LOWERCASE));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(UInt64 value, int width, bool prefix)
|
||||
inline std::string NumberFormatter::formatHex(UInt64 value, int width, Options options)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0');
|
||||
intToStr(value, 0x10, result, isEnabled(options, Options::PREFIX), width, '0', 0, isEnabled(options, Options::LOWERCASE));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+79
-24
@@ -33,6 +33,7 @@
|
||||
#if !defined(POCO_NO_LOCALE)
|
||||
#include <locale>
|
||||
#endif
|
||||
#include <type_traits>
|
||||
#if defined(POCO_NOINTMAX)
|
||||
typedef Poco::UInt64 uintmax_t;
|
||||
typedef Poco::Int64 intmax_t;
|
||||
@@ -45,8 +46,8 @@ typedef Poco::Int64 intmax_t;
|
||||
#pragma warning(disable : 4146)
|
||||
#endif // POCO_COMPILER_MSVC
|
||||
|
||||
// binary numbers are supported, thus 64 (bits) + 1 (string terminating zero)
|
||||
#define POCO_MAX_INT_STRING_LEN 65
|
||||
// binary numbers are supported, thus 64 (bits) + 1 (string terminating zero) + 2 (hex prefix)
|
||||
#define POCO_MAX_INT_STRING_LEN (67)
|
||||
// value from strtod.cc (double_conversion::kMaxSignificantDecimalDigits)
|
||||
#define POCO_MAX_FLT_STRING_LEN 780
|
||||
|
||||
@@ -207,7 +208,9 @@ bool strToInt(const char* pStr, I& outResult, short base, char thSep = ',')
|
||||
/// Converts zero-terminated character array to integer number;
|
||||
/// Thousand separators are recognized for base10 and current locale;
|
||||
/// they are silently skipped and not verified for correct positioning.
|
||||
/// It is not allowed to convert a negative number to unsigned integer.
|
||||
/// It is not allowed to convert a negative number to anything except
|
||||
/// 10-base signed integer.
|
||||
/// For hexadecimal numbers, the case of the digits is not relevant.
|
||||
///
|
||||
/// Function returns true if successful. If parsing was unsuccessful,
|
||||
/// the return value is false with the result value undetermined.
|
||||
@@ -216,7 +219,9 @@ bool strToInt(const char* pStr, I& outResult, short base, char thSep = ',')
|
||||
|
||||
if (!pStr) return false;
|
||||
while (std::isspace(*pStr)) ++pStr;
|
||||
if (*pStr == '\0') return false;
|
||||
if ((*pStr == '\0') || ((*pStr == '-') && ((base != 10) || (std::is_unsigned<I>::value))))
|
||||
return false;
|
||||
|
||||
bool negative = false;
|
||||
if ((base == 10) && (*pStr == '-'))
|
||||
{
|
||||
@@ -237,7 +242,8 @@ bool strToInt(const char* pStr, I& outResult, short base, char thSep = ',')
|
||||
if (*pStr == thSep)
|
||||
{
|
||||
if (base == 10) continue;
|
||||
throw Poco::SyntaxException("strToInt: thousand separators only allowed for base 10");
|
||||
// thousand separators only allowed for base 10
|
||||
return false;
|
||||
}
|
||||
if (result > (limitCheck / base)) return false;
|
||||
if (!safeMultiply(result, result, base)) return false;
|
||||
@@ -363,10 +369,16 @@ namespace Impl {
|
||||
const char* _end;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using EnableSigned = typename std::enable_if_t< std::is_signed<T>::value >*;
|
||||
|
||||
template <typename T>
|
||||
using EnableUnsigned = typename std::enable_if_t< std::is_unsigned<T>::value >*;
|
||||
|
||||
} // namespace Impl
|
||||
|
||||
|
||||
template <typename T>
|
||||
template <typename T, Impl::EnableSigned<T> = nullptr>
|
||||
bool intToStr(T value,
|
||||
unsigned short base,
|
||||
char* result,
|
||||
@@ -374,8 +386,10 @@ bool intToStr(T value,
|
||||
bool prefix = false,
|
||||
int width = -1,
|
||||
char fill = ' ',
|
||||
char thSep = 0)
|
||||
/// Converts integer to string. Numeric bases from binary to hexadecimal are supported.
|
||||
char thSep = 0,
|
||||
bool lowercase = false)
|
||||
/// Converts signed integer to string. Standard numeric bases from binary to hexadecimal
|
||||
/// are supported.
|
||||
/// If width is non-zero, it pads the return value with fill character to the specified width.
|
||||
/// When padding is zero character ('0'), it is prepended to the number itself; all other
|
||||
/// paddings are prepended to the formatted result with minus sign or base prefix included
|
||||
@@ -383,6 +397,8 @@ bool intToStr(T value,
|
||||
/// "0x" for hexadecimal) is prepended. For all other bases, prefix argument is ignored.
|
||||
/// Formatted string has at least [width] total length.
|
||||
{
|
||||
poco_assert_dbg (((value < 0) && (base == 10)) || (value >= 0));
|
||||
|
||||
if (base < 2 || base > 0x10)
|
||||
{
|
||||
*result = '\0';
|
||||
@@ -396,7 +412,7 @@ bool intToStr(T value,
|
||||
{
|
||||
tmpVal = value;
|
||||
value /= base;
|
||||
*ptr++ = "FEDCBA9876543210123456789ABCDEF"[15 + (tmpVal - value * base)];
|
||||
*ptr++ = (lowercase ? "fedcba9876543210123456789abcdef" : "FEDCBA9876543210123456789ABCDEF")[15 + (tmpVal - value * base)];
|
||||
if (thSep && (base == 10) && (++thCount == 3))
|
||||
{
|
||||
*ptr++ = thSep;
|
||||
@@ -444,15 +460,16 @@ bool intToStr(T value,
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool uIntToStr(T value,
|
||||
template <typename T, Impl::EnableUnsigned<T> = nullptr>
|
||||
bool intToStr(T value,
|
||||
unsigned short base,
|
||||
char* result,
|
||||
std::size_t& size,
|
||||
bool prefix = false,
|
||||
int width = -1,
|
||||
char fill = ' ',
|
||||
char thSep = 0)
|
||||
char thSep = 0,
|
||||
bool lowercase = false)
|
||||
/// Converts unsigned integer to string. Numeric bases from binary to hexadecimal are supported.
|
||||
/// If width is non-zero, it pads the return value with fill character to the specified width.
|
||||
/// When padding is zero character ('0'), it is prepended to the number itself; all other
|
||||
@@ -474,7 +491,7 @@ bool uIntToStr(T value,
|
||||
{
|
||||
tmpVal = value;
|
||||
value /= base;
|
||||
*ptr++ = "FEDCBA9876543210123456789ABCDEF"[15 + (tmpVal - value * base)];
|
||||
*ptr++ = (lowercase ? "fedcba9876543210123456789abcdef" : "FEDCBA9876543210123456789ABCDEF")[15 + (tmpVal - value * base)];
|
||||
if (thSep && (base == 10) && (++thCount == 3))
|
||||
{
|
||||
*ptr++ = thSep;
|
||||
@@ -510,7 +527,7 @@ bool uIntToStr(T value,
|
||||
char tmp;
|
||||
while(ptrr < ptr)
|
||||
{
|
||||
tmp = *ptr;
|
||||
tmp = *ptr;
|
||||
*ptr-- = *ptrr;
|
||||
*ptrr++ = tmp;
|
||||
}
|
||||
@@ -520,28 +537,66 @@ bool uIntToStr(T value,
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool intToStr (T number, unsigned short base, std::string& result, bool prefix = false, int width = -1, char fill = ' ', char thSep = 0)
|
||||
/// Converts integer to string; This is a wrapper function, for details see see the
|
||||
POCO_DEPRECATED("use intToStr instead")
|
||||
bool uIntToStr(T value,
|
||||
unsigned short base,
|
||||
char* result,
|
||||
std::size_t& size,
|
||||
bool prefix = false,
|
||||
int width = -1,
|
||||
char fill = ' ',
|
||||
char thSep = 0,
|
||||
bool lowercase = false)
|
||||
/// Converts unsigned integer to string. Numeric bases from binary to hexadecimal are supported.
|
||||
/// If width is non-zero, it pads the return value with fill character to the specified width.
|
||||
/// When padding is zero character ('0'), it is prepended to the number itself; all other
|
||||
/// paddings are prepended to the formatted result with minus sign or base prefix included
|
||||
/// If prefix is true and base is octal or hexadecimal, respective prefix ('0' for octal,
|
||||
/// "0x" for hexadecimal) is prepended. For all other bases, prefix argument is ignored.
|
||||
/// Formatted string has at least [width] total length.
|
||||
///
|
||||
/// This function is deprecated; use intToStr instead.
|
||||
{
|
||||
return intToStr(value, base, result, size, prefix, width, fill, thSep, lowercase);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool intToStr (T number,
|
||||
unsigned short base,
|
||||
std::string& result,
|
||||
bool prefix = false,
|
||||
int width = -1,
|
||||
char fill = ' ',
|
||||
char thSep = 0,
|
||||
bool lowercase = false)
|
||||
/// Converts integer to string; This is a wrapper function, for details see the
|
||||
/// bool intToStr(T, unsigned short, char*, int, int, char, char) implementation.
|
||||
{
|
||||
char res[POCO_MAX_INT_STRING_LEN] = {0};
|
||||
std::size_t size = POCO_MAX_INT_STRING_LEN;
|
||||
bool ret = intToStr(number, base, res, size, prefix, width, fill, thSep);
|
||||
bool ret = intToStr(number, base, res, size, prefix, width, fill, thSep, lowercase);
|
||||
result.assign(res, size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool uIntToStr (T number, unsigned short base, std::string& result, bool prefix = false, int width = -1, char fill = ' ', char thSep = 0)
|
||||
/// Converts unsigned integer to string; This is a wrapper function, for details see see the
|
||||
POCO_DEPRECATED("use intToStr instead")
|
||||
bool uIntToStr (T number,
|
||||
unsigned short base,
|
||||
std::string& result,
|
||||
bool prefix = false,
|
||||
int width = -1,
|
||||
char fill = ' ',
|
||||
char thSep = 0,
|
||||
bool lowercase = false)
|
||||
/// Converts unsigned integer to string; This is a wrapper function, for details see the
|
||||
/// bool uIntToStr(T, unsigned short, char*, int, int, char, char) implementation.
|
||||
///
|
||||
/// This function is deprecated; use intToStr instead.
|
||||
{
|
||||
char res[POCO_MAX_INT_STRING_LEN] = {0};
|
||||
std::size_t size = POCO_MAX_INT_STRING_LEN;
|
||||
bool ret = uIntToStr(number, base, res, size, prefix, width, fill, thSep);
|
||||
result.assign(res, size);
|
||||
return ret;
|
||||
return intToStr(number, base, result, prefix, width, fill, thSep, lowercase);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -302,6 +302,10 @@ public:
|
||||
protected:
|
||||
P activateObject(P pObject)
|
||||
{
|
||||
#if defined(POCO_COMPILER_GCC) && (__GNUC__ >= 12)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wuse-after-free"
|
||||
#endif
|
||||
try
|
||||
{
|
||||
_factory.activateObject(pObject);
|
||||
@@ -312,6 +316,9 @@ protected:
|
||||
throw;
|
||||
}
|
||||
return pObject;
|
||||
#if defined(POCO_COMPILER_GCC) && (__GNUC__ >= 12)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
+10
-9
@@ -74,15 +74,10 @@ public:
|
||||
void notify(Notification* pNf) const
|
||||
{
|
||||
Poco::Mutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (_pObject)
|
||||
{
|
||||
N* pCastNf = dynamic_cast<N*>(pNf);
|
||||
if (pCastNf)
|
||||
{
|
||||
pCastNf->duplicate();
|
||||
(_pObject->*_method)(pCastNf);
|
||||
}
|
||||
pNf->duplicate();
|
||||
(_pObject->*_method)(static_cast<N*>(pNf));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +87,15 @@ public:
|
||||
return pObs && pObs->_pObject == _pObject && pObs->_method == _method;
|
||||
}
|
||||
|
||||
bool accepts(Notification* pNf, const char* pName = 0) const
|
||||
POCO_DEPRECATED("use `bool accepts(const Notification::Ptr&)` instead")
|
||||
bool accepts(Notification* pNf, const char* pName) const
|
||||
{
|
||||
return dynamic_cast<N*>(pNf) && (!pName || pNf->name() == pName);
|
||||
return (!pName || pNf->name() == pName) && (dynamic_cast<N*>(pNf) != nullptr);
|
||||
}
|
||||
|
||||
bool accepts(const Notification::Ptr& pNf) const
|
||||
{
|
||||
return (pNf.cast<N>() != nullptr);
|
||||
}
|
||||
|
||||
AbstractObserver* clone() const
|
||||
|
||||
+23
-31
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -53,40 +53,33 @@ class Optional
|
||||
/// nillable == true.
|
||||
{
|
||||
public:
|
||||
Optional():
|
||||
Optional()
|
||||
/// Creates an empty Optional.
|
||||
_value(),
|
||||
_isSpecified(false)
|
||||
{
|
||||
}
|
||||
|
||||
Optional(const C& value):
|
||||
/// Creates a Optional with the given value.
|
||||
_value(value),
|
||||
_isSpecified(true)
|
||||
_optional(value)
|
||||
{
|
||||
}
|
||||
|
||||
Optional(C&& value):
|
||||
/// Creates a Optional by moving the given value.
|
||||
_value(std::forward<C>(value)),
|
||||
_isSpecified(true)
|
||||
_optional(std::forward<C>(value))
|
||||
{
|
||||
}
|
||||
|
||||
Optional(const Optional& other):
|
||||
/// Creates a Optional by copying another one.
|
||||
_value(other._value),
|
||||
_isSpecified(other._isSpecified)
|
||||
_optional(other._optional)
|
||||
{
|
||||
}
|
||||
|
||||
Optional(Optional&& other) noexcept:
|
||||
/// Creates a Optional by moving another one.
|
||||
_value(std::move(other._value)),
|
||||
_isSpecified(other._isSpecified)
|
||||
_optional(std::move(other._optional))
|
||||
{
|
||||
other._isSpecified = false;
|
||||
}
|
||||
|
||||
~Optional()
|
||||
@@ -97,16 +90,14 @@ public:
|
||||
Optional& assign(const C& value)
|
||||
/// Assigns a value to the Optional.
|
||||
{
|
||||
_value = value;
|
||||
_isSpecified = true;
|
||||
_optional.emplace(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Optional& assign(C&& value)
|
||||
/// Moves a value into the Optional.
|
||||
{
|
||||
_value = std::move(value);
|
||||
_isSpecified = true;
|
||||
_optional.emplace(std::move(value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -135,16 +126,14 @@ public:
|
||||
|
||||
Optional& operator = (Optional&& other) noexcept
|
||||
{
|
||||
_value = std::move(other._value);
|
||||
_isSpecified = other._isSpecified;
|
||||
other._isSpecified = false;
|
||||
_optional = std::move(other._optional);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(Optional& other) noexcept
|
||||
{
|
||||
std::swap(_value, other._value);
|
||||
std::swap(_isSpecified, other._isSpecified);
|
||||
using std::swap;
|
||||
swap(_optional, other._optional);
|
||||
}
|
||||
|
||||
const C& value() const
|
||||
@@ -152,10 +141,10 @@ public:
|
||||
///
|
||||
/// Throws a Poco::NullValueException if the value has not been specified.
|
||||
{
|
||||
if (_isSpecified)
|
||||
return _value;
|
||||
else
|
||||
throw Poco::NullValueException();
|
||||
if (_optional.has_value())
|
||||
return _optional.value();
|
||||
|
||||
throw Poco::NullValueException();
|
||||
}
|
||||
|
||||
const C& value(const C& deflt) const
|
||||
@@ -163,24 +152,27 @@ public:
|
||||
/// given default value if the Optional's
|
||||
/// value has not been specified.
|
||||
{
|
||||
return _isSpecified ? _value : deflt;
|
||||
if (_optional.has_value())
|
||||
return _optional.value();
|
||||
|
||||
return deflt;
|
||||
}
|
||||
|
||||
bool isSpecified() const
|
||||
/// Returns true iff the Optional's value has been specified.
|
||||
{
|
||||
return _isSpecified;
|
||||
return _optional.has_value();
|
||||
}
|
||||
|
||||
void clear()
|
||||
/// Clears the Optional.
|
||||
{
|
||||
_isSpecified = false;
|
||||
_optional.reset();
|
||||
}
|
||||
|
||||
private:
|
||||
C _value;
|
||||
bool _isSpecified;
|
||||
|
||||
std::optional<C> _optional;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// PIDFile.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Processes
|
||||
// Module: PIDFile
|
||||
//
|
||||
// Definition of the PIDFile class.
|
||||
//
|
||||
// Copyright (c) 2023, Applied Informatics Software Engineering GmbH.
|
||||
// Aleph ONE Software Engineering d.o.o.,
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_PIDFile_INCLUDED
|
||||
#define Foundation_PIDFile_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API PIDFile
|
||||
/// A utility class, creating process ID file on
|
||||
/// construction and deleting it on destruction.
|
||||
{
|
||||
public:
|
||||
using Ptr = std::unique_ptr<PIDFile>;
|
||||
|
||||
static const int INVALID_PID = -1;
|
||||
|
||||
PIDFile();
|
||||
/// Creates the PIDFile.
|
||||
|
||||
PIDFile(const std::string& fileName, bool write = true);
|
||||
/// Creates the PIDFile.
|
||||
/// If `fileName` is not empty, creates the PID file.
|
||||
/// If `write` is true, the file is written.
|
||||
|
||||
~PIDFile();
|
||||
/// Destroys the PIDFile.
|
||||
/// If fileName is not empty, deletes the PID file.
|
||||
|
||||
const std::string& getName() const;
|
||||
/// Returns the file name.
|
||||
|
||||
void setName(const std::string& fileName);
|
||||
/// Sets the file name.
|
||||
|
||||
void create();
|
||||
/// Creates the file and writes PID into it.
|
||||
|
||||
void destroy();
|
||||
/// Deletes the PID file and invalidates the held PID.
|
||||
|
||||
int getPID() const;
|
||||
/// Returns the PID.
|
||||
|
||||
bool exists() const;
|
||||
/// Returns true if PID file exists and its content is
|
||||
/// equal to the held PID.
|
||||
|
||||
static bool contains(const std::string& fileName, int pid);
|
||||
/// Returns true if the `fileName` contains the given `pid`.
|
||||
|
||||
static std::string& getFileName(std::string& pidFile);
|
||||
/// Returns the file name.
|
||||
|
||||
private:
|
||||
|
||||
std::string _fileName;
|
||||
int _pid = INVALID_PID;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
|
||||
inline const std::string& PIDFile::getName() const
|
||||
{
|
||||
return _fileName;
|
||||
}
|
||||
|
||||
|
||||
inline int PIDFile::getPID() const
|
||||
{
|
||||
return _pid;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_ProcessRunner_INCLUDED
|
||||
+21
-1
@@ -48,7 +48,7 @@ public:
|
||||
PATH_GUESS /// Guess the style by examining the path
|
||||
};
|
||||
|
||||
typedef std::vector<std::string> StringVec;
|
||||
using StringVec = std::vector<std::string>;
|
||||
|
||||
Path();
|
||||
/// Creates an empty relative path.
|
||||
@@ -290,6 +290,26 @@ public:
|
||||
/// this is the semicolon ';'. On OpenVMS systems, this is the
|
||||
/// comma ','.
|
||||
|
||||
static std::string addDirectorySeparator(const std::string& path);
|
||||
/// Adds a separator to the end of a string to create the correct syntax for a path.
|
||||
/// If the source path already has a trailing separator, no separator will be added.
|
||||
///
|
||||
/// On Unix systems, this is the slash '/'. On Windows systems,
|
||||
/// this is the backslash '\'. On OpenVMS systems, this is the
|
||||
/// period '.'.
|
||||
|
||||
static std::string addDirectorySeparator(const std::string& path, Style style);
|
||||
/// Adds a separator to the end of a string to create the correct syntax for a path.
|
||||
/// If the source path already has a trailing separator, no separator will be added.
|
||||
///
|
||||
/// On Unix systems, this is the slash '/'. On Windows systems,
|
||||
/// this is the backslash '\'. On OpenVMS systems, this is the
|
||||
/// period '.'.
|
||||
|
||||
static std::string self();
|
||||
/// Return path to the executable file, empty string if failed.
|
||||
/// The path is absolute one.
|
||||
|
||||
static std::string current();
|
||||
/// Returns the current working directory.
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Poco {
|
||||
class PathImpl
|
||||
{
|
||||
public:
|
||||
static std::string selfImpl();
|
||||
static std::string currentImpl();
|
||||
static std::string homeImpl();
|
||||
static std::string configHomeImpl();
|
||||
@@ -39,6 +40,7 @@ public:
|
||||
static std::string nullImpl();
|
||||
static std::string expandImpl(const std::string& path);
|
||||
static void listRootsImpl(std::vector<std::string>& roots);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Poco {
|
||||
class Foundation_API PathImpl
|
||||
{
|
||||
public:
|
||||
static std::string selfImpl();
|
||||
static std::string currentImpl();
|
||||
static std::string homeImpl();
|
||||
static std::string configHomeImpl();
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
//
|
||||
// Path_WINCE.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
// Module: Path
|
||||
//
|
||||
// Definition of the PathImpl class for WIN32.
|
||||
//
|
||||
// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Path_WINCE_INCLUDED
|
||||
#define Foundation_Path_WINCE_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API PathImpl
|
||||
{
|
||||
public:
|
||||
static std::string currentImpl();
|
||||
static std::string homeImpl();
|
||||
static std::string configHomeImpl();
|
||||
static std::string dataHomeImpl();
|
||||
static std::string cacheHomeImpl();
|
||||
static std::string tempHomeImpl();
|
||||
static std::string tempImpl();
|
||||
static std::string configImpl();
|
||||
static std::string nullImpl();
|
||||
static std::string systemImpl();
|
||||
static std::string expandImpl(const std::string& path);
|
||||
static void listRootsImpl(std::vector<std::string>& roots);
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_PATH_LEN = 32767
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Path_WINCE_INCLUDED
|
||||
@@ -22,11 +22,7 @@
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "PipeImpl_DUMMY.h"
|
||||
#else
|
||||
#include "Poco/PipeImpl_WIN32.h"
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "Poco/PipeImpl_POSIX.h"
|
||||
#else
|
||||
|
||||
+17
-7
@@ -41,7 +41,6 @@
|
||||
#define POCO_OS_ANDROID 0x000f
|
||||
#define POCO_OS_UNKNOWN_UNIX 0x00ff
|
||||
#define POCO_OS_WINDOWS_NT 0x1001
|
||||
#define POCO_OS_WINDOWS_CE 0x1011
|
||||
#define POCO_OS_VMS 0x2001
|
||||
|
||||
|
||||
@@ -61,13 +60,16 @@
|
||||
#elif defined(__NACL__)
|
||||
#define POCO_OS_FAMILY_UNIX 1
|
||||
#define POCO_OS POCO_OS_NACL
|
||||
#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__TOS_LINUX__) || defined(EMSCRIPTEN)
|
||||
#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__TOS_LINUX__) || defined(__EMSCRIPTEN__)
|
||||
#define POCO_OS_FAMILY_UNIX 1
|
||||
#if defined(__ANDROID__)
|
||||
#define POCO_OS POCO_OS_ANDROID
|
||||
#else
|
||||
#define POCO_OS POCO_OS_LINUX
|
||||
#endif
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#define POCO_EMSCRIPTEN
|
||||
#endif
|
||||
#elif defined(__APPLE__) || defined(__TOS_MACOS__)
|
||||
#define POCO_OS_FAMILY_UNIX 1
|
||||
#define POCO_OS_FAMILY_BSD 1
|
||||
@@ -98,9 +100,6 @@
|
||||
#elif defined(unix) || defined(__unix) || defined(__unix__)
|
||||
#define POCO_OS_FAMILY_UNIX 1
|
||||
#define POCO_OS POCO_OS_UNKNOWN_UNIX
|
||||
#elif defined(_WIN32_WCE)
|
||||
#define POCO_OS_FAMILY_WINDOWS 1
|
||||
#define POCO_OS POCO_OS_WINDOWS_CE
|
||||
#elif defined(_WIN32) || defined(_WIN64)
|
||||
#define POCO_OS_FAMILY_WINDOWS 1
|
||||
#define POCO_OS POCO_OS_WINDOWS_NT
|
||||
@@ -142,7 +141,7 @@
|
||||
#if defined(__ALPHA) || defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA)
|
||||
#define POCO_ARCH POCO_ARCH_ALPHA
|
||||
#define POCO_ARCH_LITTLE_ENDIAN 1
|
||||
#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(EMSCRIPTEN)
|
||||
#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(POCO_EMSCRIPTEN)
|
||||
#define POCO_ARCH POCO_ARCH_IA32
|
||||
#define POCO_ARCH_LITTLE_ENDIAN 1
|
||||
#elif defined(_IA64) || defined(__IA64__) || defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
|
||||
@@ -209,7 +208,7 @@
|
||||
#define POCO_ARCH_BIG_ENDIAN 1
|
||||
#elif defined(__sh__) || defined(__sh) || defined(SHx) || defined(_SHX_)
|
||||
#define POCO_ARCH POCO_ARCH_SH
|
||||
#if defined(__LITTLE_ENDIAN__) || (POCO_OS == POCO_OS_WINDOWS_CE)
|
||||
#if defined(__LITTLE_ENDIAN__)
|
||||
#define POCO_ARCH_LITTLE_ENDIAN 1
|
||||
#else
|
||||
#define POCO_ARCH_BIG_ENDIAN 1
|
||||
@@ -241,12 +240,23 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __SOFTFP__
|
||||
#define POCO_NO_FPENVIRONMENT
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__clang__)
|
||||
#define POCO_COMPILER_CLANG
|
||||
#if __has_include(<cxxabi.h>)
|
||||
#define POCO_HAVE_CXXABI_H
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#define POCO_COMPILER_MSVC
|
||||
#elif defined (__GNUC__)
|
||||
#define POCO_COMPILER_GCC
|
||||
#if __has_include(<cxxabi.h>)
|
||||
#define POCO_HAVE_CXXABI_H
|
||||
#endif
|
||||
#if defined (__MINGW32__) || defined (__MINGW64__)
|
||||
#define POCO_COMPILER_MINGW
|
||||
#endif
|
||||
|
||||
Loaded 100 of 3038 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user