bool WhereMatchExpression::equivalent( const MatchExpression* other ) const { if ( matchType() != other->matchType() ) return false; const WhereMatchExpression* realOther = static_cast<const WhereMatchExpression*>(other); return _ns == realOther->_ns && _code == realOther->_code && _userScope == realOther->_userScope; }
bool InternalSchemaStrLengthMatchExpression::equivalent(const MatchExpression* other) const { if (matchType() != other->matchType()) return false; const InternalSchemaStrLengthMatchExpression* realOther = static_cast<const InternalSchemaStrLengthMatchExpression*>(other); return path() == realOther->path() && _strLen == realOther->_strLen; }
bool RegexMatchExpression::equivalent( const MatchExpression* other ) const { if ( matchType() != other->matchType() ) return false; const RegexMatchExpression* realOther = static_cast<const RegexMatchExpression*>( other ); return _path == realOther->_path && _regex == realOther->_regex && _flags == realOther->_flags; }
bool ComparisonMatchExpression::equivalent( const MatchExpression* other ) const { if ( other->matchType() != matchType() ) return false; const ComparisonMatchExpression* realOther = static_cast<const ComparisonMatchExpression*>( other ); return _path == realOther->_path && _rhs.valuesEqual( realOther->_rhs ); }
bool ModMatchExpression::equivalent( const MatchExpression* other ) const { if ( matchType() != other->matchType() ) return false; const ModMatchExpression* realOther = static_cast<const ModMatchExpression*>( other ); return _path == realOther->_path && _divisor == realOther->_divisor && _remainder == realOther->_remainder; }
bool InternalSchemaFmodMatchExpression::equivalent(const MatchExpression* other) const { if (matchType() != other->matchType()) { return false; } const InternalSchemaFmodMatchExpression* realOther = static_cast<const InternalSchemaFmodMatchExpression*>(other); return path() == realOther->path() && _divisor.isEqual(realOther->_divisor) && _remainder.isEqual(realOther->_remainder); }
void AccountLookup::refresh() { QApplication::setOverrideCursor(waitCursor); qApp->processEvents(); _list->clear(); AccountSelect conditions; if (!text().isEmpty()) conditions.name = text() + "%"; conditions.type = matchType(); conditions.headerOnly = (includeHeader && !includePosting); conditions.postingOnly = (includePosting && !includeHeader); conditions.activeOnly = activeOnly; int count; _quasar->db()->count(count, conditions); if (count > 100) { QApplication::restoreOverrideCursor(); QWidget* parent = this; if (isHidden() && parentWidget() != NULL) parent = parentWidget(); QString message = tr("This will select %1 items\n" "which may be slow. Continue?").arg(count); int ch = QMessageBox::warning(parent, tr("Are You Sure?"), message, QMessageBox::Yes, QMessageBox::No); if (ch != QMessageBox::Yes) return; QApplication::setOverrideCursor(waitCursor); qApp->processEvents(); } vector<Account> accounts; _quasar->db()->select(accounts, conditions); for (unsigned int i = 0; i < accounts.size(); ++i) { Account& account = accounts[i]; if (account.id() == skipId) continue; ListViewItem* item = new ListViewItem(_list, account.id()); item->setValue(0, account.name()); item->setValue(1, account.number()); item->setValue(2, account.typeName()); } QListViewItem* current = _list->firstChild(); _list->setCurrentItem(current); _list->setSelected(current, true); _list->triggerUpdate(); QApplication::restoreOverrideCursor(); }
bool ComparisonMatchExpression::equivalent(const MatchExpression* other) const { if (other->matchType() != matchType()) return false; const ComparisonMatchExpression* realOther = static_cast<const ComparisonMatchExpression*>(other); if (!CollatorInterface::collatorsMatch(_collator, realOther->_collator)) { return false; } return path() == realOther->path() && _rhs.valuesEqual(realOther->_rhs); }
void ComparisonMatchExpression::toBSON(BSONObjBuilder* out) const { string opString = ""; switch ( matchType() ) { case LT: opString = "$lt"; break; case LTE: opString = "$lte"; break; case EQ: opString = "$eq"; break; case GT: opString = "$gt"; break; case GTE: opString = "$gte"; break; default: opString = " UNKNOWN - should be impossible"; break; } out->append(path(), BSON(opString << _rhs)); }
bool ComparisonMatchExpressionBase::equivalent(const MatchExpression* other) const { if (other->matchType() != matchType()) return false; auto realOther = static_cast<const ComparisonMatchExpressionBase*>(other); if (!CollatorInterface::collatorsMatch(_collator, realOther->_collator)) { return false; } const StringData::ComparatorInterface* stringComparator = nullptr; BSONElementComparator eltCmp(BSONElementComparator::FieldNamesMode::kIgnore, stringComparator); return path() == realOther->path() && eltCmp.evaluate(_rhs == realOther->_rhs); }
bool GeoMatchExpression::equivalent( const MatchExpression* other ) const { if ( matchType() != other->matchType() ) return false; const GeoMatchExpression* realOther = static_cast<const GeoMatchExpression*>( other ); if ( path() != realOther->path() ) return false; // TODO: // return _query == realOther->_query; return false; }
bool Rules::match(const Client* c) const { if (!matchType(c->windowType(true))) return false; if (!matchWMClass(c->resourceClass(), c->resourceName())) return false; if (!matchRole(c->windowRole())) return false; if (!matchTitle(c->caption(false))) return false; if (!matchClientMachine(c->clientMachine()->hostName(), c->clientMachine()->isLocal())) return false; return true; }
bool BitTestMatchExpression::equivalent(const MatchExpression* other) const { if (matchType() != other->matchType()) { return false; } const BitTestMatchExpression* realOther = static_cast<const BitTestMatchExpression*>(other); std::vector<uint32_t> myBitPositions = getBitPositions(); std::vector<uint32_t> otherBitPositions = realOther->getBitPositions(); std::sort(myBitPositions.begin(), myBitPositions.end()); std::sort(otherBitPositions.begin(), otherBitPositions.end()); return path() == realOther->path() && myBitPositions == otherBitPositions; }
int matchType(type_t type1, type_t type2) { // fprintf(stderr, "Matching type\n"); if (type1->base_type != type2->base_type) { // fprintf(stderr, "Matching failed\n"); return 0; } if (type1->base_type == ARRAY_T) { // fprintf(stderr, "Matching child type\n"); return matchType(type1->child_type, type2->child_type); } else { // fprintf(stderr, "Matching succeeded\n"); return 1; } }
void ComparisonMatchExpression::debugString( StringBuilder& debug, int level ) const { _debugAddSpace( debug, level ); debug << _path << " "; switch ( matchType() ) { case LT: debug << "$lt"; break; case LTE: debug << "$lte"; break; case EQ: debug << "=="; break; case GT: debug << "$gt"; break; case GTE: debug << "$gte"; break; case NE: debug << "$ne"; break; default: debug << " UNKNOWN - should be impossible"; break; } debug << " " << _rhs.toString( false ) << "\n"; }
bool ComparisonMatchExpression::matchesSingleElement( const BSONElement& e ) const { //log() << "\t ComparisonMatchExpression e: " << e << " _rhs: " << _rhs << "\n" //<< toString() << std::endl; if ( e.canonicalType() != _rhs.canonicalType() ) { // some special cases // jstNULL and undefined are treated the same if ( e.canonicalType() + _rhs.canonicalType() == 5 ) { return matchType() == EQ || matchType() == LTE || matchType() == GTE; } if ( _rhs.type() == MaxKey || _rhs.type() == MinKey ) { return matchType() != EQ; } return false; } int x = compareElementValues( e, _rhs ); //log() << "\t\t" << x << endl; switch ( matchType() ) { case LT: return x < 0; case LTE: return x <= 0; case EQ: return x == 0; case GT: return x > 0; case GTE: return x >= 0; default: fassertFailed( 16828 ); } }
bool ComparisonMatchExpression::matchesSingleElement(const BSONElement& e) const { if (e.canonicalType() != _rhs.canonicalType()) { // some special cases // jstNULL and undefined are treated the same if (e.canonicalType() + _rhs.canonicalType() == 5) { return matchType() == EQ || matchType() == LTE || matchType() == GTE; } if (_rhs.type() == MaxKey || _rhs.type() == MinKey) { return matchType() != EQ; } return false; } // Special case handling for NaN. NaN is equal to NaN but // otherwise always compares to false. if (std::isnan(e.numberDouble()) || std::isnan(_rhs.numberDouble())) { bool bothNaN = std::isnan(e.numberDouble()) && std::isnan(_rhs.numberDouble()); switch (matchType()) { case LT: return false; case LTE: return bothNaN; case EQ: return bothNaN; case GT: return false; case GTE: return bothNaN; default: // This is a comparison match expression, so it must be either // a $lt, $lte, $gt, $gte, or equality expression. fassertFailed(17448); } } int x = compareElementValues(e, _rhs, _collator); switch (matchType()) { case LT: return x < 0; case LTE: return x <= 0; case EQ: return x == 0; case GT: return x > 0; case GTE: return x >= 0; default: // This is a comparison match expression, so it must be either // a $lt, $lte, $gt, $gte, or equality expression. fassertFailed(16828); } }
bool BitTestMatchExpression::performBitTest(long long eValue) const { const MatchType mt = matchType(); switch (mt) { case BITS_ALL_SET: return (eValue & _bitMask) == _bitMask; case BITS_ALL_CLEAR: return (~eValue & _bitMask) == _bitMask; case BITS_ANY_SET: return eValue & _bitMask; case BITS_ANY_CLEAR: return ~eValue & _bitMask; default: invariant(false); } }
bool TextMatchExpression::equivalent( const MatchExpression* other ) const { if ( matchType() != other->matchType() ) { return false; } const TextMatchExpression* realOther = static_cast<const TextMatchExpression*>( other ); // TODO This is way too crude. It looks for string equality, but it should be looking for // common parsed form if ( realOther->getQuery() != _query ) { return false; } if ( realOther->getLanguage() != _language ) { return false; } return true; }
bool ListOfMatchExpression::equivalent( const MatchExpression* other ) const { if ( matchType() != other->matchType() ) return false; const ListOfMatchExpression* realOther = static_cast<const ListOfMatchExpression*>( other ); if ( _expressions.size() != realOther->_expressions.size() ) return false; // TOOD: order doesn't matter for ( unsigned i = 0; i < _expressions.size(); i++ ) if ( !_expressions[i]->equivalent( realOther->_expressions[i] ) ) return false; return true; }
bool ExprMatchExpression::equivalent(const MatchExpression* other) const { if (other->matchType() != matchType()) { return false; } const ExprMatchExpression* realOther = static_cast<const ExprMatchExpression*>(other); if (!CollatorInterface::collatorsMatch(_expCtx->getCollator(), realOther->_expCtx->getCollator())) { return false; } // TODO SERVER-30982: Add mechanism to allow for checking Expression equivalency. return ValueComparator().evaluate(_expression->serialize(false) == realOther->_expression->serialize(false)); }
bool TypeMatchExpression::equivalent(const MatchExpression* other) const { if (matchType() != other->matchType()) return false; const TypeMatchExpression* realOther = static_cast<const TypeMatchExpression*>(other); if (_path != realOther->_path) { return false; } if (_matchesAllNumbers) { return realOther->_matchesAllNumbers; } return _type == realOther->_type; }
bool AllElemMatchOp::equivalent( const MatchExpression* other ) const { if ( matchType() != other->matchType() ) return false; const AllElemMatchOp* realOther = static_cast<const AllElemMatchOp*>( other ); if ( _path != realOther->_path ) return false; if ( _list.size() != realOther->_list.size() ) return false; for ( unsigned i = 0; i < _list.size(); i++ ) if ( !_list[i]->equivalent( realOther->_list[i] ) ) return false; return true; }
bool LLNotificationsListener::Forwarder::handle(const LLSD& notification) const { LL_INFOS("LLNotificationsListener") << "handle(" << notification << ")" << LL_ENDL; if (notification["sigtype"].asString() == "delete") { LL_INFOS("LLNotificationsListener") << "ignoring delete" << LL_ENDL; // let other listeners see the "delete" operation return false; } LLNotificationPtr note(mNotifications.find(notification["id"])); if (! note) { LL_INFOS("LLNotificationsListener") << notification["id"] << " not found" << LL_ENDL; return false; } if (! matchType(mTypes, note->getType())) { LL_INFOS("LLNotificationsListener") << "didn't match types " << mTypes << LL_ENDL; // We're not supposed to intercept this particular notification. Let // other listeners process it. return false; } LL_INFOS("LLNotificationsListener") << "sending via '" << mPumpName << "'" << LL_ENDL; // This is a notification we care about. Forward it through specified // LLEventPump. LLEventPumps::instance().obtain(mPumpName).post(asLLSD(note)); // Are we also being asked to auto-respond? if (mRespond) { LL_INFOS("LLNotificationsListener") << "should respond" << LL_ENDL; note->respond(LLSD::emptyMap()); // Did that succeed in removing the notification? Only cancel() if // it's still around -- otherwise we get an LL_ERRS crash! note = mNotifications.find(notification["id"]); if (note) { LL_INFOS("LLNotificationsListener") << "respond() didn't clear, canceling" << LL_ENDL; mNotifications.cancel(note); } } // If we've auto-responded to this notification, then it's going to be // deleted. Other listeners would get the change operation, try to look it // up and be baffled by lookup failure. So when we auto-respond, suppress // this notification: don't pass it to other listeners. return mRespond; }
bool ArrayMatchingMatchExpression::equivalent( const MatchExpression* other ) const { if ( matchType() != other->matchType() ) return false; const ArrayMatchingMatchExpression* realOther = static_cast<const ArrayMatchingMatchExpression*>( other ); if ( _path != realOther->_path ) return false; if ( numChildren() != realOther->numChildren() ) return false; for ( unsigned i = 0; i < numChildren(); i++ ) if ( !getChild(i)->equivalent( realOther->getChild(i) ) ) return false; return true; }
void CNSmlDummyDataProvider_Test::DoGenerateRecordFilterQueryL() { RPointerArray< CSyncMLFilter >* filters = new ( ELeave ) RPointerArray< CSyncMLFilter >(); CleanupRPtrArrayPushL( filters ); TSyncMLFilterMatchType matchType( ESyncMLMatchDisabled ); TSyncMLFilterType filterType( ESyncMLTypeInclusive ); TBuf< 100 > mimeType; TRAPD( err, { HBufC* storeName = NULL; HBufC* record = NULL; record = iCNSmlDummyDataProvider->DoGenerateRecordFilterQueryLC( *filters, matchType, mimeType, filterType, *storeName ); delete record; delete storeName; } );
bool Rules::match(const Client* c) const { if (!matchType(c->windowType(true))) return false; if (!matchWMClass(c->resourceClass(), c->resourceName())) return false; if (!matchRole(c->windowRole().toLower())) return false; if (!matchClientMachine(c->clientMachine()->hostName(), c->clientMachine()->isLocal())) return false; if (titlematch != UnimportantMatch) // track title changes to rematch rules QObject::connect(c, &Client::captionChanged, c, &Client::evaluateWindowRules, // QueuedConnection, because title may change before // the client is ready (could segfault!) static_cast<Qt::ConnectionType>(Qt::QueuedConnection|Qt::UniqueConnection)); if (!matchTitle(c->caption(false))) return false; return true; }
void ComparisonMatchExpression::debugString( StringBuilder& debug, int level ) const { _debugAddSpace( debug, level ); debug << path() << " "; switch ( matchType() ) { case LT: debug << "$lt"; break; case LTE: debug << "$lte"; break; case EQ: debug << "=="; break; case GT: debug << "$gt"; break; case GTE: debug << "$gte"; break; default: debug << " UNKNOWN - should be impossible"; break; } debug << " " << _rhs.toString( false ); MatchExpression::TagData* td = getTag(); if (NULL != td) { debug << " "; td->debugString(&debug); } debug << "\n"; }
bool InMatchExpression::equivalent(const MatchExpression* other) const { if (matchType() != other->matchType()) { return false; } const InMatchExpression* realOther = static_cast<const InMatchExpression*>(other); if (path() != realOther->path()) { return false; } if (_hasNull != realOther->_hasNull) { return false; } if (_regexes.size() != realOther->_regexes.size()) { return false; } for (size_t i = 0; i < _regexes.size(); ++i) { if (!_regexes[i]->equivalent(realOther->_regexes[i].get())) { return false; } } if (!CollatorInterface::collatorsMatch(_collator, realOther->_collator)) { return false; } // We use an element-wise comparison to check equivalence of '_equalitySet'. Unfortunately, we // can't use BSONElementSet::operator==(), as it does not use the comparator object the set is // initialized with (and as such, it is not collation-aware). if (_equalitySet.size() != realOther->_equalitySet.size()) { return false; } auto thisEqIt = _equalitySet.begin(); auto otherEqIt = realOther->_equalitySet.begin(); for (; thisEqIt != _equalitySet.end(); ++thisEqIt, ++otherEqIt) { const bool considerFieldName = false; if (thisEqIt->woCompare(*otherEqIt, considerFieldName, _collator)) { return false; } } invariant(otherEqIt == realOther->_equalitySet.end()); return true; }
ComparisonMatchExpression::ComparisonMatchExpression(MatchType type, StringData path, const BSONElement& rhs) : ComparisonMatchExpressionBase(type, path, rhs, ElementPath::LeafArrayBehavior::kTraverse, ElementPath::NonLeafArrayBehavior::kTraverse) { uassert( ErrorCodes::BadValue, "cannot compare to undefined", _rhs.type() != BSONType::Undefined); switch (matchType()) { case LT: case LTE: case EQ: case GT: case GTE: break; default: uasserted(ErrorCodes::BadValue, "bad match type for ComparisonMatchExpression"); } }