mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-20 22:31:23 +01:00
SF [2000408] DynamicAny non-initialized state support (more changes/fixes)
This commit is contained in:
parent
8e993b9240
commit
cfbe8fd28a
@ -192,7 +192,7 @@ public:
|
||||
/// Inequality operator.
|
||||
|
||||
bool operator < (const Row& other) const;
|
||||
/// Less-then operator.
|
||||
/// Less-than operator.
|
||||
|
||||
const NameVecPtr names() const;
|
||||
/// Returns the shared pointer to names vector.
|
||||
|
@ -45,8 +45,8 @@ namespace Data {
|
||||
|
||||
std::ostream& operator << (std::ostream &os, const Row& row)
|
||||
{
|
||||
os << row.valuesToString();
|
||||
return os;
|
||||
os << row.valuesToString();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@ -182,14 +182,18 @@ void Row::replaceSortField(std::size_t oldPos, std::size_t newPos)
|
||||
|
||||
ComparisonType ct;
|
||||
|
||||
if ((_values[newPos].type() == typeid(Poco::Int8)) ||
|
||||
(_values[newPos].type() == typeid(Poco::UInt8)) ||
|
||||
(_values[newPos].type() == typeid(Poco::Int16)) ||
|
||||
(_values[newPos].type() == typeid(Poco::UInt16)) ||
|
||||
(_values[newPos].type() == typeid(Poco::Int32)) ||
|
||||
(_values[newPos].type() == typeid(Poco::UInt32)) ||
|
||||
(_values[newPos].type() == typeid(Poco::Int64)) ||
|
||||
(_values[newPos].type() == typeid(Poco::UInt64)) ||
|
||||
if (_values[newPos].isEmpty())
|
||||
{
|
||||
throw IllegalStateException("Empty value not sortable.");
|
||||
}
|
||||
else if ((_values[newPos].type() == typeid(Poco::Int8)) ||
|
||||
(_values[newPos].type() == typeid(Poco::UInt8)) ||
|
||||
(_values[newPos].type() == typeid(Poco::Int16)) ||
|
||||
(_values[newPos].type() == typeid(Poco::UInt16)) ||
|
||||
(_values[newPos].type() == typeid(Poco::Int32)) ||
|
||||
(_values[newPos].type() == typeid(Poco::UInt32)) ||
|
||||
(_values[newPos].type() == typeid(Poco::Int64)) ||
|
||||
(_values[newPos].type() == typeid(Poco::UInt64)) ||
|
||||
(_values[newPos].type() == typeid(bool)))
|
||||
{
|
||||
ct = COMPARE_AS_INTEGER;
|
||||
|
@ -495,7 +495,7 @@ inline void DynamicAny::swap(DynamicAny& ptr)
|
||||
|
||||
inline const std::type_info& DynamicAny::type() const
|
||||
{
|
||||
return _pHolder->type();
|
||||
return _pHolder ? _pHolder->type() : typeid(void);
|
||||
}
|
||||
|
||||
|
||||
@ -525,6 +525,7 @@ inline DynamicAny& DynamicAny::operator += (const char*other)
|
||||
|
||||
inline bool DynamicAny::operator == (const DynamicAny& other) const
|
||||
{
|
||||
if (isEmpty() || other.isEmpty()) return false;
|
||||
return convert<std::string>() == other.convert<std::string>();
|
||||
}
|
||||
|
||||
@ -537,6 +538,7 @@ inline bool DynamicAny::operator == (const char* other) const
|
||||
|
||||
inline bool DynamicAny::operator != (const DynamicAny& other) const
|
||||
{
|
||||
if (isEmpty() || other.isEmpty()) return false;
|
||||
return convert<std::string>() != other.convert<std::string>();
|
||||
}
|
||||
|
||||
@ -562,37 +564,37 @@ inline bool DynamicAny::isEmpty() const
|
||||
|
||||
inline bool DynamicAny::isArray() const
|
||||
{
|
||||
return _pHolder->isArray();
|
||||
return _pHolder ? _pHolder->isArray() : false;
|
||||
}
|
||||
|
||||
|
||||
inline bool DynamicAny::isStruct() const
|
||||
{
|
||||
return _pHolder->isStruct();
|
||||
return _pHolder ? _pHolder->isStruct() : false;
|
||||
}
|
||||
|
||||
|
||||
inline bool DynamicAny::isInteger() const
|
||||
{
|
||||
return _pHolder->isInteger();
|
||||
return _pHolder ? _pHolder->isInteger() : false;
|
||||
}
|
||||
|
||||
|
||||
inline bool DynamicAny::isSigned() const
|
||||
{
|
||||
return _pHolder->isSigned();
|
||||
return _pHolder ? _pHolder->isSigned() : false;
|
||||
}
|
||||
|
||||
|
||||
inline bool DynamicAny::isNumeric() const
|
||||
{
|
||||
return _pHolder->isNumeric();
|
||||
return _pHolder ? _pHolder->isNumeric() : false;
|
||||
}
|
||||
|
||||
|
||||
inline bool DynamicAny::isString() const
|
||||
{
|
||||
return _pHolder->isString();
|
||||
return _pHolder ? _pHolder->isString() : false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2228,6 +2228,15 @@ void DynamicAnyTest::testEmpty()
|
||||
{
|
||||
DynamicAny da;
|
||||
assert (da.isEmpty());
|
||||
assert (da.type() == typeid(void));
|
||||
assert (!da.isArray());
|
||||
assert (!da.isInteger());
|
||||
assert (!da.isNumeric());
|
||||
assert (!da.isSigned());
|
||||
assert (!da.isString());
|
||||
assert (!(da == da));
|
||||
assert (!(da != da));
|
||||
|
||||
da = "123";
|
||||
int i = da.convert<int>();
|
||||
assert (123 == i);
|
||||
@ -2236,6 +2245,14 @@ void DynamicAnyTest::testEmpty()
|
||||
assert (!da.isEmpty());
|
||||
da.empty();
|
||||
assert (da.isEmpty());
|
||||
assert (da.type() == typeid(void));
|
||||
assert (!da.isArray());
|
||||
assert (!da.isInteger());
|
||||
assert (!da.isNumeric());
|
||||
assert (!da.isSigned());
|
||||
assert (!da.isString());
|
||||
assert (!(da == da));
|
||||
assert (!(da != da));
|
||||
|
||||
try
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user