MatchExpression.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. "use strict";
  2. // Autogenerated by cport.py on 2013-09-17 14:37
  3. var MatchExpression = module.exports = function MatchExpression( type ){
  4. this._matchType = type;
  5. }, klass = MatchExpression, base = Object, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  6. // DEPENDENCIES
  7. var errors = require("../../Errors.js"),
  8. ErrorCodes = errors.ErrorCodes;
  9. // File: expression.h lines: 172-172
  10. proto._matchType = undefined;
  11. // File: expression.h lines: 173-173
  12. proto._tagData = undefined;
  13. /**
  14. *
  15. * Writes a debug string for this object
  16. * @method debugString
  17. * @param level
  18. *
  19. */
  20. proto._debugAddSpace = function _debugAddSpace(level){
  21. // File: expression.cpp lines: 37-39
  22. return new Array( level + 1).join(" ");
  23. };
  24. /**
  25. *
  26. * Get our child elements
  27. * @method getChild
  28. *
  29. */
  30. proto.getChild = function getChild() {
  31. // File: expression.h lines: 78-77
  32. throw new Error('Virtual function called.');
  33. };
  34. /**
  35. *
  36. * Return the _tagData property
  37. * @method getTag
  38. *
  39. */
  40. proto.getTag = function getTag(){
  41. // File: expression.h lines: 159-158
  42. return this._tagData;
  43. };
  44. /**
  45. *
  46. * Return if our _matchType needs an array
  47. * @method isArray
  48. *
  49. */
  50. proto.isArray = function isArray(){
  51. // File: expression.h lines: 111-113
  52. switch (this._matchType){
  53. case 'SIZE':
  54. case 'ALL':
  55. case 'ELEM_MATCH_VALUE':
  56. case 'ELEM_MATCH_OBJECT':
  57. return true;
  58. default:
  59. return false;
  60. }
  61. return false;
  62. };
  63. /**
  64. *
  65. * Check if we do not need an array, and we are not a logical element (leaves are very emotional)
  66. * @method isLeaf
  67. *
  68. */
  69. proto.isLeaf = function isLeaf(){
  70. // File: expression.h lines: 124-125
  71. return !this.isArray() && !this.isLogical();
  72. };
  73. /**
  74. *
  75. * Check if we are a vulcan
  76. * @method isLogical
  77. *
  78. */
  79. proto.isLogical = function isLogical(){
  80. // File: expression.h lines: 100-101
  81. switch( this._matchType ){
  82. case 'AND':
  83. case 'OR':
  84. case 'NOT':
  85. case 'NOR':
  86. return true;
  87. default:
  88. return false;
  89. }
  90. return false;
  91. };
  92. /**
  93. *
  94. * Return the _matchType property
  95. * @method matchType
  96. *
  97. */
  98. proto.matchType = function matchType(){
  99. // File: expression.h lines: 67-66
  100. return this._matchType;
  101. };
  102. /**
  103. *
  104. * Wrapper around matches function
  105. * @method matchesBSON
  106. * @param
  107. *
  108. */
  109. proto.matchesBSON = function matchesBSON(doc, details){
  110. // File: expression.cpp lines: 42-44
  111. return this.matches(doc, details);
  112. };
  113. /**
  114. *
  115. * Return the number of children we have
  116. * @method numChildren
  117. *
  118. */
  119. proto.numChildren = function numChildren( ){
  120. // File: expression.h lines: 73-72
  121. return 0;
  122. };
  123. /**
  124. *
  125. * Return our internal path
  126. * @method path
  127. *
  128. */
  129. proto.path = function path( ){
  130. // File: expression.h lines: 83-82
  131. return '';
  132. };
  133. /**
  134. *
  135. * Set the _tagData property
  136. * @method setTag
  137. * @param data
  138. *
  139. */
  140. proto.setTag = function setTag(data){
  141. // File: expression.h lines: 158-157
  142. this._tagData = data;
  143. };
  144. /**
  145. *
  146. * Call the debugString method
  147. * @method toString
  148. *
  149. */
  150. proto.toString = function toString(){
  151. // File: expression.cpp lines: 31-34
  152. return this.debugString( 0 );
  153. };