mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 09:12:28 +02:00
SF 1969276 DynamicAny("") should be false; added operator!
This commit is contained in:
@@ -66,8 +66,8 @@ class Foundation_API DynamicAny
|
|||||||
///
|
///
|
||||||
/// Boolean conversion is performed as follows:
|
/// Boolean conversion is performed as follows:
|
||||||
///
|
///
|
||||||
/// A string value "false" (not case sensitive) or "0" can be converted to a boolean value false, any other string
|
/// A string value "false" (not case sensitive), "0" or "" (empty string) can be converted to a boolean value false,
|
||||||
/// not being false by the above criteria evaluates to true (e.g: "hi" -> true).
|
/// any other string not being false by the above criteria evaluates to true (e.g: "hi" -> true).
|
||||||
/// Integer 0 values are false, everything else is true.
|
/// Integer 0 values are false, everything else is true.
|
||||||
/// Floating point values equal to the minimal FP representation on a given platform are false, everything else is true.
|
/// Floating point values equal to the minimal FP representation on a given platform are false, everything else is true.
|
||||||
///
|
///
|
||||||
@@ -186,6 +186,11 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator ! ()
|
||||||
|
{
|
||||||
|
return !convert<bool>();
|
||||||
|
}
|
||||||
|
|
||||||
DynamicAny& operator = (const DynamicAny& other);
|
DynamicAny& operator = (const DynamicAny& other);
|
||||||
/// Assignment operator specialization for DynamicAny
|
/// Assignment operator specialization for DynamicAny
|
||||||
|
|
||||||
|
|||||||
@@ -2214,12 +2214,15 @@ public:
|
|||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
static const std::string VAL_FALSE("false");
|
static const std::string VAL_FALSE("false");
|
||||||
static const std::string VAL_INTFALSE("0");
|
static const std::string VAL_INT_FALSE("0");
|
||||||
|
|
||||||
if (_val == VAL_INTFALSE || (icompare(_val, VAL_FALSE) == 0))
|
if (_val.empty() ||
|
||||||
|
_val == VAL_INT_FALSE ||
|
||||||
|
(icompare(_val, VAL_FALSE) == 0))
|
||||||
|
{
|
||||||
val = false;
|
val = false;
|
||||||
else
|
}
|
||||||
val = true;
|
else val = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(float& val) const
|
void convert(float& val) const
|
||||||
|
|||||||
@@ -1154,6 +1154,13 @@ void DynamicAnyTest::testString()
|
|||||||
assert (a6 == "123456789");
|
assert (a6 == "123456789");
|
||||||
a4 += "789";
|
a4 += "789";
|
||||||
assert (a4 == "123456789");
|
assert (a4 == "123456789");
|
||||||
|
|
||||||
|
a4 = "";
|
||||||
|
assert(!a4);
|
||||||
|
a4 = "0";
|
||||||
|
assert(!a4);
|
||||||
|
a4 = "FaLsE";
|
||||||
|
assert(!a4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user