ArrayMatchingMatchExpression.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. "use strict";
  2. var MatchExpression = require('./MatchExpression');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var ArrayMatchingMatchExpression = module.exports = function ArrayMatchingMatchExpression(matchType){
  5. this._matchType = matchType;
  6. }, klass = ArrayMatchingMatchExpression, base = MatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  7. // File: expression_array.h lines: 55-55
  8. proto._elementPath = undefined;
  9. // File: expression_array.h lines: 54-54
  10. proto._path = undefined;
  11. // File: expression_array.h lines: 55-55
  12. proto._elementPath = undefined;
  13. // File: expression_array.h lines: 54-54
  14. proto._path = undefined;
  15. /**
  16. *
  17. * Check if the input element is equivalent to us
  18. * @method equivalent
  19. * @param
  20. *
  21. */
  22. proto.equivalent = function equivalent(other){
  23. // File: expression_array.cpp lines: 63-79
  24. if ( this._matchType != other._matchType)
  25. return false;
  26. var realOther = new ArrayMatchingMatchExpression(other);
  27. if (this._path != realOther._path)
  28. return false;
  29. if (this.numChildren() != realOther.numChildren())
  30. return false;
  31. for (var i = 0; i < this.numChildren(); i++)
  32. if (!this.getChild(i).equivalent(realOther.getChild(i)))
  33. return false;
  34. return true;
  35. };
  36. /**
  37. *
  38. * Initialize the input path as our element path
  39. * @method initPath
  40. * @param path
  41. *
  42. */
  43. proto.initPath = function initPath(path){
  44. // File: expression_array.cpp lines: 27-31
  45. this._path = path;
  46. var status = this._elementPath.init(this._path);
  47. this._elementPath.setTraverseLeafArray(false);
  48. return status;
  49. };
  50. /**
  51. *
  52. * This documentation was automatically generated. Please update when you touch this function.
  53. * @method matches
  54. * @param
  55. *
  56. */
  57. proto.matches = function matches(doc, details){
  58. // File: expression_array.cpp lines: 34-53
  59. var element;
  60. for (var k in doc[this._elementPath]) {
  61. element = doc[this._elementPath][k];
  62. if (!(element instanceof Array))
  63. continue;
  64. var amIRoot = (element.length === 0);
  65. if (!this.matchesArray(element, amIRoot ? details : null))
  66. continue;
  67. if (!amIRoot && details && details.needRecord() /* && !e.arrayOffset().eoo() same as amIRoot? */) {
  68. details.setElemMatchKey(element.fieldName());
  69. }
  70. return true;
  71. }
  72. return false;
  73. };
  74. /**
  75. *
  76. * This documentation was automatically generated. Please update when you touch this function.
  77. * @method matchesSingleElement
  78. * @param
  79. *
  80. */
  81. proto.matchesSingleElement = function matchesSingleElement(element){
  82. // File: expression_array.cpp lines: 56-59
  83. if (!(element instanceof Array))
  84. return false;
  85. return this.matchesArray(element, null);
  86. };
  87. /**
  88. *
  89. * This documentation was automatically generated. Please update when you touch this function.
  90. * @method path
  91. * @param
  92. *
  93. */
  94. proto.path = function path(){
  95. // File: expression_array.h lines: 52-51
  96. return this._path;
  97. };
  98. /**
  99. *
  100. * Check if the input array matches
  101. * @method path
  102. * @param anArray
  103. * @param details
  104. *
  105. */
  106. proto.matchesArray = function matchesArray(anArray, details){
  107. throw new Error("not implemented");
  108. };