mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-20 22:31:23 +01:00
added Var::isBoolean() and fixed JSON stringifier
This commit is contained in:
parent
65628a6f60
commit
f2512856ee
@ -495,6 +495,10 @@ public:
|
||||
/// Returns true if stored value is numeric.
|
||||
/// 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;
|
||||
/// 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
|
||||
{
|
||||
VarHolder* pHolder = content();
|
||||
|
@ -246,6 +246,10 @@ public:
|
||||
/// Returns false. Must be properly overriden in a type
|
||||
/// 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;
|
||||
/// Returns false. Must be properly overriden in a type
|
||||
/// 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
|
||||
{
|
||||
return false;
|
||||
@ -782,6 +792,11 @@ public:
|
||||
return std::numeric_limits<Int8>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -921,6 +936,7 @@ public:
|
||||
return std::numeric_limits<Int16>::is_specialized;
|
||||
}
|
||||
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -1054,6 +1070,11 @@ public:
|
||||
return std::numeric_limits<Int32>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -1202,6 +1223,11 @@ public:
|
||||
return std::numeric_limits<Int64>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -1335,6 +1361,11 @@ public:
|
||||
return std::numeric_limits<UInt8>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -1468,6 +1499,11 @@ public:
|
||||
return std::numeric_limits<UInt16>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -1601,6 +1637,11 @@ public:
|
||||
return std::numeric_limits<UInt32>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -1755,6 +1796,11 @@ public:
|
||||
return std::numeric_limits<UInt64>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -1886,6 +1932,11 @@ public:
|
||||
return std::numeric_limits<bool>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -2020,6 +2071,11 @@ public:
|
||||
return std::numeric_limits<float>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -2160,6 +2216,11 @@ public:
|
||||
return std::numeric_limits<double>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -2291,6 +2352,11 @@ public:
|
||||
return std::numeric_limits<char>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -2793,6 +2859,11 @@ public:
|
||||
return std::numeric_limits<long>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -2926,6 +2997,11 @@ public:
|
||||
return std::numeric_limits<unsigned long>::is_specialized;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -3245,6 +3321,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -3341,6 +3422,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
@ -3437,6 +3523,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isBoolean() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
|
@ -55,6 +55,10 @@ void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int inde
|
||||
{
|
||||
out << "null";
|
||||
}
|
||||
else if ( any.isNumeric() || any.isBoolean() )
|
||||
{
|
||||
out << any.convert<std::string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string value = any.convert<std::string>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user