class static */
| 1194 | // ---------------- |
| 1195 | |
| 1196 | /* class static */ void |
| 1197 | XMPUtils::DuplicateSubtree ( const XMPMeta & source, |
| 1198 | XMPMeta * dest, |
| 1199 | XMP_StringPtr sourceNS, |
| 1200 | XMP_StringPtr sourceRoot, |
| 1201 | XMP_StringPtr destNS, |
| 1202 | XMP_StringPtr destRoot, |
| 1203 | XMP_OptionBits options ) |
| 1204 | { |
| 1205 | UNUSED(options); |
| 1206 | |
| 1207 | bool fullSourceTree = false; |
| 1208 | bool fullDestTree = false; |
| 1209 | |
| 1210 | XMP_ExpandedXPath sourcePath, destPath; |
| 1211 | |
| 1212 | const XMP_Node * sourceNode = 0; |
| 1213 | XMP_Node * destNode = 0; |
| 1214 | |
| 1215 | XMP_Assert ( (sourceNS != 0) && (*sourceNS != 0) ); |
| 1216 | XMP_Assert ( (sourceRoot != 0) && (*sourceRoot != 0) ); |
| 1217 | XMP_Assert ( (dest != 0) && (destNS != 0) && (destRoot != 0) ); |
| 1218 | |
| 1219 | if ( *destNS == 0 ) destNS = sourceNS; |
| 1220 | if ( *destRoot == 0 ) destRoot = sourceRoot; |
| 1221 | |
| 1222 | if ( XMP_LitMatch ( sourceNS, "*" ) ) fullSourceTree = true; |
| 1223 | if ( XMP_LitMatch ( destNS, "*" ) ) fullDestTree = true; |
| 1224 | |
| 1225 | if ( (&source == dest) && (fullSourceTree | fullDestTree) ) { |
| 1226 | XMP_Throw ( "Can't duplicate tree onto itself", kXMPErr_BadParam ); |
| 1227 | } |
| 1228 | |
| 1229 | if ( fullSourceTree & fullDestTree ) XMP_Throw ( "Use Clone for full tree to full tree", kXMPErr_BadParam ); |
| 1230 | |
| 1231 | if ( fullSourceTree ) { |
| 1232 | |
| 1233 | // The destination must be an existing empty struct, copy all of the source top level as fields. |
| 1234 | |
| 1235 | ExpandXPath ( destNS, destRoot, &destPath ); |
| 1236 | destNode = FindNode ( &dest->tree, destPath, kXMP_ExistingOnly ); |
| 1237 | |
| 1238 | if ( (destNode == 0) || (! XMP_PropIsStruct ( destNode->options )) ) { |
| 1239 | XMP_Throw ( "Destination must be an existing struct", kXMPErr_BadXPath ); |
| 1240 | } |
| 1241 | |
| 1242 | if ( ! destNode->children.empty() ) { |
| 1243 | if ( options & kXMP_DeleteExisting ) { |
| 1244 | destNode->RemoveChildren(); |
| 1245 | } else { |
| 1246 | XMP_Throw ( "Destination must be an empty struct", kXMPErr_BadXPath ); |
| 1247 | } |
| 1248 | } |
| 1249 | |
| 1250 | for ( size_t schemaNum = 0, schemaLim = source.tree.children.size(); schemaNum < schemaLim; ++schemaNum ) { |
| 1251 | |
| 1252 | const XMP_Node * currSchema = source.tree.children[schemaNum]; |
| 1253 |
nothing calls this directly
no test coverage detected