InMatchExpression.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. "use strict";
  2. var LeafMatchExpression = require('./LeafMatchExpression');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var InMatchExpression = module.exports = function InMatchExpression(){
  5. base.call(this);
  6. this._matchType = 'MATCH_IN';
  7. this._arrayEntries = new ArrayFilterEntries();
  8. }, klass = InMatchExpression, base = LeafMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  9. // DEPENDENCIES
  10. var errors = require("../../Errors.js"),
  11. ErrorCodes = errors.ErrorCodes,
  12. ArrayFilterEntries = require("./ArrayFilterEntries.js");
  13. // File: expression_leaf.h lines: 294-294
  14. // ArrayFilterEntries _arrayEntries;
  15. proto._arrayEntries = null;
  16. /**
  17. *
  18. * This documentation was automatically generated. Please update when you touch this function.
  19. * @method _matchesRealElement
  20. * @param
  21. *
  22. */
  23. proto._matchesRealElement = function _matchesRealElement( e ) { // const BSONElement& e
  24. // File: expression_leaf.cpp lines: 422-431
  25. if(this._arrayEntries.contains(e)) { // array wrapper.... so no e "in" array
  26. return true;
  27. }
  28. for (var i = 0; i < this._arrayEntries.numRegexes(); i++) {
  29. if(e.match && e.match(this._arrayEntries.regex(i)._regex)) {
  30. return true;
  31. } else if (e instanceof RegExp) {
  32. if(e.toString() == this._arrayEntries.regex(i)._regex.toString()) {
  33. return true;
  34. }
  35. }
  36. }
  37. return false;
  38. };
  39. /**
  40. *
  41. * This documentation was automatically generated. Please update when you touch this function.
  42. * @method copyTo
  43. * @param
  44. *
  45. */
  46. proto.copyTo = function copyTo( toFillIn ) { // InMatchExpression* toFillIn
  47. // File: expression_leaf.cpp lines: 481-483
  48. toFillIn.init(this.path());
  49. this._arrayEntries.copyTo( toFillIn._arrayEntries );
  50. };
  51. /**
  52. *
  53. * This documentation was automatically generated. Please update when you touch this function.
  54. * @method debugString
  55. * @param
  56. *
  57. */
  58. proto.debugString = function debugString( level ) { // StringBuilder& debug, int level
  59. // File: expression_leaf.cpp lines: 455-463
  60. return this._debugAddSpace( level ) + this.path() + ";$in: TODO " + (this.getTag() ? this.getTag().debugString() : '') + "\n";
  61. };
  62. /**
  63. *
  64. * This documentation was automatically generated. Please update when you touch this function.
  65. * @method equivalent
  66. * @param
  67. *
  68. */
  69. proto.equivalent = function equivalent( other ) { // const MatchExpression* other
  70. // File: expression_leaf.cpp lines: 466-472
  71. if ( other._matchType != 'MATCH_IN' ) {
  72. return false;
  73. }
  74. return this.path() == other.path() && this._arrayEntries.equivalent( other._arrayEntries );
  75. };
  76. /**
  77. *
  78. * This documentation was automatically generated. Please update when you touch this function.
  79. * @method getArrayFilterEntries
  80. * @param
  81. *
  82. */
  83. proto.getArrayFilterEntries = function getArrayFilterEntries( /* */ ){
  84. // File: expression_leaf.h lines: 280-279
  85. return this._arrayEntries;
  86. };
  87. /**
  88. *
  89. * This documentation was automatically generated. Please update when you touch this function.
  90. * @method getData
  91. * @param
  92. *
  93. */
  94. proto.getData = function getData( /* */ ){
  95. // File: expression_leaf.h lines: 290-289
  96. return this._arrayEntries;
  97. };
  98. /**
  99. *
  100. * This documentation was automatically generated. Please update when you touch this function.
  101. * @method init
  102. * @param
  103. *
  104. */
  105. proto.init = function init( path ) { // const StringData& path
  106. // File: expression_leaf.cpp lines: 418-419
  107. return this.initPath( path );
  108. };
  109. /**
  110. *
  111. * This documentation was automatically generated. Please update when you touch this function.
  112. * @method matchesSingleElement
  113. * @param
  114. *
  115. */
  116. proto.matchesSingleElement = function matchesSingleElement( e ) { // const BSONElement& e
  117. // File: expression_leaf.cpp lines: 434-452
  118. if( this._arrayEntries === null && typeof(e) == 'object' && Object.keys(e).length === 0) {
  119. return true;
  120. }
  121. if (this._matchesRealElement( e )) {
  122. return true;
  123. }
  124. if (e instanceof Array){
  125. for (var i = 0; i < e.length; i++) {
  126. if(this._matchesRealElement( e[i] )) {
  127. return true;
  128. }
  129. }
  130. }
  131. return false;
  132. };
  133. /**
  134. *
  135. * This documentation was automatically generated. Please update when you touch this function.
  136. * @method shallowClone
  137. * @param
  138. *
  139. */
  140. proto.shallowClone = function shallowClone( /* */ ){
  141. // File: expression_leaf.cpp lines: 475-478
  142. var e = new InMatchExpression();
  143. this.copyTo( e );
  144. return e;
  145. };