SizeMatchExpression.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. "use strict";
  2. var ArrayMatchingMatchExpression = require('./ArrayMatchingMatchExpression');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var SizeMatchExpression = module.exports = function SizeMatchExpression(){
  5. this._matchType = 'SIZE';
  6. }, klass = SizeMatchExpression, base = ArrayMatchingMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  7. // File: expression_array.h lines: 131-131
  8. // int _size; // >= 0 real, < 0, nothing will match
  9. proto._size = undefined;
  10. /**
  11. *
  12. * This documentation was automatically generated. Please update when you touch this function.
  13. * @method debugString
  14. * @param
  15. *
  16. */
  17. proto.debugString = function debugString( level ) { // StringBuilder& debug, int level
  18. // File: expression_array.cpp lines: 259-261
  19. return this._debugAddSpace( level ) + this.path() + " $size : " + str(this._size) + "\n";
  20. };
  21. /**
  22. *
  23. * This documentation was automatically generated. Please update when you touch this function.
  24. * @method equivalent
  25. * @param
  26. *
  27. */
  28. proto.equivalent = function equivalent( other ) { // const MatchExpression* other
  29. // File: expression_array.cpp lines: 264-269
  30. if(other._matchType != 'SIZE') {
  31. return false;
  32. }
  33. return this._size == other._size && this._path == other._size;
  34. };
  35. /**
  36. *
  37. * This documentation was automatically generated. Please update when you touch this function.
  38. * @method getData
  39. * @param
  40. *
  41. */
  42. proto.getData = function getData( /* */ ){
  43. // File: expression_array.h lines: 128-127
  44. return this._size;
  45. };
  46. /**
  47. *
  48. * This documentation was automatically generated. Please update when you touch this function.
  49. * @method init
  50. * @param
  51. *
  52. */
  53. proto.init = function init( path,size ) { // const StringData& path, int size
  54. // File: expression_array.cpp lines: 248-250
  55. this._size = size;
  56. return this.initPath(path);
  57. };
  58. /**
  59. *
  60. * This documentation was automatically generated. Please update when you touch this function.
  61. * @method matchesArray
  62. * @param
  63. *
  64. */
  65. proto.matchesArray = function matchesArray( anArray,details ) { // const BSONObj& anArray, MatchDetails* details
  66. // File: expression_array.cpp lines: 253-256
  67. if(this._size < 0) {
  68. return false;
  69. }
  70. return anArray.length == this._size();
  71. };
  72. /**
  73. *
  74. * This documentation was automatically generated. Please update when you touch this function.
  75. * @method shallowClone
  76. * @param
  77. *
  78. */
  79. proto.shallowClone = function shallowClone( /* */ ){
  80. // File: expression_array.h lines: 116-119
  81. // virtual SizeMatchExpression* shallowClone() const {
  82. // SizeMatchExpression* e = new SizeMatchExpression();
  83. // e->init(path(), _size);
  84. // return e;
  85. // }
  86. var e = new SizeMatchExpression();
  87. e.init(this.path(),this._size);
  88. return e;
  89. };