|
|
@@ -1,23 +1,11 @@
|
|
|
-"use strict"
|
|
|
-
|
|
|
+"use strict";
|
|
|
|
|
|
+var LeafMatchExpression = require('./LeafMatchExpression');
|
|
|
|
|
|
// Autogenerated by cport.py on 2013-09-17 14:37
|
|
|
-var ModMatchExpression = module.exports = function (){
|
|
|
-
|
|
|
-}, klass = ModMatchExpression, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_leaf.h lines: 210-210
|
|
|
-// int _divisor;
|
|
|
-
|
|
|
-proto._divisor = undefined;
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_leaf.h lines: 211-211
|
|
|
-// int _remainder;
|
|
|
-
|
|
|
-proto._remainder = undefined;
|
|
|
+var ModMatchExpression = module.exports = function ModMatchExpression(){
|
|
|
+ this._matchType = 'MOD';
|
|
|
+}, klass = ModMatchExpression, base = LeafMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
|
|
|
// File: expression_leaf.h lines: 210-210
|
|
|
@@ -31,27 +19,6 @@ proto._divisor = undefined;
|
|
|
|
|
|
proto._remainder = undefined;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- * This documentation was automatically generated. Please update when you touch this function.
|
|
|
- * @method ModMatchExpression
|
|
|
- * @param
|
|
|
- *
|
|
|
- */
|
|
|
-proto.ModMatchExpression = function ModMatchExpression( /* MOD */ ){
|
|
|
-// File: expression_leaf.h lines: 190-189
|
|
|
-// ModMatchExpression() : LeafMatchExpression( MOD ){}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
* This documentation was automatically generated. Please update when you touch this function.
|
|
|
@@ -59,23 +26,10 @@ proto.ModMatchExpression = function ModMatchExpression( /* MOD */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.debugString = function debugString( /* StringBuilder& debug, int level */ ){
|
|
|
-
|
|
|
+proto.debugString = function debugString( level ) { // StringBuilder& debug, int level
|
|
|
// File: expression_leaf.cpp lines: 253-261
|
|
|
-// void ModMatchExpression::debugString( StringBuilder& debug, int level ) const {
|
|
|
-// _debugAddSpace( debug, level );
|
|
|
-// debug << path() << " mod " << _divisor << " % x == " << _remainder;
|
|
|
-// MatchExpression::TagData* td = getTag();
|
|
|
-// if (NULL != td) {
|
|
|
-// debug << " ";
|
|
|
-// td->debugString(&debug);
|
|
|
-// }
|
|
|
-// debug << "\n";
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._debugAddSpace( level ) + this.path() + " mod " + this._divisor + " % x == " + this._remainder + (this.getTag() ? " " + this.getTag().debugString() : '') + "\n";
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -85,23 +39,12 @@ 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_leaf.cpp lines: 264-272
|
|
|
-// bool ModMatchExpression::equivalent( const MatchExpression* other ) const {
|
|
|
-// if ( matchType() != other->matchType() )
|
|
|
-// return false;
|
|
|
-//
|
|
|
-// const ModMatchExpression* realOther = static_cast<const ModMatchExpression*>( other );
|
|
|
-// return
|
|
|
-// path() == realOther->path() &&
|
|
|
-// _divisor == realOther->_divisor &&
|
|
|
-// _remainder == realOther->_remainder;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ if(other._matchType != 'MOD')
|
|
|
+ return false;
|
|
|
+ return this.path() == other.path() && this._divisor == other._divisor && this._remainder == other._remainder;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -113,12 +56,8 @@ proto.equivalent = function equivalent( /* const MatchExpression* other */ ){
|
|
|
*/
|
|
|
proto.getDivisor = function getDivisor( /* */ ){
|
|
|
// File: expression_leaf.h lines: 206-205
|
|
|
-// int getDivisor() const { return _divisor; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._divisor;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -130,12 +69,8 @@ proto.getDivisor = function getDivisor( /* */ ){
|
|
|
*/
|
|
|
proto.getRemainder = function getRemainder( /* */ ){
|
|
|
// File: expression_leaf.h lines: 207-206
|
|
|
-// int getRemainder() const { return _remainder; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._remainder;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -145,20 +80,16 @@ proto.getRemainder = function getRemainder( /* */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.init = function init( /* const StringData& path, int divisor, int remainder */ ){
|
|
|
-
|
|
|
+proto.init = function init( path,divisor,remainder ) { // const StringData& path, int divisor, int remainder
|
|
|
// File: expression_leaf.cpp lines: 239-244
|
|
|
-// Status ModMatchExpression::init( const StringData& path, int divisor, int remainder ) {
|
|
|
-// if ( divisor == 0 )
|
|
|
-// return Status( ErrorCodes::BadValue, "divisor cannot be 0" );
|
|
|
-// _divisor = divisor;
|
|
|
-// _remainder = remainder;
|
|
|
-// return initPath( path );
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
+ if (divisor === 0 ){
|
|
|
+ return {'code':'BAD_VALUE', 'desc':'Divisor cannot be 0'};
|
|
|
+ }
|
|
|
|
|
|
-}
|
|
|
+ this._divisor = divisor;
|
|
|
+ this._remainder = remainder;
|
|
|
+ return this.initPath( path );
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -168,18 +99,14 @@ proto.init = function init( /* const StringData& path, int divisor, int remaind
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.matchesSingleElement = function matchesSingleElement( /* const BSONElement& e */ ){
|
|
|
-
|
|
|
+proto.matchesSingleElement = function matchesSingleElement( e ) { // const BSONElement& e
|
|
|
// File: expression_leaf.cpp lines: 247-250
|
|
|
-// bool ModMatchExpression::matchesSingleElement( const BSONElement& e ) const {
|
|
|
-// if ( !e.isNumber() )
|
|
|
-// return false;
|
|
|
-// return e.numberLong() % _divisor == _remainder;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ if(typeof(e) == 'number') {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return (e % this._divisor) == this._remainder;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -191,13 +118,9 @@ proto.matchesSingleElement = function matchesSingleElement( /* const BSONElemen
|
|
|
*/
|
|
|
proto.shallowClone = function shallowClone( /* */ ){
|
|
|
// File: expression_leaf.h lines: 194-197
|
|
|
-// virtual LeafMatchExpression* shallowClone() const {
|
|
|
-// ModMatchExpression* m = new ModMatchExpression();
|
|
|
-// m->init( path(), _divisor, _remainder );
|
|
|
-// return m;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
+ var e = new ModMatchObject();
|
|
|
+ e.init(this.path(),this._divisor, this._remainder);
|
|
|
+ return e;
|
|
|
+};
|
|
|
|
|
|
|
|
|
-}
|