| 550 | } |
| 551 | |
| 552 | void 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 | |
| 582 | void IptcKey::makeKey() { |
| 583 | key_ = std::string(familyName_) + "." + IptcDataSets::recordName(record_) + "." + |