string addBinary(string a, string b) { if(a.size() == 0) return b; if(b.size() == 0) return a; char c= '0'; int i_ = a.size(); int j_ = b.size(); string ret; while(i_ || j_){ char c1; char c2; if(i_ > 0) {c1 = a[--i_];} else {c1 = '0';} if(j_ > 0) {c2 = b[--j_];} else {c2 = '0';} char tmp1 = xorOp(c1, c2); char tmp2 = andOp(c1, c2); char sum = xorOp(tmp1, c); c = orOp(tmp2, andOp(c, tmp1)); ret = sum + ret; } if(c =='1') ret = "1" + ret; return ret; }
ObjPtr Boolean::sendMsg(MsgPtr message) { switch(message->id) { case 5859493UL: // == return equal(message->args.front()); break; case 5858873UL: // != return notEqual(message->args.front()); break; case 1756282918UL: // to-str return toStr(); break; case 177539UL: // & return andOp(message->args.front()); break; case 177625UL: // | return orOp(message->args.front()); break; case 177540UL: // ! return notOp(); break; case 2123293021UL: // to-bool return make(_value); break; default: std::cerr << "Boolean does not support method(" << message << ")" << std::endl; throw 100; break; } return ObjPtr(); }
TEST( ElemMatchObjectMatchExpression, MatchesElementMultiple ) { BSONObj baseOperand1 = BSON( "b" << 5 ); BSONObj baseOperand2 = BSON( "b" << 6 ); BSONObj baseOperand3 = BSON( "c" << 7 ); BSONObj notMatch1 = BSON( "a" << BSON_ARRAY( BSON( "b" << 5 << "c" << 7 ) ) ); BSONObj notMatch2 = BSON( "a" << BSON_ARRAY( BSON( "b" << 6 << "c" << 7 ) ) ); BSONObj notMatch3 = BSON( "a" << BSON_ARRAY( BSON( "b" << BSON_ARRAY( 5 << 6 ) ) ) ); BSONObj match = BSON( "a" << BSON_ARRAY( BSON( "b" << BSON_ARRAY( 5 << 6 ) << "c" << 7 ) ) ); auto_ptr<ComparisonMatchExpression> eq1( new ComparisonMatchExpression() ); ASSERT( eq1->init( "b", ComparisonMatchExpression::EQ, baseOperand1[ "b" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> eq2( new ComparisonMatchExpression() ); ASSERT( eq2->init( "b", ComparisonMatchExpression::EQ, baseOperand2[ "b" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> eq3( new ComparisonMatchExpression() ); ASSERT( eq3->init( "c", ComparisonMatchExpression::EQ, baseOperand3[ "c" ] ).isOK() ); auto_ptr<AndMatchExpression> andOp( new AndMatchExpression() ); andOp->add( eq1.release() ); andOp->add( eq2.release() ); andOp->add( eq3.release() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", andOp.release() ).isOK() ); ASSERT( !op.matchesSingleElement( notMatch1[ "a" ] ) ); ASSERT( !op.matchesSingleElement( notMatch2[ "a" ] ) ); ASSERT( !op.matchesSingleElement( notMatch3[ "a" ] ) ); ASSERT( op.matchesSingleElement( match[ "a" ] ) ); }
LOCA::StatusTest::StatusType LOCA::StatusTest::Combo:: //checkStatus(const LOCA::Stepper& stepper, checkStatus(const LOCA::Abstract::Iterator& stepper, LOCA::StatusTest::CheckType checkType) { if (type == OR) orOp(stepper, checkType); else andOp(stepper, checkType); return status; }
StatusType StatusTestCombo<ScalarType,MV,OP>::checkStatus( Iteration<ScalarType,MV,OP>* iSolver ) { status_ = Failed; if (type_ == OR) orOp( iSolver ); else if (type_ == AND) andOp( iSolver ); else seqOp( iSolver ); return status_; }