| 547 | // sorts the elements by value. If the node is an AltText array it sorts the elements by language. |
| 548 | |
| 549 | static void |
| 550 | SortWithinOffspring ( XMP_NodeOffspring & nodeVec ) |
| 551 | { |
| 552 | |
| 553 | for ( size_t i = 0, limit = nodeVec.size(); i < limit; ++i ) { |
| 554 | |
| 555 | XMP_Node * currPos = nodeVec[i]; |
| 556 | |
| 557 | if ( ! currPos->qualifiers.empty() ) { |
| 558 | sort ( currPos->qualifiers.begin(), currPos->qualifiers.end(), CompareNodeNames ); |
| 559 | SortWithinOffspring ( currPos->qualifiers ); |
| 560 | } |
| 561 | |
| 562 | if ( ! currPos->children.empty() ) { |
| 563 | |
| 564 | if ( XMP_PropIsStruct ( currPos->options ) || XMP_NodeIsSchema ( currPos->options ) ) { |
| 565 | sort ( currPos->children.begin(), currPos->children.end(), CompareNodeNames ); |
| 566 | } else if ( XMP_PropIsArray ( currPos->options ) ) { |
| 567 | if ( XMP_ArrayIsUnordered ( currPos->options ) ) { |
| 568 | stable_sort ( currPos->children.begin(), currPos->children.end(), CompareNodeValues ); |
| 569 | } else if ( XMP_ArrayIsAltText ( currPos->options ) ) { |
| 570 | sort ( currPos->children.begin(), currPos->children.end(), CompareNodeLangs ); |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | SortWithinOffspring ( currPos->children ); |
| 575 | |
| 576 | } |
| 577 | |
| 578 | } |
| 579 | |
| 580 | } // SortWithinOffspring |
| 581 | |
| 582 | |
| 583 | // ================================================================================================= |