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

Method decomposeKey

src/datasets.cpp:552–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

550}
551
552void IptcKey::decomposeKey() {
553 // Check that the key has the expected format with RE
554 auto posDot1 = key_.find('.');
555 auto posDot2 = key_.find('.', posDot1 + 1);
556
557 if (posDot1 == std::string::npos || posDot2 == std::string::npos) {
558 throw Error(ErrorCode::kerInvalidKey, key_);
559 }
560
561 // Get the family name, record name and dataSet name parts of the key
562 const std::string familyName = key_.substr(0, posDot1);
563 if (familyName != familyName_)
564 throw Error(ErrorCode::kerInvalidKey, key_);
565
566 std::string recordName = key_.substr(posDot1 + 1, posDot2 - posDot1 - 1);
567 std::string dataSetName = key_.substr(posDot2 + 1);
568
569 // Use the parts of the key to find dataSet and recordId
570 uint16_t recId = IptcDataSets::recordId(recordName);
571 uint16_t dataSet = IptcDataSets::dataSet(dataSetName, recId);
572
573 // Possibly translate hex name parts (0xabcd) to real names
574 recordName = IptcDataSets::recordName(recId);
575 dataSetName = IptcDataSets::dataSetName(dataSet, recId);
576
577 tag_ = dataSet;
578 record_ = recId;
579 key_ = familyName + "." + recordName + "." + dataSetName;
580}
581
582void IptcKey::makeKey() {
583 key_ = std::string(familyName_) + "." + IptcDataSets::recordName(record_) + "." +

Callers

nothing calls this directly

Calls 1

ErrorFunction · 0.85

Tested by

no test coverage detected