From 7495f0592c12faa016d4ce9ee53c0729d37c7b88 Mon Sep 17 00:00:00 2001 From: Matej Kenda Date: Wed, 8 Jan 2025 12:50:09 +0100 Subject: [PATCH] enh(Poco::Dynamic): Modernised code to use C++17 features. --- Foundation/include/Poco/Dynamic/Pair.h | 123 +- Foundation/include/Poco/Dynamic/Struct.h | 284 ++-- Foundation/include/Poco/Dynamic/Var.h | 74 +- Foundation/include/Poco/Dynamic/VarHolder.h | 1458 ++++++++--------- Foundation/include/Poco/Dynamic/VarIterator.h | 10 +- Foundation/include/Poco/Foundation.h | 2 +- Foundation/include/Poco/Types.h | 4 +- 7 files changed, 942 insertions(+), 1013 deletions(-) diff --git a/Foundation/include/Poco/Dynamic/Pair.h b/Foundation/include/Poco/Dynamic/Pair.h index e9bfa84c5..822cba5ea 100644 --- a/Foundation/include/Poco/Dynamic/Pair.h +++ b/Foundation/include/Poco/Dynamic/Pair.h @@ -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); } - 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* pVarHolder = 0) const + VarHolder* clone(Placeholder* 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); } - 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* pVarHolder = 0) const + VarHolder* clone(Placeholder* 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; } diff --git a/Foundation/include/Poco/Dynamic/Struct.h b/Foundation/include/Poco/Dynamic/Struct.h index f5c9cffbb..433461947 100644 --- a/Foundation/include/Poco/Dynamic/Struct.h +++ b/Foundation/include/Poco/Dynamic/Struct.h @@ -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::Data::value_type ValueType; - typedef typename Struct::Data::size_type SizeType; - typedef typename std::pair::Iterator, bool> InsRetVal; - typedef typename Poco::SharedPtr> Ptr; + using Data = M; + using NameSet = S; + using Iterator = typename Data::iterator; + using ConstIterator = typename Data::const_iterator; + using ValueType = typename Struct::Data::value_type; + using SizeType = typename Struct::Data::size_type; + using InsRetVal = typename std::pair::Iterator, bool>; + using Ptr = typename Poco::SharedPtr>; 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 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, std::set>>: public VarHolder { public: - typedef std::string KeyType; - typedef std::map MapType; - typedef std::set SetType; - typedef Struct ValueType; + using KeyType = std::string; + using MapType = std::map; + using SetType = std::set; + using ValueType = Struct; 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* pVarHolder = 0) const + VarHolder* clone(Placeholder* 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, std::set>> : public VarHolder { public: - typedef int KeyType; - typedef std::map MapType; - typedef std::set SetType; - typedef Struct ValueType; + using KeyType = int; + using MapType = std::map; + using SetType = std::set; + using ValueType = Struct; 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* pVarHolder = 0) const + VarHolder* clone(Placeholder* 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, Poco::OrderedSet>> : public VarHolder { public: - typedef std::string KeyType; - typedef Poco::OrderedMap MapType; - typedef Poco::OrderedSet SetType; - typedef Struct ValueType; + using KeyType = std::string; + using MapType = Poco::OrderedMap; + using SetType = Poco::OrderedSet; + using ValueType = Struct; 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* pVarHolder = 0) const + VarHolder* clone(Placeholder* 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, Poco::OrderedSet>> : public VarHolder { public: - typedef int KeyType; - typedef Poco::OrderedMap MapType; - typedef Poco::OrderedSet SetType; - typedef Struct ValueType; + using KeyType = int; + using MapType = Poco::OrderedMap; + using SetType = Poco::OrderedSet; + using ValueType = Struct; 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* pVarHolder = 0) const + VarHolder *clone(Placeholder* 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(); } diff --git a/Foundation/include/Poco/Dynamic/Var.h b/Foundation/include/Poco/Dynamic/Var.h index 2eec24cd9..ad1b8d59d 100644 --- a/Foundation/include/Poco/Dynamic/Var.h +++ b/Foundation/include/Poco/Dynamic/Var.h @@ -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(); - else - { - T result; - pHolder->convert(result); - return result; - } + + T result; + pHolder->convert(result); + return result; } template @@ -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*>(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*>(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, 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(this), true); + if (size() == 0) return {const_cast(this), true}; - return ConstIterator(const_cast(this), false); + return {const_cast(this), false}; } inline Var::ConstIterator Var::end() const { - return ConstIterator(const_cast(this), true); + return {const_cast(this), true}; } inline Var::Iterator Var::begin() { - if (size() == 0) return Iterator(const_cast(this), true); + if (size() == 0) return {const_cast(this), true}; - return Iterator(const_cast(this), false); + return {const_cast(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(); } diff --git a/Foundation/include/Poco/Dynamic/VarHolder.h b/Foundation/include/Poco/Dynamic/VarHolder.h index cac21b780..8bafc1760 100644 --- a/Foundation/include/Poco/Dynamic/VarHolder.h +++ b/Foundation/include/Poco/Dynamic/VarHolder.h @@ -367,7 +367,7 @@ protected: template && !std::is_signed_v, F>* = nullptr, - std::enable_if_t<(std::is_integral_v && !std::is_signed::value) || std::is_floating_point::value, T>* = nullptr> + std::enable_if_t<(std::is_integral_v && !std::is_signed_v) || std::is_floating_point_v, 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 @@ -814,16 +814,18 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(T); } - void convert(Int8& val) const + void convert(Int8& val) const override { if constexpr (std::is_enum_v) { @@ -835,7 +837,7 @@ public: } } - void convert(Int16& val) const + void convert(Int16& val) const override { if constexpr (std::is_enum_v) { @@ -847,7 +849,7 @@ public: } } - void convert(Int32& val) const + void convert(Int32& val) const override { if constexpr (std::is_enum_v) { @@ -859,7 +861,7 @@ public: } } - void convert(Int64& val) const + void convert(Int64& val) const override { if constexpr (std::is_enum_v) { @@ -871,7 +873,7 @@ public: } } - void convert(UInt8& val) const + void convert(UInt8& val) const override { if constexpr (std::is_enum_v) { @@ -883,7 +885,7 @@ public: } } - void convert(UInt16& val) const + void convert(UInt16& val) const override { if constexpr (std::is_enum_v) { @@ -895,7 +897,7 @@ public: } } - void convert(UInt32& val) const + void convert(UInt32& val) const override { if constexpr (std::is_enum_v) { @@ -907,7 +909,7 @@ public: } } - void convert(UInt64& val) const + void convert(UInt64& val) const override { if constexpr (std::is_enum_v) { @@ -921,7 +923,7 @@ public: #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { if constexpr (std::is_enum_v) { @@ -933,7 +935,7 @@ public: } } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { if constexpr (std::is_enum_v) { @@ -947,7 +949,7 @@ public: #endif - void convert(bool& val) const + void convert(bool& val) const override { if constexpr (std::is_enum_v) { @@ -959,7 +961,7 @@ public: } } - void convert(float& val) const + void convert(float& val) const override { if constexpr (std::is_enum_v) { @@ -971,7 +973,7 @@ public: } } - void convert(double& val) const + void convert(double& val) const override { if constexpr (std::is_enum_v) { @@ -983,7 +985,7 @@ public: } } - void convert(char& val) const + void convert(char& val) const override { if constexpr (std::is_enum_v) { @@ -995,7 +997,7 @@ public: } } - void convert(std::string& val) const + void convert(std::string& val) const override { if constexpr (std::is_enum_v) { @@ -1007,7 +1009,7 @@ public: } } - void convert(Poco::UTF16String& val) const + void convert(Poco::UTF16String& val) const override { if constexpr (std::is_enum_v) { @@ -1020,7 +1022,7 @@ public: } } - bool isArray() const + bool isArray() const override { if constexpr (std::is_enum_v) { @@ -1032,7 +1034,7 @@ public: } } - bool isStruct() const + bool isStruct() const override { if constexpr (std::is_enum_v) { @@ -1044,7 +1046,7 @@ public: } } - bool isInteger() const + bool isInteger() const override { if constexpr (std::is_enum_v) { @@ -1056,7 +1058,7 @@ public: } } - bool isSigned() const + bool isSigned() const override { if constexpr (std::is_enum_v) { @@ -1068,7 +1070,7 @@ public: } } - bool isNumeric() const + bool isNumeric() const override { if constexpr (std::is_enum_v) { @@ -1080,7 +1082,7 @@ public: } } - bool isBoolean() const + bool isBoolean() const override { if constexpr (std::is_enum_v) { @@ -1092,7 +1094,7 @@ public: } } - bool isString() const + bool isString() const override { if constexpr (std::is_enum_v) { @@ -1104,7 +1106,7 @@ public: } } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -1115,10 +1117,6 @@ public: } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - T _val; }; @@ -1131,101 +1129,103 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(Int8); } - void convert(Int8& val) const + void convert(Int8& val) const override { val = _val; } - void convert(Int16& val) const + void convert(Int16& val) const override { val = _val; } - void convert(Int32& val) const + void convert(Int32& val) const override { val = _val; } - void convert(Int64& val) const + void convert(Int64& val) const override { val = _val; } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { convertSignedToUnsigned(_val, val); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = _val; } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { convertSignedToUnsigned(_val, val); } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { convertToFP(_val, val); } - void convert(double& val) const + void convert(double& val) const override { convertToFP(_val, val); } - void convert(char& val) const + void convert(char& val) const override { val = static_cast(_val); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - void convert(Poco::UTF16String& val) const + void convert(Poco::UTF16String& val) const override { - std::string str = NumberFormatter::format(_val); + const std::string str = NumberFormatter::format(_val); Poco::UnicodeConverter::convert(str, val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -1235,46 +1235,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - Int8 _val; }; @@ -1287,103 +1283,105 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(Int16); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertToSmaller(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { val = _val; } - void convert(Int32& val) const + void convert(Int32& val) const override { val = _val; } - void convert(Int64& val) const + void convert(Int64& val) const override { val = _val; } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { convertSignedToUnsigned(_val, val); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = _val; } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { convertSignedToUnsigned(_val, val); } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { convertToFP(_val, val); } - void convert(double& val) const + void convert(double& val) const override { convertToFP(_val, val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - void convert(Poco::UTF16String& val) const + void convert(Poco::UTF16String& val) const override { - std::string str = NumberFormatter::format(_val); + const std::string str = NumberFormatter::format(_val); Poco::UnicodeConverter::convert(str, val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -1393,41 +1391,37 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - Int16 _val; }; @@ -1440,97 +1434,99 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(Int32); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertToSmaller(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertToSmaller(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { val = _val; } - void convert(Int64& val) const + void convert(Int64& val) const override { val = _val; } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { convertSignedToUnsigned(_val, val); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = _val; } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { convertSignedToUnsigned(_val, val); } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { convertToFP(_val, val); } - void convert(double& val) const + void convert(double& val) const override { convertToFP(_val, val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -1540,46 +1536,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - Int32 _val; }; @@ -1592,112 +1584,114 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(Int64); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertToSmaller(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertToSmaller(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { convertToSmaller(_val, val); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = _val; } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { convertSignedToUnsigned(_val, val); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = _val; } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { convertSignedToUnsigned(_val, val); } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { convertToFP(_val, val); } - void convert(double& val) const + void convert(double& val) const override { convertToFP(_val, val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - void convert(DateTime& dt) const + void convert(DateTime& dt) const override { dt = Timestamp(_val); } - void convert(LocalDateTime& ldt) const + void convert(LocalDateTime& ldt) const override { ldt = Timestamp(_val); } - void convert(Timestamp& val) const + void convert(Timestamp& val) const override { val = Timestamp(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -1707,46 +1701,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - Int64 _val; }; @@ -1759,97 +1749,99 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(UInt8); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { val = static_cast(_val); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = static_cast(_val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { val = _val; } - void convert(UInt16& val) const + void convert(UInt16& val) const override { val = _val; } - void convert(UInt32& val) const + void convert(UInt32& val) const override { val = _val; } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = _val; } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = static_cast(_val); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = _val; } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { convertToFP(_val, val); } - void convert(double& val) const + void convert(double& val) const override { convertToFP(_val, val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -1859,46 +1851,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - UInt8 _val; }; @@ -1911,97 +1899,99 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(UInt16); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = static_cast(_val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { val = _val; } - void convert(UInt32& val) const + void convert(UInt32& val) const override { val = _val; } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = _val; } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = static_cast(_val); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = _val; } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { convertToFP(_val, val); } - void convert(double& val) const + void convert(double& val) const override { convertToFP(_val, val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -2011,46 +2001,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - UInt16 _val; }; @@ -2063,97 +2049,99 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(UInt32); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int64& val) const + void convert(Int64& val) const override { convertUnsignedToSigned(_val, val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { val = _val; } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = _val; } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { convertUnsignedToSigned(_val, val); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = _val; } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { convertToFP(_val, val); } - void convert(double& val) const + void convert(double& val) const override { convertToFP(_val, val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -2163,46 +2151,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - UInt32 _val; }; @@ -2215,118 +2199,120 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(UInt64); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int64& val) const + void convert(Int64& val) const override { convertUnsignedToSigned(_val, val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = _val; } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { convertUnsignedToSigned(_val, val); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = _val; } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { convertToFP(_val, val); } - void convert(double& val) const + void convert(double& val) const override { convertToFP(_val, val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - void convert(DateTime& dt) const + void convert(DateTime& dt) const override { Int64 val; convertUnsignedToSigned(_val, val); dt = Timestamp(val); } - void convert(LocalDateTime& ldt) const + void convert(LocalDateTime& ldt) const override { Int64 val; convertUnsignedToSigned(_val, val); ldt = Timestamp(val); } - void convert(Timestamp& val) const + void convert(Timestamp& val) const override { Int64 tmp; convertUnsignedToSigned(_val, tmp); val = Timestamp(tmp); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -2336,46 +2322,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - UInt64 _val; }; @@ -2388,95 +2370,96 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; - const std::type_info& type() const + const std::type_info& type() const override { return typeid(bool); } - void convert(Int8& val) const + void convert(Int8& val) const override { val = static_cast(_val ? 1 : 0); } - void convert(Int16& val) const + void convert(Int16& val) const override { val = static_cast(_val ? 1 : 0); } - void convert(Int32& val) const + void convert(Int32& val) const override { val = static_cast(_val ? 1 : 0); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = static_cast(_val ? 1 : 0); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { val = static_cast(_val ? 1 : 0); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { val = static_cast(_val ? 1 : 0); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { val = static_cast(_val ? 1 : 0); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = static_cast(_val ? 1 : 0); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = static_cast(_val ? 1 : 0); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = static_cast(_val ? 1 : 0); } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = _val; } - void convert(float& val) const + void convert(float& val) const override { val = (_val ? 1.0f : 0.0f); } - void convert(double& val) const + void convert(double& val) const override { val = (_val ? 1.0 : 0.0); } - void convert(char& val) const + void convert(char& val) const override { val = static_cast(_val ? 1 : 0); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = (_val ? "true" : "false"); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -2486,46 +2469,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return true; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - bool _val; }; @@ -2538,98 +2517,100 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(float); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertToSmaller(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertToSmaller(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { convertToSmaller(_val, val); } - void convert(Int64& val) const + void convert(Int64& val) const override { convertToSmaller(_val, val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertSignedFloatToUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertSignedFloatToUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertSignedFloatToUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { convertSignedFloatToUnsigned(_val, val); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { convertToSmaller(_val, val); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { convertSignedFloatToUnsigned(_val, val); } #endif - void convert(bool& val) const + void convert(bool& val) const override { - val = !(_val <= std::numeric_limits::min() && - _val >= -1 * std::numeric_limits::min()); + val = _val > std::numeric_limits::min() || + _val < -1 * std::numeric_limits::min(); } - void convert(float& val) const + void convert(float& val) const override { val = _val; } - void convert(double& val) const + void convert(double& val) const override { val = _val; } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -2639,46 +2620,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - float _val; }; @@ -2691,79 +2668,81 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(double); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertToSmaller(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertToSmaller(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { convertToSmaller(_val, val); } - void convert(Int64& val) const + void convert(Int64& val) const override { convertToSmaller(_val, val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertSignedFloatToUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertSignedFloatToUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertSignedFloatToUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { convertSignedFloatToUnsigned(_val, val); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { convertToSmaller(_val, val); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { convertSignedFloatToUnsigned(_val, val); } #endif - void convert(bool& val) const + void convert(bool& val) const override { - val = !(_val <= std::numeric_limits::min() && - _val >= -1 * std::numeric_limits::min()); + val = _val > std::numeric_limits::min() || + _val < -1 * std::numeric_limits::min(); } - void convert(float& val) const + void convert(float& val) const override { - double fMin = -1 * std::numeric_limits::max(); - double fMax = std::numeric_limits::max(); + const double fMin = -1 * std::numeric_limits::max(); + const double fMax = std::numeric_limits::max(); if (_val < fMin) throw RangeException("Value too small."); if (_val > fMax) throw RangeException("Value too large."); @@ -2771,24 +2750,24 @@ public: val = static_cast(_val); } - void convert(double& val) const + void convert(double& val) const override { val = _val; } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -2798,46 +2777,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - double _val; }; @@ -2850,95 +2825,97 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(char); } - void convert(Int8& val) const + void convert(Int8& val) const override { val = static_cast(_val); } - void convert(Int16& val) const + void convert(Int16& val) const override { val = static_cast(_val); } - void convert(Int32& val) const + void convert(Int32& val) const override { val = static_cast(_val); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = static_cast(_val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { val = static_cast(_val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { val = static_cast(_val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { val = static_cast(_val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = static_cast(_val); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = static_cast(_val); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = static_cast(_val); } #endif - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != '\0'); } - void convert(float& val) const + void convert(float& val) const override { val = static_cast(_val); } - void convert(double& val) const + void convert(double& val) const override { val = static_cast(_val); } - void convert(char& val) const + void convert(char& val) const override { val = _val; } - void convert(std::string& val) const + void convert(std::string& val) const override { val = std::string(1, _val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -2948,46 +2925,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - char _val; }; @@ -3004,74 +2977,76 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(std::string); } - void convert(Int8& val) const + void convert(Int8& val) const override { - int v = NumberParser::parse(_val); + const int v = NumberParser::parse(_val); convertToSmaller(v, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { - int v = NumberParser::parse(_val); + const int v = NumberParser::parse(_val); convertToSmaller(v, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { val = NumberParser::parse(_val); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = NumberParser::parse64(_val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { - unsigned int v = NumberParser::parseUnsigned(_val); + const unsigned int v = NumberParser::parseUnsigned(_val); convertToSmallerUnsigned(v, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { - unsigned int v = NumberParser::parseUnsigned(_val); + const unsigned int v = NumberParser::parseUnsigned(_val); convertToSmallerUnsigned(v, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { val = NumberParser::parseUnsigned(_val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = NumberParser::parseUnsigned64(_val); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = NumberParser::parse64(_val); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = NumberParser::parseUnsigned64(_val); } #endif - void convert(bool& val) const + void convert(bool& val) const override { if (_val.empty()) { @@ -3085,18 +3060,18 @@ public: (icompare(_val, VAL_FALSE) != 0)); } - void convert(float& val) const + void convert(float& val) const override { - double v = NumberParser::parseFloat(_val); + const double v = NumberParser::parseFloat(_val); convertToSmaller(v, val); } - void convert(double& val) const + void convert(double& val) const override { val = NumberParser::parseFloat(_val); } - void convert(char& val) const + void convert(char& val) const override { if (_val.empty()) val = '\0'; @@ -3104,24 +3079,24 @@ public: val = _val[0]; } - void convert(std::string& val) const + void convert(std::string& val) const override { val = _val; } - void convert(Poco::UTF16String& val) const + void convert(Poco::UTF16String& val) const override { Poco::UnicodeConverter::convert(_val, val); } - void convert(DateTime& val) const + void convert(DateTime& val) const override { int tzd = 0; if (!DateTimeParser::tryParse(DateTimeFormat::ISO8601_FORMAT, _val, val, tzd)) throw BadCastException("string -> DateTime"); } - void convert(LocalDateTime& ldt) const + void convert(LocalDateTime& ldt) const override { int tzd = 0; DateTime tmp; @@ -3131,7 +3106,7 @@ public: ldt = LocalDateTime(tzd, tmp, false); } - void convert(Timestamp& ts) const + void convert(Timestamp& ts) const override { int tzd = 0; DateTime tmp; @@ -3141,12 +3116,12 @@ public: ts = tmp.timestamp(); } - void convert(UUID& uuid) const + void convert(UUID& uuid) const override { uuid.parse(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -3156,12 +3131,12 @@ public: return _val; } - bool isString() const + bool isString() const override { return true; } - std::size_t size() const + std::size_t size() const override { return _val.length(); } @@ -3181,10 +3156,6 @@ public: } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - std::string _val; }; @@ -3201,74 +3172,76 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(Poco::UTF16String); } - void convert(Int8& val) const + void convert(Int8& val) const override { - int v = NumberParser::parse(toStdString()); + const int v = NumberParser::parse(toStdString()); convertToSmaller(v, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { - int v = NumberParser::parse(toStdString()); + const int v = NumberParser::parse(toStdString()); convertToSmaller(v, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { val = NumberParser::parse(toStdString()); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = NumberParser::parse64(toStdString()); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { - unsigned int v = NumberParser::parseUnsigned(toStdString()); + const unsigned int v = NumberParser::parseUnsigned(toStdString()); convertToSmallerUnsigned(v, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { - unsigned int v = NumberParser::parseUnsigned(toStdString()); + const unsigned int v = NumberParser::parseUnsigned(toStdString()); convertToSmallerUnsigned(v, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { val = NumberParser::parseUnsigned(toStdString()); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = NumberParser::parseUnsigned64(toStdString()); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = NumberParser::parse64(toStdString()); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = NumberParser::parseUnsigned64(toStdString()); } #endif - void convert(bool& val) const + void convert(bool& val) const override { static const std::string VAL_FALSE("false"); static const std::string VAL_INT_FALSE("0"); @@ -3281,18 +3254,18 @@ public: (icompare(str, VAL_FALSE) != 0)); } - void convert(float& val) const + void convert(float& val) const override { - double v = NumberParser::parseFloat(toStdString()); + const double v = NumberParser::parseFloat(toStdString()); convertToSmaller(v, val); } - void convert(double& val) const + void convert(double& val) const override { val = NumberParser::parseFloat(toStdString()); } - void convert(char& val) const + void convert(char& val) const override { if (_val.empty()) val = '\0'; @@ -3304,24 +3277,24 @@ public: } } - void convert(Poco::UTF16String& val) const + void convert(Poco::UTF16String& val) const override { val = _val; } - void convert(std::string& val) const + void convert(std::string& val) const override { UnicodeConverter::convert(_val, val); } - void convert(DateTime& val) const + void convert(DateTime& val) const override { int tzd = 0; if (!DateTimeParser::tryParse(DateTimeFormat::ISO8601_FORMAT, toStdString(), val, tzd)) throw BadCastException("string -> DateTime"); } - void convert(LocalDateTime& ldt) const + void convert(LocalDateTime& ldt) const override { int tzd = 0; DateTime tmp; @@ -3331,7 +3304,7 @@ public: ldt = LocalDateTime(tzd, tmp, false); } - void convert(Timestamp& ts) const + void convert(Timestamp& ts) const override { int tzd = 0; DateTime tmp; @@ -3341,7 +3314,7 @@ public: ts = tmp.timestamp(); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -3351,12 +3324,12 @@ public: return _val; } - bool isString() const + bool isString() const override { return true; } - std::size_t size() const + std::size_t size() const override { return _val.length(); } @@ -3376,10 +3349,6 @@ public: } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - std::string toStdString() const { std::string str; @@ -3402,83 +3371,85 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator = (const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(long); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertToSmaller(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertToSmaller(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { val = static_cast(_val); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = static_cast(_val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { convertSignedToUnsigned(_val, val); } - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { val = static_cast(_val); } - void convert(double& val) const + void convert(double& val) const override { val = static_cast(_val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = 0) const override { return cloneHolder(pVarHolder, _val); } @@ -3488,46 +3459,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - long _val; }; @@ -3540,83 +3507,85 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator = (const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(unsigned long); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int64& val) const + void convert(Int64& val) const override { convertUnsignedToSigned(_val, val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = static_cast(_val); } - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { val = static_cast(_val); } - void convert(double& val) const + void convert(double& val) const override { val = static_cast(_val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = 0) const override { return cloneHolder(pVarHolder, _val); } @@ -3626,46 +3595,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - unsigned long _val; }; @@ -3681,93 +3646,95 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(long long); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertToSmaller(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertToSmaller(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { convertToSmaller(_val, val); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = static_cast(_val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertSignedToUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { convertSignedToUnsigned(_val, val); } - void convert(long long& val) const + void convert(long long& val) const override { val = _val; } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { convertSignedToUnsigned(_val, val); } - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { val = static_cast(_val); } - void convert(double& val) const + void convert(double& val) const override { val = static_cast(_val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -3777,46 +3744,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - long long _val; }; @@ -3829,93 +3792,95 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(unsigned long long); } - void convert(Int8& val) const + void convert(Int8& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int16& val) const + void convert(Int16& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int32& val) const + void convert(Int32& val) const override { convertUnsignedToSigned(_val, val); } - void convert(Int64& val) const + void convert(Int64& val) const override { convertUnsignedToSigned(_val, val); } - void convert(UInt8& val) const + void convert(UInt8& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt16& val) const + void convert(UInt16& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt32& val) const + void convert(UInt32& val) const override { convertToSmallerUnsigned(_val, val); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = static_cast(_val); } - void convert(long long& val) const + void convert(long long& val) const override { convertUnsignedToSigned(_val, val); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = _val; } - void convert(bool& val) const + void convert(bool& val) const override { val = (_val != 0); } - void convert(float& val) const + void convert(float& val) const override { val = static_cast(_val); } - void convert(double& val) const + void convert(double& val) const override { val = static_cast(_val); } - void convert(char& val) const + void convert(char& val) const override { UInt8 tmp; convert(tmp); val = static_cast(tmp); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = NumberFormatter::format(_val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -3925,46 +3890,42 @@ 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 std::numeric_limits::is_integer; } - bool isSigned() const + bool isSigned() const override { return std::numeric_limits::is_signed; } - bool isNumeric() const + bool isNumeric() const override { return std::numeric_limits::is_specialized; } - bool isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - unsigned long long _val; }; @@ -3980,21 +3941,23 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(std::vector); } - void convert(std::string& val) const + void convert(std::string& val) const override { Impl::containerToJSON(_val, val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -4004,12 +3967,12 @@ public: return _val; } - bool isVector() const + bool isVector() const override { return true; } - std::size_t size() const + std::size_t size() const override { return _val.size(); } @@ -4029,10 +3992,6 @@ public: } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - std::vector _val; }; @@ -4045,21 +4004,23 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(std::list); } - void convert(std::string& val) const + void convert(std::string& val) const override { Impl::containerToJSON(_val, val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -4069,12 +4030,12 @@ public: return _val; } - bool isList() const + bool isList() const override { return true; } - std::size_t size() const + std::size_t size() const override { return _val.size(); } @@ -4104,10 +4065,6 @@ public: } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - std::list _val; }; @@ -4120,21 +4077,23 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(std::deque); } - void convert(std::string& val) const + void convert(std::string& val) const override { Impl::containerToJSON(_val, val); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -4144,12 +4103,12 @@ public: return _val; } - bool isDeque() const + bool isDeque() const override { return true; } - std::size_t size() const + std::size_t size() const override { return _val.size(); } @@ -4169,10 +4128,6 @@ public: } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - std::deque _val; }; @@ -4185,75 +4140,77 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(DateTime); } - void convert(Int8& /*val*/) const + void convert(Int8 & /*val*/) const override { throw BadCastException(); } - void convert(Int16& /*val*/) const + void convert(Int16 & /*val*/) const override { throw BadCastException(); } - void convert(Int32& /*val*/) const + void convert(Int32 & /*val*/) const override { throw BadCastException(); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = _val.timestamp().epochMicroseconds(); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = _val.timestamp().epochMicroseconds(); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = _val.timestamp().epochMicroseconds(); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = _val.timestamp().epochMicroseconds(); } #endif - void convert(std::string& val) const + void convert(std::string& val) const override { val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT); } - void convert(DateTime& val) const + void convert(DateTime& val) const override { val = _val; } - void convert(LocalDateTime& ldt) const + void convert(LocalDateTime &ldt) const override { ldt = _val.timestamp(); } - void convert(Timestamp& ts) const + void convert(Timestamp &ts) const override { ts = _val.timestamp(); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -4263,66 +4220,62 @@ 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 isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } - bool isDate() const + bool isDate() const override { return true; } - bool isTime() const + bool isTime() const override { return true; } - bool isDateTime() const + bool isDateTime() const override { return true; } - bool isUUID() const + bool isUUID() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - DateTime _val; }; @@ -4335,60 +4288,61 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(LocalDateTime); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = _val.timestamp().epochMicroseconds(); } - void convert(UInt64& val) const - { + void convert(UInt64& val) const override { val = _val.timestamp().epochMicroseconds(); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = _val.timestamp().epochMicroseconds(); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = _val.timestamp().epochMicroseconds(); } #endif - void convert(std::string& val) const + void convert(std::string& val) const override { val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT); } - void convert(DateTime& val) const + void convert(DateTime& val) const override { val = _val.timestamp(); } - void convert(LocalDateTime& ldt) const + void convert(LocalDateTime &ldt) const override { ldt = _val; } - void convert(Timestamp& ts) const + void convert(Timestamp &ts) const override { ts = _val.timestamp(); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -4398,66 +4352,62 @@ 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 isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } - bool isDate() const + bool isDate() const override { return true; } - bool isTime() const + bool isTime() const override { return true; } - bool isDateTime() const + bool isDateTime() const override { return true; } - bool isUUID() const + bool isUUID() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - LocalDateTime _val; }; @@ -4470,60 +4420,62 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(Timestamp); } - void convert(Int64& val) const + void convert(Int64& val) const override { val = _val.epochMicroseconds(); } - void convert(UInt64& val) const + void convert(UInt64& val) const override { val = _val.epochMicroseconds(); } #ifdef POCO_INT64_IS_LONG - void convert(long long& val) const + void convert(long long& val) const override { val = _val.epochMicroseconds(); } - void convert(unsigned long long& val) const + void convert(unsigned long long& val) const override { val = _val.epochMicroseconds(); } #endif - void convert(std::string& val) const + void convert(std::string& val) const override { val = DateTimeFormatter::format(_val, Poco::DateTimeFormat::ISO8601_FORMAT); } - void convert(DateTime& val) const + void convert(DateTime& val) const override { val = _val; } - void convert(LocalDateTime& ldt) const + void convert(LocalDateTime &ldt) const override { ldt = _val; } - void convert(Timestamp& ts) const + void convert(Timestamp &ts) const override { ts = _val; } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -4533,66 +4485,62 @@ 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 isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } - bool isDate() const + bool isDate() const override { return true; } - bool isTime() const + bool isTime() const override { return true; } - bool isDateTime() const + bool isDateTime() const override { return true; } - bool isUUID() const + bool isUUID() const override { return false; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - Timestamp _val; }; @@ -4605,21 +4553,23 @@ public: { } - ~VarHolderImpl() - { - } + ~VarHolderImpl() override = default; - const std::type_info& type() const + VarHolderImpl() = delete; + VarHolderImpl(const VarHolderImpl&) = delete; + VarHolderImpl& operator=(const VarHolderImpl&) = delete; + + const std::type_info& type() const override { return typeid(UUID); } - void convert(std::string& val) const + void convert(std::string& val) const override { val = _val.toString(); } - VarHolder* clone(Placeholder* pVarHolder = 0) const + VarHolder* clone(Placeholder* pVarHolder = nullptr) const override { return cloneHolder(pVarHolder, _val); } @@ -4629,66 +4579,62 @@ 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 isBoolean() const + bool isBoolean() const override { return false; } - bool isString() const + bool isString() const override { return false; } - bool isDate() const + bool isDate() const override { return false; } - bool isTime() const + bool isTime() const override { return false; } - bool isDateTime() const + bool isDateTime() const override { return false; } - bool isUUID() const + bool isUUID() const override { return true; } private: - VarHolderImpl(); - VarHolderImpl(const VarHolderImpl&); - VarHolderImpl& operator = (const VarHolderImpl&); - Poco::UUID _val; }; diff --git a/Foundation/include/Poco/Dynamic/VarIterator.h b/Foundation/include/Poco/Dynamic/VarIterator.h index ebf6c0853..466451e9e 100644 --- a/Foundation/include/Poco/Dynamic/VarIterator.h +++ b/Foundation/include/Poco/Dynamic/VarIterator.h @@ -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. diff --git a/Foundation/include/Poco/Foundation.h b/Foundation/include/Poco/Foundation.h index 9f51c4754..11317f1e3 100644 --- a/Foundation/include/Poco/Foundation.h +++ b/Foundation/include/Poco/Foundation.h @@ -150,7 +150,7 @@ namespace Poco { using LineNumber = decltype(__LINE__); -} +} // namespace Poco // // Pull in basic definitions diff --git a/Foundation/include/Poco/Types.h b/Foundation/include/Poco/Types.h index fe51a233f..3a7f5495c 100644 --- a/Foundation/include/Poco/Types.h +++ b/Foundation/include/Poco/Types.h @@ -36,7 +36,7 @@ namespace Poco { -using Int8 = std::conditional::value, std::int8_t, signed char>::type; +using Int8 = std::conditional_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