added Var::isBoolean() and fixed JSON stringifier

This commit is contained in:
Guenter Obiltschnig
2014-09-18 20:57:34 +02:00
parent 65628a6f60
commit f2512856ee
3 changed files with 106 additions and 0 deletions

View File

@@ -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();

View File

@@ -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;