diff options
author | Andrew Morrow <acm@mongodb.com> | 2015-06-10 17:43:13 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2015-06-10 22:37:44 -0400 |
commit | a9b6612f5322f916298c19a6728817a1034c6aab (patch) | |
tree | 0da5b1ce36e6a8e2d85dbdeb49d505ac99bf6e1d /src/mongo/db/matcher | |
parent | 0ec1e625760eb9c1a20a3dba78200e8f9ff28d9e (diff) | |
download | mongo-a9b6612f5322f916298c19a6728817a1034c6aab.tar.gz |
SERVER-17309 Replace std::auto_ptr<T> with std::unique_ptr<T>
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r-- | src/mongo/db/matcher/expression_array_test.cpp | 72 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_parser.cpp | 50 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_parser_geo.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_parser_text.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_parser_tree.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_tree.h | 2 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_tree_test.cpp | 98 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_where.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_where_noop.cpp | 4 |
9 files changed, 126 insertions, 126 deletions
diff --git a/src/mongo/db/matcher/expression_array_test.cpp b/src/mongo/db/matcher/expression_array_test.cpp index 96a89254a34..891d12752f6 100644 --- a/src/mongo/db/matcher/expression_array_test.cpp +++ b/src/mongo/db/matcher/expression_array_test.cpp @@ -38,13 +38,13 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; TEST( ElemMatchObjectMatchExpression, MatchesElementSingle ) { BSONObj baseOperand = BSON( "b" << 5 ); BSONObj match = BSON( "a" << BSON_ARRAY( BSON( "b" << 5.0 ) ) ); BSONObj notMatch = BSON( "a" << BSON_ARRAY( BSON( "b" << 6 ) ) ); - auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -56,7 +56,7 @@ namespace mongo { BSONObj baseOperand = BSON( "1" << 5 ); BSONObj match = BSON( "a" << BSON_ARRAY( BSON_ARRAY( 's' << 5.0 ) ) ); BSONObj notMatch = BSON( "a" << BSON_ARRAY( BSON_ARRAY( 5 << 6 ) ) ); - auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); ASSERT( eq->init( "1", baseOperand[ "1" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -73,14 +73,14 @@ namespace mongo { 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 EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq1( new EqualityMatchExpression() ); ASSERT( eq1->init( "b", baseOperand1[ "b" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> eq2( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq2( new EqualityMatchExpression() ); ASSERT( eq2->init( "b", baseOperand2[ "b" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> eq3( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq3( new EqualityMatchExpression() ); ASSERT( eq3->init( "c", baseOperand3[ "c" ] ).isOK() ); - auto_ptr<AndMatchExpression> andOp( new AndMatchExpression() ); + unique_ptr<AndMatchExpression> andOp( new AndMatchExpression() ); andOp->add( eq1.release() ); andOp->add( eq2.release() ); andOp->add( eq3.release() ); @@ -95,7 +95,7 @@ namespace mongo { TEST( ElemMatchObjectMatchExpression, MatchesNonArray ) { BSONObj baseOperand = BSON( "b" << 5 ); - auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -108,7 +108,7 @@ namespace mongo { TEST( ElemMatchObjectMatchExpression, MatchesArrayObject ) { BSONObj baseOperand = BSON( "b" << 5 ); - auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -121,7 +121,7 @@ namespace mongo { TEST( ElemMatchObjectMatchExpression, MatchesMultipleNamedValues ) { BSONObj baseOperand = BSON( "c" << 5 ); - auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); ASSERT( eq->init( "c", baseOperand[ "c" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a.b", eq.release() ).isOK() ); @@ -142,7 +142,7 @@ namespace mongo { TEST( ElemMatchObjectMatchExpression, ElemMatchKey ) { BSONObj baseOperand = BSON( "c" << 6 ); - auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); ASSERT( eq->init( "c", baseOperand[ "c" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a.b", eq.release() ).isOK() ); @@ -172,7 +172,7 @@ namespace mongo { /** TEST( ElemMatchObjectMatchExpression, MatchesIndexKey ) { BSONObj baseOperand = BSON( "b" << 5 ); - auto_ptr<ComparisonMatchExpression> eq( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new ComparisonMatchExpression() ); ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", eq.release() ).isOK() ); @@ -187,7 +187,7 @@ namespace mongo { BSONObj baseOperand = BSON( "$gt" << 5 ); BSONObj match = BSON( "a" << BSON_ARRAY( 6 ) ); BSONObj notMatch = BSON( "a" << BSON_ARRAY( 4 ) ); - auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a", gt.release() ).isOK() ); @@ -201,9 +201,9 @@ namespace mongo { BSONObj notMatch1 = BSON( "a" << BSON_ARRAY( 0 << 1 ) ); BSONObj notMatch2 = BSON( "a" << BSON_ARRAY( 10 << 11 ) ); BSONObj match = BSON( "a" << BSON_ARRAY( 0 << 5 << 11 ) ); - auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() ); ASSERT( lt->init( "", baseOperand2[ "$lt" ] ).isOK() ); ElemMatchValueMatchExpression op; @@ -218,7 +218,7 @@ namespace mongo { TEST( ElemMatchValueMatchExpression, MatchesNonArray ) { BSONObj baseOperand = BSON( "$gt" << 5 ); - auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchObjectMatchExpression op; ASSERT( op.init( "a", gt.release() ).isOK() ); @@ -230,7 +230,7 @@ namespace mongo { TEST( ElemMatchValueMatchExpression, MatchesArrayScalar ) { BSONObj baseOperand = BSON( "$gt" << 5 ); - auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a", gt.release() ).isOK() ); @@ -241,7 +241,7 @@ namespace mongo { TEST( ElemMatchValueMatchExpression, MatchesMultipleNamedValues ) { BSONObj baseOperand = BSON( "$gt" << 5 ); - auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a.b", gt.release() ).isOK() ); @@ -254,7 +254,7 @@ namespace mongo { TEST( ElemMatchValueMatchExpression, ElemMatchKey ) { BSONObj baseOperand = BSON( "$gt" << 6 ); - auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() ); ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a.b", gt.release() ).isOK() ); @@ -282,7 +282,7 @@ namespace mongo { /** TEST( ElemMatchValueMatchExpression, MatchesIndexKey ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr<LtOp> lt( new ComparisonMatchExpression() ); + unique_ptr<LtOp> lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a", lt.release() ).isOK() ); @@ -297,40 +297,40 @@ namespace mongo { BSONObj baseOperanda1 = BSON( "a" << 1 ); - auto_ptr<ComparisonMatchExpression> eqa1( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eqa1( new EqualityMatchExpression() ); ASSERT( eqa1->init( "a", baseOperanda1[ "a" ] ).isOK() ); BSONObj baseOperandb1 = BSON( "b" << 1 ); - auto_ptr<ComparisonMatchExpression> eqb1( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eqb1( new EqualityMatchExpression() ); ASSERT( eqb1->init( "b", baseOperandb1[ "b" ] ).isOK() ); - auto_ptr<AndMatchExpression> and1( new AndMatchExpression() ); + unique_ptr<AndMatchExpression> and1( new AndMatchExpression() ); and1->add( eqa1.release() ); and1->add( eqb1.release() ); // and1 = { a : 1, b : 1 } - auto_ptr<ElemMatchObjectMatchExpression> elemMatch1( new ElemMatchObjectMatchExpression() ); + unique_ptr<ElemMatchObjectMatchExpression> elemMatch1( new ElemMatchObjectMatchExpression() ); elemMatch1->init( "x", and1.release() ); // elemMatch1 = { x : { $elemMatch : { a : 1, b : 1 } } } BSONObj baseOperanda2 = BSON( "a" << 2 ); - auto_ptr<ComparisonMatchExpression> eqa2( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eqa2( new EqualityMatchExpression() ); ASSERT( eqa2->init( "a", baseOperanda2[ "a" ] ).isOK() ); BSONObj baseOperandb2 = BSON( "b" << 2 ); - auto_ptr<ComparisonMatchExpression> eqb2( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eqb2( new EqualityMatchExpression() ); ASSERT( eqb2->init( "b", baseOperandb2[ "b" ] ).isOK() ); - auto_ptr<AndMatchExpression> and2( new AndMatchExpression() ); + unique_ptr<AndMatchExpression> and2( new AndMatchExpression() ); and2->add( eqa2.release() ); and2->add( eqb2.release() ); // and2 = { a : 2, b : 2 } - auto_ptr<ElemMatchObjectMatchExpression> elemMatch2( new ElemMatchObjectMatchExpression() ); + unique_ptr<ElemMatchObjectMatchExpression> elemMatch2( new ElemMatchObjectMatchExpression() ); elemMatch2->init( "x", and2.release() ); // elemMatch2 = { x : { $elemMatch : { a : 2, b : 2 } } } - auto_ptr<AndMatchExpression> andOfEM( new AndMatchExpression() ); + unique_ptr<AndMatchExpression> andOfEM( new AndMatchExpression() ); andOfEM->add( elemMatch1.release() ); andOfEM->add( elemMatch2.release() ); @@ -354,34 +354,34 @@ namespace mongo { TEST( AndOfElemMatch, Matches ) { BSONObj baseOperandgt1 = BSON( "$gt" << 1 ); - auto_ptr<ComparisonMatchExpression> gt1( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> gt1( new GTMatchExpression() ); ASSERT( gt1->init( "", baseOperandgt1[ "$gt" ] ).isOK() ); BSONObj baseOperandlt1 = BSON( "$lt" << 10 ); - auto_ptr<ComparisonMatchExpression> lt1( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt1( new LTMatchExpression() ); ASSERT( lt1->init( "", baseOperandlt1[ "$lt" ] ).isOK() ); - auto_ptr<ElemMatchValueMatchExpression> elemMatch1( new ElemMatchValueMatchExpression() ); + unique_ptr<ElemMatchValueMatchExpression> elemMatch1( new ElemMatchValueMatchExpression() ); elemMatch1->init( "x" ); elemMatch1->add( gt1.release() ); elemMatch1->add( lt1.release() ); // elemMatch1 = { x : { $elemMatch : { $gt : 1 , $lt : 10 } } } BSONObj baseOperandgt2 = BSON( "$gt" << 101 ); - auto_ptr<ComparisonMatchExpression> gt2( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> gt2( new GTMatchExpression() ); ASSERT( gt2->init( "", baseOperandgt2[ "$gt" ] ).isOK() ); BSONObj baseOperandlt2 = BSON( "$lt" << 110 ); - auto_ptr<ComparisonMatchExpression> lt2( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt2( new LTMatchExpression() ); ASSERT( lt2->init( "", baseOperandlt2[ "$lt" ] ).isOK() ); - auto_ptr<ElemMatchValueMatchExpression> elemMatch2( new ElemMatchValueMatchExpression() ); + unique_ptr<ElemMatchValueMatchExpression> elemMatch2( new ElemMatchValueMatchExpression() ); elemMatch2->init( "x" ); elemMatch2->add( gt2.release() ); elemMatch2->add( lt2.release() ); // elemMatch2 = { x : { $elemMatch : { $gt : 101 , $lt : 110 } } } - auto_ptr<AndMatchExpression> andOfEM( new AndMatchExpression() ); + unique_ptr<AndMatchExpression> andOfEM( new AndMatchExpression() ); andOfEM->add( elemMatch1.release() ); andOfEM->add( elemMatch2.release() ); diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp index 3564d71a907..b2977e34117 100644 --- a/src/mongo/db/matcher/expression_parser.cpp +++ b/src/mongo/db/matcher/expression_parser.cpp @@ -67,7 +67,7 @@ namespace mongo { StatusWithMatchExpression MatchExpressionParser::_parseComparison( const char* name, ComparisonMatchExpression* cmp, const BSONElement& e ) { - std::auto_ptr<ComparisonMatchExpression> temp(cmp); + std::unique_ptr<ComparisonMatchExpression> temp(cmp); // Non-equality comparison match expressions cannot have // a regular expression as the argument (e.g. {a: {$gt: /b/}} is illegal). @@ -129,7 +129,7 @@ namespace mongo { StatusWithMatchExpression s = _parseComparison( name, new EqualityMatchExpression(), e ); if ( !s.isOK() ) return s; - std::auto_ptr<NotMatchExpression> n( new NotMatchExpression() ); + std::unique_ptr<NotMatchExpression> n( new NotMatchExpression() ); Status s2 = n->init( s.getValue() ); if ( !s2.isOK() ) return StatusWithMatchExpression( s2 ); @@ -141,7 +141,7 @@ namespace mongo { case BSONObj::opIN: { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$in needs an array" ); - std::auto_ptr<InMatchExpression> temp( new InMatchExpression() ); + std::unique_ptr<InMatchExpression> temp( new InMatchExpression() ); Status s = temp->init( name ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -154,7 +154,7 @@ namespace mongo { case BSONObj::NIN: { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$nin needs an array" ); - std::auto_ptr<InMatchExpression> temp( new InMatchExpression() ); + std::unique_ptr<InMatchExpression> temp( new InMatchExpression() ); Status s = temp->init( name ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -162,7 +162,7 @@ namespace mongo { if ( !s.isOK() ) return StatusWithMatchExpression( s ); - std::auto_ptr<NotMatchExpression> temp2( new NotMatchExpression() ); + std::unique_ptr<NotMatchExpression> temp2( new NotMatchExpression() ); s = temp2->init( temp.release() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -200,7 +200,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, "$size needs a number" ); } - std::auto_ptr<SizeMatchExpression> temp( new SizeMatchExpression() ); + std::unique_ptr<SizeMatchExpression> temp( new SizeMatchExpression() ); Status s = temp->init( name, size ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -210,13 +210,13 @@ namespace mongo { case BSONObj::opEXISTS: { if ( e.eoo() ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$exists can't be eoo" ); - std::auto_ptr<ExistsMatchExpression> temp( new ExistsMatchExpression() ); + std::unique_ptr<ExistsMatchExpression> temp( new ExistsMatchExpression() ); Status s = temp->init( name ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); if ( e.trueValue() ) return StatusWithMatchExpression( temp.release() ); - std::auto_ptr<NotMatchExpression> temp2( new NotMatchExpression() ); + std::unique_ptr<NotMatchExpression> temp2( new NotMatchExpression() ); s = temp2->init( temp.release() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -229,7 +229,7 @@ namespace mongo { int type = e.numberInt(); if ( e.type() != NumberInt && type != e.number() ) type = -1; - std::auto_ptr<TypeMatchExpression> temp( new TypeMatchExpression() ); + std::unique_ptr<TypeMatchExpression> temp( new TypeMatchExpression() ); Status s = temp->init( name, type ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -281,7 +281,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, ss ); } - std::auto_ptr<AndMatchExpression> root( new AndMatchExpression() ); + std::unique_ptr<AndMatchExpression> root( new AndMatchExpression() ); bool topLevel = (level == 0); level++; @@ -298,7 +298,7 @@ namespace mongo { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$or needs an array" ); - std::auto_ptr<OrMatchExpression> temp( new OrMatchExpression() ); + std::unique_ptr<OrMatchExpression> temp( new OrMatchExpression() ); Status s = _parseTreeList( e.Obj(), temp.get(), level ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -308,7 +308,7 @@ namespace mongo { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "and needs an array" ); - std::auto_ptr<AndMatchExpression> temp( new AndMatchExpression() ); + std::unique_ptr<AndMatchExpression> temp( new AndMatchExpression() ); Status s = _parseTreeList( e.Obj(), temp.get(), level ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -318,7 +318,7 @@ namespace mongo { if ( e.type() != Array ) return StatusWithMatchExpression( ErrorCodes::BadValue, "and needs an array" ); - std::auto_ptr<NorMatchExpression> temp( new NorMatchExpression() ); + std::unique_ptr<NorMatchExpression> temp( new NorMatchExpression() ); Status s = _parseTreeList( e.Obj(), temp.get(), level ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -355,7 +355,7 @@ namespace mongo { mongoutils::str::equals( "id", rest ) || mongoutils::str::equals( "db", rest ) ) { // DBRef fields. - std::auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + std::unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); Status s = eq->init( e.fieldName(), e ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -387,7 +387,7 @@ namespace mongo { continue; } - std::auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + std::unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); Status s = eq->init( e.fieldName(), e ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -548,7 +548,7 @@ namespace mongo { if ( i.more() ) return StatusWithMatchExpression( ErrorCodes::BadValue, "malformed mod, too many elements" ); - std::auto_ptr<ModMatchExpression> temp( new ModMatchExpression() ); + std::unique_ptr<ModMatchExpression> temp( new ModMatchExpression() ); Status s = temp->init( name, d.numberInt(), r.numberInt() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -560,7 +560,7 @@ namespace mongo { if ( e.type() != RegEx ) return StatusWithMatchExpression( ErrorCodes::BadValue, "not a regex" ); - std::auto_ptr<RegexMatchExpression> temp( new RegexMatchExpression() ); + std::unique_ptr<RegexMatchExpression> temp( new RegexMatchExpression() ); Status s = temp->init( name, e.regex(), e.regexFlags() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -602,7 +602,7 @@ namespace mongo { } - std::auto_ptr<RegexMatchExpression> temp( new RegexMatchExpression() ); + std::unique_ptr<RegexMatchExpression> temp( new RegexMatchExpression() ); Status s = temp->init( name, regex, regexOptions ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -623,7 +623,7 @@ namespace mongo { } if ( e.type() == RegEx ) { - std::auto_ptr<RegexMatchExpression> r( new RegexMatchExpression() ); + std::unique_ptr<RegexMatchExpression> r( new RegexMatchExpression() ); Status s = r->init( "", e ); if ( !s.isOK() ) return s; @@ -677,7 +677,7 @@ namespace mongo { if ( !s.isOK() ) return StatusWithMatchExpression( s ); - std::auto_ptr<ElemMatchValueMatchExpression> temp( new ElemMatchValueMatchExpression() ); + std::unique_ptr<ElemMatchValueMatchExpression> temp( new ElemMatchValueMatchExpression() ); s = temp->init( name ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -699,7 +699,7 @@ namespace mongo { StatusWithMatchExpression subRaw = _parse( obj, level ); if ( !subRaw.isOK() ) return subRaw; - std::auto_ptr<MatchExpression> sub( subRaw.getValue() ); + std::unique_ptr<MatchExpression> sub( subRaw.getValue() ); // $where is not supported under $elemMatch because $where // applies to top-level document, not array elements in a field. @@ -708,7 +708,7 @@ namespace mongo { "$elemMatch cannot contain $where expression" ); } - std::auto_ptr<ElemMatchObjectMatchExpression> temp( new ElemMatchObjectMatchExpression() ); + std::unique_ptr<ElemMatchObjectMatchExpression> temp( new ElemMatchObjectMatchExpression() ); Status status = temp->init( name, sub.release() ); if ( !status.isOK() ) return StatusWithMatchExpression( status ); @@ -723,7 +723,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, "$all needs an array" ); BSONObj arr = e.Obj(); - std::auto_ptr<AndMatchExpression> myAnd( new AndMatchExpression() ); + std::unique_ptr<AndMatchExpression> myAnd( new AndMatchExpression() ); BSONObjIterator i( arr ); if ( arr.firstElement().type() == Object && @@ -762,7 +762,7 @@ namespace mongo { BSONElement e = i.next(); if ( e.type() == RegEx ) { - std::auto_ptr<RegexMatchExpression> r( new RegexMatchExpression() ); + std::unique_ptr<RegexMatchExpression> r( new RegexMatchExpression() ); Status s = r->init( name, e ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -772,7 +772,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, "no $ expressions in $all" ); } else { - std::auto_ptr<EqualityMatchExpression> x( new EqualityMatchExpression() ); + std::unique_ptr<EqualityMatchExpression> x( new EqualityMatchExpression() ); Status s = x->init( name, e ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); diff --git a/src/mongo/db/matcher/expression_parser_geo.cpp b/src/mongo/db/matcher/expression_parser_geo.cpp index 72145c029b1..837d61b448c 100644 --- a/src/mongo/db/matcher/expression_parser_geo.cpp +++ b/src/mongo/db/matcher/expression_parser_geo.cpp @@ -37,18 +37,18 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; StatusWithMatchExpression expressionParserGeoCallbackReal( const char* name, int type, const BSONObj& section ) { if (BSONObj::opWITHIN == type || BSONObj::opGEO_INTERSECTS == type) { - auto_ptr<GeoExpression> gq(new GeoExpression(name)); + unique_ptr<GeoExpression> gq(new GeoExpression(name)); Status parseStatus = gq->parseFrom(section); if (!parseStatus.isOK()) return StatusWithMatchExpression(parseStatus); - auto_ptr<GeoMatchExpression> e( new GeoMatchExpression() ); + unique_ptr<GeoMatchExpression> e( new GeoMatchExpression() ); // Until the index layer accepts non-BSON predicates, or special indices are moved into // stages, we have to clean up the raw object so it can be passed down to the index @@ -62,12 +62,12 @@ namespace mongo { } else { verify(BSONObj::opNEAR == type); - auto_ptr<GeoNearExpression> nq(new GeoNearExpression(name)); + unique_ptr<GeoNearExpression> nq(new GeoNearExpression(name)); Status s = nq->parseFrom( section ); if ( !s.isOK() ) { return StatusWithMatchExpression( s ); } - auto_ptr<GeoNearMatchExpression> e( new GeoNearMatchExpression() ); + unique_ptr<GeoNearMatchExpression> e( new GeoNearMatchExpression() ); // Until the index layer accepts non-BSON predicates, or special indices are moved into // stages, we have to clean up the raw object so it can be passed down to the index // layer. diff --git a/src/mongo/db/matcher/expression_parser_text.cpp b/src/mongo/db/matcher/expression_parser_text.cpp index 0a7cb0b01ab..f8b40a1823b 100644 --- a/src/mongo/db/matcher/expression_parser_text.cpp +++ b/src/mongo/db/matcher/expression_parser_text.cpp @@ -37,7 +37,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; StatusWithMatchExpression expressionParserTextCallbackReal( const BSONObj& queryObj ) { @@ -84,7 +84,7 @@ namespace mongo { return StatusWithMatchExpression( ErrorCodes::BadValue, "extra fields in $text" ); } - auto_ptr<TextMatchExpression> e( new TextMatchExpression() ); + unique_ptr<TextMatchExpression> e( new TextMatchExpression() ); Status s = e->init( query, language, caseSensitive ); if ( !s.isOK() ) { return StatusWithMatchExpression( s ); diff --git a/src/mongo/db/matcher/expression_parser_tree.cpp b/src/mongo/db/matcher/expression_parser_tree.cpp index 8e2582e52e0..7c5359e6318 100644 --- a/src/mongo/db/matcher/expression_parser_tree.cpp +++ b/src/mongo/db/matcher/expression_parser_tree.cpp @@ -73,7 +73,7 @@ namespace mongo { StatusWithMatchExpression s = _parseRegexElement( name, e ); if ( !s.isOK() ) return s; - std::auto_ptr<NotMatchExpression> n( new NotMatchExpression() ); + std::unique_ptr<NotMatchExpression> n( new NotMatchExpression() ); Status s2 = n->init( s.getValue() ); if ( !s2.isOK() ) return StatusWithMatchExpression( s2 ); @@ -87,7 +87,7 @@ namespace mongo { if ( notObject.isEmpty() ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$not cannot be empty" ); - std::auto_ptr<AndMatchExpression> theAnd( new AndMatchExpression() ); + std::unique_ptr<AndMatchExpression> theAnd( new AndMatchExpression() ); Status s = _parseSub( name, notObject, theAnd.get(), level ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); @@ -98,7 +98,7 @@ namespace mongo { if ( theAnd->getChild(i)->matchType() == MatchExpression::REGEX ) return StatusWithMatchExpression( ErrorCodes::BadValue, "$not cannot have a regex" ); - std::auto_ptr<NotMatchExpression> theNot( new NotMatchExpression() ); + std::unique_ptr<NotMatchExpression> theNot( new NotMatchExpression() ); s = theNot->init( theAnd.release() ); if ( !s.isOK() ) return StatusWithMatchExpression( s ); diff --git a/src/mongo/db/matcher/expression_tree.h b/src/mongo/db/matcher/expression_tree.h index b0caebd1e71..b6441e70f57 100644 --- a/src/mongo/db/matcher/expression_tree.h +++ b/src/mongo/db/matcher/expression_tree.h @@ -190,7 +190,7 @@ namespace mongo { void resetChild( MatchExpression* newChild) { _exp.reset(newChild); } private: - std::auto_ptr<MatchExpression> _exp; + std::unique_ptr<MatchExpression> _exp; }; } diff --git a/src/mongo/db/matcher/expression_tree_test.cpp b/src/mongo/db/matcher/expression_tree_test.cpp index 27516ff4344..72e9766404a 100644 --- a/src/mongo/db/matcher/expression_tree_test.cpp +++ b/src/mongo/db/matcher/expression_tree_test.cpp @@ -38,11 +38,11 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; TEST( NotMatchExpression, MatchesScalar ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); NotMatchExpression notOp; ASSERT( notOp.init( lt.release() ).isOK() ); @@ -52,7 +52,7 @@ namespace mongo { TEST( NotMatchExpression, MatchesArray ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); NotMatchExpression notOp; ASSERT( notOp.init( lt.release() ).isOK() ); @@ -64,7 +64,7 @@ namespace mongo { TEST( NotMatchExpression, ElemMatchKey ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); NotMatchExpression notOp; ASSERT( notOp.init( lt.release() ).isOK() ); @@ -81,7 +81,7 @@ namespace mongo { /* TEST( NotMatchExpression, MatchesIndexKey ) { BSONObj baseOperand = BSON( "$lt" << 5 ); - auto_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); NotMatchExpression notOp; ASSERT( notOp.init( lt.release() ).isOK() ); @@ -97,7 +97,7 @@ namespace mongo { BSONObj baseOperand = BSON( "$lt" << 5 ); BSONObj match = BSON( "a" << 4 ); BSONObj notMatch = BSON( "a" << 5 ); - auto_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "", baseOperand[ "$lt" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( lt.release() ); @@ -121,11 +121,11 @@ namespace mongo { BSONObj notMatch2 = BSON( "a" << "a1" ); BSONObj notMatch3 = BSON( "a" << "r" ); - auto_ptr<ComparisonMatchExpression> sub1( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new LTMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$lt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new GTMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$gt" ] ).isOK() ); - auto_ptr<RegexMatchExpression> sub3( new RegexMatchExpression() ); + unique_ptr<RegexMatchExpression> sub3( new RegexMatchExpression() ); ASSERT( sub3->init( "a", "1", "" ).isOK() ); AndMatchExpression andOp; @@ -141,9 +141,9 @@ namespace mongo { TEST( AndOp, MatchesSingleClause ) { BSONObj baseOperand = BSON( "$ne" << 5 ); - auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); ASSERT( eq->init( "a", baseOperand[ "$ne" ] ).isOK() ); - auto_ptr<NotMatchExpression> ne( new NotMatchExpression() ); + unique_ptr<NotMatchExpression> ne( new NotMatchExpression() ); ASSERT( ne->init( eq.release() ).isOK() ); AndMatchExpression andOp; @@ -160,13 +160,13 @@ namespace mongo { BSONObj baseOperand2 = BSON( "$lt" << 10 ); BSONObj baseOperand3 = BSON( "$lt" << 100 ); - auto_ptr<ComparisonMatchExpression> sub1( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new GTMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new LTMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub3( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub3( new LTMatchExpression() ); ASSERT( sub3->init( "b", baseOperand3[ "$lt" ] ).isOK() ); AndMatchExpression andOp; @@ -185,10 +185,10 @@ namespace mongo { BSONObj baseOperand1 = BSON( "a" << 1 ); BSONObj baseOperand2 = BSON( "b" << 2 ); - auto_ptr<ComparisonMatchExpression> sub1( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new EqualityMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "a" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new EqualityMatchExpression() ); ASSERT( sub2->init( "b", baseOperand2[ "b" ] ).isOK() ); AndMatchExpression andOp; @@ -212,9 +212,9 @@ namespace mongo { TEST( AndOp, MatchesIndexKeyWithoutUnknown ) { BSONObj baseOperand1 = BSON( "$gt" << 1 ); BSONObj baseOperand2 = BSON( "$lt" << 5 ); - auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -235,11 +235,11 @@ namespace mongo { BSONObj baseOperand2 = BSON( "$lt" << 5 ); // This part will return PartialMatchResult_Unknown. BSONObj baseOperand3 = BSON( "$ne" << 5 ); - auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr<NeOp> sub3( new NeOp() ); + unique_ptr<NeOp> sub3( new NeOp() ); ASSERT( sub3->init( "a", baseOperand3[ "$ne" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -262,7 +262,7 @@ namespace mongo { BSONObj baseOperand = BSON( "$lt" << 5 ); BSONObj match = BSON( "a" << 4 ); BSONObj notMatch = BSON( "a" << 5 ); - auto_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( lt.release() ); @@ -286,11 +286,11 @@ namespace mongo { BSONObj match2 = BSON( "a" << 11 ); BSONObj match3 = BSON( "a" << 5 ); BSONObj notMatch = BSON( "a" << "6" ); - auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$lt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub3( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub3( new ComparisonMatchExpression() ); ASSERT( sub3->init( "a", baseOperand3[ "a" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -306,9 +306,9 @@ namespace mongo { */ TEST( OrOp, MatchesSingleClause ) { BSONObj baseOperand = BSON( "$ne" << 5 ); - auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); ASSERT( eq->init( "a", baseOperand[ "$ne" ] ).isOK() ); - auto_ptr<NotMatchExpression> ne( new NotMatchExpression() ); + unique_ptr<NotMatchExpression> ne( new NotMatchExpression() ); ASSERT( ne->init( eq.release() ).isOK() ); OrMatchExpression orOp; @@ -324,11 +324,11 @@ namespace mongo { BSONObj baseOperand1 = BSON( "$gt" << 10 ); BSONObj baseOperand2 = BSON( "$lt" << 0 ); BSONObj baseOperand3 = BSON( "b" << 100 ); - auto_ptr<ComparisonMatchExpression> sub1( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new GTMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new LTMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub3( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub3( new EqualityMatchExpression() ); ASSERT( sub3->init( "b", baseOperand3[ "b" ] ).isOK() ); OrMatchExpression orOp; @@ -348,9 +348,9 @@ namespace mongo { TEST( OrOp, ElemMatchKey ) { BSONObj baseOperand1 = BSON( "a" << 1 ); BSONObj baseOperand2 = BSON( "b" << 2 ); - auto_ptr<ComparisonMatchExpression> sub1( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new EqualityMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "a" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new EqualityMatchExpression() ); ASSERT( sub2->init( "b", baseOperand2[ "b" ] ).isOK() ); OrMatchExpression orOp; @@ -374,9 +374,9 @@ namespace mongo { TEST( OrOp, MatchesIndexKeyWithoutUnknown ) { BSONObj baseOperand1 = BSON( "$gt" << 5 ); BSONObj baseOperand2 = BSON( "$lt" << 1 ); - auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -397,11 +397,11 @@ namespace mongo { BSONObj baseOperand2 = BSON( "$lt" << 1 ); // This part will return PartialMatchResult_Unknown. BSONObj baseOperand3 = BSON( "$ne" << 5 ); - auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr<NeOp> sub3( new NeOp() ); + unique_ptr<NeOp> sub3( new NeOp() ); ASSERT( sub3->init( "a", baseOperand3[ "$ne" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -424,7 +424,7 @@ namespace mongo { BSONObj baseOperand = BSON( "$lt" << 5 ); BSONObj match = BSON( "a" << 5 ); BSONObj notMatch = BSON( "a" << 4 ); - auto_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( lt.release() ); @@ -448,11 +448,11 @@ namespace mongo { BSONObj notMatch2 = BSON( "a" << 11 ); BSONObj notMatch3 = BSON( "a" << 5 ); BSONObj match = BSON( "a" << "6" ); - auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$lt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub3( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub3( new ComparisonMatchExpression() ); ASSERT( sub3->init( "a", baseOperand3[ "a" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( sub1.release() ); @@ -469,9 +469,9 @@ namespace mongo { TEST( NorOp, MatchesSingleClause ) { BSONObj baseOperand = BSON( "$ne" << 5 ); - auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() ); ASSERT( eq->init( "a", baseOperand[ "$ne" ] ).isOK() ); - auto_ptr<NotMatchExpression> ne( new NotMatchExpression() ); + unique_ptr<NotMatchExpression> ne( new NotMatchExpression() ); ASSERT( ne->init( eq.release() ).isOK() ); NorMatchExpression norOp; @@ -488,11 +488,11 @@ namespace mongo { BSONObj baseOperand2 = BSON( "$lt" << 0 ); BSONObj baseOperand3 = BSON( "b" << 100 ); - auto_ptr<ComparisonMatchExpression> sub1( new GTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new GTMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new LTMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new LTMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub3( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub3( new EqualityMatchExpression() ); ASSERT( sub3->init( "b", baseOperand3[ "b" ] ).isOK() ); NorMatchExpression norOp; @@ -512,9 +512,9 @@ namespace mongo { TEST( NorOp, ElemMatchKey ) { BSONObj baseOperand1 = BSON( "a" << 1 ); BSONObj baseOperand2 = BSON( "b" << 2 ); - auto_ptr<ComparisonMatchExpression> sub1( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub1( new EqualityMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "a" ] ).isOK() ); - auto_ptr<ComparisonMatchExpression> sub2( new EqualityMatchExpression() ); + unique_ptr<ComparisonMatchExpression> sub2( new EqualityMatchExpression() ); ASSERT( sub2->init( "b", baseOperand2[ "b" ] ).isOK() ); NorMatchExpression norOp; @@ -557,7 +557,7 @@ namespace mongo { /** TEST( NorOp, MatchesIndexKey ) { BSONObj baseOperand = BSON( "a" << 5 ); - auto_ptr<ComparisonMatchExpression> eq( new ComparisonMatchExpression() ); + unique_ptr<ComparisonMatchExpression> eq( new ComparisonMatchExpression() ); ASSERT( eq->init( "a", baseOperand[ "a" ] ).isOK() ); OwnedPointerVector<MatchMatchExpression> subMatchExpressions; subMatchExpressions.mutableVector().push_back( eq.release() ); diff --git a/src/mongo/db/matcher/expression_where.cpp b/src/mongo/db/matcher/expression_where.cpp index c2e95e2dd50..290b2bc3071 100644 --- a/src/mongo/db/matcher/expression_where.cpp +++ b/src/mongo/db/matcher/expression_where.cpp @@ -42,7 +42,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::endl; using std::string; using std::stringstream; @@ -91,7 +91,7 @@ namespace mongo { string _code; BSONObj _userScope; - auto_ptr<Scope> _scope; + unique_ptr<Scope> _scope; ScriptingFunction _func; // Not owned. See comments insde WhereCallbackReal for the lifetime of this pointer. @@ -191,7 +191,7 @@ namespace mongo { return StatusWithMatchExpression(ErrorCodes::BadValue, "no globalScriptEngine in $where parsing"); - auto_ptr<WhereMatchExpression> exp(new WhereMatchExpression(_txn)); + unique_ptr<WhereMatchExpression> exp(new WhereMatchExpression(_txn)); if (where.type() == String || where.type() == Code) { Status s = exp->init(_dbName, where.valuestr(), BSONObj()); if (!s.isOK()) diff --git a/src/mongo/db/matcher/expression_where_noop.cpp b/src/mongo/db/matcher/expression_where_noop.cpp index dfb6a694c28..d7f5a3c74e1 100644 --- a/src/mongo/db/matcher/expression_where_noop.cpp +++ b/src/mongo/db/matcher/expression_where_noop.cpp @@ -35,7 +35,7 @@ namespace mongo { - using std::auto_ptr; + using std::unique_ptr; using std::string; /** @@ -118,7 +118,7 @@ namespace mongo { StatusWithMatchExpression WhereCallbackNoop::parseWhere(const BSONElement& where) const { - auto_ptr<WhereNoOpMatchExpression> exp( new WhereNoOpMatchExpression() ); + unique_ptr<WhereNoOpMatchExpression> exp( new WhereNoOpMatchExpression() ); if ( where.type() == String || where.type() == Code ) { Status s = exp->init( where.valuestr() ); if ( !s.isOK() ) |