ArrayFilterEntries.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. "use strict";
  2. var Value = require('../Value');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var ArrayFilterEntries = module.exports = function ArrayFilterEntries(){
  5. this._hasNull = false;
  6. this._hasEmptyArray = false;
  7. this._equalities = [];
  8. this._regexes = [];
  9. }, klass = ArrayFilterEntries, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  10. // File: expression_leaf.h lines: 266-266
  11. // BSONElementSet _equalities;
  12. proto._equalities = undefined;
  13. // File: expression_leaf.h lines: 265-265
  14. // bool _hasEmptyArray;
  15. proto._hasEmptyArray = undefined;
  16. // File: expression_leaf.h lines: 264-264
  17. // bool _hasNull; // if _equalities has a jstNULL element in it
  18. proto._hasNull = undefined;
  19. // File: expression_leaf.h lines: 267-267
  20. // std::vector<RegexMatchExpression*> _regexes;
  21. proto._regexes = undefined;
  22. /**
  23. * addEquality
  24. *
  25. * @method addEquality
  26. *
  27. *
  28. */
  29. proto.addEquality = function addEquality( e ) {
  30. //File expression_leaf.cpp lines 369-387
  31. if(e instanceof Object && Object.keys(e)[0][0] === '$'){
  32. return {'code':'BAD_VALUE', 'desc':'cannot next $ under $in'};
  33. }
  34. if( e instanceof RegExp ) {
  35. return {'code': 'BAD_VALUE', 'desc':'ArrayFilterEntries equality cannot be a regex'};
  36. }
  37. if( e === null ) {
  38. this._hasNull = true;
  39. }
  40. if (e instanceof Array && e.length === 0) {
  41. this._hasEmptyArray = true;
  42. }
  43. this._equalities.push( e );
  44. return {'code':'OK'};
  45. };
  46. /**
  47. *
  48. * This documentation was automatically generated. Please update when you touch this function.
  49. * @method addRegex
  50. * @param
  51. *
  52. */
  53. proto.addRegex = function addRegex( expr ) { // RegexMatchExpression* expr
  54. // File: expression_leaf.cpp lines: 389-391
  55. this._regexes.append( expr );
  56. return {'code':'OK'};
  57. };
  58. /**
  59. *
  60. * This documentation was automatically generated. Please update when you touch this function.
  61. * @method contains
  62. * @param
  63. *
  64. */
  65. proto.contains = function contains( elem ) { // const BSONElement& elem
  66. // File: expression_leaf.h lines: 249-248
  67. for (var i = 0; i < this._equalities.length; i++) {
  68. if( Value.compare(elem, this._equalities[i])) {
  69. return true;
  70. }
  71. }
  72. return false;
  73. };
  74. /**
  75. *
  76. * This documentation was automatically generated. Please update when you touch this function.
  77. * @method copyTo
  78. * @param
  79. *
  80. */
  81. proto.copyTo = function copyTo( toFillIn ) { // ArrayFilterEntries& toFillIn
  82. // File: expression_leaf.cpp lines: 407-412
  83. toFillIn._hasNull = this._hasNull;
  84. toFillIn._hasEmptyArray = this._hasEmptyArray;
  85. toFillIn._equalities = this._equalities;
  86. toFillIn._regexes = this._regexes.slice(0); // Copy array
  87. };
  88. /**
  89. *
  90. * This documentation was automatically generated. Please update when you touch this function.
  91. * @method equalities
  92. * @param
  93. *
  94. */
  95. proto.equalities = function equalities( /* */ ){
  96. // File: expression_leaf.h lines: 248-247
  97. return this._equalities;
  98. };
  99. /**
  100. *
  101. * This documentation was automatically generated. Please update when you touch this function.
  102. * @method equivalent
  103. * @param
  104. *
  105. */
  106. proto.equivalent = function equivalent( other ) { // const ArrayFilterEntries& other
  107. // File: expression_leaf.cpp lines: 394-404
  108. if (this._hasNull != other._hasNull) {return false;}
  109. if (this._regexes.length != other._regexes.length) {return false;}
  110. for (var i = 0; i < this._regexes.length; i++) {
  111. if ( !this._regexes[i].equivalent( other._regexes[i] ) ) {
  112. return false;
  113. }
  114. }
  115. return Value.compare(this._equalities, other._equalities);
  116. };
  117. /**
  118. *
  119. * This documentation was automatically generated. Please update when you touch this function.
  120. * @method hasEmptyArray
  121. * @param
  122. *
  123. */
  124. proto.hasEmptyArray = function hasEmptyArray( /* */ ){
  125. // File: expression_leaf.h lines: 256-255
  126. return this._hasEmptyArray;
  127. };
  128. /**
  129. *
  130. * This documentation was automatically generated. Please update when you touch this function.
  131. * @method hasNull
  132. * @param
  133. *
  134. */
  135. proto.hasNull = function hasNull( /* */ ){
  136. // File: expression_leaf.h lines: 254-253
  137. return this._hasNull;
  138. };
  139. /**
  140. *
  141. * This documentation was automatically generated. Please update when you touch this function.
  142. * @method numRegexes
  143. * @param
  144. *
  145. */
  146. proto.numRegexes = function numRegexes( /* */ ){
  147. // File: expression_leaf.h lines: 251-250
  148. return this._regexes.length;
  149. };
  150. /**
  151. *
  152. * This documentation was automatically generated. Please update when you touch this function.
  153. * @method regex
  154. * @param
  155. *
  156. */
  157. proto.regex = function regex( idx ) { // int idx
  158. // File: expression_leaf.h lines: 252-251
  159. return this._regexes[idx];
  160. };
  161. /**
  162. *
  163. * This documentation was automatically generated. Please update when you touch this function.
  164. * @method singleNull
  165. * @param
  166. *
  167. */
  168. proto.singleNull = function singleNull( /* */ ){
  169. // File: expression_leaf.h lines: 255-254
  170. return this.size() == 1 && _hasNull;
  171. };
  172. /**
  173. *
  174. * This documentation was automatically generated. Please update when you touch this function.
  175. * @method size
  176. * @param
  177. *
  178. */
  179. proto.size = function size( /* */ ){
  180. // File: expression_leaf.h lines: 257-256
  181. return this._equalities.length + this._regexes.length;
  182. };