"use strict"; var FieldRef = require('./FieldRef'); // Autogenerated by cport.py on 2013-09-17 14:37 var ElementPath = module.exports = function ElementPath(){ this._fieldRef = new FieldRef(); this.shouldTraverseLeafArray = false; }, klass = ElementPath, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}}); // File: path.h lines: 41-41 // FieldRef _fieldRef; proto._fieldRef = undefined; // File: path.h lines: 42-42 // bool _shouldTraverseLeafArray; proto._shouldTraverseLeafArray = undefined; /** * getFieldDottedOrArray * * @method getFieldDottedArray * @param doc * @param path * @param idxPathObj This is an object with a pathID element. This allows for pass by ref in calling function. * */ klass.getFieldDottedOrArray = function getFieldDottedOrArray(doc, path, idxPathObj){ // File path_internal.cpp lines 31-72 if (path.numParts() === 0 ) { return doc.getField(""); } var res,curr = doc, stop = false, partNum = 0; while (partNum < path.numParts() && !stop) { res = curr.getField( path.getPart( partNum) ); if(res instanceof EOO){ stop = true; } else if (res instanceof Object) { curr = res; partNum++; } else if (res instanceof Array) { stop = true; } else { if (partNum + 1 < path.numParts() ) { res = {}; } stope = true; } } idxPath.pathID = partNum; return res; }; /** * isAllDigits does what it says on the tin. * * @method isAllDigits * @param str */ klass.isAllDigits = function isAllDigits ( str ){ // File path_internal.cpp lines 23-29 digitCheck = /\D/g; if (digitCheck.exec(str) === null){ return true; } return false; }; /** * * This documentation was automatically generated. Please update when you touch this function. * @method fieldRef * @param * */ proto.fieldRef = function fieldRef( /* */ ){ // File: path.h lines: 37-36 return this._fieldRef; }; /** * * This documentation was automatically generated. Please update when you touch this function. * @method init * @param * */ proto.init = function init( path ){ // const StringData& path // File: path.cpp lines: 26-29 this._shouldTraverseLeafArray = true; this._fieldRef.parse( path ); return {'code':'OK'}; }; /** * * This documentation was automatically generated. Please update when you touch this function. * @method setTraverseLeafArray * @param * */ proto.setTraverseLeafArray = function setTraverseLeafArray( b ){ // bool b // File: path.h lines: 35-34 this._shouldTraverseLeafArray = b; }; /** * * This documentation was automatically generated. Please update when you touch this function. * @method shouldTraverseLeafArray * @param * */ proto.shouldTraverseLeafArray = function shouldTraverseLeafArray( /* */ ){ // File: path.h lines: 38-37 return this._shouldTraverseLeafArray; }; klass.objAtPath = function objAtPath( doc,path) { debugger; if(path.length == 0) { debugger; return doc; } if (path.length > 0 && Object.keys(doc).length == 0){ debugger; return {}; } if (doc === null || doc === undefined) { debugger; return doc; } var tpath = path.split('.'); debugger; return klass.objAtPath(doc[tpath[0]],tpath.slice(1).join('.')); };