"use strict"; var Value = require('../Value'); // Autogenerated by cport.py on 2013-09-17 14:37 var ArrayFilterEntries = module.exports = function ArrayFilterEntries(){ this._hasNull = false; this._hasEmptyArray = false; this._equalities = []; this._regexes = []; }, klass = ArrayFilterEntries, base = Object, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}}); // File: expression_leaf.h lines: 266-266 proto._equalities = undefined; // File: expression_leaf.h lines: 265-265 proto._hasEmptyArray = undefined; // File: expression_leaf.h lines: 264-264 proto._hasNull = undefined; // File: expression_leaf.h lines: 267-267 proto._regexes = undefined; /** * * Push the input expression onto the _equalities array * @method addEquality * @param e * */ proto.addEquality = function addEquality(e) { //File expression_leaf.cpp lines 369-387 if(e instanceof Object && Object.keys(e)[0][0] === '$'){ return {'code':'BAD_VALUE', 'desc':'cannot next $ under $in'}; } if( e instanceof RegExp ) { return {'code': 'BAD_VALUE', 'desc':'ArrayFilterEntries equality cannot be a regex'}; } if( e === null ) { this._hasNull = true; } if (e instanceof Array && e.length === 0) { this._hasEmptyArray = true; } this._equalities.push( e ); return {'code':'OK'}; }; /** * * Push the input regex onto the _regexes array * @method addRegex * @param expr * */ proto.addRegex = function addRegex(expr) { // File: expression_leaf.cpp lines: 389-391 this._regexes.push( expr ); return {'code':'OK'}; }; /** * * Check if the input element is contained inside of _equalities * @method contains * @param elem * */ proto.contains = function contains(elem) { // File: expression_leaf.h lines: 249-248 for (var i = 0; i < this._equalities.length; i++) { if(typeof(elem) == typeof(this._equalities[i])){ if(Value.compare(elem, this._equalities[i]) === 0) { return true; } } } return false; }; /** * * Copy our internal fields to the input * @method copyTo * @param toFillIn * */ proto.copyTo = function copyTo(toFillIn) { // File: expression_leaf.cpp lines: 407-412 toFillIn._hasNull = this._hasNull; toFillIn._hasEmptyArray = this._hasEmptyArray; toFillIn._equalities = this._equalities.slice(0); // Copy array toFillIn._regexes = this._regexes.slice(0); // Copy array }; /** * * Return the _equalities property * @method equalities * */ proto.equalities = function equalities(){ // File: expression_leaf.h lines: 248-247 return this._equalities; }; /** * * checks if this expression is == to the other * @method equivalent * @param other * */ proto.equivalent = function equivalent(other) { // File: expression_leaf.cpp lines: 394-404 if (this._hasNull != other._hasNull) {return false;} if (this._regexes.length != other._regexes.length) {return false;} for (var i = 0; i < this._regexes.length; i++) { if ( !this._regexes[i].equivalent( other._regexes[i] ) ) { return false; } } return Value.compare(this._equalities, other._equalities); }; /** * * Return the _hasEmptyArray property * @method hasEmptyArray * */ proto.hasEmptyArray = function hasEmptyArray(){ // File: expression_leaf.h lines: 256-255 return this._hasEmptyArray; }; /** * * Return the _hasNull property * @method hasNull * */ proto.hasNull = function hasNull(){ // File: expression_leaf.h lines: 254-253 return this._hasNull; }; /** * * Return the length of the _regexes property * @method numRegexes * */ proto.numRegexes = function numRegexes(){ // File: expression_leaf.h lines: 251-250 return this._regexes.length; }; /** * * Return the regex at the given index * @method regex * @param idx * */ proto.regex = function regex(idx) { // File: expression_leaf.h lines: 252-251 return this._regexes[idx]; }; /** * * Return whether we have a single item and it is null * @method singleNull * */ proto.singleNull = function singleNull(){ // File: expression_leaf.h lines: 255-254 return this.size() == 1 && this._hasNull; }; /** * * Return the length of both _regexes and _equalities * @method size * */ proto.size = function size(){ // File: expression_leaf.h lines: 257-256 return this._equalities.length + this._regexes.length; };