AllElemMatchOp.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. "use strict";
  2. var MatchExpression = require('./MatchExpression');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var AllElemMatchOp = module.exports = function AllElemMatchOp(){
  5. base.call(this);
  6. this._matchType = 'ALL';
  7. }, klass = AllElemMatchOp, base = MatchExpression , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  8. // File: expression_array.h lines: 175-175
  9. // ElementPath _elementPath;
  10. proto._elementPath = undefined;
  11. // File: expression_array.h lines: 176-176
  12. // std::vector< const ArrayMatchingMatchExpression* > _list;
  13. proto._list = undefined;
  14. // File: expression_array.h lines: 174-174
  15. // StringData _path;
  16. proto._path = undefined;
  17. /**
  18. *
  19. * This documentation was automatically generated. Please update when you touch this function.
  20. * @method _allMatch
  21. * @param
  22. *
  23. */
  24. proto._allMatch = function _allMatch( anArray ){ // const BSONObj& anArray
  25. // File: expression_array.cpp lines: 208-215
  26. if(this._list.length === 0) { return false; }
  27. for (var i = 0; i < this._list.length; i++) {
  28. if( ! this._list[i].matchesArray( anArray, null ) ) { return false; }
  29. }
  30. return true;
  31. };
  32. /**
  33. *
  34. * This documentation was automatically generated. Please update when you touch this function.
  35. * @method add
  36. * @param
  37. *
  38. */
  39. proto.add = function add( expr ){// const ArrayMatchingMatchExpression* expr
  40. // File: expression_array.cpp lines: 184-186
  41. // void AllElemMatchOp::add( const ArrayMatchingMatchExpression* expr ) {
  42. // verify( expr );
  43. // _list.push_back( expr );
  44. // }
  45. this.verify( expr );
  46. this._list.append( expr );
  47. };
  48. /**
  49. *
  50. * This documentation was automatically generated. Please update when you touch this function.
  51. * @method debugString
  52. * @param
  53. *
  54. */
  55. proto.debugString = function debugString( level ){ // StringBuilder& debug, int level
  56. // File: expression_array.cpp lines: 219-224
  57. // void AllElemMatchOp::debugString( StringBuilder& debug, int level ) const {
  58. // _debugAddSpace( debug, level );
  59. // debug << _path << " AllElemMatchOp: " << _path << "\n";
  60. // for ( size_t i = 0; i < _list.size(); i++ ) {
  61. // _list[i]->debugString( debug, level + 1);
  62. // }
  63. // }
  64. console.debug(this._debugAddSpace(level) + this._path + " AllElemMatchOp: " + this._path + '\n');
  65. for (var i = 0; i < this._list.length; i++) {
  66. this._list[i].debugString(level +1);
  67. }
  68. };
  69. /**
  70. *
  71. * This documentation was automatically generated. Please update when you touch this function.
  72. * @method equivalent
  73. * @param
  74. *
  75. */
  76. proto.equivalent = function equivalent( other ){// const MatchExpression* other
  77. // File: expression_array.cpp lines: 227-242
  78. if (this.matchType() != other.matchType()) {
  79. return false;
  80. }
  81. if( this._path != other._path ) {
  82. return false;
  83. }
  84. if( this._list.length != other._list.length ) {
  85. return false;
  86. }
  87. for (var i = 0; i < this._list.length; i++) {
  88. if ( !this._list[i].equivalent( other._list[i] ) ) {
  89. return false;
  90. }
  91. }
  92. return true;
  93. };
  94. /**
  95. *
  96. * This documentation was automatically generated. Please update when you touch this function.
  97. * @method getChild
  98. * @param
  99. *
  100. */
  101. proto.getChild = function getChild( i ){ // size_t i
  102. // File: expression_array.h lines: 167-166
  103. return this._list[i];
  104. };
  105. /**
  106. *
  107. * This documentation was automatically generated. Please update when you touch this function.
  108. * @method init
  109. * @param
  110. *
  111. */
  112. proto.init = function init( path ){ // const StringData& path
  113. // File: expression_array.cpp lines: 177-181
  114. this._path = path;
  115. var s = this._elementPath.init( this._path );
  116. this._elementPath.setTraverseLeafArray( false );
  117. return s;
  118. };
  119. /**
  120. *
  121. * This documentation was automatically generated. Please update when you touch this function.
  122. * @method matches
  123. * @param
  124. *
  125. */
  126. proto.matches = function matches( doc,details ) { // const MatchableDocument* doc, MatchDetails* details
  127. // File: expression_array.cpp lines: 189-198
  128. var cursor = doc.getIterator( this._elementPath );
  129. while ( cursor.more ) {
  130. var e = cursor.next();
  131. if (e.element().type() != 'Array') {
  132. continue;
  133. }
  134. if (this.all_match(e.element().Obj())) {
  135. return true;
  136. }
  137. }
  138. return false;
  139. };
  140. /**
  141. *
  142. * This documentation was automatically generated. Please update when you touch this function.
  143. * @method matchesSingleElement
  144. * @param
  145. *
  146. */
  147. proto.matchesSingleElement = function matchesSingleElement( e ){ // const BSONElement& e
  148. // File: expression_array.cpp lines: 201-205
  149. if ( e instanceof 'Array' ) {
  150. return false;
  151. }
  152. return this._allMatch(e.Obj());
  153. };
  154. /**
  155. *
  156. * This documentation was automatically generated. Please update when you touch this function.
  157. * @method numChildren
  158. * @param
  159. *
  160. */
  161. proto.numChildren = function numChildren( /* */ ){
  162. // File: expression_array.h lines: 166-165
  163. return this._list.length;
  164. };
  165. /**
  166. *
  167. * This documentation was automatically generated. Please update when you touch this function.
  168. * @method path
  169. * @param
  170. *
  171. */
  172. proto.path = function path( /* */ ){
  173. // File: expression_array.h lines: 169-168
  174. return this._path;
  175. };
  176. /**
  177. *
  178. * This documentation was automatically generated. Please update when you touch this function.
  179. * @method shallowClone
  180. * @param
  181. *
  182. */
  183. proto.shallowClone = function shallowClone( /* */ ){
  184. // File: expression_array.h lines: 145-152
  185. var e = new AllElemMatchOp();
  186. e.init( this._path );
  187. e._list = this._list.slice(0);
  188. return e;
  189. };