enh(Poco::Dynamic): Modernised code to use C++17 features.

This commit is contained in:
Matej Kenda 2025-01-08 12:50:09 +01:00
parent 4ca735d7d8
commit 7495f0592c
7 changed files with 942 additions and 1013 deletions

View File

@ -111,103 +111,101 @@ public:
{
}
~VarHolderImpl()
{
}
~VarHolderImpl() override = default;
const std::type_info& type() const
const std::type_info& type() const override
{
return typeid(Pair<std::string>);
}
void convert(Int8&) const
void convert(Int8&) const override
{
throw BadCastException("Cannot cast Pair type to Int8");
}
void convert(Int16&) const
void convert(Int16&) const override
{
throw BadCastException("Cannot cast Pair type to Int16");
}
void convert(Int32&) const
void convert(Int32&) const override
{
throw BadCastException("Cannot cast Pair type to Int32");
}
void convert(Int64&) const
void convert(Int64&) const override
{
throw BadCastException("Cannot cast Pair type to Int64");
}
void convert(UInt8&) const
void convert(UInt8&) const override
{
throw BadCastException("Cannot cast Pair type to UInt8");
}
void convert(UInt16&) const
void convert(UInt16&) const override
{
throw BadCastException("Cannot cast Pair type to UInt16");
}
void convert(UInt32&) const
void convert(UInt32&) const override
{
throw BadCastException("Cannot cast Pair type to UInt32");
}
void convert(UInt64&) const
void convert(UInt64&) const override
{
throw BadCastException("Cannot cast Pair type to UInt64");
}
void convert(bool&) const
void convert(bool&) const override
{
throw BadCastException("Cannot cast Pair type to bool");
}
void convert(float&) const
void convert(float&) const override
{
throw BadCastException("Cannot cast Pair type to float");
}
void convert(double&) const
void convert(double&) const override
{
throw BadCastException("Cannot cast Pair type to double");
}
void convert(char&) const
void convert(char&) const override
{
throw BadCastException("Cannot cast Pair type to char");
}
void convert(std::string& val) const
void convert(std::string& val) const override
{
// Serialize in JSON format: equals an object
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
val.append("{ ");
Var key(_val.first());
const Var key(_val.first());
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, _val.second());
val.append(" }");
}
void convert(Poco::DateTime&) const
void convert(Poco::DateTime&) const override
{
throw BadCastException("Pair -> Poco::DateTime");
}
void convert(Poco::LocalDateTime&) const
void convert(Poco::LocalDateTime&) const override
{
throw BadCastException("Pair -> Poco::LocalDateTime");
}
void convert(Poco::Timestamp&) const
void convert(Poco::Timestamp&) const override
{
throw BadCastException("Pair -> Poco::Timestamp");
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
{
return cloneHolder(pVarHolder, _val);
}
@ -217,32 +215,32 @@ public:
return _val;
}
bool isArray() const
bool isArray() const override
{
return false;
}
bool isStruct() const
bool isStruct() const override
{
return false;
}
bool isInteger() const
bool isInteger() const override
{
return false;
}
bool isSigned() const
bool isSigned() const override
{
return false;
}
bool isNumeric() const
bool isNumeric() const override
{
return false;
}
bool isString() const
bool isString() const override
{
return false;
}
@ -260,103 +258,101 @@ public:
{
}
~VarHolderImpl()
{
}
~VarHolderImpl() override = default;
const std::type_info& type() const
const std::type_info& type() const override
{
return typeid(Pair<int>);
}
void convert(Int8&) const
void convert(Int8&) const override
{
throw BadCastException("Cannot cast Pair type to Int8");
}
void convert(Int16&) const
void convert(Int16&) const override
{
throw BadCastException("Cannot cast Pair type to Int16");
}
void convert(Int32&) const
void convert(Int32&) const override
{
throw BadCastException("Cannot cast Pair type to Int32");
}
void convert(Int64&) const
void convert(Int64&) const override
{
throw BadCastException("Cannot cast Pair type to Int64");
}
void convert(UInt8&) const
void convert(UInt8&) const override
{
throw BadCastException("Cannot cast Pair type to UInt8");
}
void convert(UInt16&) const
void convert(UInt16&) const override
{
throw BadCastException("Cannot cast Pair type to UInt16");
}
void convert(UInt32&) const
void convert(UInt32&) const override
{
throw BadCastException("Cannot cast Pair type to UInt32");
}
void convert(UInt64&) const
void convert(UInt64&) const override
{
throw BadCastException("Cannot cast Pair type to UInt64");
}
void convert(bool&) const
void convert(bool&) const override
{
throw BadCastException("Cannot cast Pair type to bool");
}
void convert(float&) const
void convert(float&) const override
{
throw BadCastException("Cannot cast Pair type to float");
}
void convert(double&) const
void convert(double&) const override
{
throw BadCastException("Cannot cast Pair type to double");
}
void convert(char&) const
void convert(char&) const override
{
throw BadCastException("Cannot cast Pair type to char");
}
void convert(std::string& val) const
void convert(std::string& val) const override
{
// Serialize in JSON format: equals an object
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
val.append("{ ");
Var key(_val.first());
const Var key(_val.first());
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, _val.second());
val.append(" }");
}
void convert(Poco::DateTime&) const
void convert(Poco::DateTime&) const override
{
throw BadCastException("Pair -> Poco::DateTime");
}
void convert(Poco::LocalDateTime&) const
void convert(Poco::LocalDateTime&) const override
{
throw BadCastException("Pair -> Poco::LocalDateTime");
}
void convert(Poco::Timestamp&) const
void convert(Poco::Timestamp&) const override
{
throw BadCastException("Pair -> Poco::Timestamp");
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
{
return cloneHolder(pVarHolder, _val);
}
@ -366,33 +362,30 @@ public:
return _val;
}
bool isArray() const
bool isArray() const override
{
return false;
}
bool isStruct() const
bool isStruct() const override {
return false;
}
bool isInteger() const override
{
return false;
}
bool isInteger() const
bool isSigned() const override {
return false;
}
bool isNumeric() const override
{
return false;
}
bool isSigned() const
{
return false;
}
bool isNumeric() const
{
return false;
}
bool isString() const
{
bool isString() const override {
return false;
}

View File

@ -44,7 +44,7 @@ std::string structToString(const S& data, bool wrap = true)
I itEnd = data.end();
if (!data.empty())
{
Var key(it->first);
const Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second, wrap);
@ -53,7 +53,7 @@ std::string structToString(const S& data, bool wrap = true)
for (; it != itEnd; ++it)
{
val.append(", ");
Var key(it->first);
const Var key(it->first);
Impl::appendJSONKey(val, key);
val.append(": ");
Impl::appendJSONValue(val, it->second, wrap);
@ -68,14 +68,14 @@ class Struct
/// Struct allows to define a named collection of Var objects.
{
public:
typedef M Data;
typedef S NameSet;
typedef typename Data::iterator Iterator;
typedef typename Data::const_iterator ConstIterator;
typedef typename Struct<K>::Data::value_type ValueType;
typedef typename Struct<K>::Data::size_type SizeType;
typedef typename std::pair<typename Struct<K, M, S>::Iterator, bool> InsRetVal;
typedef typename Poco::SharedPtr<Struct<K, M, S>> Ptr;
using Data = M;
using NameSet = S;
using Iterator = typename Data::iterator;
using ConstIterator = typename Data::const_iterator;
using ValueType = typename Struct<K>::Data::value_type;
using SizeType = typename Struct<K>::Data::size_type;
using InsRetVal = typename std::pair<typename Struct<K, M, S>::Iterator, bool>;
using Ptr = typename Poco::SharedPtr<Struct<K, M, S>>;
Struct(): _data()
/// Creates an empty Struct
@ -99,10 +99,8 @@ public:
assignMap(val);
}
virtual ~Struct()
virtual ~Struct() = default;
/// Destroys the Struct.
{
}
inline Var& operator [] (const K& name)
/// Returns the Var with the given name, creates an entry if not found.
@ -114,7 +112,7 @@ public:
/// Returns the Var with the given name, throws a
/// NotFoundException if the data member is not found.
{
ConstIterator it = find(name);
const auto it = find(name);
if (it == end()) throw NotFoundException(name);
return it->second;
}
@ -277,7 +275,7 @@ private:
template <typename T>
void assignMap(const T& map)
{
typedef typename T::const_iterator MapConstIterator;
using MapConstIterator = typename T::const_iterator;
MapConstIterator it = map.begin();
MapConstIterator end = map.end();
@ -311,105 +309,103 @@ template <>
class VarHolderImpl<Struct<std::string, std::map<std::string, Var>, std::set<std::string>>>: public VarHolder
{
public:
typedef std::string KeyType;
typedef std::map<KeyType, Var> MapType;
typedef std::set<KeyType> SetType;
typedef Struct<KeyType, MapType, SetType> ValueType;
using KeyType = std::string;
using MapType = std::map<KeyType, Var>;
using SetType = std::set<KeyType>;
using ValueType = Struct<KeyType, MapType, SetType>;
VarHolderImpl(const ValueType& val): _val(val)
{
}
~VarHolderImpl()
{
}
~VarHolderImpl() override = default;
const std::type_info& type() const
const std::type_info& type() const override
{
return typeid(ValueType);
}
void convert(Int8&) const
void convert(Int8&) const override
{
throw BadCastException("Cannot cast Struct type to Int8");
}
void convert(Int16&) const
void convert(Int16&) const override
{
throw BadCastException("Cannot cast Struct type to Int16");
}
void convert(Int32&) const
void convert(Int32&) const override
{
throw BadCastException("Cannot cast Struct type to Int32");
}
void convert(Int64&) const
void convert(Int64&) const override
{
throw BadCastException("Cannot cast Struct type to Int64");
}
void convert(UInt8&) const
void convert(UInt8&) const override
{
throw BadCastException("Cannot cast Struct type to UInt8");
}
void convert(UInt16&) const
void convert(UInt16&) const override
{
throw BadCastException("Cannot cast Struct type to UInt16");
}
void convert(UInt32&) const
void convert(UInt32&) const override
{
throw BadCastException("Cannot cast Struct type to UInt32");
}
void convert(UInt64&) const
void convert(UInt64&) const override
{
throw BadCastException("Cannot cast Struct type to UInt64");
}
void convert(bool&) const
void convert(bool&) const override
{
throw BadCastException("Cannot cast Struct type to bool");
}
void convert(float&) const
void convert(float&) const override
{
throw BadCastException("Cannot cast Struct type to float");
}
void convert(double&) const
void convert(double&) const override
{
throw BadCastException("Cannot cast Struct type to double");
}
void convert(char&) const
void convert(char&) const override
{
throw BadCastException("Cannot cast Struct type to char");
}
void convert(std::string& val) const
void convert(std::string& val) const override
{
val = structToString(_val);
}
void convert(Poco::DateTime&) const
void convert(Poco::DateTime&) const override
{
throw BadCastException("Struct -> Poco::DateTime");
}
void convert(Poco::LocalDateTime&) const
void convert(Poco::LocalDateTime&) const override
{
throw BadCastException("Struct -> Poco::LocalDateTime");
}
void convert(Poco::Timestamp&) const
void convert(Poco::Timestamp&) const override
{
throw BadCastException("Struct -> Poco::Timestamp");
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
{
return cloneHolder(pVarHolder, _val);
}
@ -419,42 +415,42 @@ public:
return _val;
}
bool isArray() const
bool isArray() const override
{
return false;
}
bool isStruct() const
bool isStruct() const override
{
return true;
}
bool isOrdered() const
bool isOrdered() const override
{
return false;
}
bool isInteger() const
bool isInteger() const override
{
return false;
}
bool isSigned() const
bool isSigned() const override
{
return false;
}
bool isNumeric() const
bool isNumeric() const override
{
return false;
}
bool isString() const
bool isString() const override
{
return false;
}
std::size_t size() const
std::size_t size() const override
{
return _val.size();
}
@ -478,105 +474,103 @@ template <>
class VarHolderImpl<Struct<int, std::map<int, Var>, std::set<int>>> : public VarHolder
{
public:
typedef int KeyType;
typedef std::map<KeyType, Var> MapType;
typedef std::set<KeyType> SetType;
typedef Struct<KeyType, MapType, SetType> ValueType;
using KeyType = int;
using MapType = std::map<KeyType, Var>;
using SetType = std::set<KeyType>;
using ValueType = Struct<KeyType, MapType, SetType>;
VarHolderImpl(const ValueType& val) : _val(val)
{
}
~VarHolderImpl()
{
}
~VarHolderImpl() override = default;
const std::type_info& type() const
const std::type_info& type() const override
{
return typeid(ValueType);
}
void convert(Int8&) const
void convert(Int8&) const override
{
throw BadCastException("Cannot cast Struct type to Int8");
}
void convert(Int16&) const
void convert(Int16&) const override
{
throw BadCastException("Cannot cast Struct type to Int16");
}
void convert(Int32&) const
void convert(Int32&) const override
{
throw BadCastException("Cannot cast Struct type to Int32");
}
void convert(Int64&) const
void convert(Int64&) const override
{
throw BadCastException("Cannot cast Struct type to Int64");
}
void convert(UInt8&) const
void convert(UInt8&) const override
{
throw BadCastException("Cannot cast Struct type to UInt8");
}
void convert(UInt16&) const
void convert(UInt16&) const override
{
throw BadCastException("Cannot cast Struct type to UInt16");
}
void convert(UInt32&) const
void convert(UInt32&) const override
{
throw BadCastException("Cannot cast Struct type to UInt32");
}
void convert(UInt64&) const
void convert(UInt64&) const override
{
throw BadCastException("Cannot cast Struct type to UInt64");
}
void convert(bool&) const
void convert(bool&) const override
{
throw BadCastException("Cannot cast Struct type to bool");
}
void convert(float&) const
void convert(float&) const override
{
throw BadCastException("Cannot cast Struct type to float");
}
void convert(double&) const
void convert(double&) const override
{
throw BadCastException("Cannot cast Struct type to double");
}
void convert(char&) const
void convert(char&) const override
{
throw BadCastException("Cannot cast Struct type to char");
}
void convert(std::string& val) const
void convert(std::string& val) const override
{
val = structToString(_val);
}
void convert(Poco::DateTime&) const
void convert(Poco::DateTime&) const override
{
throw BadCastException("Struct -> Poco::DateTime");
}
void convert(Poco::LocalDateTime&) const
void convert(Poco::LocalDateTime&) const override
{
throw BadCastException("Struct -> Poco::LocalDateTime");
}
void convert(Poco::Timestamp&) const
void convert(Poco::Timestamp&) const override
{
throw BadCastException("Struct -> Poco::Timestamp");
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
{
return cloneHolder(pVarHolder, _val);
}
@ -586,42 +580,42 @@ public:
return _val;
}
bool isArray() const
bool isArray() const override
{
return false;
}
bool isStruct() const
bool isStruct() const override
{
return true;
}
bool isOrdered() const
bool isOrdered() const override
{
return false;
}
bool isInteger() const
bool isInteger() const override
{
return false;
}
bool isSigned() const
bool isSigned() const override
{
return false;
}
bool isNumeric() const
bool isNumeric() const override
{
return false;
}
bool isString() const
bool isString() const override
{
return false;
}
std::size_t size() const
std::size_t size() const override
{
return _val.size();
}
@ -645,105 +639,103 @@ template <>
class VarHolderImpl<Struct<std::string, Poco::OrderedMap<std::string, Var>, Poco::OrderedSet<std::string>>> : public VarHolder
{
public:
typedef std::string KeyType;
typedef Poco::OrderedMap<KeyType, Var> MapType;
typedef Poco::OrderedSet<KeyType> SetType;
typedef Struct<KeyType, MapType, SetType> ValueType;
using KeyType = std::string;
using MapType = Poco::OrderedMap<KeyType, Var>;
using SetType = Poco::OrderedSet<KeyType>;
using ValueType = Struct<KeyType, MapType, SetType>;
VarHolderImpl(const ValueType& val) : _val(val)
{
}
~VarHolderImpl()
{
}
~VarHolderImpl() override = default;
const std::type_info& type() const
const std::type_info& type() const override
{
return typeid(ValueType);
}
void convert(Int8&) const
void convert(Int8&) const override
{
throw BadCastException("Cannot cast Struct type to Int8");
}
void convert(Int16&) const
void convert(Int16&) const override
{
throw BadCastException("Cannot cast Struct type to Int16");
}
void convert(Int32&) const
void convert(Int32&) const override
{
throw BadCastException("Cannot cast Struct type to Int32");
}
void convert(Int64&) const
void convert(Int64&) const override
{
throw BadCastException("Cannot cast Struct type to Int64");
}
void convert(UInt8&) const
void convert(UInt8&) const override
{
throw BadCastException("Cannot cast Struct type to UInt8");
}
void convert(UInt16&) const
void convert(UInt16&) const override
{
throw BadCastException("Cannot cast Struct type to UInt16");
}
void convert(UInt32&) const
void convert(UInt32&) const override
{
throw BadCastException("Cannot cast Struct type to UInt32");
}
void convert(UInt64&) const
void convert(UInt64&) const override
{
throw BadCastException("Cannot cast Struct type to UInt64");
}
void convert(bool&) const
void convert(bool&) const override
{
throw BadCastException("Cannot cast Struct type to bool");
}
void convert(float&) const
void convert(float&) const override
{
throw BadCastException("Cannot cast Struct type to float");
}
void convert(double&) const
void convert(double&) const override
{
throw BadCastException("Cannot cast Struct type to double");
}
void convert(char&) const
void convert(char&) const override
{
throw BadCastException("Cannot cast Struct type to char");
}
void convert(std::string& val) const
void convert(std::string&val) const override
{
val = structToString(_val);
}
void convert(Poco::DateTime&) const
void convert(Poco::DateTime&) const override
{
throw BadCastException("Struct -> Poco::DateTime");
}
void convert(Poco::LocalDateTime&) const
void convert(Poco::LocalDateTime&) const override
{
throw BadCastException("Struct -> Poco::LocalDateTime");
}
void convert(Poco::Timestamp&) const
void convert(Poco::Timestamp&) const override
{
throw BadCastException("Struct -> Poco::Timestamp");
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
{
return cloneHolder(pVarHolder, _val);
}
@ -753,42 +745,42 @@ public:
return _val;
}
bool isArray() const
bool isArray() const override
{
return false;
}
bool isStruct() const
bool isStruct() const override
{
return true;
}
bool isOrdered() const
bool isOrdered() const override
{
return true;
}
bool isInteger() const
bool isInteger() const override
{
return false;
}
bool isSigned() const
bool isSigned() const override
{
return false;
}
bool isNumeric() const
bool isNumeric() const override
{
return false;
}
bool isString() const
bool isString() const override
{
return false;
}
std::size_t size() const
std::size_t size() const override
{
return _val.size();
}
@ -812,105 +804,103 @@ template <>
class VarHolderImpl<Struct<int, Poco::OrderedMap<int, Var>, Poco::OrderedSet<int>>> : public VarHolder
{
public:
typedef int KeyType;
typedef Poco::OrderedMap<KeyType, Var> MapType;
typedef Poco::OrderedSet<KeyType> SetType;
typedef Struct<KeyType, MapType, SetType> ValueType;
using KeyType = int;
using MapType = Poco::OrderedMap<KeyType, Var>;
using SetType = Poco::OrderedSet<KeyType>;
using ValueType = Struct<KeyType, MapType, SetType>;
VarHolderImpl(const ValueType& val) : _val(val)
{
}
~VarHolderImpl()
{
}
~VarHolderImpl() override = default;
const std::type_info& type() const
const std::type_info&type() const override
{
return typeid(ValueType);
}
void convert(Int8&) const
void convert(Int8&) const override
{
throw BadCastException("Cannot cast Struct type to Int8");
}
void convert(Int16&) const
void convert(Int16&) const override
{
throw BadCastException("Cannot cast Struct type to Int16");
}
void convert(Int32&) const
void convert(Int32&) const override
{
throw BadCastException("Cannot cast Struct type to Int32");
}
void convert(Int64&) const
void convert(Int64&) const override
{
throw BadCastException("Cannot cast Struct type to Int64");
}
void convert(UInt8&) const
void convert(UInt8&) const override
{
throw BadCastException("Cannot cast Struct type to UInt8");
}
void convert(UInt16&) const
void convert(UInt16&) const override
{
throw BadCastException("Cannot cast Struct type to UInt16");
}
void convert(UInt32&) const
void convert(UInt32&) const override
{
throw BadCastException("Cannot cast Struct type to UInt32");
}
void convert(UInt64&) const
void convert(UInt64&) const override
{
throw BadCastException("Cannot cast Struct type to UInt64");
}
void convert(bool&) const
void convert(bool&) const override
{
throw BadCastException("Cannot cast Struct type to bool");
}
void convert(float&) const
void convert(float&) const override
{
throw BadCastException("Cannot cast Struct type to float");
}
void convert(double&) const
void convert(double&) const override
{
throw BadCastException("Cannot cast Struct type to double");
}
void convert(char&) const
void convert(char&) const override
{
throw BadCastException("Cannot cast Struct type to char");
}
void convert(std::string& val) const
void convert(std::string& val) const override
{
val = structToString(_val);
}
void convert(Poco::DateTime&) const
void convert(Poco::DateTime&) const override
{
throw BadCastException("Struct -> Poco::DateTime");
}
void convert(Poco::LocalDateTime&) const
void convert(Poco::LocalDateTime&) const override
{
throw BadCastException("Struct -> Poco::LocalDateTime");
}
void convert(Poco::Timestamp&) const
void convert(Poco::Timestamp&) const override
{
throw BadCastException("Struct -> Poco::Timestamp");
}
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
VarHolder *clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
{
return cloneHolder(pVarHolder, _val);
}
@ -920,42 +910,42 @@ public:
return _val;
}
bool isArray() const
bool isArray() const override
{
return false;
}
bool isStruct() const
bool isStruct() const override
{
return true;
}
bool isOrdered() const
bool isOrdered() const override
{
return true;
}
bool isInteger() const
bool isInteger() const override
{
return false;
}
bool isSigned() const
bool isSigned() const override
{
return false;
}
bool isNumeric() const
bool isNumeric() const override
{
return false;
}
bool isString() const
bool isString() const override
{
return false;
}
std::size_t size() const
std::size_t size() const override
{
return _val.size();
}

View File

@ -185,16 +185,14 @@ public:
VarHolder* pHolder = content();
if (!pHolder)
throw InvalidAccessException("Can not convert empty value.");
throw InvalidAccessException("Can not convert empty value.");
if (typeid(T) == pHolder->type())
return extract<T>();
else
{
T result;
pHolder->convert(result);
return result;
}
T result;
pHolder->convert(result);
return result;
}
template <typename T>
@ -208,12 +206,13 @@ public:
{
VarHolder* pHolder = content();
if (pHolder && pHolder->type() == typeid(T))
if ( (pHolder != nullptr) && pHolder->type() == typeid(T))
{
auto* pHolderImpl = static_cast<VarHolderImpl<T>*>(pHolder);
return pHolderImpl->value();
}
else if (!pHolder)
if (!pHolder)
throw InvalidAccessException("Can not extract empty value.");
else
throw BadCastException(Poco::format("Can not convert %s to %s.",
@ -580,7 +579,8 @@ private:
if (pHolder && pHolder->type() == typeid(T))
return static_cast<VarHolderImpl<T>*>(pHolder);
else if (!pHolder)
if (pHolder == nullptr)
throw InvalidAccessException("Can not access empty value.");
else
throw E(errorMessage);
@ -625,7 +625,7 @@ private:
inline void Var::construct(const char* value)
{
std::string val(value);
const std::string val(value);
_placeholder.assign<VarHolderImpl<std::string>, std::string>(val);
}
@ -647,7 +647,7 @@ inline void Var::swap(Var& other)
}
else
{
Var tmp(*this);
const Var tmp(*this);
try
{
construct(other);
@ -665,39 +665,39 @@ inline void Var::swap(Var& other)
inline const std::type_info& Var::type() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->type() : typeid(void);
return (pHolder != nullptr) ? pHolder->type() : typeid(void);
}
inline std::string Var::typeName(bool demangle) const
{
VarHolder* pHolder = content();
return pHolder ? demangle ? Poco::demangle(pHolder->type().name()) : pHolder->type().name() : std::string();
return (pHolder != nullptr) ? 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);
if (size() == 0) return {const_cast<Var*>(this), true};
return ConstIterator(const_cast<Var*>(this), false);
return {const_cast<Var*>(this), false};
}
inline Var::ConstIterator Var::end() const
{
return ConstIterator(const_cast<Var*>(this), true);
return {const_cast<Var*>(this), true};
}
inline Var::Iterator Var::begin()
{
if (size() == 0) return Iterator(const_cast<Var*>(this), true);
if (size() == 0) return {const_cast<Var*>(this), true};
return Iterator(const_cast<Var*>(this), false);
return {const_cast<Var*>(this), false};
}
inline Var::Iterator Var::end()
{
return Iterator(this, true);
return {this, true};
}
@ -742,112 +742,112 @@ inline bool Var::isArray() const
if (isEmpty() || isString()) return false;
VarHolder* pHolder = content();
return pHolder ? pHolder->isArray() : false;
return (pHolder != nullptr) ? pHolder->isArray() : false;
}
inline bool Var::isVector() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isVector() : false;
return (pHolder != nullptr) ? pHolder->isVector() : false;
}
inline bool Var::isList() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isList() : false;
return (pHolder != nullptr) ? pHolder->isList() : false;
}
inline bool Var::isDeque() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isDeque() : false;
return (pHolder != nullptr) ? pHolder->isDeque() : false;
}
inline bool Var::isStruct() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isStruct() : false;
return (pHolder != nullptr) ? pHolder->isStruct() : false;
}
inline bool Var::isOrdered() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isOrdered() : false;
return (pHolder != nullptr) ? pHolder->isOrdered() : false;
}
inline bool Var::isInteger() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isInteger() : false;
return (pHolder != nullptr) ? pHolder->isInteger() : false;
}
inline bool Var::isSigned() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isSigned() : false;
return (pHolder != nullptr) ? pHolder->isSigned() : false;
}
inline bool Var::isNumeric() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isNumeric() : false;
return (pHolder != nullptr) ? pHolder->isNumeric() : false;
}
inline bool Var::isBoolean() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isBoolean() : false;
return (pHolder != nullptr) ? pHolder->isBoolean() : false;
}
inline bool Var::isString() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isString() : false;
return (pHolder != nullptr) ? pHolder->isString() : false;
}
inline bool Var::isDate() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isDate() : false;
return (pHolder != nullptr) ? pHolder->isDate() : false;
}
inline bool Var::isTime() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isTime() : false;
return (pHolder != nullptr) ? pHolder->isTime() : false;
}
inline bool Var::isDateTime() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isDateTime() : false;
return (pHolder != nullptr) ? pHolder->isDateTime() : false;
}
inline bool Var::isUUID() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isUUID() : false;
return (pHolder != nullptr) ? pHolder->isUUID() : false;
}
inline std::size_t Var::size() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->size() : 0;
return (pHolder != nullptr) ? pHolder->size() : 0;
}
@ -858,7 +858,7 @@ inline std::size_t Var::size() const
inline const Var operator + (const char* other, const Var& da)
/// Addition operator for adding Var to const char*
{
std::string tmp = other;
const std::string tmp = other;
return tmp + da.convert<std::string>();
}

File diff suppressed because it is too large Load Diff

View File

@ -34,11 +34,11 @@ class Foundation_API VarIterator
/// VarIterator class.
{
public:
typedef std::bidirectional_iterator_tag iterator_category;
typedef Var value_type;
typedef std::ptrdiff_t difference_type;
typedef Var* pointer;
typedef Var& reference;
using iterator_category = std::bidirectional_iterator_tag;
using value_type = Var;
using difference_type = std::ptrdiff_t;
using pointer = Var *;
using reference = Var &;
static const std::size_t POSITION_END;
/// End position indicator.

View File

@ -150,7 +150,7 @@ namespace Poco {
using LineNumber = decltype(__LINE__);
}
} // namespace Poco
//
// Pull in basic definitions

View File

@ -36,7 +36,7 @@
namespace Poco {
using Int8 = std::conditional<std::is_same<signed char, std::int8_t>::value, std::int8_t, signed char>::type;
using Int8 = std::conditional_t<std::is_same_v<signed char, std::int8_t>, std::int8_t, signed char>;
using UInt8 = std::uint8_t;
using Int16 = std::int16_t;
using UInt16 = std::uint16_t;
@ -88,7 +88,7 @@ inline std::string Foundation_API demangle(const char* typeName)
#ifdef POCO_HAVE_CXXABI_H
int status;
char* demangled = abi::__cxa_demangle(typeName, nullptr, nullptr, &status);
if (demangled)
if (demangled != nullptr)
{
if (status == 0) result = demangled;
else