ModMatchExpression.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. "use strict";
  2. var LeafMatchExpression = require('./LeafMatchExpression');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var ModMatchExpression = module.exports = function ModMatchExpression(){
  5. base.call(this);
  6. this._matchType = 'MOD';
  7. }, klass = ModMatchExpression, base = LeafMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  8. // File: expression_leaf.h lines: 210-210
  9. // int _divisor;
  10. proto._divisor = undefined;
  11. // File: expression_leaf.h lines: 211-211
  12. // int _remainder;
  13. proto._remainder = undefined;
  14. /**
  15. *
  16. * This documentation was automatically generated. Please update when you touch this function.
  17. * @method debugString
  18. * @param
  19. *
  20. */
  21. proto.debugString = function debugString( level ) { // StringBuilder& debug, int level
  22. // File: expression_leaf.cpp lines: 253-261
  23. return this._debugAddSpace( level ) + this.path() + " mod " + this._divisor + " % x == " + this._remainder + (this.getTag() ? " " + this.getTag().debugString() : '') + "\n";
  24. };
  25. /**
  26. *
  27. * This documentation was automatically generated. Please update when you touch this function.
  28. * @method equivalent
  29. * @param
  30. *
  31. */
  32. proto.equivalent = function equivalent( other ) { // const MatchExpression* other
  33. // File: expression_leaf.cpp lines: 264-272
  34. if(other._matchType != 'MOD')
  35. return false;
  36. return this.path() == other.path() && this._divisor == other._divisor && this._remainder == other._remainder;
  37. };
  38. /**
  39. *
  40. * This documentation was automatically generated. Please update when you touch this function.
  41. * @method getDivisor
  42. * @param
  43. *
  44. */
  45. proto.getDivisor = function getDivisor( /* */ ){
  46. // File: expression_leaf.h lines: 206-205
  47. return this._divisor;
  48. };
  49. /**
  50. *
  51. * This documentation was automatically generated. Please update when you touch this function.
  52. * @method getRemainder
  53. * @param
  54. *
  55. */
  56. proto.getRemainder = function getRemainder( /* */ ){
  57. // File: expression_leaf.h lines: 207-206
  58. return this._remainder;
  59. };
  60. /**
  61. *
  62. * This documentation was automatically generated. Please update when you touch this function.
  63. * @method init
  64. * @param
  65. *
  66. */
  67. proto.init = function init( path,divisor,remainder ) { // const StringData& path, int divisor, int remainder
  68. // File: expression_leaf.cpp lines: 239-244
  69. if (divisor === 0 ){
  70. return {'code':'BAD_VALUE', 'desc':'Divisor cannot be 0'};
  71. }
  72. this._divisor = divisor;
  73. this._remainder = remainder;
  74. return this.initPath( path );
  75. };
  76. /**
  77. *
  78. * This documentation was automatically generated. Please update when you touch this function.
  79. * @method matchesSingleElement
  80. * @param
  81. *
  82. */
  83. proto.matchesSingleElement = function matchesSingleElement( e ) { // const BSONElement& e
  84. // File: expression_leaf.cpp lines: 247-250
  85. if(!(typeof(e) == 'number')) {
  86. return false;
  87. }
  88. return (e % this._divisor) == this._remainder;
  89. };
  90. /**
  91. *
  92. * This documentation was automatically generated. Please update when you touch this function.
  93. * @method shallowClone
  94. * @param
  95. *
  96. */
  97. proto.shallowClone = function shallowClone( /* */ ){
  98. // File: expression_leaf.h lines: 194-197
  99. var e = new ModMatchObject();
  100. e.init(this.path(),this._divisor, this._remainder);
  101. return e;
  102. };