| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- "use strict";
- var MatchExpression = require('./MatchExpression');
- // Autogenerated by cport.py on 2013-09-17 14:37
- var AllElemMatchOp = module.exports = function AllElemMatchOp(){
- base.call(this);
- this._matchType = 'ALL';
- this._elementPath = new ElementPath();
- this._list = [];
- }, klass = AllElemMatchOp, base = MatchExpression , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
- // DEPENDENCIES
- var errors = require("../../Errors.js"),
- ErrorCodes = errors.ErrorCodes,
- ElementPath = require('./ElementPath.js');
- // 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 documentation was automatically generated. Please update when you touch this function.
- * @method _allMatch
- * @param
- *
- */
- proto._allMatch = function _allMatch( anArray ){ // const BSONObj& anArray
- // File: expression_array.cpp lines: 208-215
- 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;
- };
- /**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method add
- * @param
- *
- */
- 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 );
- // }
- if (!expr) throw new Error("AllElemMatchOp:add#68 failed to verify expr");
- this._list.push(expr);
- };
- /**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method debugString
- * @param
- *
- */
- 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 );
- // debug << _path << " AllElemMatchOp: " << _path << "\n";
- // for ( size_t i = 0; i < _list.size(); i++ ) {
- // _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);
- }
- };
- /**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method equivalent
- * @param
- *
- */
- proto.equivalent = function equivalent( other ){// const MatchExpression* other
- // File: expression_array.cpp lines: 227-242
- 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;
- };
- /**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method getChild
- * @param
- *
- */
- proto.getChild = function getChild( i ){ // size_t i
- // File: expression_array.h lines: 167-166
- return this._list[i];
- };
- /**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method init
- * @param
- *
- */
- proto.init = function init( path ){ // const StringData& path
- // File: expression_array.cpp lines: 177-181
- this._path = path;
- var s = this._elementPath.init( this._path );
- this._elementPath.setTraverseLeafArray( false );
- return s;
- };
- /**
- *
- * matches checks the input doc against the internal path to see if it is a match
- * @method matches
- * @param doc
- * @param details
- *
- */
- proto.matches = function matches(doc, details){
- // File: expression_array.cpp lines: 189-198
- var self = this,
- checker = function(element) {
- if (!(element instanceof Array))
- return false;
- //var amIRoot = (element.length === 0);
- if (self._allMatch(element))
- return true;
- /*
- if (!amIRoot && details && details.needRecord() {
- details.setElemMatchKey(element);
- }
- */
- return false;
- };
- return this._elementPath._matches(doc, details, checker);
- };
- /**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method matchesSingleElement
- * @param
- *
- */
- proto.matchesSingleElement = function matchesSingleElement( e ){ // const BSONElement& e
- // File: expression_array.cpp lines: 201-205
- if (!(e instanceof Array)) {
- return false;
- }
- return this._allMatch(e);
- };
- /**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method numChildren
- * @param
- *
- */
- proto.numChildren = function numChildren( /* */ ){
- // File: expression_array.h lines: 166-165
- return this._list.length;
- };
- /**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method path
- * @param
- *
- */
- proto.path = function path( /* */ ){
- // File: expression_array.h lines: 169-168
- return this._path;
- };
- /**
- *
- * This documentation was automatically generated. Please update when you touch this function.
- * @method shallowClone
- * @param
- *
- */
- proto.shallowClone = function shallowClone( /* */ ){
- // File: expression_array.h lines: 145-152
- var e = new AllElemMatchOp();
- e.init( this._path );
- e._list = this._list.slice(0);
- return e;
- };
|