ElementPath.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. "use strict";
  2. FieldRef = require('FieldRef');
  3. BSONElement = require('BSONElement');
  4. // Autogenerated by cport.py on 2013-09-17 14:37
  5. var ElementPath = module.exports = function (){
  6. }, klass = ElementPath, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  7. // File: path.h lines: 41-41
  8. // FieldRef _fieldRef;
  9. proto._fieldRef = undefined;
  10. // File: path.h lines: 42-42
  11. // bool _shouldTraverseLeafArray;
  12. proto._shouldTraverseLeafArray = undefined;
  13. // File: path.h lines: 41-41
  14. // FieldRef _fieldRef;
  15. proto._fieldRef = undefined;
  16. // File: path.h lines: 42-42
  17. // bool _shouldTraverseLeafArray;
  18. proto._shouldTraverseLeafArray = undefined;
  19. // File: path_internal.cpp
  20. /**
  21. * getFieldDottedOrArray
  22. *
  23. * @method getFieldDottedArray
  24. * @param doc
  25. * @param path
  26. * @param idxPathObj This is an object with a pathID element. This allows for pass by ref in calling function.
  27. * */
  28. klass.getFieldDottedOrArray = function getFieldDottedOrArray(doc, path, idxPathObj){
  29. // File path_internal.cpp lines 31-72
  30. if (path.numParts() === 0 ) { return doc.getField(""); }
  31. var res,curr = doc,
  32. stop = false,
  33. partNum = 0;
  34. while (partNum < path.numParts() && !stop) {
  35. res = curr.getField( path.getPart( partNum) );
  36. switch (res.type() ) {
  37. case 'EOO':
  38. stop = true;
  39. break;
  40. case 'Object':
  41. curr = res.Obj();
  42. partNum++;
  43. break;
  44. case 'Array':
  45. stop = true;
  46. break;
  47. default:
  48. if (partNum + 1 < path.numParts() ) {
  49. res = new BSONELEMENT();
  50. }
  51. stope = true;
  52. break;
  53. }
  54. }
  55. idxPath.pathID = partNum;
  56. return res;
  57. };
  58. /**
  59. * isAllDigits does what it says on the tin.
  60. *
  61. * @method isAllDigits
  62. * @param str
  63. */
  64. klass.isAllDigits = function isAllDigits ( str ){
  65. // File path_internal.cpp lines 23-29
  66. digitCheck = /\D/g;
  67. if (digitCheck.exec(str) === null){ return true; }
  68. return false;
  69. };
  70. /**
  71. *
  72. * This documentation was automatically generated. Please update when you touch this function.
  73. * @method fieldRef
  74. * @param
  75. *
  76. */
  77. proto.fieldRef = function fieldRef( /* */ ){
  78. // File: path.h lines: 37-36
  79. return this._fieldRef;
  80. };
  81. /**
  82. *
  83. * This documentation was automatically generated. Please update when you touch this function.
  84. * @method init
  85. * @param
  86. *
  87. */
  88. proto.init = function init( path ){ // const StringData& path
  89. // File: path.cpp lines: 26-29
  90. this._shouldTraverseLeafArray = true;
  91. this._fieldRef.parse( path );
  92. return Status.OK;
  93. };
  94. /**
  95. *
  96. * This documentation was automatically generated. Please update when you touch this function.
  97. * @method setTraverseLeafArray
  98. * @param
  99. *
  100. */
  101. proto.setTraverseLeafArray = function setTraverseLeafArray( b ){ // bool b
  102. // File: path.h lines: 35-34
  103. this._shouldTraverseLeafArray = b;
  104. };
  105. /**
  106. *
  107. * This documentation was automatically generated. Please update when you touch this function.
  108. * @method shouldTraverseLeafArray
  109. * @param
  110. *
  111. */
  112. proto.shouldTraverseLeafArray = function shouldTraverseLeafArray( /* */ ){
  113. // File: path.h lines: 38-37
  114. return this._shouldTraverseLeafArray;
  115. };