ArrayFilterEntries.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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.push( 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(typeof(elem) == typeof(this._equalities[i])){
  69. if(Value.compare(elem, this._equalities[i]) === 0) {
  70. return true;
  71. }
  72. } else {
  73. return false;
  74. }
  75. }
  76. return false;
  77. };
  78. /**
  79. *
  80. * This documentation was automatically generated. Please update when you touch this function.
  81. * @method copyTo
  82. * @param
  83. *
  84. */
  85. proto.copyTo = function copyTo( toFillIn ) { // ArrayFilterEntries& toFillIn
  86. // File: expression_leaf.cpp lines: 407-412
  87. toFillIn._hasNull = this._hasNull;
  88. toFillIn._hasEmptyArray = this._hasEmptyArray;
  89. toFillIn._equalities = this._equalities;
  90. toFillIn._regexes = this._regexes.slice(0); // Copy array
  91. };
  92. /**
  93. *
  94. * This documentation was automatically generated. Please update when you touch this function.
  95. * @method equalities
  96. * @param
  97. *
  98. */
  99. proto.equalities = function equalities( /* */ ){
  100. // File: expression_leaf.h lines: 248-247
  101. return this._equalities;
  102. };
  103. /**
  104. *
  105. * This documentation was automatically generated. Please update when you touch this function.
  106. * @method equivalent
  107. * @param
  108. *
  109. */
  110. proto.equivalent = function equivalent( other ) { // const ArrayFilterEntries& other
  111. // File: expression_leaf.cpp lines: 394-404
  112. if (this._hasNull != other._hasNull) {return false;}
  113. if (this._regexes.length != other._regexes.length) {return false;}
  114. for (var i = 0; i < this._regexes.length; i++) {
  115. if ( !this._regexes[i].equivalent( other._regexes[i] ) ) {
  116. return false;
  117. }
  118. }
  119. return Value.compare(this._equalities, other._equalities);
  120. };
  121. /**
  122. *
  123. * This documentation was automatically generated. Please update when you touch this function.
  124. * @method hasEmptyArray
  125. * @param
  126. *
  127. */
  128. proto.hasEmptyArray = function hasEmptyArray( /* */ ){
  129. // File: expression_leaf.h lines: 256-255
  130. return this._hasEmptyArray;
  131. };
  132. /**
  133. *
  134. * This documentation was automatically generated. Please update when you touch this function.
  135. * @method hasNull
  136. * @param
  137. *
  138. */
  139. proto.hasNull = function hasNull( /* */ ){
  140. // File: expression_leaf.h lines: 254-253
  141. return this._hasNull;
  142. };
  143. /**
  144. *
  145. * This documentation was automatically generated. Please update when you touch this function.
  146. * @method numRegexes
  147. * @param
  148. *
  149. */
  150. proto.numRegexes = function numRegexes( /* */ ){
  151. // File: expression_leaf.h lines: 251-250
  152. return this._regexes.length;
  153. };
  154. /**
  155. *
  156. * This documentation was automatically generated. Please update when you touch this function.
  157. * @method regex
  158. * @param
  159. *
  160. */
  161. proto.regex = function regex( idx ) { // int idx
  162. // File: expression_leaf.h lines: 252-251
  163. return this._regexes[idx];
  164. };
  165. /**
  166. *
  167. * This documentation was automatically generated. Please update when you touch this function.
  168. * @method singleNull
  169. * @param
  170. *
  171. */
  172. proto.singleNull = function singleNull( /* */ ){
  173. // File: expression_leaf.h lines: 255-254
  174. return this.size() == 1 && _hasNull;
  175. };
  176. /**
  177. *
  178. * This documentation was automatically generated. Please update when you touch this function.
  179. * @method size
  180. * @param
  181. *
  182. */
  183. proto.size = function size( /* */ ){
  184. // File: expression_leaf.h lines: 257-256
  185. return this._equalities.length + this._regexes.length;
  186. };