diff --git a/include/exiv2/datasets.hpp b/include/exiv2/datasets.hpp index ed9ff58e..48f50596 100644 --- a/include/exiv2/datasets.hpp +++ b/include/exiv2/datasets.hpp @@ -230,13 +230,6 @@ namespace Exiv2 { @return the description of the Record */ static const char* recordDesc(uint16_t recordId); - /*! - @brief Return the Id number of a record - @param recordName Name of a record type - @return the Id number of a Record - @throw Error if the record is not known; - */ - static uint16_t recordId(const std::string& recordName); static void dataSetList(std::ostream& os); @@ -245,7 +238,6 @@ namespace Exiv2 { static int dataSetIdx(const std::string& dataSetName, uint16_t recordId); static const DataSet* const records_[]; - static const RecordInfo recordInfo_[]; }; // class IptcDataSets diff --git a/src/datasets.cpp b/src/datasets.cpp index 5e750d46..53b6764c 100644 --- a/src/datasets.cpp +++ b/src/datasets.cpp @@ -38,8 +38,9 @@ // ***************************************************************************** // class member definitions + namespace Exiv2 { - constexpr RecordInfo IptcDataSets::recordInfo_[] = { + constexpr RecordInfo recordInfo_[] = { {IptcDataSets::invalidRecord, "(invalid)", N_("(invalid)")}, {IptcDataSets::envelope, "Envelope", N_("IIM envelope record")}, {IptcDataSets::application2, "Application2", N_("IIM application record 2")}, @@ -397,6 +398,22 @@ namespace Exiv2 { false, false, 0, 0, Exiv2::unsignedShort, IptcDataSets::application2, ""}, }; + uint16_t recordId(const std::string& recordName) + { + uint16_t i; + for (i = IptcDataSets::application2; i > 0; --i) { + if (recordInfo_[i].name_ == recordName) + break; + } + if (i == 0) { + if (!isHex(recordName, 4, "0x")) + throw Error(kerInvalidRecord, recordName); + std::istringstream is(recordName); + is >> std::hex >> i; + } + return i; + } + constexpr DataSet unknownDataSet{ 0xffff, "Unknown dataset", N_("Unknown dataset"), N_("Unknown dataset"), false, true, 0, 0xffffffff, Exiv2::string, IptcDataSets::invalidRecord, N_("Unknown dataset"), @@ -527,21 +544,6 @@ namespace Exiv2 { return recordInfo_[recordId].desc_; } - uint16_t IptcDataSets::recordId(const std::string& recordName) - { - uint16_t i; - for (i = application2; i > 0; --i) { - if (recordInfo_[i].name_ == recordName) - break; - } - if (i == 0) { - if (!isHex(recordName, 4, "0x")) - throw Error(kerInvalidRecord, recordName); - std::istringstream is(recordName); - is >> std::hex >> i; - } - return i; - } void IptcDataSets::dataSetList(std::ostream& os) { @@ -633,23 +635,27 @@ namespace Exiv2 { std::string::size_type pos1 = key_.find('.'); if (pos1 == std::string::npos) throw Error(kerInvalidKey, key_); + std::string familyName = key_.substr(0, pos1); if (0 != strcmp(familyName.c_str(), familyName_)) { throw Error(kerInvalidKey, key_); } + std::string::size_type pos0 = pos1 + 1; pos1 = key_.find('.', pos0); if (pos1 == std::string::npos) throw Error(kerInvalidKey, key_); + std::string recordName = key_.substr(pos0, pos1 - pos0); if (recordName.empty()) throw Error(kerInvalidKey, key_); + std::string dataSetName = key_.substr(pos1 + 1); if (dataSetName.empty()) throw Error(kerInvalidKey, key_); // Use the parts of the key to find dataSet and recordId - uint16_t recId = IptcDataSets::recordId(recordName); + uint16_t recId = recordId(recordName); uint16_t dataSet = IptcDataSets::dataSet(dataSetName, recId); // Possibly translate hex name parts (0xabcd) to real names