mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-25 10:09:36 +02:00
added Var::isBoolean() and fixed JSON stringifier
This commit is contained in:
@@ -495,6 +495,10 @@ public:
|
|||||||
/// Returns true if stored value is numeric.
|
/// Returns true if stored value is numeric.
|
||||||
/// Returns false for numeric strings (e.g. "123" is string, not number)
|
/// Returns false for numeric strings (e.g. "123" is string, not number)
|
||||||
|
|
||||||
|
bool isBoolean() const;
|
||||||
|
/// Returns true if stored value is boolean.
|
||||||
|
/// Returns false for boolean strings (e.g. "true" is string, not number)
|
||||||
|
|
||||||
bool isString() const;
|
bool isString() const;
|
||||||
/// Returns true if stored value is std::string.
|
/// Returns true if stored value is std::string.
|
||||||
|
|
||||||
@@ -825,6 +829,13 @@ inline bool Var::isNumeric() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Var::isBoolean() const
|
||||||
|
{
|
||||||
|
VarHolder* pHolder = content();
|
||||||
|
return pHolder ? pHolder->isBoolean() : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Var::isString() const
|
inline bool Var::isString() const
|
||||||
{
|
{
|
||||||
VarHolder* pHolder = content();
|
VarHolder* pHolder = content();
|
||||||
|
|||||||
@@ -246,6 +246,10 @@ public:
|
|||||||
/// Returns false. Must be properly overriden in a type
|
/// Returns false. Must be properly overriden in a type
|
||||||
/// specialization in order to suport the diagnostic.
|
/// specialization in order to suport the diagnostic.
|
||||||
|
|
||||||
|
virtual bool isBoolean() const;
|
||||||
|
/// Returns false. Must be properly overriden in a type
|
||||||
|
/// specialization in order to suport the diagnostic.
|
||||||
|
|
||||||
virtual bool isString() const;
|
virtual bool isString() const;
|
||||||
/// Returns false. Must be properly overriden in a type
|
/// Returns false. Must be properly overriden in a type
|
||||||
/// specialization in order to suport the diagnostic.
|
/// specialization in order to suport the diagnostic.
|
||||||
@@ -594,6 +598,12 @@ inline bool VarHolder::isNumeric() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool VarHolder::isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool VarHolder::isString() const
|
inline bool VarHolder::isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -782,6 +792,11 @@ public:
|
|||||||
return std::numeric_limits<Int8>::is_specialized;
|
return std::numeric_limits<Int8>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -921,6 +936,7 @@ public:
|
|||||||
return std::numeric_limits<Int16>::is_specialized;
|
return std::numeric_limits<Int16>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1054,6 +1070,11 @@ public:
|
|||||||
return std::numeric_limits<Int32>::is_specialized;
|
return std::numeric_limits<Int32>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1202,6 +1223,11 @@ public:
|
|||||||
return std::numeric_limits<Int64>::is_specialized;
|
return std::numeric_limits<Int64>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1335,6 +1361,11 @@ public:
|
|||||||
return std::numeric_limits<UInt8>::is_specialized;
|
return std::numeric_limits<UInt8>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1468,6 +1499,11 @@ public:
|
|||||||
return std::numeric_limits<UInt16>::is_specialized;
|
return std::numeric_limits<UInt16>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1601,6 +1637,11 @@ public:
|
|||||||
return std::numeric_limits<UInt32>::is_specialized;
|
return std::numeric_limits<UInt32>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1755,6 +1796,11 @@ public:
|
|||||||
return std::numeric_limits<UInt64>::is_specialized;
|
return std::numeric_limits<UInt64>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1886,6 +1932,11 @@ public:
|
|||||||
return std::numeric_limits<bool>::is_specialized;
|
return std::numeric_limits<bool>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -2020,6 +2071,11 @@ public:
|
|||||||
return std::numeric_limits<float>::is_specialized;
|
return std::numeric_limits<float>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -2160,6 +2216,11 @@ public:
|
|||||||
return std::numeric_limits<double>::is_specialized;
|
return std::numeric_limits<double>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -2291,6 +2352,11 @@ public:
|
|||||||
return std::numeric_limits<char>::is_specialized;
|
return std::numeric_limits<char>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -2793,6 +2859,11 @@ public:
|
|||||||
return std::numeric_limits<long>::is_specialized;
|
return std::numeric_limits<long>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -2926,6 +2997,11 @@ public:
|
|||||||
return std::numeric_limits<unsigned long>::is_specialized;
|
return std::numeric_limits<unsigned long>::is_specialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -3245,6 +3321,11 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -3341,6 +3422,11 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -3437,6 +3523,11 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBoolean() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isString() const
|
bool isString() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int inde
|
|||||||
{
|
{
|
||||||
out << "null";
|
out << "null";
|
||||||
}
|
}
|
||||||
|
else if ( any.isNumeric() || any.isBoolean() )
|
||||||
|
{
|
||||||
|
out << any.convert<std::string>();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string value = any.convert<std::string>();
|
std::string value = any.convert<std::string>();
|
||||||
|
|||||||
Reference in New Issue
Block a user