ElemMatchValueMatchExpression.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. "use strict";
  2. var ArrayMatchingMatchExpression = require('./ArrayMatchingMatchExpression.js');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var ElemMatchValueMatchExpression = module.exports = function ElemMatchValueMatchExpression(){
  5. base.call(this);
  6. this._matchType = 'ELEM_MATCH_VALUE';
  7. this._subs = [];
  8. }, klass = ElemMatchValueMatchExpression, base = ArrayMatchingMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  9. // DEPENDENCIES
  10. var errors = require("../../Errors.js"),
  11. ErrorCodes = errors.ErrorCodes;
  12. // File: expression_array.h lines: 108-108
  13. proto._subs = undefined;
  14. /**
  15. *
  16. * This documentation was automatically generated. Please update when you touch this function.
  17. * @method _arrayElementMatchesAll
  18. * @param
  19. *
  20. */
  21. proto._arrayElementMatchesAll = function _arrayElementMatchesAll(element){
  22. // File: expression_array.cpp lines: 152-157
  23. for (var i = 0; i < this._subs.length; i++ ) {
  24. if (!this._subs[i].matchesSingleElement(element))
  25. return false;
  26. }
  27. return true;
  28. };
  29. /**
  30. *
  31. * This documentation was automatically generated. Please update when you touch this function.
  32. * @method add
  33. * @param
  34. *
  35. */
  36. proto.add = function add(sub){
  37. // File: expression_array.cpp lines: 132-134
  38. if (!sub) throw new Error(sub + " ElemMatchValueMatchExpression:36");
  39. this._subs.push(sub);
  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){
  49. // File: expression_array.cpp lines: 160-165
  50. var debug = this._debugAddSpace(level);
  51. debug = debug + this.path() + " $elemMatch\n";
  52. for (var i = 0; i < this._subs.length; i++) {
  53. debug = debug + this._subs[i].debugString(level + 1);
  54. }
  55. return debug;
  56. };
  57. /**
  58. *
  59. * This documentation was automatically generated. Please update when you touch this function.
  60. * @method getChild
  61. * @param
  62. *
  63. */
  64. proto.getChild = function getChild(i){
  65. // File: expression_array.h lines: 103-102
  66. return this._subs[i];
  67. };
  68. /**
  69. *
  70. * This documentation was automatically generated. Please update when you touch this function.
  71. * @method init
  72. * @param
  73. *
  74. */
  75. proto.init = function init(path, sub){
  76. // File: expression_array.cpp lines: 121-124
  77. this.initPath(path);
  78. if (sub)
  79. this.add(sub);
  80. return {code:ErrorCodes.OK};
  81. };
  82. /**
  83. *
  84. * This documentation was automatically generated. Please update when you touch this function.
  85. * @method matchesArray
  86. * @param
  87. *
  88. */
  89. proto.matchesArray = function matchesArray(anArray, details){
  90. // File: expression_array.cpp lines: 137-149
  91. for (var i in anArray) {
  92. var inner = anArray[i];
  93. if (this._arrayElementMatchesAll(inner)) {
  94. if (details && details.needRecord()) {
  95. details.setElemMatchKey(i);
  96. }
  97. return true;
  98. }
  99. }
  100. return false;
  101. };
  102. /**
  103. *
  104. * This documentation was automatically generated. Please update when you touch this function.
  105. * @method numChildren
  106. * @param
  107. *
  108. */
  109. proto.numChildren = function numChildren(){
  110. // File: expression_array.h lines: 102-101
  111. return this._subs.length;
  112. };
  113. /**
  114. *
  115. * This documentation was automatically generated. Please update when you touch this function.
  116. * @method shallowClone
  117. * @param
  118. *
  119. */
  120. proto.shallowClone = function shallowClone(){
  121. // File: expression_array.h lines: 91-97
  122. var element = new ElemMatchValueMatchExpression();
  123. element.init(this.path());
  124. for (var i = 0; i < this._subs.length; ++i) {
  125. element.add(this._subs[i].shallowClone());
  126. }
  127. return element;
  128. };