AllElemMatchOp.js 5.3 KB

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