ElementPath.js 3.0 KB

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