diff options
author | Eliot Horowitz <eliot@10gen.com> | 2013-06-05 11:48:11 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2013-06-05 11:49:39 -0400 |
commit | e0c8f9047f55ccfc1012c47689871d519f7f6dc0 (patch) | |
tree | 277c58700ab75633f51de4c28e3314b174c9c95d | |
parent | c4378a6f860a68117b2c879944b3fe39ab6b3e75 (diff) | |
download | mongo-e0c8f9047f55ccfc1012c47689871d519f7f6dc0.tar.gz |
SERVER-9820: change ElementIterator::Element to Context
-rw-r--r-- | src/mongo/db/matcher/expression_array.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_leaf.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/matcher/path.cpp | 16 | ||||
-rw-r--r-- | src/mongo/db/matcher/path.h | 14 | ||||
-rw-r--r-- | src/mongo/db/matcher/path_test.cpp | 26 |
5 files changed, 32 insertions, 32 deletions
diff --git a/src/mongo/db/matcher/expression_array.cpp b/src/mongo/db/matcher/expression_array.cpp index b2330e82355..8332c47160f 100644 --- a/src/mongo/db/matcher/expression_array.cpp +++ b/src/mongo/db/matcher/expression_array.cpp @@ -36,7 +36,7 @@ namespace mongo { boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) ); while ( cursor->more() ) { - ElementIterator::Element e = cursor->next(); + ElementIterator::Context e = cursor->next(); if ( e.element().type() != Array ) continue; @@ -189,7 +189,7 @@ namespace mongo { bool AllElemMatchOp::matches( const MatchableDocument* doc, MatchDetails* details ) const { boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) ); while ( cursor->more() ) { - ElementIterator::Element e = cursor->next(); + ElementIterator::Context e = cursor->next(); if ( e.element().type() != Array ) continue; if ( _allMatch( e.element().Obj() ) ) diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp index 4c62026d8c8..895c7ef3dde 100644 --- a/src/mongo/db/matcher/expression_leaf.cpp +++ b/src/mongo/db/matcher/expression_leaf.cpp @@ -37,7 +37,7 @@ namespace mongo { bool LeafMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const { boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) ); while ( cursor->more() ) { - ElementIterator::Element e = cursor->next(); + ElementIterator::Context e = cursor->next(); if ( !matchesSingleElement( e.element() ) ) continue; if ( details && details->needRecord() && !e.arrayOffset().eoo() ) { @@ -291,7 +291,7 @@ namespace mongo { bool TypeMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const { boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) ); while ( cursor->more() ) { - ElementIterator::Element e = cursor->next(); + ElementIterator::Context e = cursor->next(); if ( e.outerArray() ) continue; diff --git a/src/mongo/db/matcher/path.cpp b/src/mongo/db/matcher/path.cpp index 320ea31ad79..15573796d1b 100644 --- a/src/mongo/db/matcher/path.cpp +++ b/src/mongo/db/matcher/path.cpp @@ -34,11 +34,11 @@ namespace mongo { ElementIterator::~ElementIterator(){ } - void ElementIterator::Element::reset() { + void ElementIterator::Context::reset() { _element = BSONElement(); } - void ElementIterator::Element::reset( BSONElement element, + void ElementIterator::Context::reset( BSONElement element, BSONElement arrayOffset, bool outerArray ) { _element = element; @@ -58,14 +58,14 @@ namespace mongo { return _iterator.more() || _returnArrayLast; } - ElementIterator::Element SimpleArrayElementIterator::next() { + ElementIterator::Context SimpleArrayElementIterator::next() { if ( _iterator.more() ) { - Element e; + Context e; e.reset( _iterator.next(), BSONElement(), false ); return e; } _returnArrayLast = false; - Element e; + Context e; e.reset( _theArray, BSONElement(), true ); return e; } @@ -230,13 +230,13 @@ namespace mongo { return false; } - ElementIterator::Element BSONElementIterator::next() { + ElementIterator::Context BSONElementIterator::next() { if ( _subCursor ) { - Element e = _subCursor->next(); + Context e = _subCursor->next(); e.setArrayOffset( _arrayIterationState._current ); return e; } - Element x = _next; + Context x = _next; _next.reset(); return x; } diff --git a/src/mongo/db/matcher/path.h b/src/mongo/db/matcher/path.h index 08f4caed258..39d632733d5 100644 --- a/src/mongo/db/matcher/path.h +++ b/src/mongo/db/matcher/path.h @@ -44,7 +44,7 @@ namespace mongo { class ElementIterator { public: - class Element { + class Context { public: void reset(); @@ -66,7 +66,7 @@ namespace mongo { virtual ~ElementIterator(); virtual bool more() = 0; - virtual Element next() = 0; + virtual Context next() = 0; }; @@ -81,11 +81,11 @@ namespace mongo { virtual ~SingleElementElementIterator(){} virtual bool more() { return !_seen; } - virtual Element next() { _seen = true; return _element; } + virtual Context next() { _seen = true; return _element; } private: bool _seen; - ElementIterator::Element _element; + ElementIterator::Context _element; }; class SimpleArrayElementIterator : public ElementIterator { @@ -93,7 +93,7 @@ namespace mongo { SimpleArrayElementIterator( const BSONElement& theArray, bool returnArrayLast ); virtual bool more(); - virtual Element next(); + virtual Context next(); private: BSONElement _theArray; @@ -107,14 +107,14 @@ namespace mongo { virtual ~BSONElementIterator(); bool more(); - Element next(); + Context next(); private: const ElementPath& _path; BSONObj _context; enum State { BEGIN, IN_ARRAY, DONE } _state; - Element _next; + Context _next; struct ArrayIterationState { diff --git a/src/mongo/db/matcher/path_test.cpp b/src/mongo/db/matcher/path_test.cpp index 6fdf2f045bb..3b9f9fdb23c 100644 --- a/src/mongo/db/matcher/path_test.cpp +++ b/src/mongo/db/matcher/path_test.cpp @@ -32,7 +32,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - ElementIterator::Element e = cursor.next(); + ElementIterator::Context e = cursor.next(); ASSERT_EQUALS( (string)"a", e.element().fieldName() ); ASSERT_EQUALS( 5, e.element().numberInt() ); ASSERT( !cursor.more() ); @@ -47,7 +47,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - BSONElementIterator::Element e = cursor.next(); + BSONElementIterator::Context e = cursor.next(); ASSERT_EQUALS( 5, e.element().numberInt() ); ASSERT( cursor.more() ); @@ -71,7 +71,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - BSONElementIterator::Element e = cursor.next(); + BSONElementIterator::Context e = cursor.next(); ASSERT( e.element().type() == Array ); ASSERT( !cursor.more() ); @@ -90,7 +90,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - BSONElementIterator::Element e = cursor.next(); + BSONElementIterator::Context e = cursor.next(); ASSERT_EQUALS( 5, e.element().numberInt() ); ASSERT( !e.outerArray() ); @@ -138,7 +138,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - BSONElementIterator::Element e = cursor.next(); + BSONElementIterator::Context e = cursor.next(); ASSERT_EQUALS( 5, e.element().numberInt() ); ASSERT( !e.outerArray() ); @@ -172,7 +172,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - BSONElementIterator::Element e = cursor.next(); + BSONElementIterator::Context e = cursor.next(); ASSERT_EQUALS( 7, e.element().numberInt() ); ASSERT( !cursor.more() ); @@ -187,7 +187,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - BSONElementIterator::Element e = cursor.next(); + BSONElementIterator::Context e = cursor.next(); ASSERT_EQUALS( Array, e.element().type() ); ASSERT( !cursor.more() ); @@ -202,7 +202,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - BSONElementIterator::Element e = cursor.next(); + BSONElementIterator::Context e = cursor.next(); ASSERT_EQUALS( 4, e.element().numberInt() ); ASSERT( cursor.more() ); @@ -221,7 +221,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - BSONElementIterator::Element e = cursor.next(); + BSONElementIterator::Context e = cursor.next(); ASSERT( e.element().eoo() ); ASSERT( cursor.more() ); @@ -241,7 +241,7 @@ namespace mongo { BSONElementIterator cursor( p, doc ); ASSERT( cursor.more() ); - BSONElementIterator::Element e = cursor.next(); + BSONElementIterator::Context e = cursor.next(); ASSERT_EQUALS( 4, e.element().numberInt() ); @@ -253,7 +253,7 @@ namespace mongo { SimpleArrayElementIterator i( obj["a"], false ); ASSERT( i.more() ); - ElementIterator::Element e = i.next(); + ElementIterator::Context e = i.next(); ASSERT_EQUALS( 5, e.element().numberInt() ); ASSERT( i.more() ); @@ -276,7 +276,7 @@ namespace mongo { SimpleArrayElementIterator i( obj["a"], true ); ASSERT( i.more() ); - ElementIterator::Element e = i.next(); + ElementIterator::Context e = i.next(); ASSERT_EQUALS( 5, e.element().numberInt() ); ASSERT( i.more() ); @@ -303,7 +303,7 @@ namespace mongo { SingleElementElementIterator i( obj["y"] ); ASSERT( i.more() ); - ElementIterator::Element e = i.next(); + ElementIterator::Context e = i.next(); ASSERT_EQUALS( 5, e.element().numberInt() ); ASSERT( !i.more() ); |