mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-19 13:59:33 +01:00
enh(Poco::Dynamic): Modernised code to use C++17 features.
This commit is contained in:
parent
4ca735d7d8
commit
7495f0592c
@ -111,103 +111,101 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~VarHolderImpl()
|
~VarHolderImpl() override = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::type_info& type() const
|
const std::type_info& type() const override
|
||||||
{
|
{
|
||||||
return typeid(Pair<std::string>);
|
return typeid(Pair<std::string>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int8&) const
|
void convert(Int8&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Cannot cast Pair type to Int8");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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
|
// Serialize in JSON format: equals an object
|
||||||
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
|
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
|
||||||
val.append("{ ");
|
val.append("{ ");
|
||||||
Var key(_val.first());
|
const Var key(_val.first());
|
||||||
Impl::appendJSONKey(val, key);
|
Impl::appendJSONKey(val, key);
|
||||||
val.append(": ");
|
val.append(": ");
|
||||||
Impl::appendJSONValue(val, _val.second());
|
Impl::appendJSONValue(val, _val.second());
|
||||||
val.append(" }");
|
val.append(" }");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::DateTime&) const
|
void convert(Poco::DateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Pair -> Poco::DateTime");
|
throw BadCastException("Pair -> Poco::DateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::LocalDateTime&) const
|
void convert(Poco::LocalDateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Pair -> Poco::LocalDateTime");
|
throw BadCastException("Pair -> Poco::LocalDateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::Timestamp&) const
|
void convert(Poco::Timestamp&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Pair -> Poco::Timestamp");
|
throw BadCastException("Pair -> Poco::Timestamp");
|
||||||
}
|
}
|
||||||
|
|
||||||
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
|
||||||
{
|
{
|
||||||
return cloneHolder(pVarHolder, _val);
|
return cloneHolder(pVarHolder, _val);
|
||||||
}
|
}
|
||||||
@ -217,32 +215,32 @@ public:
|
|||||||
return _val;
|
return _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isArray() const
|
bool isArray() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isStruct() const
|
bool isStruct() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInteger() const
|
bool isInteger() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSigned() const
|
bool isSigned() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNumeric() const
|
bool isNumeric() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -260,103 +258,101 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~VarHolderImpl()
|
~VarHolderImpl() override = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::type_info& type() const
|
const std::type_info& type() const override
|
||||||
{
|
{
|
||||||
return typeid(Pair<int>);
|
return typeid(Pair<int>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int8&) const
|
void convert(Int8&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Cannot cast Pair type to Int8");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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
|
// Serialize in JSON format: equals an object
|
||||||
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
|
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
|
||||||
val.append("{ ");
|
val.append("{ ");
|
||||||
Var key(_val.first());
|
const Var key(_val.first());
|
||||||
Impl::appendJSONKey(val, key);
|
Impl::appendJSONKey(val, key);
|
||||||
val.append(": ");
|
val.append(": ");
|
||||||
Impl::appendJSONValue(val, _val.second());
|
Impl::appendJSONValue(val, _val.second());
|
||||||
val.append(" }");
|
val.append(" }");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::DateTime&) const
|
void convert(Poco::DateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Pair -> Poco::DateTime");
|
throw BadCastException("Pair -> Poco::DateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::LocalDateTime&) const
|
void convert(Poco::LocalDateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Pair -> Poco::LocalDateTime");
|
throw BadCastException("Pair -> Poco::LocalDateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::Timestamp&) const
|
void convert(Poco::Timestamp&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Pair -> Poco::Timestamp");
|
throw BadCastException("Pair -> Poco::Timestamp");
|
||||||
}
|
}
|
||||||
|
|
||||||
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
|
||||||
{
|
{
|
||||||
return cloneHolder(pVarHolder, _val);
|
return cloneHolder(pVarHolder, _val);
|
||||||
}
|
}
|
||||||
@ -366,33 +362,30 @@ public:
|
|||||||
return _val;
|
return _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isArray() const
|
bool isArray() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isStruct() const
|
bool isStruct() const override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isInteger() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInteger() const
|
bool isSigned() const override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isNumeric() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSigned() const
|
bool isString() const override {
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNumeric() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isString() const
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ std::string structToString(const S& data, bool wrap = true)
|
|||||||
I itEnd = data.end();
|
I itEnd = data.end();
|
||||||
if (!data.empty())
|
if (!data.empty())
|
||||||
{
|
{
|
||||||
Var key(it->first);
|
const Var key(it->first);
|
||||||
Impl::appendJSONKey(val, key);
|
Impl::appendJSONKey(val, key);
|
||||||
val.append(": ");
|
val.append(": ");
|
||||||
Impl::appendJSONValue(val, it->second, wrap);
|
Impl::appendJSONValue(val, it->second, wrap);
|
||||||
@ -53,7 +53,7 @@ std::string structToString(const S& data, bool wrap = true)
|
|||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
val.append(", ");
|
val.append(", ");
|
||||||
Var key(it->first);
|
const Var key(it->first);
|
||||||
Impl::appendJSONKey(val, key);
|
Impl::appendJSONKey(val, key);
|
||||||
val.append(": ");
|
val.append(": ");
|
||||||
Impl::appendJSONValue(val, it->second, wrap);
|
Impl::appendJSONValue(val, it->second, wrap);
|
||||||
@ -68,14 +68,14 @@ class Struct
|
|||||||
/// Struct allows to define a named collection of Var objects.
|
/// Struct allows to define a named collection of Var objects.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef M Data;
|
using Data = M;
|
||||||
typedef S NameSet;
|
using NameSet = S;
|
||||||
typedef typename Data::iterator Iterator;
|
using Iterator = typename Data::iterator;
|
||||||
typedef typename Data::const_iterator ConstIterator;
|
using ConstIterator = typename Data::const_iterator;
|
||||||
typedef typename Struct<K>::Data::value_type ValueType;
|
using ValueType = typename Struct<K>::Data::value_type;
|
||||||
typedef typename Struct<K>::Data::size_type SizeType;
|
using SizeType = typename Struct<K>::Data::size_type;
|
||||||
typedef typename std::pair<typename Struct<K, M, S>::Iterator, bool> InsRetVal;
|
using InsRetVal = typename std::pair<typename Struct<K, M, S>::Iterator, bool>;
|
||||||
typedef typename Poco::SharedPtr<Struct<K, M, S>> Ptr;
|
using Ptr = typename Poco::SharedPtr<Struct<K, M, S>>;
|
||||||
|
|
||||||
Struct(): _data()
|
Struct(): _data()
|
||||||
/// Creates an empty Struct
|
/// Creates an empty Struct
|
||||||
@ -99,10 +99,8 @@ public:
|
|||||||
assignMap(val);
|
assignMap(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Struct()
|
virtual ~Struct() = default;
|
||||||
/// Destroys the Struct.
|
/// Destroys the Struct.
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Var& operator [] (const K& name)
|
inline Var& operator [] (const K& name)
|
||||||
/// Returns the Var with the given name, creates an entry if not found.
|
/// 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
|
/// Returns the Var with the given name, throws a
|
||||||
/// NotFoundException if the data member is not found.
|
/// NotFoundException if the data member is not found.
|
||||||
{
|
{
|
||||||
ConstIterator it = find(name);
|
const auto it = find(name);
|
||||||
if (it == end()) throw NotFoundException(name);
|
if (it == end()) throw NotFoundException(name);
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
@ -277,7 +275,7 @@ private:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void assignMap(const T& map)
|
void assignMap(const T& map)
|
||||||
{
|
{
|
||||||
typedef typename T::const_iterator MapConstIterator;
|
using MapConstIterator = typename T::const_iterator;
|
||||||
|
|
||||||
MapConstIterator it = map.begin();
|
MapConstIterator it = map.begin();
|
||||||
MapConstIterator end = map.end();
|
MapConstIterator end = map.end();
|
||||||
@ -311,105 +309,103 @@ template <>
|
|||||||
class VarHolderImpl<Struct<std::string, std::map<std::string, Var>, std::set<std::string>>>: public VarHolder
|
class VarHolderImpl<Struct<std::string, std::map<std::string, Var>, std::set<std::string>>>: public VarHolder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::string KeyType;
|
using KeyType = std::string;
|
||||||
typedef std::map<KeyType, Var> MapType;
|
using MapType = std::map<KeyType, Var>;
|
||||||
typedef std::set<KeyType> SetType;
|
using SetType = std::set<KeyType>;
|
||||||
typedef Struct<KeyType, MapType, SetType> ValueType;
|
using ValueType = Struct<KeyType, MapType, SetType>;
|
||||||
|
|
||||||
VarHolderImpl(const ValueType& val): _val(val)
|
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);
|
return typeid(ValueType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int8&) const
|
void convert(Int8&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Cannot cast Struct type to Int8");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
throw BadCastException("Cannot cast Struct type to char");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const override
|
||||||
{
|
{
|
||||||
val = structToString(_val);
|
val = structToString(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::DateTime&) const
|
void convert(Poco::DateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::DateTime");
|
throw BadCastException("Struct -> Poco::DateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::LocalDateTime&) const
|
void convert(Poco::LocalDateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::LocalDateTime");
|
throw BadCastException("Struct -> Poco::LocalDateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::Timestamp&) const
|
void convert(Poco::Timestamp&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::Timestamp");
|
throw BadCastException("Struct -> Poco::Timestamp");
|
||||||
}
|
}
|
||||||
|
|
||||||
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
|
||||||
{
|
{
|
||||||
return cloneHolder(pVarHolder, _val);
|
return cloneHolder(pVarHolder, _val);
|
||||||
}
|
}
|
||||||
@ -419,42 +415,42 @@ public:
|
|||||||
return _val;
|
return _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isArray() const
|
bool isArray() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isStruct() const
|
bool isStruct() const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isOrdered() const
|
bool isOrdered() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInteger() const
|
bool isInteger() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSigned() const
|
bool isSigned() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNumeric() const
|
bool isNumeric() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t size() const
|
std::size_t size() const override
|
||||||
{
|
{
|
||||||
return _val.size();
|
return _val.size();
|
||||||
}
|
}
|
||||||
@ -478,105 +474,103 @@ template <>
|
|||||||
class VarHolderImpl<Struct<int, std::map<int, Var>, std::set<int>>> : public VarHolder
|
class VarHolderImpl<Struct<int, std::map<int, Var>, std::set<int>>> : public VarHolder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef int KeyType;
|
using KeyType = int;
|
||||||
typedef std::map<KeyType, Var> MapType;
|
using MapType = std::map<KeyType, Var>;
|
||||||
typedef std::set<KeyType> SetType;
|
using SetType = std::set<KeyType>;
|
||||||
typedef Struct<KeyType, MapType, SetType> ValueType;
|
using ValueType = Struct<KeyType, MapType, SetType>;
|
||||||
|
|
||||||
VarHolderImpl(const ValueType& val) : _val(val)
|
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);
|
return typeid(ValueType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int8&) const
|
void convert(Int8&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Cannot cast Struct type to Int8");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
throw BadCastException("Cannot cast Struct type to char");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const override
|
||||||
{
|
{
|
||||||
val = structToString(_val);
|
val = structToString(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::DateTime&) const
|
void convert(Poco::DateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::DateTime");
|
throw BadCastException("Struct -> Poco::DateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::LocalDateTime&) const
|
void convert(Poco::LocalDateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::LocalDateTime");
|
throw BadCastException("Struct -> Poco::LocalDateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::Timestamp&) const
|
void convert(Poco::Timestamp&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::Timestamp");
|
throw BadCastException("Struct -> Poco::Timestamp");
|
||||||
}
|
}
|
||||||
|
|
||||||
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
|
||||||
{
|
{
|
||||||
return cloneHolder(pVarHolder, _val);
|
return cloneHolder(pVarHolder, _val);
|
||||||
}
|
}
|
||||||
@ -586,42 +580,42 @@ public:
|
|||||||
return _val;
|
return _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isArray() const
|
bool isArray() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isStruct() const
|
bool isStruct() const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isOrdered() const
|
bool isOrdered() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInteger() const
|
bool isInteger() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSigned() const
|
bool isSigned() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNumeric() const
|
bool isNumeric() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t size() const
|
std::size_t size() const override
|
||||||
{
|
{
|
||||||
return _val.size();
|
return _val.size();
|
||||||
}
|
}
|
||||||
@ -645,105 +639,103 @@ template <>
|
|||||||
class VarHolderImpl<Struct<std::string, Poco::OrderedMap<std::string, Var>, Poco::OrderedSet<std::string>>> : public VarHolder
|
class VarHolderImpl<Struct<std::string, Poco::OrderedMap<std::string, Var>, Poco::OrderedSet<std::string>>> : public VarHolder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::string KeyType;
|
using KeyType = std::string;
|
||||||
typedef Poco::OrderedMap<KeyType, Var> MapType;
|
using MapType = Poco::OrderedMap<KeyType, Var>;
|
||||||
typedef Poco::OrderedSet<KeyType> SetType;
|
using SetType = Poco::OrderedSet<KeyType>;
|
||||||
typedef Struct<KeyType, MapType, SetType> ValueType;
|
using ValueType = Struct<KeyType, MapType, SetType>;
|
||||||
|
|
||||||
VarHolderImpl(const ValueType& val) : _val(val)
|
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);
|
return typeid(ValueType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int8&) const
|
void convert(Int8&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Cannot cast Struct type to Int8");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
throw BadCastException("Cannot cast Struct type to char");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string&val) const override
|
||||||
{
|
{
|
||||||
val = structToString(_val);
|
val = structToString(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::DateTime&) const
|
void convert(Poco::DateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::DateTime");
|
throw BadCastException("Struct -> Poco::DateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::LocalDateTime&) const
|
void convert(Poco::LocalDateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::LocalDateTime");
|
throw BadCastException("Struct -> Poco::LocalDateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::Timestamp&) const
|
void convert(Poco::Timestamp&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::Timestamp");
|
throw BadCastException("Struct -> Poco::Timestamp");
|
||||||
}
|
}
|
||||||
|
|
||||||
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
|
||||||
{
|
{
|
||||||
return cloneHolder(pVarHolder, _val);
|
return cloneHolder(pVarHolder, _val);
|
||||||
}
|
}
|
||||||
@ -753,42 +745,42 @@ public:
|
|||||||
return _val;
|
return _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isArray() const
|
bool isArray() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isStruct() const
|
bool isStruct() const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isOrdered() const
|
bool isOrdered() const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInteger() const
|
bool isInteger() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSigned() const
|
bool isSigned() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNumeric() const
|
bool isNumeric() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t size() const
|
std::size_t size() const override
|
||||||
{
|
{
|
||||||
return _val.size();
|
return _val.size();
|
||||||
}
|
}
|
||||||
@ -812,105 +804,103 @@ template <>
|
|||||||
class VarHolderImpl<Struct<int, Poco::OrderedMap<int, Var>, Poco::OrderedSet<int>>> : public VarHolder
|
class VarHolderImpl<Struct<int, Poco::OrderedMap<int, Var>, Poco::OrderedSet<int>>> : public VarHolder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef int KeyType;
|
using KeyType = int;
|
||||||
typedef Poco::OrderedMap<KeyType, Var> MapType;
|
using MapType = Poco::OrderedMap<KeyType, Var>;
|
||||||
typedef Poco::OrderedSet<KeyType> SetType;
|
using SetType = Poco::OrderedSet<KeyType>;
|
||||||
typedef Struct<KeyType, MapType, SetType> ValueType;
|
using ValueType = Struct<KeyType, MapType, SetType>;
|
||||||
|
|
||||||
VarHolderImpl(const ValueType& val) : _val(val)
|
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);
|
return typeid(ValueType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int8&) const
|
void convert(Int8&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Cannot cast Struct type to Int8");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
throw BadCastException("Cannot cast Struct type to char");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const override
|
||||||
{
|
{
|
||||||
val = structToString(_val);
|
val = structToString(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::DateTime&) const
|
void convert(Poco::DateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::DateTime");
|
throw BadCastException("Struct -> Poco::DateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::LocalDateTime&) const
|
void convert(Poco::LocalDateTime&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::LocalDateTime");
|
throw BadCastException("Struct -> Poco::LocalDateTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Poco::Timestamp&) const
|
void convert(Poco::Timestamp&) const override
|
||||||
{
|
{
|
||||||
throw BadCastException("Struct -> Poco::Timestamp");
|
throw BadCastException("Struct -> Poco::Timestamp");
|
||||||
}
|
}
|
||||||
|
|
||||||
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
VarHolder *clone(Placeholder<VarHolder>* pVarHolder = nullptr) const override
|
||||||
{
|
{
|
||||||
return cloneHolder(pVarHolder, _val);
|
return cloneHolder(pVarHolder, _val);
|
||||||
}
|
}
|
||||||
@ -920,42 +910,42 @@ public:
|
|||||||
return _val;
|
return _val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isArray() const
|
bool isArray() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isStruct() const
|
bool isStruct() const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isOrdered() const
|
bool isOrdered() const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInteger() const
|
bool isInteger() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSigned() const
|
bool isSigned() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNumeric() const
|
bool isNumeric() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t size() const
|
std::size_t size() const override
|
||||||
{
|
{
|
||||||
return _val.size();
|
return _val.size();
|
||||||
}
|
}
|
||||||
|
@ -189,13 +189,11 @@ public:
|
|||||||
|
|
||||||
if (typeid(T) == pHolder->type())
|
if (typeid(T) == pHolder->type())
|
||||||
return extract<T>();
|
return extract<T>();
|
||||||
else
|
|
||||||
{
|
|
||||||
T result;
|
T result;
|
||||||
pHolder->convert(result);
|
pHolder->convert(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T& extract() const
|
const T& extract() const
|
||||||
@ -208,12 +206,13 @@ public:
|
|||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
|
|
||||||
if (pHolder && pHolder->type() == typeid(T))
|
if ( (pHolder != nullptr) && pHolder->type() == typeid(T))
|
||||||
{
|
{
|
||||||
auto* pHolderImpl = static_cast<VarHolderImpl<T>*>(pHolder);
|
auto* pHolderImpl = static_cast<VarHolderImpl<T>*>(pHolder);
|
||||||
return pHolderImpl->value();
|
return pHolderImpl->value();
|
||||||
}
|
}
|
||||||
else if (!pHolder)
|
|
||||||
|
if (!pHolder)
|
||||||
throw InvalidAccessException("Can not extract empty value.");
|
throw InvalidAccessException("Can not extract empty value.");
|
||||||
else
|
else
|
||||||
throw BadCastException(Poco::format("Can not convert %s to %s.",
|
throw BadCastException(Poco::format("Can not convert %s to %s.",
|
||||||
@ -580,7 +579,8 @@ private:
|
|||||||
|
|
||||||
if (pHolder && pHolder->type() == typeid(T))
|
if (pHolder && pHolder->type() == typeid(T))
|
||||||
return static_cast<VarHolderImpl<T>*>(pHolder);
|
return static_cast<VarHolderImpl<T>*>(pHolder);
|
||||||
else if (!pHolder)
|
|
||||||
|
if (pHolder == nullptr)
|
||||||
throw InvalidAccessException("Can not access empty value.");
|
throw InvalidAccessException("Can not access empty value.");
|
||||||
else
|
else
|
||||||
throw E(errorMessage);
|
throw E(errorMessage);
|
||||||
@ -625,7 +625,7 @@ private:
|
|||||||
|
|
||||||
inline void Var::construct(const char* value)
|
inline void Var::construct(const char* value)
|
||||||
{
|
{
|
||||||
std::string val(value);
|
const std::string val(value);
|
||||||
_placeholder.assign<VarHolderImpl<std::string>, std::string>(val);
|
_placeholder.assign<VarHolderImpl<std::string>, std::string>(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,7 +647,7 @@ inline void Var::swap(Var& other)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Var tmp(*this);
|
const Var tmp(*this);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
construct(other);
|
construct(other);
|
||||||
@ -665,39 +665,39 @@ inline void Var::swap(Var& other)
|
|||||||
inline const std::type_info& Var::type() const
|
inline const std::type_info& Var::type() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->type() : typeid(void);
|
return (pHolder != nullptr) ? pHolder->type() : typeid(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::string Var::typeName(bool demangle) const
|
inline std::string Var::typeName(bool demangle) const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
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
|
inline Var::ConstIterator Var::begin() const
|
||||||
{
|
{
|
||||||
if (size() == 0) return ConstIterator(const_cast<Var*>(this), true);
|
if (size() == 0) return {const_cast<Var*>(this), true};
|
||||||
|
|
||||||
return ConstIterator(const_cast<Var*>(this), false);
|
return {const_cast<Var*>(this), false};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Var::ConstIterator Var::end() const
|
inline Var::ConstIterator Var::end() const
|
||||||
{
|
{
|
||||||
return ConstIterator(const_cast<Var*>(this), true);
|
return {const_cast<Var*>(this), true};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Var::Iterator Var::begin()
|
inline Var::Iterator Var::begin()
|
||||||
{
|
{
|
||||||
if (size() == 0) return Iterator(const_cast<Var*>(this), true);
|
if (size() == 0) return {const_cast<Var*>(this), true};
|
||||||
|
|
||||||
return Iterator(const_cast<Var*>(this), false);
|
return {const_cast<Var*>(this), false};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Var::Iterator Var::end()
|
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;
|
if (isEmpty() || isString()) return false;
|
||||||
|
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isArray() : false;
|
return (pHolder != nullptr) ? pHolder->isArray() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isVector() const
|
inline bool Var::isVector() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isVector() : false;
|
return (pHolder != nullptr) ? pHolder->isVector() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isList() const
|
inline bool Var::isList() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isList() : false;
|
return (pHolder != nullptr) ? pHolder->isList() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isDeque() const
|
inline bool Var::isDeque() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isDeque() : false;
|
return (pHolder != nullptr) ? pHolder->isDeque() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isStruct() const
|
inline bool Var::isStruct() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isStruct() : false;
|
return (pHolder != nullptr) ? pHolder->isStruct() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isOrdered() const
|
inline bool Var::isOrdered() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isOrdered() : false;
|
return (pHolder != nullptr) ? pHolder->isOrdered() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isInteger() const
|
inline bool Var::isInteger() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isInteger() : false;
|
return (pHolder != nullptr) ? pHolder->isInteger() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isSigned() const
|
inline bool Var::isSigned() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isSigned() : false;
|
return (pHolder != nullptr) ? pHolder->isSigned() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isNumeric() const
|
inline bool Var::isNumeric() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isNumeric() : false;
|
return (pHolder != nullptr) ? pHolder->isNumeric() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isBoolean() const
|
inline bool Var::isBoolean() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isBoolean() : false;
|
return (pHolder != nullptr) ? pHolder->isBoolean() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isString() const
|
inline bool Var::isString() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isString() : false;
|
return (pHolder != nullptr) ? pHolder->isString() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isDate() const
|
inline bool Var::isDate() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isDate() : false;
|
return (pHolder != nullptr) ? pHolder->isDate() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isTime() const
|
inline bool Var::isTime() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isTime() : false;
|
return (pHolder != nullptr) ? pHolder->isTime() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isDateTime() const
|
inline bool Var::isDateTime() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isDateTime() : false;
|
return (pHolder != nullptr) ? pHolder->isDateTime() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isUUID() const
|
inline bool Var::isUUID() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
return pHolder ? pHolder->isUUID() : false;
|
return (pHolder != nullptr) ? pHolder->isUUID() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t Var::size() const
|
inline std::size_t Var::size() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
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)
|
inline const Var operator + (const char* other, const Var& da)
|
||||||
/// Addition operator for adding Var to const char*
|
/// Addition operator for adding Var to const char*
|
||||||
{
|
{
|
||||||
std::string tmp = other;
|
const std::string tmp = other;
|
||||||
return tmp + da.convert<std::string>();
|
return tmp + da.convert<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -34,11 +34,11 @@ class Foundation_API VarIterator
|
|||||||
/// VarIterator class.
|
/// VarIterator class.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::bidirectional_iterator_tag iterator_category;
|
using iterator_category = std::bidirectional_iterator_tag;
|
||||||
typedef Var value_type;
|
using value_type = Var;
|
||||||
typedef std::ptrdiff_t difference_type;
|
using difference_type = std::ptrdiff_t;
|
||||||
typedef Var* pointer;
|
using pointer = Var *;
|
||||||
typedef Var& reference;
|
using reference = Var &;
|
||||||
|
|
||||||
static const std::size_t POSITION_END;
|
static const std::size_t POSITION_END;
|
||||||
/// End position indicator.
|
/// End position indicator.
|
||||||
|
@ -150,7 +150,7 @@ namespace Poco {
|
|||||||
|
|
||||||
using LineNumber = decltype(__LINE__);
|
using LineNumber = decltype(__LINE__);
|
||||||
|
|
||||||
}
|
} // namespace Poco
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pull in basic definitions
|
// Pull in basic definitions
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
using Int8 = std::conditional<std::is_same<signed char, std::int8_t>::value, std::int8_t, signed char>::type;
|
using Int8 = std::conditional_t<std::is_same_v<signed char, std::int8_t>, std::int8_t, signed char>;
|
||||||
using UInt8 = std::uint8_t;
|
using UInt8 = std::uint8_t;
|
||||||
using Int16 = std::int16_t;
|
using Int16 = std::int16_t;
|
||||||
using UInt16 = std::uint16_t;
|
using UInt16 = std::uint16_t;
|
||||||
@ -88,7 +88,7 @@ inline std::string Foundation_API demangle(const char* typeName)
|
|||||||
#ifdef POCO_HAVE_CXXABI_H
|
#ifdef POCO_HAVE_CXXABI_H
|
||||||
int status;
|
int status;
|
||||||
char* demangled = abi::__cxa_demangle(typeName, nullptr, nullptr, &status);
|
char* demangled = abi::__cxa_demangle(typeName, nullptr, nullptr, &status);
|
||||||
if (demangled)
|
if (demangled != nullptr)
|
||||||
{
|
{
|
||||||
if (status == 0) result = demangled;
|
if (status == 0) result = demangled;
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user