InMatchExpression.js 3.8 KB

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