LeafMatchExpression.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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( /* const MatchableDocument* doc, MatchDetails* details */ ){
  38. // File: expression_leaf.cpp lines: 37-48
  39. var docKeys = Object.keys(doc);
  40. for(var i = 0;i < docKeys.length; i++ ) {
  41. if(!this.matchesSingleElement( doc[docKeys[i]] ))
  42. continue;
  43. if( details && details.needRecord() && (doc instanceof Array) && i < docKeys.length-1 ) {
  44. details.setElemMatchKey( docKeys[i+1] );
  45. }
  46. return true;
  47. }
  48. return false;
  49. };
  50. /**
  51. *
  52. * This documentation was automatically generated. Please update when you touch this function.
  53. * @method path
  54. * @param
  55. *
  56. */
  57. proto.path = function path( /* */ ){
  58. // File: expression_leaf.h lines: 56-55
  59. return this._path;
  60. };