| 304 | // This isolates some messy code, allowing a clean loop in Next if kXMP_IterJustLeafNodes is set. |
| 305 | |
| 306 | static const XMP_Node * |
| 307 | GetNextXMPNode ( IterInfo & info ) |
| 308 | { |
| 309 | const XMP_Node * xmpNode = 0; |
| 310 | |
| 311 | // ---------------------------------------------------------------------------------------------- |
| 312 | // On entry currPos points to an iteration node whose state is either before-visit or visit-self. |
| 313 | // If it is before-visit then we will return that node's value part now. If it is visit-self it |
| 314 | // means the previous iteration returned the value portion of that node, so we can advance to the |
| 315 | // next node in the iteration tree. Then we find the corresponding XMP node, allowing for the XMP |
| 316 | // tree to have been modified since that part of the iteration tree was constructed. |
| 317 | |
| 318 | // ! NOTE: Supporting aliases throws in some nastiness with schemas. There might not be any XMP |
| 319 | // ! node for the schema, but we still have to visit it because of possible aliases. The static |
| 320 | // ! sDummySchema is returned if there is no real schema node. |
| 321 | |
| 322 | if ( info.currPos->visitStage != kIter_BeforeVisit ) AdvanceIterPos ( info ); |
| 323 | |
| 324 | bool isSchemaNode = false; |
| 325 | XMP_ExpandedXPath expPath; // Keep outside the loop to avoid constant construct/destruct. |
| 326 | |
| 327 | while ( info.currPos != info.endPos ) { |
| 328 | |
| 329 | isSchemaNode = XMP_NodeIsSchema ( info.currPos->options ); |
| 330 | if ( isSchemaNode ) { |
| 331 | SetCurrSchema ( info, info.currPos->fullPath ); |
| 332 | xmpNode = FindConstSchema ( &info.xmpObj->tree, info.currPos->fullPath.c_str() ); |
| 333 | if ( xmpNode == 0 ) xmpNode = sDummySchema; |
| 334 | } else { |
| 335 | ExpandXPath ( info.currSchema.c_str(), info.currPos->fullPath.c_str(), &expPath ); |
| 336 | xmpNode = FindConstNode ( &info.xmpObj->tree, expPath ); |
| 337 | } |
| 338 | if ( xmpNode != 0 ) break; // Exit the loop, we found a live XMP node. |
| 339 | |
| 340 | info.currPos->visitStage = kIter_VisitChildren; // Make AdvanceIterPos move to the next sibling. |
| 341 | info.currPos->children.clear(); |
| 342 | info.currPos->qualifiers.clear(); |
| 343 | AdvanceIterPos ( info ); |
| 344 | |
| 345 | } |
| 346 | |
| 347 | if ( info.currPos == info.endPos ) return 0; |
| 348 | |
| 349 | // ------------------------------------------------------------------------------------------- |
| 350 | // Now we've got the iteration node and corresponding XMP node. Add the iteration children for |
| 351 | // structs and arrays. The children of schema were added when the iterator was constructed. |
| 352 | |
| 353 | XMP_Assert ( info.currPos->visitStage == kIter_BeforeVisit ); |
| 354 | |
| 355 | if ( info.currPos->visitStage == kIter_BeforeVisit ) { |
| 356 | if ( (! isSchemaNode) && (! (info.options & kXMP_IterJustChildren)) ) { |
| 357 | AddNodeOffspring ( info, *info.currPos, xmpNode ); |
| 358 | } |
| 359 | info.currPos->visitStage = kIter_VisitSelf; |
| 360 | } |
| 361 | |
| 362 | return xmpNode; |
| 363 |
no test coverage detected