|
|
@@ -1,29 +1,12 @@
|
|
|
-"use strict"
|
|
|
+"use strict";
|
|
|
|
|
|
+MatchExpression = require('MatchExpression');
|
|
|
|
|
|
|
|
|
// Autogenerated by cport.py on 2013-09-17 14:37
|
|
|
var AllElemMatchOp = module.exports = function (){
|
|
|
-
|
|
|
-}, klass = AllElemMatchOp, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_array.h lines: 175-175
|
|
|
-// ElementPath _elementPath;
|
|
|
-
|
|
|
-proto._elementPath = undefined;
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_array.h lines: 176-176
|
|
|
-// std::vector< const ArrayMatchingMatchExpression* > _list;
|
|
|
-
|
|
|
-proto._list = undefined;
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_array.h lines: 174-174
|
|
|
-// StringData _path;
|
|
|
-
|
|
|
-proto._path = undefined;
|
|
|
+ this._matchType = 'ALL';
|
|
|
+}, klass = AllElemMatchOp, base = MatchExpression , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
|
|
|
// File: expression_array.h lines: 175-175
|
|
|
@@ -43,27 +26,6 @@ proto._list = undefined;
|
|
|
|
|
|
proto._path = undefined;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- * This documentation was automatically generated. Please update when you touch this function.
|
|
|
- * @method AllElemMatchOp
|
|
|
- * @param
|
|
|
- *
|
|
|
- */
|
|
|
-proto.AllElemMatchOp = function AllElemMatchOp( /* ALL */ ){
|
|
|
-// File: expression_array.h lines: 139-138
|
|
|
-// AllElemMatchOp() : MatchExpression( ALL ){}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
* This documentation was automatically generated. Please update when you touch this function.
|
|
|
@@ -71,22 +33,16 @@ proto.AllElemMatchOp = function AllElemMatchOp( /* ALL */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto._allMatch = function _allMatch( /* const BSONObj& anArray */ ){
|
|
|
-
|
|
|
+proto._allMatch = function _allMatch( anArray ){ // const BSONObj& anArray
|
|
|
// File: expression_array.cpp lines: 208-215
|
|
|
-// bool AllElemMatchOp::_allMatch( const BSONObj& anArray ) const {
|
|
|
-// if ( _list.size() == 0 )
|
|
|
-// return false;
|
|
|
-// for ( unsigned i = 0; i < _list.size(); i++ ) {
|
|
|
-// if ( !_list[i]->matchesArray( anArray, NULL ) )
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ if(this._list.length === 0) { return false; }
|
|
|
+
|
|
|
+ for (var i = 0; i < this._list.length; i++) {
|
|
|
+ if( ! this._list[i].matchesArray( anArray, null ) ) { return false; }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -96,17 +52,16 @@ proto._allMatch = function _allMatch( /* const BSONObj& anArray */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.add = function add( /* const ArrayMatchingMatchExpression* expr */ ){
|
|
|
+proto.add = function add( expr ){// const ArrayMatchingMatchExpression* expr
|
|
|
|
|
|
// File: expression_array.cpp lines: 184-186
|
|
|
// void AllElemMatchOp::add( const ArrayMatchingMatchExpression* expr ) {
|
|
|
// verify( expr );
|
|
|
// _list.push_back( expr );
|
|
|
// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ this.verify( expr );
|
|
|
+ this._list.append( expr );
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -116,8 +71,7 @@ proto.add = function add( /* const ArrayMatchingMatchExpression* expr */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.debugString = function debugString( /* StringBuilder& debug, int level */ ){
|
|
|
-
|
|
|
+proto.debugString = function debugString( level ){ // StringBuilder& debug, int level
|
|
|
// File: expression_array.cpp lines: 219-224
|
|
|
// void AllElemMatchOp::debugString( StringBuilder& debug, int level ) const {
|
|
|
// _debugAddSpace( debug, level );
|
|
|
@@ -126,10 +80,11 @@ proto.debugString = function debugString( /* StringBuilder& debug, int level *
|
|
|
// _list[i]->debugString( debug, level + 1);
|
|
|
// }
|
|
|
// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ console.debug(this._debugAddSpace(level) + this._path + " AllElemMatchOp: " + this._path + '\n');
|
|
|
+ for (var i = 0; i < this._list.length; i++) {
|
|
|
+ this._list[i].debugString(level +1);
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -139,30 +94,27 @@ proto.debugString = function debugString( /* StringBuilder& debug, int level *
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.equivalent = function equivalent( /* const MatchExpression* other */ ){
|
|
|
-
|
|
|
+proto.equivalent = function equivalent( other ){// const MatchExpression* other
|
|
|
// File: expression_array.cpp lines: 227-242
|
|
|
-// 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;
|
|
|
-// }
|
|
|
+ if (this.matchType() != other.matchType()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
+ if( this._path != other._path ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
+ if( this._list.length != other._list.length ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (var i = 0; i < this._list.length; i++) {
|
|
|
+ if ( !this._list[i].equivalent( other._list[i] ) ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+};
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -172,14 +124,10 @@ proto.equivalent = function equivalent( /* const MatchExpression* other */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.getChild = function getChild( /* size_t i */ ){
|
|
|
+proto.getChild = function getChild( i ){ // size_t i
|
|
|
// File: expression_array.h lines: 167-166
|
|
|
-// virtual const ArrayMatchingMatchExpression* getChild( size_t i ) const { return _list[i]; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._list[i];
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -189,19 +137,13 @@ proto.getChild = function getChild( /* size_t i */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.init = function init( /* const StringData& path */ ){
|
|
|
-
|
|
|
+proto.init = function init( path ){ // const StringData& path
|
|
|
// File: expression_array.cpp lines: 177-181
|
|
|
-// Status AllElemMatchOp::init( const StringData& path ) {
|
|
|
-// _path = path;
|
|
|
-// Status s = _elementPath.init( _path );
|
|
|
-// _elementPath.setTraverseLeafArray( false );
|
|
|
-// return s;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ this._path = path;
|
|
|
+ var s = this._elementPath.init( this._path );
|
|
|
+ this._elementPath.setTraverseLeafArray( false );
|
|
|
+ return s;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -211,24 +153,21 @@ proto.init = function init( /* const StringData& path */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.matches = function matches( /* const MatchableDocument* doc, MatchDetails* details */ ){
|
|
|
+proto.matches = function matches( doc,details ) { // const MatchableDocument* doc, MatchDetails* details
|
|
|
|
|
|
// File: expression_array.cpp lines: 189-198
|
|
|
-// bool AllElemMatchOp::matches( const MatchableDocument* doc, MatchDetails* details ) const {
|
|
|
-// boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) );
|
|
|
-// while ( cursor->more() ) {
|
|
|
-// ElementIterator::Context e = cursor->next();
|
|
|
-// if ( e.element().type() != Array )
|
|
|
-// continue;
|
|
|
-// if ( _allMatch( e.element().Obj() ) )
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ var cursor = doc.getIterator( this._elementPath );
|
|
|
+ while ( cursor.more ) {
|
|
|
+ var e = cursor.next();
|
|
|
+ if (e.element().type() != 'Array') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (this.all_match(e.element().Obj())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -238,19 +177,14 @@ proto.matches = function matches( /* const MatchableDocument* doc, MatchDetails
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.matchesSingleElement = function matchesSingleElement( /* const BSONElement& e */ ){
|
|
|
+proto.matchesSingleElement = function matchesSingleElement( e ){ // const BSONElement& e
|
|
|
|
|
|
// File: expression_array.cpp lines: 201-205
|
|
|
-// bool AllElemMatchOp::matchesSingleElement( const BSONElement& e ) const {
|
|
|
-// if ( e.type() != Array )
|
|
|
-// return false;
|
|
|
-//
|
|
|
-// return _allMatch( e.Obj() );
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ if ( e.type() != 'Array' ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return this._allMatch(e.Obj());
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -262,12 +196,8 @@ proto.matchesSingleElement = function matchesSingleElement( /* const BSONElemen
|
|
|
*/
|
|
|
proto.numChildren = function numChildren( /* */ ){
|
|
|
// File: expression_array.h lines: 166-165
|
|
|
-// virtual size_t numChildren() const { return _list.size(); }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._list.length;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -279,12 +209,8 @@ proto.numChildren = function numChildren( /* */ ){
|
|
|
*/
|
|
|
proto.path = function path( /* */ ){
|
|
|
// File: expression_array.h lines: 169-168
|
|
|
-// const StringData path() const { return _path; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._path;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -296,38 +222,9 @@ proto.path = function path( /* */ ){
|
|
|
*/
|
|
|
proto.shallowClone = function shallowClone( /* */ ){
|
|
|
// File: expression_array.h lines: 145-152
|
|
|
-// virtual MatchExpression* shallowClone() const {
|
|
|
-// AllElemMatchOp* e = new AllElemMatchOp();
|
|
|
-// e->init(path());
|
|
|
-// for (size_t i = 0; i < _list.size(); ++i) {
|
|
|
-// e->add(reinterpret_cast<const ArrayMatchingMatchExpression*>(
|
|
|
-// _list[i]->shallowClone()));
|
|
|
-// }
|
|
|
-// return e;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- * This documentation was automatically generated. Please update when you touch this function.
|
|
|
- * @method ~AllElemMatchOp
|
|
|
- * @param
|
|
|
- *
|
|
|
- */
|
|
|
-proto.~AllElemMatchOp = function ~AllElemMatchOp( /* */ ){
|
|
|
-
|
|
|
-// File: expression_array.cpp lines: 171-174
|
|
|
-// AllElemMatchOp::~AllElemMatchOp() {
|
|
|
-// for ( unsigned i = 0; i < _list.size(); i++ )
|
|
|
-// delete _list[i];
|
|
|
-// _list.clear();
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
+ var e = new AllElemMatchOp();
|
|
|
+ e.init( this._path );
|
|
|
+ e._list = this._list.slice(0);
|
|
|
+ return e;
|
|
|
+};
|
|
|
|
|
|
-}
|