MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / ResolveAlias

Method ResolveAlias

xmpsdk/src/XMPMeta.cpp:1272–1326  ·  view source on GitHub ↗

class-static */

Source from the content-addressed store, hash-verified

1270// ------------
1271
1272/* class-static */ bool
1273XMPMeta::ResolveAlias ( XMP_StringPtr aliasNS,
1274 XMP_StringPtr aliasProp,
1275 XMP_StringPtr * actualNS,
1276 XMP_StringLen * nsSize,
1277 XMP_StringPtr * actualProp,
1278 XMP_StringLen * propSize,
1279 XMP_OptionBits * arrayForm )
1280{
1281 XMP_Assert ( (aliasNS != 0) && (aliasProp != 0) ); // Enforced by wrapper.
1282 XMP_Assert ( (actualNS != 0) && (nsSize != 0) && (actualProp != 0) && (propSize != 0) && (arrayForm != 0) ); // Enforced by wrapper.
1283
1284 // Expand the input path and look up the first component in the alias table. Return if not an alias.
1285
1286 XMP_ExpandedXPath fullPath, minPath;
1287 ExpandXPath ( aliasNS, aliasProp, &fullPath );
1288 XMP_Assert ( fullPath.size() >= 2 );
1289
1290 minPath.push_back ( fullPath[kSchemaStep] );
1291 minPath.push_back ( fullPath[kRootPropStep] );
1292 XMP_AliasMapPos mapPos = sRegisteredAliasMap->find ( minPath[kRootPropStep].step );
1293 if ( mapPos == sRegisteredAliasMap->end() ) return false;
1294
1295 // Replace the alias portion of the full expanded path. Compose the output path string.
1296
1297 const XMP_ExpandedXPath & actualPath = mapPos->second;
1298
1299 fullPath[kSchemaStep] = actualPath[kSchemaStep];
1300 fullPath[kRootPropStep] = actualPath[kRootPropStep];
1301 if ( actualPath.size() > 2 ) { // This is an alias to an array item.
1302 XMP_ExpandedXPathPos insertPos = fullPath.begin() + kAliasIndexStep;
1303 fullPath.insert ( insertPos, actualPath[kAliasIndexStep] );
1304 }
1305
1306 *sOutputNS = fullPath[kSchemaStep].step;
1307 *actualNS = sOutputNS->c_str();
1308 *nsSize = sOutputNS->size();
1309
1310 ComposeXPath ( fullPath, sOutputStr );
1311 *actualProp = sOutputStr->c_str();
1312 *propSize = sOutputStr->size();
1313
1314 *arrayForm = actualPath[kRootPropStep].options & kXMP_PropArrayFormMask;
1315
1316 #if XMP_DebugBuild // Test that the output string is valid and unchanged by round trip expand/compose.
1317 XMP_ExpandedXPath rtPath;
1318 ExpandXPath ( *actualNS, *actualProp, &rtPath );
1319 std::string rtString;
1320 ComposeXPath ( rtPath, &rtString );
1321 XMP_Assert ( rtString == *sOutputStr );
1322 #endif
1323
1324 return true;
1325
1326} // ResolveAlias
1327
1328
1329// -------------------------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 6

ExpandXPathFunction · 0.85
ComposeXPathFunction · 0.85
c_strMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected