MCPcopy Create free account
hub / github.com/cinder/Cinder / getPath

Method getPath

src/cinder/JsonTree.cpp:482–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482string JsonTree::getPath( char separator ) const
483{
484 string result;
485
486 const JsonTree *node = this;
487 bool prevWasArrayIndex = false;
488 while( node != 0 ) {
489 bool isArrayIndex = false;
490 string nodeName = node->mKey;
491 if( nodeName.empty() && node->mParent ) { // should be an array index; find out which by searching our parent's children for ourselves
492 size_t index = 0;
493 for( ConstIter parentChildIt = node->mParent->mChildren.begin(); parentChildIt != node->mParent->mChildren.end(); ++parentChildIt, ++index ) {
494 if( &(*parentChildIt) == node ) {
495 isArrayIndex = true;
496 break;
497 }
498 }
499 if( isArrayIndex ) {
500 nodeName = '[' + toString( index ) + ']';
501 }
502 }
503 if( (! prevWasArrayIndex) && (! nodeName.empty()) && ( node != this ) ) {
504 result = nodeName + separator + result;
505 } else if( ! nodeName.empty() ) {
506 result = nodeName + result;
507 }
508 node = node->mParent;
509 prevWasArrayIndex = isArrayIndex;
510 }
511 return result;
512}
513
514/////////////////////////////////////////////////////////////////////////////////////////////////////////////
515

Callers 4

removeChildMethod · 0.45
replaceChildMethod · 0.45
ExcChildNotFoundMethod · 0.45
ExcNonConvertibleMethod · 0.45

Calls 4

toStringFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected