ModMatchExpression.js 3.1 KB

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