static bool _Evaluate( const WQLOperand& lhs, const WQLOperand& rhs, WQLOperation op) { switch (lhs.getType()) { case WQLOperand::NULL_VALUE: { // return true if the op is WQL_EQ and the rhs is NULL // also if op is WQL_NE and rhs is not NULL return !(op == WQL_EQ) ^ (rhs.getType() == WQLOperand::NULL_VALUE); break; } case WQLOperand::INTEGER_VALUE: { return _Compare( lhs.getIntegerValue(), rhs.getIntegerValue(), op); } case WQLOperand::DOUBLE_VALUE: { return _Compare( lhs.getDoubleValue(), rhs.getDoubleValue(), op); } case WQLOperand::BOOLEAN_VALUE: { return _Compare( lhs.getBooleanValue(), rhs.getBooleanValue(), op); } case WQLOperand::STRING_VALUE: { return _Compare( lhs.getStringValue(), rhs.getStringValue(), op); } default: OW_ASSERT(0); } return false; }
static bool operator==(const WQLOperand& x, const WQLOperand& y) { if( x.getType()==y.getType() ) { switch( x.getType() ) { case WQLOperand::PROPERTY_NAME: return x.getPropertyName()==y.getPropertyName(); case WQLOperand::INTEGER_VALUE: return x.getIntegerValue()==y.getIntegerValue(); case WQLOperand::DOUBLE_VALUE: return x.getDoubleValue()==y.getDoubleValue(); case WQLOperand::BOOLEAN_VALUE: return x.getBooleanValue()==y.getBooleanValue(); case WQLOperand::STRING_VALUE: return x.getStringValue()==y.getStringValue(); case WQLOperand::NULL_VALUE: return true; } } return false; }
String WQL2String(const WQLOperand &o) { switch( o.getType() ) { case WQLOperand::PROPERTY_NAME: return o.getPropertyName(); case WQLOperand::STRING_VALUE: return o.getStringValue(); case WQLOperand::INTEGER_VALUE: return Formatter::format("$0",o.getIntegerValue()); case WQLOperand::DOUBLE_VALUE: return Formatter::format("$0",o.getDoubleValue()); case WQLOperand::BOOLEAN_VALUE: return Formatter::format("$0",o.getBooleanValue()); default: ; } return "NULL_VALUE"; }
static Boolean _Evaluate( const WQLOperand& lhs, const WQLOperand& rhs, WQLOperation op) { switch (lhs.getType()) { case WQLOperand::NULL_VALUE: { #ifdef PEGASUS_SNIA_EXTENSIONS return (rhs.getType() == WQLOperand::NULL_VALUE); #else // This cannot happen since expressions of the form // OPERAND OPERATOR NULL are converted to unary form. // For example: "count IS NULL" is treated as a unary // operation in which IS_NULL is the unary operation // and count is the the unary operand. PEGASUS_ASSERT(0); break; #endif } case WQLOperand::INTEGER_VALUE: { return _Compare( lhs.getIntegerValue(), rhs.getIntegerValue(), op); } case WQLOperand::DOUBLE_VALUE: { return _Compare( lhs.getDoubleValue(), rhs.getDoubleValue(), op); } case WQLOperand::BOOLEAN_VALUE: { return _Compare( lhs.getBooleanValue(), rhs.getBooleanValue(), op); } case WQLOperand::STRING_VALUE: { if(op != WQL_LIKE) { return _Compare( lhs.getStringValue(), rhs.getStringValue(), op); } else { CString lhsstr = lhs.getStringValue().getCString(); CString rhsstr = rhs.getStringValue().getCString(); const char* lhscs = (const char *)lhsstr; const char* rhscs = (const char *)rhsstr; return _LikeEvaluate((const char *)lhsstr, (const char *)rhsstr); } } default: PEGASUS_ASSERT(0); } return false; }