| 110 | // Add the immediate children and qualifiers to an IterNode. |
| 111 | |
| 112 | static void |
| 113 | AddNodeOffspring ( IterInfo & info, IterNode & iterParent, const XMP_Node * xmpParent ) |
| 114 | { |
| 115 | XMP_VarString currPath ( iterParent.fullPath ); |
| 116 | size_t leafOffset = iterParent.fullPath.size(); |
| 117 | |
| 118 | if ( (! xmpParent->qualifiers.empty()) && (! (info.options & kXMP_IterOmitQualifiers)) ) { |
| 119 | |
| 120 | #if TraceIterators |
| 121 | printf ( " Adding qualifiers of %s\n", currPath.c_str() ); |
| 122 | #endif |
| 123 | |
| 124 | currPath += "/?"; // All qualifiers are named and use paths like "Prop/?Qual". |
| 125 | leafOffset += 2; |
| 126 | |
| 127 | for ( size_t qualNum = 0, qualLim = xmpParent->qualifiers.size(); qualNum != qualLim; ++qualNum ) { |
| 128 | const XMP_Node * xmpQual = xmpParent->qualifiers[qualNum]; |
| 129 | currPath += xmpQual->name; |
| 130 | iterParent.qualifiers.push_back ( IterNode ( xmpQual->options, currPath, leafOffset ) ); |
| 131 | currPath.erase ( leafOffset ); |
| 132 | #if TraceIterators |
| 133 | printf ( " %s\n", xmpQual->name.c_str() ); |
| 134 | #endif |
| 135 | } |
| 136 | |
| 137 | leafOffset -= 2; |
| 138 | currPath.erase ( leafOffset ); |
| 139 | |
| 140 | } |
| 141 | |
| 142 | if ( ! xmpParent->children.empty() ) { |
| 143 | |
| 144 | #if TraceIterators |
| 145 | printf ( " Adding children of %s\n", currPath.c_str() ); |
| 146 | #endif |
| 147 | |
| 148 | XMP_Assert ( xmpParent->options & kXMP_PropCompositeMask ); |
| 149 | |
| 150 | if ( xmpParent->options & kXMP_PropValueIsStruct ) { |
| 151 | currPath += '/'; |
| 152 | leafOffset += 1; |
| 153 | } |
| 154 | |
| 155 | for ( size_t childNum = 0, childLim = xmpParent->children.size(); childNum != childLim; ++childNum ) { |
| 156 | const XMP_Node * xmpChild = xmpParent->children[childNum]; |
| 157 | if ( ! (xmpParent->options & kXMP_PropValueIsArray) ) { |
| 158 | currPath += xmpChild->name; |
| 159 | } else { |
| 160 | char buffer [32]; // AUDIT: Using sizeof(buffer) below for snprintf length is safe. |
| 161 | snprintf ( buffer, sizeof(buffer), "[%lu]", static_cast<unsigned long>(childNum+1) ); // ! XPath indices are one-based. |
| 162 | currPath += buffer; |
| 163 | } |
| 164 | iterParent.children.push_back ( IterNode ( xmpChild->options, currPath, leafOffset ) ); |
| 165 | currPath.erase ( leafOffset ); |
| 166 | #if TraceIterators |
| 167 | printf ( " %s\n", (iterParent.children.back().fullPath.c_str() + leafOffset) ); |
| 168 | #endif |
| 169 | } |
no test coverage detected