"use strict"; var MatchExpression = require('./MatchExpression'); var ElementPath = require('./ElementPath'); // Autogenerated by cport.py on 2013-09-17 14:37 var LeafMatchExpression = module.exports = function LeafMatchExpression( type ){ base.call(this); this._matchType = type; this._elementPath = new ElementPath(); }, klass = LeafMatchExpression, base = MatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}}); // File: expression_leaf.h lines: 63-63 // ElementPath _elementPath; proto._elementPath = undefined; // File: expression_leaf.h lines: 62-62 // StringData _path; proto._path = undefined; /** * * Initialize the ElementPath to the input path * @method initPath * @param path * */ proto.initPath = function initPath( path ) { // const StringData& path // File: expression_leaf.cpp lines: 31-33 this._path = path; if(this._elementPath === undefined){ this._elementPath = new ElementPath(); } return this._elementPath.init( this._path ); }; /** * * Check whether the input doc matches * @method matches * @param doc * */ proto.matches = function matches( doc, details ) { // const MatchableDocument* doc, MatchDetails* details // File: expression_leaf.cpp lines: 37-48 var self = this, checker = function(element) { /*if (element instanceof Array) { for (var i = 0; i < element.length; i++) { if(self.matchesSingleElement(element[i])) { if(details && details.needRecord()) { details.setElemMatchKey(i.toString()); } return true; } } return false; }*/ if (!self.matchesSingleElement(element)) { return false; } /* if( details && details.needRecord() && (element instanceof Array)) { details.setElemMatchKey( docKeys[i+1] ); } */ return true; }; return this._elementPath._matches(doc, details, checker); /* var tDoc = ElementPath.objAtPath( doc, this._path ); if(tDoc instanceof RegExp || typeof(tDoc) != 'object') { return this.matchesSingleElement(tDoc); } if(!this.matchesSingleElement( tDoc[docKeys[i]] )) continue; if( details && details.needRecord() && (tDoc instanceof Array) && i < docKeys.length-1 ) { console.log('test2'); details.setElemMatchKey( docKeys[i+1] ); } return true; } return false; */ }; /** * * Return the internal path * @method path * @param * */ proto.path = function path( /* */ ){ // File: expression_leaf.h lines: 56-55 return this._path; };