LeafMatchExpression.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. "use strict";
  2. var MatchExpression = require('./MatchExpression');
  3. var ElementPath = require('./ElementPath');
  4. // Autogenerated by cport.py on 2013-09-17 14:37
  5. var LeafMatchExpression = module.exports = function LeafMatchExpression( type ){
  6. this._matchType = type;
  7. this._elementPath = new ElementPath();
  8. }, klass = LeafMatchExpression, base = MatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  9. // File: expression_leaf.h lines: 63-63
  10. // ElementPath _elementPath;
  11. proto._elementPath = undefined;
  12. // File: expression_leaf.h lines: 62-62
  13. // StringData _path;
  14. proto._path = undefined;
  15. /**
  16. *
  17. * This documentation was automatically generated. Please update when you touch this function.
  18. * @method initPath
  19. * @param
  20. *
  21. */
  22. proto.initPath = function initPath( path ) { // const StringData& path
  23. // File: expression_leaf.cpp lines: 31-33
  24. this._path = path;
  25. if(this._elementPath === undefined){
  26. this._elementPath = new ElementPath();
  27. }
  28. return this._elementPath.init( this._path );
  29. };
  30. /**
  31. *
  32. * This documentation was automatically generated. Please update when you touch this function.
  33. * @method matches
  34. * @param
  35. *
  36. */
  37. proto.matches = function matches( doc, details ) { // const MatchableDocument* doc, MatchDetails* details
  38. // File: expression_leaf.cpp lines: 37-48
  39. var tDoc = ElementPath.objAtPath( doc, this._path );
  40. if(typeof(tDoc) != 'object') {
  41. return this.matchesSingleElement(tDoc);
  42. }
  43. var docKeys = Object.keys(tDoc);
  44. for(var i = 0;i < docKeys.length; i++ ) {
  45. if(!this.matchesSingleElement( tDoc[docKeys[i]] ))
  46. continue;
  47. if( details && details.needRecord() && (tDoc instanceof Array) && i < docKeys.length-1 ) {
  48. details.setElemMatchKey( docKeys[i+1] );
  49. }
  50. return true;
  51. }
  52. return false;
  53. };
  54. /**
  55. *
  56. * This documentation was automatically generated. Please update when you touch this function.
  57. * @method path
  58. * @param
  59. *
  60. */
  61. proto.path = function path( /* */ ){
  62. // File: expression_leaf.h lines: 56-55
  63. return this._path;
  64. };