|
|
@@ -1,10 +1,11 @@
|
|
|
-"use strict"
|
|
|
-
|
|
|
+"use strict";
|
|
|
|
|
|
+Value = require('../Value');
|
|
|
|
|
|
// Autogenerated by cport.py on 2013-09-17 14:37
|
|
|
var ArrayFilterEntries = module.exports = function (){
|
|
|
-
|
|
|
+ this._hasNull = false;
|
|
|
+ this._hasEmptyArray = false;
|
|
|
}, klass = ArrayFilterEntries, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
|
|
|
@@ -32,86 +33,35 @@ proto._hasNull = undefined;
|
|
|
proto._regexes = undefined;
|
|
|
|
|
|
|
|
|
-// File: expression_leaf.h lines: 266-266
|
|
|
-// BSONElementSet _equalities;
|
|
|
-
|
|
|
-proto._equalities = undefined;
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_leaf.h lines: 265-265
|
|
|
-// bool _hasEmptyArray;
|
|
|
-
|
|
|
-proto._hasEmptyArray = undefined;
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_leaf.h lines: 264-264
|
|
|
-// bool _hasNull; // if _equalities has a jstNULL element in it
|
|
|
-
|
|
|
-proto._hasNull = undefined;
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_leaf.h lines: 267-267
|
|
|
-// std::vector<RegexMatchExpression*> _regexes;
|
|
|
-
|
|
|
-proto._regexes = undefined;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
- *
|
|
|
- * This documentation was automatically generated. Please update when you touch this function.
|
|
|
- * @method ArrayFilterEntries
|
|
|
- * @param
|
|
|
+ * addEquality
|
|
|
*
|
|
|
- */
|
|
|
-proto.ArrayFilterEntries = function ArrayFilterEntries( /* */ ){
|
|
|
-
|
|
|
-// File: expression_leaf.cpp lines: 358-360
|
|
|
-// ArrayFilterEntries::ArrayFilterEntries(){
|
|
|
-// _hasNull = false;
|
|
|
-// _hasEmptyArray = false;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- * This documentation was automatically generated. Please update when you touch this function.
|
|
|
* @method addEquality
|
|
|
- * @param
|
|
|
+ *
|
|
|
*
|
|
|
*/
|
|
|
-proto.addEquality = function addEquality( /* const BSONElement& e */ ){
|
|
|
-
|
|
|
-// File: expression_leaf.cpp lines: 369-386
|
|
|
-// Status ArrayFilterEntries::addEquality( const BSONElement& e ) {
|
|
|
-// if ( e.isABSONObj() ) {
|
|
|
-// if ( e.Obj().firstElement().fieldName()[0] == '$' )
|
|
|
-// return Status( ErrorCodes::BadValue, "cannot next $ under $in" );
|
|
|
-// }
|
|
|
-//
|
|
|
-// if ( e.type() == RegEx )
|
|
|
-// return Status( ErrorCodes::BadValue, "ArrayFilterEntries equality cannot be a regex" );
|
|
|
-//
|
|
|
-// if ( e.type() == jstNULL ) {
|
|
|
-// _hasNull = true;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if ( e.type() == Array && e.Obj().isEmpty() )
|
|
|
-// _hasEmptyArray = true;
|
|
|
-//
|
|
|
-// _equalities.insert( e );
|
|
|
-// return Status::OK();
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+proto.addEquality = function addEquality( e ) {
|
|
|
+ //File expression_leaf.cpp lines 369-387
|
|
|
+
|
|
|
+ if(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.insert( e );
|
|
|
+ return {'code':'OK'};
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -121,17 +71,11 @@ proto.addEquality = function addEquality( /* const BSONElement& e */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.addRegex = function addRegex( /* RegexMatchExpression* expr */ ){
|
|
|
-
|
|
|
+proto.addRegex = function addRegex( expr ) { // RegexMatchExpression* expr
|
|
|
// File: expression_leaf.cpp lines: 389-391
|
|
|
-// Status ArrayFilterEntries::addRegex( RegexMatchExpression* expr ) {
|
|
|
-// _regexes.push_back( expr );
|
|
|
-// return Status::OK();
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ this._regexes.append( expr );
|
|
|
+ return {'code':'OK'};
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -141,14 +85,15 @@ proto.addRegex = function addRegex( /* RegexMatchExpression* expr */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.contains = function contains( /* const BSONElement& elem */ ){
|
|
|
+proto.contains = function contains( elem ) { // const BSONElement& elem
|
|
|
// File: expression_leaf.h lines: 249-248
|
|
|
-// bool contains( const BSONElement& elem ) const { return _equalities.count(elem) > 0; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ for (var i = 0; i < this._equalities.length; i++) {
|
|
|
+ if( Value.compare(elem, this._equalities[i])) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -158,20 +103,13 @@ proto.contains = function contains( /* const BSONElement& elem */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.copyTo = function copyTo( /* ArrayFilterEntries& toFillIn */ ){
|
|
|
-
|
|
|
+proto.copyTo = function copyTo( toFillIn ) { // ArrayFilterEntries& toFillIn
|
|
|
// File: expression_leaf.cpp lines: 407-412
|
|
|
-// void ArrayFilterEntries::copyTo( ArrayFilterEntries& toFillIn ) const {
|
|
|
-// toFillIn._hasNull = _hasNull;
|
|
|
-// toFillIn._hasEmptyArray = _hasEmptyArray;
|
|
|
-// toFillIn._equalities = _equalities;
|
|
|
-// for ( unsigned i = 0; i < _regexes.size(); i++ )
|
|
|
-// toFillIn._regexes.push_back( static_cast<RegexMatchExpression*>(_regexes[i]->shallowClone()) );
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ toFillIn._hasNull = this._hasNull;
|
|
|
+ toFillIn._hasEmptyArray = this._hasEmptyArray;
|
|
|
+ toFillIn._equalities = this._equalities;
|
|
|
+ toFillIn._regexes = this._regexes.slice(0); // Copy array
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -183,12 +121,8 @@ proto.copyTo = function copyTo( /* ArrayFilterEntries& toFillIn */ ){
|
|
|
*/
|
|
|
proto.equalities = function equalities( /* */ ){
|
|
|
// File: expression_leaf.h lines: 248-247
|
|
|
-// const BSONElementSet& equalities() const { return _equalities; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._equalities;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -198,25 +132,18 @@ proto.equalities = function equalities( /* */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.equivalent = function equivalent( /* const ArrayFilterEntries& other */ ){
|
|
|
-
|
|
|
+proto.equivalent = function equivalent( other ) { // const ArrayFilterEntries& other
|
|
|
// File: expression_leaf.cpp lines: 394-404
|
|
|
-// bool ArrayFilterEntries::equivalent( const ArrayFilterEntries& other ) const {
|
|
|
-// if ( _hasNull != other._hasNull )
|
|
|
-// return false;
|
|
|
-//
|
|
|
-// if ( _regexes.size() != other._regexes.size() )
|
|
|
-// return false;
|
|
|
-// for ( unsigned i = 0; i < _regexes.size(); i++ )
|
|
|
-// if ( !_regexes[i]->equivalent( other._regexes[i] ) )
|
|
|
-// return false;
|
|
|
-//
|
|
|
-// return _equalities == other._equalities;
|
|
|
-// }
|
|
|
-
|
|
|
+ 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);
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -228,12 +155,8 @@ proto.equivalent = function equivalent( /* const ArrayFilterEntries& other */
|
|
|
*/
|
|
|
proto.hasEmptyArray = function hasEmptyArray( /* */ ){
|
|
|
// File: expression_leaf.h lines: 256-255
|
|
|
-// bool hasEmptyArray() const { return _hasEmptyArray; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._hasEmptyArray;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -245,12 +168,8 @@ proto.hasEmptyArray = function hasEmptyArray( /* */ ){
|
|
|
*/
|
|
|
proto.hasNull = function hasNull( /* */ ){
|
|
|
// File: expression_leaf.h lines: 254-253
|
|
|
-// bool hasNull() const { return _hasNull; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._hasNull;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -262,12 +181,8 @@ proto.hasNull = function hasNull( /* */ ){
|
|
|
*/
|
|
|
proto.numRegexes = function numRegexes( /* */ ){
|
|
|
// File: expression_leaf.h lines: 251-250
|
|
|
-// size_t numRegexes() const { return _regexes.size(); }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._regexes.length;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -277,14 +192,10 @@ proto.numRegexes = function numRegexes( /* */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.regex = function regex( /* int idx */ ){
|
|
|
+proto.regex = function regex( idx ) { // int idx
|
|
|
// File: expression_leaf.h lines: 252-251
|
|
|
-// RegexMatchExpression* regex( int idx ) const { return _regexes[idx]; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._regexes[idx];
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -296,12 +207,8 @@ proto.regex = function regex( /* int idx */ ){
|
|
|
*/
|
|
|
proto.singleNull = function singleNull( /* */ ){
|
|
|
// File: expression_leaf.h lines: 255-254
|
|
|
-// bool singleNull() const { return size() == 1 && _hasNull; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this.size() == 1 && _hasNull;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -313,30 +220,6 @@ proto.singleNull = function singleNull( /* */ ){
|
|
|
*/
|
|
|
proto.size = function size( /* */ ){
|
|
|
// File: expression_leaf.h lines: 257-256
|
|
|
-// int size() const { return _equalities.size() + _regexes.size(); }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- * This documentation was automatically generated. Please update when you touch this function.
|
|
|
- * @method ~ArrayFilterEntries
|
|
|
- * @param
|
|
|
- *
|
|
|
- */
|
|
|
-proto.~ArrayFilterEntries = function ~ArrayFilterEntries( /* */ ){
|
|
|
-
|
|
|
-// File: expression_leaf.cpp lines: 363-366
|
|
|
-// ArrayFilterEntries::~ArrayFilterEntries() {
|
|
|
-// for ( unsigned i = 0; i < _regexes.size(); i++ )
|
|
|
-// delete _regexes[i];
|
|
|
-// _regexes.clear();
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
+ return this._equalities.length + this._regexes.length;
|
|
|
+};
|
|
|
|
|
|
-}
|