diff options
author | Aaron <aaron@10gen.com> | 2012-03-12 20:59:51 -0700 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2012-03-22 15:51:58 -0700 |
commit | 70bc2ce86c6b950d83e062c80129c4bb7103d79b (patch) | |
tree | a5365e64626afc9a9256181d2f63b3ca4f33d2c2 /src/mongo/db/matcher.cpp | |
parent | e4340b9c4338ee7829624a237e1b71d418852af8 (diff) | |
download | mongo-70bc2ce86c6b950d83e062c80129c4bb7103d79b.tar.gz |
Make MatchDetails a class.
Diffstat (limited to 'src/mongo/db/matcher.cpp')
-rwxr-xr-x | src/mongo/db/matcher.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/mongo/db/matcher.cpp b/src/mongo/db/matcher.cpp index c49b5e84771..a6ba719d51e 100755 --- a/src/mongo/db/matcher.cpp +++ b/src/mongo/db/matcher.cpp @@ -178,6 +178,22 @@ namespace mongo { (_compareOp == BSONObj::NIN && _myset->count( staticNull.firstElement()) == 0 ); } + MatchDetails::MatchDetails() { + reset(); + } + + void MatchDetails::reset() { + _loadedObject = false; + _elemMatchKey = 0; + } + + string MatchDetails::toString() const { + stringstream ss; + ss << "loadedObject: " << _loadedObject << " "; + ss << "elemMatchKey: " << ( _elemMatchKey ? _elemMatchKey : "NULL" ) << " "; + return ss.str(); + } + void Matcher::addRegex(const char *fieldName, const char *regex, const char *flags, bool isNot) { RegexMatcher rm; @@ -729,7 +745,7 @@ namespace mongo { if (valuesMatch(z, toMatch, compareOp, em) ) { // "field.<n>" array notation was used if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } } @@ -739,7 +755,7 @@ namespace mongo { int cmp = matchesDotted(fieldName, toMatch, eo, compareOp, em, false, details ); if ( cmp > 0 ) { if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } else if ( cmp < 0 ) { @@ -780,14 +796,14 @@ namespace mongo { if ( z.type() == Object ) { if ( em._subMatcher->matches( z.embeddedObject() ) ) { if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } } else if ( em._subMatcherOnPrimitives ) { if ( z.type() && em._subMatcher->matches( z.wrap( "" ) ) ) { if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } } @@ -795,7 +811,7 @@ namespace mongo { else { if ( valuesMatch( z, toMatch, compareOp, em) ) { if ( details ) - details->_elemMatchKey = z.fieldName(); + details->setElemMatchKey( z.fieldName() ); return 1; } } |