InMatchExpression.js 4.1 KB

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