|
|
|
@ -7,10 +7,9 @@
|
|
|
|
|
#include "../world/columns.hpp"
|
|
|
|
|
#include "../world/idtable.hpp"
|
|
|
|
|
|
|
|
|
|
CSMFilter::ValueNode::ValueNode (int columnId,
|
|
|
|
|
double lower, double upper, bool min, bool max)
|
|
|
|
|
: mColumnId (columnId), mLower (lower), mUpper (upper), mMin (min), mMax (max)
|
|
|
|
|
{}
|
|
|
|
|
CSMFilter::ValueNode::ValueNode (int columnId, Type lowerType, Type upperType,
|
|
|
|
|
double lower, double upper)
|
|
|
|
|
: mColumnId (columnId), mLowerType (lowerType), mUpperType (upperType), mLower (lower), mUpper (upper){}
|
|
|
|
|
|
|
|
|
|
bool CSMFilter::ValueNode::test (const CSMWorld::IdTable& table, int row,
|
|
|
|
|
const std::map<int, int>& columns) const
|
|
|
|
@ -33,10 +32,21 @@ bool CSMFilter::ValueNode::test (const CSMWorld::IdTable& table, int row,
|
|
|
|
|
|
|
|
|
|
double value = data.toDouble();
|
|
|
|
|
|
|
|
|
|
if (mLower==mUpper && mMin && mMax)
|
|
|
|
|
return value==mLower;
|
|
|
|
|
|
|
|
|
|
return (mMin ? value>=mLower : value>mLower) && (mMax ? value<=mUpper : value<mUpper);
|
|
|
|
|
switch (mLowerType)
|
|
|
|
|
{
|
|
|
|
|
case Type_Closed: if (value<mLower) return false; break;
|
|
|
|
|
case Type_Open: if (value<=mLower) return false; break;
|
|
|
|
|
case Type_Infinite: break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (mUpperType)
|
|
|
|
|
{
|
|
|
|
|
case Type_Closed: if (value>mUpper) return false; break;
|
|
|
|
|
case Type_Open: if (value>=mUpper) return false; break;
|
|
|
|
|
case Type_Infinite: break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<int> CSMFilter::ValueNode::getReferencedColumns() const
|
|
|
|
@ -60,10 +70,26 @@ std::string CSMFilter::ValueNode::toString (bool numericColumns) const
|
|
|
|
|
|
|
|
|
|
stream << ", \"";
|
|
|
|
|
|
|
|
|
|
if (mLower==mUpper && mMin && mMax)
|
|
|
|
|
if (mLower==mUpper && mLowerType!=Type_Infinite && mUpperType!=Type_Infinite)
|
|
|
|
|
stream << mLower;
|
|
|
|
|
else
|
|
|
|
|
stream << (mMin ? "[" : "(") << mLower << ", " << mUpper << (mMax ? "]" : ")");
|
|
|
|
|
{
|
|
|
|
|
switch (mLowerType)
|
|
|
|
|
{
|
|
|
|
|
case Type_Closed: stream << "[" << mLower; break;
|
|
|
|
|
case Type_Open: stream << "(" << mLower; break;
|
|
|
|
|
case Type_Infinite: stream << "("; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream << ", ";
|
|
|
|
|
|
|
|
|
|
switch (mUpperType)
|
|
|
|
|
{
|
|
|
|
|
case Type_Closed: stream << mUpper << "]"; break;
|
|
|
|
|
case Type_Open: stream << mUpper << ")"; break;
|
|
|
|
|
case Type_Infinite: stream << ")"; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream << ")";
|
|
|
|
|
|
|
|
|
|