[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:37:03 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=54a42fc
The following commit has been merged in the master branch:
commit 54a42fc1f7944a1af2c4ac12579a508bd64f4a0f
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Sun Mar 13 12:52:56 2005 +0000
Generalized and cleaned-up makernote handling
---
src/canonmn.cpp | 42 ++---
src/canonmn.hpp | 16 +-
src/exif.cpp | 24 +--
src/fujimn.cpp | 66 +++----
src/fujimn.hpp | 16 +-
src/ifd.cpp | 6 +-
src/ifd.hpp | 7 -
src/makernote.cpp | 108 ++----------
src/makernote.hpp | 106 +++--------
src/nikonmn.cpp | 242 +++++++++----------------
src/nikonmn.hpp | 56 +++---
src/sigmamn.cpp | 78 +++-----
src/sigmamn.hpp | 16 +-
src/taglist.cpp | 8 +-
src/tags.cpp | 282 +++++++++++++++++++----------
src/tags.hpp | 39 +++-
src/types.hpp | 7 +-
test/data/exifdata-test.out | 421 ++++++++++++++++++++++++++++++++++++++++++++
test/exifdata-test.sh | 2 +
19 files changed, 884 insertions(+), 658 deletions(-)
diff --git a/src/canonmn.cpp b/src/canonmn.cpp
index 8874e90..46cd2cf 100644
--- a/src/canonmn.cpp
+++ b/src/canonmn.cpp
@@ -54,26 +54,26 @@ namespace Exiv2 {
const CanonMakerNote::RegisterMakerNote CanonMakerNote::register_;
// Canon MakerNote Tag Info
- static const MakerNote::MnTagInfo canonMnTagInfo[] = {
- MakerNote::MnTagInfo(0x0001, "CameraSettings1", "Various camera settings (1)"),
- MakerNote::MnTagInfo(0x0004, "CameraSettings2", "Various camera settings (2)"),
- MakerNote::MnTagInfo(0x0006, "ImageType", "Image type"),
- MakerNote::MnTagInfo(0x0007, "FirmwareVersion", "Firmware version"),
- MakerNote::MnTagInfo(0x0008, "ImageNumber", "Image number"),
- MakerNote::MnTagInfo(0x0009, "OwnerName", "Owner Name"),
- MakerNote::MnTagInfo(0x000c, "SerialNumber", "Camera serial number"),
- MakerNote::MnTagInfo(0x000f, "EosD30Functions", "EOS D30 Custom Functions"),
+ const TagInfo CanonMakerNote::tagInfo_[] = {
+ TagInfo(0x0001, "CameraSettings1", "Various camera settings (1)", canonIfdId, makerTags, print0x0001),
+ TagInfo(0x0004, "CameraSettings2", "Various camera settings (2)", canonIfdId, makerTags, print0x0004),
+ TagInfo(0x0006, "ImageType", "Image type", canonIfdId, makerTags, printValue),
+ TagInfo(0x0007, "FirmwareVersion", "Firmware version", canonIfdId, makerTags, printValue),
+ TagInfo(0x0008, "ImageNumber", "Image number", canonIfdId, makerTags, print0x0008),
+ TagInfo(0x0009, "OwnerName", "Owner Name", canonIfdId, makerTags, printValue),
+ TagInfo(0x000c, "SerialNumber", "Camera serial number", canonIfdId, makerTags, print0x000c),
+ TagInfo(0x000f, "EosD30Functions", "EOS D30 Custom Functions", canonIfdId, makerTags, print0x000f),
// End of list marker
- MakerNote::MnTagInfo(0xffff, "(UnknownCanonMakerNoteTag)", "Unknown CanonMakerNote tag")
+ TagInfo(0xffff, "(UnknownCanonMakerNoteTag)", "Unknown CanonMakerNote tag", canonIfdId, makerTags, printValue)
};
CanonMakerNote::CanonMakerNote(bool alloc)
- : IfdMakerNote(canonMnTagInfo, alloc), ifdItem_("Canon")
+ : IfdMakerNote(canonIfdId, alloc)
{
}
CanonMakerNote::CanonMakerNote(const CanonMakerNote& rhs)
- : IfdMakerNote(rhs), ifdItem_(rhs.ifdItem_)
+ : IfdMakerNote(rhs)
{
}
@@ -97,24 +97,6 @@ namespace Exiv2 {
return new CanonMakerNote(*this);
}
- std::ostream& CanonMakerNote::printTag(std::ostream& os,
- uint16_t tag,
- const Value& value) const
- {
- switch (tag) {
- case 0x0001: print0x0001(os, value); break;
- case 0x0004: print0x0004(os, value); break;
- case 0x0008: print0x0008(os, value); break;
- case 0x000c: print0x000c(os, value); break;
- case 0x000f: print0x000f(os, value); break;
- default:
- // All other tags (known or unknown) go here
- os << value;
- break;
- }
- return os;
- }
-
std::ostream& CanonMakerNote::print0x0001(std::ostream& os,
const Value& value)
{
diff --git a/src/canonmn.hpp b/src/canonmn.hpp
index 447731a..f4de1ad 100644
--- a/src/canonmn.hpp
+++ b/src/canonmn.hpp
@@ -36,6 +36,7 @@
// included header files
#include "types.hpp"
#include "makernote.hpp"
+#include "tags.hpp"
// + standard includes
#include <string>
@@ -107,11 +108,6 @@ namespace Exiv2 {
//@{
AutoPtr create(bool alloc =true) const;
AutoPtr clone() const;
- //! Return the name of the makernote item ("Canon")
- std::string ifdItem() const { return ifdItem_; }
- std::ostream& printTag(std::ostream& os,
- uint16_t tag,
- const Value& value) const;
//@}
//! @name Print functions for Canon %MakerNote tags
@@ -184,6 +180,9 @@ namespace Exiv2 {
//! Internal virtual copy constructor.
CanonMakerNote* clone_() const;
+ //! Tag information
+ static const TagInfo tagInfo_[];
+
//! Structure used to auto-register the MakerNote.
struct RegisterMakerNote {
//! Default constructor
@@ -191,7 +190,9 @@ namespace Exiv2 {
{
MakerNoteFactory& mnf = MakerNoteFactory::instance();
mnf.registerMakerNote("Canon", "*", createCanonMakerNote);
- mnf.registerMakerNote(MakerNote::AutoPtr(new CanonMakerNote));
+ mnf.registerMakerNote(canonIfdId,
+ MakerNote::AutoPtr(new CanonMakerNote));
+ ExifTags::registerMakerTagInfo(canonIfdId, tagInfo_);
}
};
/*!
@@ -208,9 +209,6 @@ namespace Exiv2 {
*/
static const RegisterMakerNote register_;
- //! The item name (second part of the key) used for makernote tags
- std::string ifdItem_;
-
}; // class CanonMakerNote
} // namespace Exiv2
diff --git a/src/exif.cpp b/src/exif.cpp
index 80d0f69..04a0107 100644
--- a/src/exif.cpp
+++ b/src/exif.cpp
@@ -475,10 +475,8 @@ namespace Exiv2 {
pExifIfd_->offset() + pos->offset());
if (rc) {
// Todo: How to handle debug output like this
- std::cerr << "Warning: Failed to read "
- << makerNote_->ifdItem()
- << " Makernote, rc = " << rc << "
";
-
+ std::cerr << "Warning: Failed to read Makernote, rc = "
+ << rc << "
";
makerNote_.reset();
}
}
@@ -710,14 +708,10 @@ namespace Exiv2 {
void ExifData::add(const Exifdatum& exifdatum)
{
- if (exifdatum.ifdId() == makerIfdId) {
- if ( makerNote_.get() != 0
- && makerNote_->ifdItem() != exifdatum.groupName()) {
- throw Error("Inconsistent MakerNote");
- }
+ if (ExifTags::isMakerIfd(exifdatum.ifdId())) {
if (makerNote_.get() == 0) {
MakerNoteFactory& mnf = MakerNoteFactory::instance();
- makerNote_ = mnf.create(exifdatum.groupName());
+ makerNote_ = mnf.create(exifdatum.ifdId());
}
}
// allow duplicates
@@ -1033,7 +1027,7 @@ namespace Exiv2 {
Entries::const_iterator entry;
std::pair<bool, Entries::const_iterator> rc(false, entry);
- if (ifdId == makerIfdId && makerNote_.get() != 0) {
+ if (ExifTags::isMakerIfd(ifdId) && makerNote_.get() != 0) {
entry = makerNote_->findIdx(idx);
if (entry != makerNote_->end()) {
rc.first = true;
@@ -1042,7 +1036,7 @@ namespace Exiv2 {
return rc;
}
const Ifd* ifd = getIfd(ifdId);
- if (ifd && ifdId != makerIfdId) {
+ if (ifd && isExifIfd(ifdId)) {
entry = ifd->findIdx(idx);
if (entry != ifd->end()) {
rc.first = true;
@@ -1166,8 +1160,7 @@ namespace Exiv2 {
ByteOrder byteOrder)
{
for (ExifMetadata::const_iterator i = begin; i != end; ++i) {
- // add only metadata with IFD id 'makerIfd'
- if (i->ifdId() == makerIfdId) {
+ if (ExifTags::isMakerIfd(i->ifdId())) {
addToMakerNote(makerNote, *i, byteOrder);
}
}
@@ -1196,8 +1189,7 @@ namespace Exiv2 {
std::ostream& operator<<(std::ostream& os, const Exifdatum& md)
{
- assert(md.key_.get() != 0);
- return md.key_->printTag(os, md.value());
+ return ExifTags::printTag(os, md.tag(), md.ifdId(), md.value());
}
} // namespace Exiv2
diff --git a/src/fujimn.cpp b/src/fujimn.cpp
index a8429d5..3364b19 100644
--- a/src/fujimn.cpp
+++ b/src/fujimn.cpp
@@ -56,29 +56,29 @@ namespace Exiv2 {
const FujiMakerNote::RegisterMakerNote FujiMakerNote::register_;
// Fujifilm MakerNote Tag Info
- static const MakerNote::MnTagInfo fujiMnTagInfo[] = {
- MakerNote::MnTagInfo(0x0000, "Version", "Fujifilm Makernote version"),
- MakerNote::MnTagInfo(0x1000, "Quality", "Image quality setting"),
- MakerNote::MnTagInfo(0x1001, "Sharpness", "Sharpness setting"),
- MakerNote::MnTagInfo(0x1002, "WhiteBalance", "White balance setting"),
- MakerNote::MnTagInfo(0x1003, "Color", "Chroma saturation setting"),
- MakerNote::MnTagInfo(0x1004, "Tone", "Contrast setting"),
- MakerNote::MnTagInfo(0x1010, "FlashMode", "Flash firing mode setting"),
- MakerNote::MnTagInfo(0x1011, "FlashStrength", "Flash firing strength compensation setting"),
- MakerNote::MnTagInfo(0x1020, "Macro", "Macro mode setting"),
- MakerNote::MnTagInfo(0x1021, "FocusMode", "Focusing mode setting"),
- MakerNote::MnTagInfo(0x1030, "SlowSync", "Slow synchro mode setting"),
- MakerNote::MnTagInfo(0x1031, "PictureMode", "Picture mode setting"),
- MakerNote::MnTagInfo(0x1100, "Continuous", "Continuous shooting or auto bracketing setting"),
- MakerNote::MnTagInfo(0x1300, "BlurWarning", "Blur warning status"),
- MakerNote::MnTagInfo(0x1301, "FocusWarning", "Auto Focus warning status"),
- MakerNote::MnTagInfo(0x1302, "AeWarning", "Auto Exposure warning status"),
+ const TagInfo FujiMakerNote::tagInfo_[] = {
+ TagInfo(0x0000, "Version", "Fujifilm Makernote version", fujiIfdId, makerTags, printValue),
+ TagInfo(0x1000, "Quality", "Image quality setting", fujiIfdId, makerTags, printValue),
+ TagInfo(0x1001, "Sharpness", "Sharpness setting", fujiIfdId, makerTags, print0x1001),
+ TagInfo(0x1002, "WhiteBalance", "White balance setting", fujiIfdId, makerTags, print0x1002),
+ TagInfo(0x1003, "Color", "Chroma saturation setting", fujiIfdId, makerTags, print0x1003),
+ TagInfo(0x1004, "Tone", "Contrast setting", fujiIfdId, makerTags, print0x1004),
+ TagInfo(0x1010, "FlashMode", "Flash firing mode setting", fujiIfdId, makerTags, print0x1010),
+ TagInfo(0x1011, "FlashStrength", "Flash firing strength compensation setting", fujiIfdId, makerTags, printValue),
+ TagInfo(0x1020, "Macro", "Macro mode setting", fujiIfdId, makerTags, printOffOn),
+ TagInfo(0x1021, "FocusMode", "Focusing mode setting", fujiIfdId, makerTags, print0x1021),
+ TagInfo(0x1030, "SlowSync", "Slow synchro mode setting", fujiIfdId, makerTags, printOffOn),
+ TagInfo(0x1031, "PictureMode", "Picture mode setting", fujiIfdId, makerTags, print0x1031),
+ TagInfo(0x1100, "Continuous", "Continuous shooting or auto bracketing setting", fujiIfdId, makerTags, printOffOn),
+ TagInfo(0x1300, "BlurWarning", "Blur warning status", fujiIfdId, makerTags, printOffOn),
+ TagInfo(0x1301, "FocusWarning", "Auto Focus warning status", fujiIfdId, makerTags, printOffOn),
+ TagInfo(0x1302, "AeWarning", "Auto Exposure warning status", fujiIfdId, makerTags, printOffOn),
// End of list marker
- MakerNote::MnTagInfo(0xffff, "(UnknownFujiMakerNoteTag)", "Unknown FujiMakerNote tag")
+ TagInfo(0xffff, "(UnknownFujiMakerNoteTag)", "Unknown FujiMakerNote tag", fujiIfdId, makerTags, printValue)
};
FujiMakerNote::FujiMakerNote(bool alloc)
- : IfdMakerNote(fujiMnTagInfo, alloc), ifdItem_("Fujifilm")
+ : IfdMakerNote(fujiIfdId, alloc)
{
byteOrder_ = littleEndian;
absOffset_ = false;
@@ -89,7 +89,7 @@ namespace Exiv2 {
}
FujiMakerNote::FujiMakerNote(const FujiMakerNote& rhs)
- : IfdMakerNote(rhs), ifdItem_(rhs.ifdItem_)
+ : IfdMakerNote(rhs)
{
}
@@ -142,32 +142,6 @@ namespace Exiv2 {
return new FujiMakerNote(*this);
}
- std::ostream& FujiMakerNote::printTag(std::ostream& os,
- uint16_t tag,
- const Value& value) const
- {
- switch (tag) {
- case 0x1020: // fallthrough
- case 0x1030: // fallthrough
- case 0x1100: // fallthrough
- case 0x1300: // fallthrough
- case 0x1301: // fallthrough
- case 0x1302: printOffOn(os, value); break;
- case 0x1001: print0x1001(os, value); break;
- case 0x1002: print0x1002(os, value); break;
- case 0x1003: print0x1003(os, value); break;
- case 0x1004: print0x1004(os, value); break;
- case 0x1010: print0x1010(os, value); break;
- case 0x1021: print0x1021(os, value); break;
- case 0x1031: print0x1031(os, value); break;
- default:
- // All other tags (known or unknown) go here
- os << value;
- break;
- }
- return os;
- }
-
std::ostream& FujiMakerNote::printOffOn(std::ostream& os,
const Value& value)
{
diff --git a/src/fujimn.hpp b/src/fujimn.hpp
index e9701be..6be13ec 100644
--- a/src/fujimn.hpp
+++ b/src/fujimn.hpp
@@ -36,6 +36,7 @@
// included header files
#include "types.hpp"
#include "makernote.hpp"
+#include "tags.hpp"
// + standard includes
#include <string>
@@ -115,11 +116,6 @@ namespace Exiv2 {
int checkHeader() const;
AutoPtr create(bool alloc =true) const;
AutoPtr clone() const;
- //! Return the name of the makernote item ("Fujifilm")
- std::string ifdItem() const { return ifdItem_; }
- std::ostream& printTag(std::ostream& os,
- uint16_t tag,
- const Value& value) const;
//@}
//! @name Print functions for Fujifilm %MakerNote tags
@@ -148,6 +144,9 @@ namespace Exiv2 {
//! Internal virtual copy constructor.
FujiMakerNote* clone_() const;
+ //! Tag information
+ static const TagInfo tagInfo_[];
+
//! Structure used to auto-register the MakerNote.
struct RegisterMakerNote {
//! Default constructor
@@ -155,7 +154,9 @@ namespace Exiv2 {
{
MakerNoteFactory& mnf = MakerNoteFactory::instance();
mnf.registerMakerNote("FUJIFILM", "*", createFujiMakerNote);
- mnf.registerMakerNote(MakerNote::AutoPtr(new FujiMakerNote));
+ mnf.registerMakerNote(fujiIfdId,
+ MakerNote::AutoPtr(new FujiMakerNote));
+ ExifTags::registerMakerTagInfo(fujiIfdId, tagInfo_);
}
};
/*!
@@ -172,9 +173,6 @@ namespace Exiv2 {
*/
static const RegisterMakerNote register_;
- //! The item name (second part of the key) used for makernote tags
- std::string ifdItem_;
-
}; // class FujiMakerNote
} // namespace Exiv2
diff --git a/src/ifd.cpp b/src/ifd.cpp
index 39e613d..5108e7c 100644
--- a/src/ifd.cpp
+++ b/src/ifd.cpp
@@ -50,7 +50,7 @@ EXIV2_RCSID("@(#) $Id$");
namespace Exiv2 {
Entry::Entry(bool alloc)
- : alloc_(alloc), ifdId_(ifdIdNotSet), idx_(0), pMakerNote_(0),
+ : alloc_(alloc), ifdId_(ifdIdNotSet), idx_(0),
tag_(0), type_(0), count_(0), offset_(0), size_(0), pData_(0),
sizeDataArea_(0), pDataArea_(0)
{
@@ -62,12 +62,11 @@ namespace Exiv2 {
delete[] pData_;
delete[] pDataArea_;
}
- // do *not* delete the MakerNote
}
Entry::Entry(const Entry& rhs)
: alloc_(rhs.alloc_), ifdId_(rhs.ifdId_), idx_(rhs.idx_),
- pMakerNote_(rhs.pMakerNote_), tag_(rhs.tag_), type_(rhs.type_),
+ tag_(rhs.tag_), type_(rhs.type_),
count_(rhs.count_), offset_(rhs.offset_), size_(rhs.size_), pData_(0),
sizeDataArea_(rhs.sizeDataArea_), pDataArea_(0)
{
@@ -93,7 +92,6 @@ namespace Exiv2 {
alloc_ = rhs.alloc_;
ifdId_ = rhs.ifdId_;
idx_ = rhs.idx_;
- pMakerNote_ = rhs.pMakerNote_;
tag_ = rhs.tag_;
type_ = rhs.type_;
count_ = rhs.count_;
diff --git a/src/ifd.hpp b/src/ifd.hpp
index e35e965..cce2a16 100644
--- a/src/ifd.hpp
+++ b/src/ifd.hpp
@@ -45,7 +45,6 @@ namespace Exiv2 {
// *****************************************************************************
// class declarations
- class MakerNote;
class Ifd;
// *****************************************************************************
@@ -84,8 +83,6 @@ namespace Exiv2 {
void setIfdId(IfdId ifdId) { ifdId_ = ifdId; }
//! Set the index (unique id of an entry within one IFD)
void setIdx(int idx) { idx_ = idx; }
- //! Set the pointer to the MakerNote
- void setMakerNote(MakerNote* makerNote) { pMakerNote_ = makerNote; }
//! Set the offset. The offset is relative to the start of the IFD.
void setOffset(long offset) { offset_ = offset; }
/*!
@@ -177,8 +174,6 @@ namespace Exiv2 {
IfdId ifdId() const { return ifdId_; }
//! Return the index (unique id >0 of an entry within an IFD, 0 if not set)
int idx() const { return idx_; }
- //! Return the pointer to the associated MakerNote
- MakerNote* makerNote() const { return pMakerNote_; }
//! Return the number of components in the value
uint32_t count() const { return count_; }
/*!
@@ -232,8 +227,6 @@ namespace Exiv2 {
IfdId ifdId_;
//! Unique id of an entry within an IFD (0 if not set)
int idx_;
- //! Pointer to the associated MakerNote
- MakerNote* pMakerNote_;
//! Tag
uint16_t tag_;
//! Type
diff --git a/src/makernote.cpp b/src/makernote.cpp
index 1c79563..c26178c 100644
--- a/src/makernote.cpp
+++ b/src/makernote.cpp
@@ -35,7 +35,6 @@ EXIV2_RCSID("@(#) $Id$");
// *****************************************************************************
// included header files
#include "makernote.hpp"
-#include "tags.hpp" // for ExifTags::ifdItem
#include "error.hpp"
// + standard includes
@@ -51,9 +50,8 @@ EXIV2_RCSID("@(#) $Id$");
// class member definitions
namespace Exiv2 {
- MakerNote::MakerNote(const MnTagInfo* pMnTagInfo, bool alloc)
- : pMnTagInfo_(pMnTagInfo), alloc_(alloc),
- offset_(0), byteOrder_(invalidByteOrder)
+ MakerNote::MakerNote(bool alloc)
+ : alloc_(alloc), offset_(0), byteOrder_(invalidByteOrder)
{
}
@@ -67,83 +65,9 @@ namespace Exiv2 {
return AutoPtr(clone_());
}
- std::string MakerNote::tagName(uint16_t tag) const
- {
- std::string tagName;
- if (pMnTagInfo_) {
- for (int i = 0; pMnTagInfo_[i].tag_ != 0xffff; ++i) {
- if (pMnTagInfo_[i].tag_ == tag) {
- tagName = pMnTagInfo_[i].name_;
- break;
- }
- }
- }
- if (tagName.empty()) {
- std::ostringstream os;
- os << "0x" << std::setw(4) << std::setfill('0') << std::right
- << std::hex << tag;
- tagName = os.str();
- }
- return tagName;
- } // MakerNote::tagName
-
- uint16_t MakerNote::tag(const std::string& tagName) const
- {
- uint16_t tag = 0xffff;
- if (pMnTagInfo_) {
- for (int i = 0; pMnTagInfo_[i].tag_ != 0xffff; ++i) {
- if (pMnTagInfo_[i].name_ == tagName) {
- tag = pMnTagInfo_[i].tag_;
- break;
- }
- }
- }
- if (tag == 0xffff) {
- std::istringstream is(tagName);
- is >> std::hex >> tag;
- }
- return tag;
- } // MakerNote::tag
-
- std::string MakerNote::tagDesc(uint16_t tag) const
- {
- std::string tagDesc;
- if (pMnTagInfo_) {
- for (int i = 0; pMnTagInfo_[i].tag_ != 0xffff; ++i) {
- if (pMnTagInfo_[i].tag_ == tag) {
- tagDesc = pMnTagInfo_[i].desc_;
- break;
- }
- }
- }
- return tagDesc;
- } // MakerNote::tagDesc
-
- void MakerNote::taglist(std::ostream& os) const
- {
- if (pMnTagInfo_) {
- for (int i = 0; pMnTagInfo_[i].tag_ != 0xffff; ++i) {
- writeMnTagInfo(os, pMnTagInfo_[i].tag_) << std::endl;
- }
- }
- } // MakerNote::taglist
-
- std::ostream& MakerNote::writeMnTagInfo(std::ostream& os, uint16_t tag) const
- {
- ExifKey exifKey(tag, ifdItem());
- return os << tagName(tag) << ", "
- << std::dec << tag << ", "
- << "0x" << std::setw(4) << std::setfill('0')
- << std::right << std::hex << tag << ", "
- << ExifTags::ifdItem(makerIfdId) << ", "
- << exifKey.key() << ", "
- << tagDesc(tag);
- } // MakerNote::writeMnTagInfo
-
- IfdMakerNote::IfdMakerNote(const MakerNote::MnTagInfo* pMnTagInfo,
- bool alloc)
- : MakerNote(pMnTagInfo, alloc),
- absOffset_(true), adjOffset_(0), ifd_(makerIfdId, 0, alloc)
+ IfdMakerNote::IfdMakerNote(IfdId ifdId, bool alloc)
+ : MakerNote(alloc),
+ absOffset_(true), adjOffset_(0), ifd_(ifdId, 0, alloc)
{
}
@@ -181,12 +105,6 @@ namespace Exiv2 {
// IfdMakerNote currently does not support multiple IFDs
if (ifd_.next() != 0) rc = 3;
}
- if (rc == 0) {
- Entries::iterator end = ifd_.end();
- for (Entries::iterator i = ifd_.begin(); i != end; ++i) {
- i->setMakerNote(this);
- }
- }
#ifdef DEBUG_MAKERNOTE
hexdump(std::cerr, buf, len, offset);
if (rc == 0) ifd_.print(std::cerr);
@@ -224,10 +142,6 @@ namespace Exiv2 {
if (absOffset_) {
ifd_.updateBase(pNewBase);
}
- Entries::iterator end = ifd_.end();
- for (Entries::iterator i = ifd_.begin(); i != end; ++i) {
- i->setMakerNote(this);
- }
}
int IfdMakerNote::checkHeader() const
@@ -277,18 +191,18 @@ namespace Exiv2 {
return *pInstance_;
} // MakerNoteFactory::instance
- void MakerNoteFactory::registerMakerNote(MakerNote::AutoPtr makerNote)
+ void MakerNoteFactory::registerMakerNote(IfdId ifdId,
+ MakerNote::AutoPtr makerNote)
{
MakerNote* pMakerNote = makerNote.release();
assert(pMakerNote);
- ifdItemRegistry_[pMakerNote->ifdItem()] = pMakerNote;
+ ifdIdRegistry_[ifdId] = pMakerNote;
} // MakerNoteFactory::registerMakerNote
- MakerNote::AutoPtr MakerNoteFactory::create(const std::string& ifdItem,
- bool alloc) const
+ MakerNote::AutoPtr MakerNoteFactory::create(IfdId ifdId, bool alloc) const
{
- IfdItemRegistry::const_iterator i = ifdItemRegistry_.find(ifdItem);
- if (i == ifdItemRegistry_.end()) return MakerNote::AutoPtr(0);
+ IfdIdRegistry::const_iterator i = ifdIdRegistry_.find(ifdId);
+ if (i == ifdIdRegistry_.end()) return MakerNote::AutoPtr(0);
assert(i->second);
return i->second->create(alloc);
} // MakerNoteFactory::create
diff --git a/src/makernote.hpp b/src/makernote.hpp
index 4696f17..6dd0b89 100644
--- a/src/makernote.hpp
+++ b/src/makernote.hpp
@@ -69,7 +69,6 @@ namespace Exiv2 {
- read the makernote from a character buffer
- copy the makernote to a character buffer
- maintain a list of makernote entries (similar to IFD entries)
- - provide makernote specific tag names and tag information
- interpret (print) the values of makernote tags
Makernotes can be added to the system by subclassing %MakerNote and
@@ -104,25 +103,13 @@ namespace Exiv2 {
//! Shortcut for a %MakerNote auto pointer.
typedef std::auto_ptr<MakerNote> AutoPtr;
- //! MakerNote Tag information
- struct MnTagInfo {
- //! Constructor
- MnTagInfo(uint16_t tag, const char* name, const char* desc)
- : tag_(tag), name_(name), desc_(desc) {}
-
- uint16_t tag_; //!< Tag
- const char* name_; //!< One word tag label
- const char* desc_; //!< Short tag description
- }; // struct MnTagInfo
-
//! @name Creators
//@{
/*!
- @brief Constructor. Takes an optional makernote info tag array and
- allows to choose whether or not memory management is required
- for the Entries.
+ @brief Constructor. Allows to choose whether or not memory management
+ is required for the Entries.
*/
- explicit MakerNote(const MnTagInfo* pMnTagInfo =0, bool alloc =true);
+ explicit MakerNote(bool alloc =true);
//! Virtual destructor.
virtual ~MakerNote() {}
//@}
@@ -197,36 +184,6 @@ namespace Exiv2 {
Use updateBase(byte* pNewBase) to adjust them.
*/
AutoPtr clone() const;
- /*!
- @brief Return the name of a makernote tag. The default implementation
- looks up the makernote info tag array if one is set, else
- it translates the tag to a string with the hexadecimal value of
- the tag.
- */
- virtual std::string tagName(uint16_t tag) const;
- /*!
- @brief Return the tag associated with a makernote tag name. The
- default implementation looks up the makernote info tag array
- if one is set, else it expects tag names in the form "0x01ff"
- and converts them to unsigned integer.
- */
- virtual uint16_t tag(const std::string& tagName) const;
- /*!
- @brief Return the description of a makernote tag. The default
- implementation looks up the makernote info tag array if one is
- set, else it returns an empty string.
- */
- virtual std::string tagDesc(uint16_t tag) const;
- /*!
- @brief Print a list of all tags known by this MakerNote to the output
- stream os. The default implementation prints all tags in the
- makernote info tag array if one is set.
- */
- virtual void taglist(std::ostream& os) const;
- /*!
- @brief Write the makernote tag info of tag to the output stream os.
- */
- virtual std::ostream& writeMnTagInfo(std::ostream& os, uint16_t tag) const;
//! The first makernote entry
virtual Entries::const_iterator begin() const =0;
//! End of the makernote entries
@@ -235,18 +192,10 @@ namespace Exiv2 {
virtual Entries::const_iterator findIdx(int idx) const =0;
//! Return the size of the makernote in bytes
virtual long size() const =0;
- //! Return the name of the makernote item
- virtual std::string ifdItem() const =0;
- //! Interpret and print the value of a makernote tag
- virtual std::ostream& printTag(std::ostream& os,
- uint16_t tag,
- const Value& value) const =0;
//@}
protected:
// DATA
- //! Pointer to an array of makernote tag infos
- const MnTagInfo* pMnTagInfo_;
/*!
@brief Flag to control the memory management: <BR>
True: requires memory allocation and deallocation, <BR>
@@ -274,6 +223,7 @@ namespace Exiv2 {
//! Type for a pointer to a function creating a makernote
typedef MakerNote::AutoPtr (*CreateFct)(bool, const byte*, long, ByteOrder, long);
+
/*!
@brief Interface for MakerNotes in IFD format. See MakerNote.
*/
@@ -291,12 +241,10 @@ namespace Exiv2 {
//! @name Creators
//@{
/*!
- @brief Constructor. Takes an optional makernote info tag array and
- allows to choose whether or not memory management is required
- for the Entries.
- */
- explicit IfdMakerNote(const MakerNote::MnTagInfo* pMnTagInfo =0,
- bool alloc =true);
+ @brief Constructor. Requires an %Ifd id and allows to choose whether
+ or not memory management is needed for the Entries.
+ */
+ explicit IfdMakerNote(IfdId ifdId, bool alloc =true);
//! Copy constructor
IfdMakerNote(const IfdMakerNote& rhs);
//! Virtual destructor
@@ -321,18 +269,18 @@ namespace Exiv2 {
long len,
ByteOrder byteOrder);
virtual long copy(byte* buf, ByteOrder byteOrder, long offset);
- void add(const Entry& entry) { ifd_.add(entry); }
- Entries::iterator begin() { return ifd_.begin(); }
- Entries::iterator end() { return ifd_.end(); }
+ virtual void add(const Entry& entry) { ifd_.add(entry); }
+ virtual Entries::iterator begin() { return ifd_.begin(); }
+ virtual Entries::iterator end() { return ifd_.end(); }
virtual void updateBase(byte* pNewBase);
//@}
//! @name Accessors
//@{
- Entries::const_iterator begin() const { return ifd_.begin(); }
- Entries::const_iterator end() const { return ifd_.end(); }
- Entries::const_iterator findIdx(int idx) const;
- long size() const;
+ virtual Entries::const_iterator begin() const { return ifd_.begin(); }
+ virtual Entries::const_iterator end() const { return ifd_.end(); }
+ virtual Entries::const_iterator findIdx(int idx) const;
+ virtual long size() const;
AutoPtr create(bool alloc =true) const;
AutoPtr clone() const;
/*!
@@ -355,10 +303,6 @@ namespace Exiv2 {
buffer.
*/
virtual long headerSize() const;
- virtual std::string ifdItem() const =0;
- virtual std::ostream& printTag(std::ostream& os,
- uint16_t tag,
- const Value& value) const =0;
//@}
protected:
@@ -409,7 +353,8 @@ namespace Exiv2 {
//! @name Manipulators
//@{
/*!
- @brief Register a %MakerNote create function for a camera make and model.
+ @brief Register a %MakerNote create function for a camera make and
+ model.
Registers a create function for a %MakerNote for a given make and
model combination with the factory. Both the make and model strings
@@ -429,8 +374,8 @@ namespace Exiv2 {
const std::string& model,
CreateFct createMakerNote);
- //! Register a %MakerNote prototype in the IFD item registry.
- void registerMakerNote(MakerNote::AutoPtr makerNote);
+ //! Register a %MakerNote prototype in the IFD id registry.
+ void registerMakerNote(IfdId ifdId, MakerNote::AutoPtr makerNote);
//@}
//! @name Accessors
@@ -486,9 +431,8 @@ namespace Exiv2 {
ByteOrder byteOrder,
long offset) const;
- //! Create a %MakerNote based on its IFD item string.
- MakerNote::AutoPtr create(const std::string& ifdItem,
- bool alloc =true) const;
+ //! Create a %MakerNote for an IFD id.
+ MakerNote::AutoPtr create(IfdId ifdId, bool alloc =true) const;
//@}
/*!
@@ -523,16 +467,16 @@ namespace Exiv2 {
typedef std::vector<std::pair<std::string, CreateFct> > ModelRegistry;
//! Type used to store a list of make labels and model registries
typedef std::vector<std::pair<std::string, ModelRegistry*> > Registry;
- //! Type used to store a list of IFD items and %MakerNote prototypes
- typedef std::map<std::string, MakerNote*> IfdItemRegistry;
+ //! Type used to store a list of IFD ids and %MakerNote prototypes
+ typedef std::map<IfdId, MakerNote*> IfdIdRegistry;
// DATA
//! Pointer to the one and only instance of this class.
static MakerNoteFactory* pInstance_;
//! List of makernote types and corresponding makernote create functions.
Registry registry_;
- //! List of makernote IfdItems and corresponding create functions.
- IfdItemRegistry ifdItemRegistry_;
+ //! List of makernote IFD ids and corresponding create functions.
+ IfdIdRegistry ifdIdRegistry_;
}; // class MakerNoteFactory
diff --git a/src/nikonmn.cpp b/src/nikonmn.cpp
index 99f0218..af6c98a 100644
--- a/src/nikonmn.cpp
+++ b/src/nikonmn.cpp
@@ -36,6 +36,8 @@ EXIV2_RCSID("@(#) $Id$");
#include "makernote.hpp"
#include "value.hpp"
#include "image.hpp"
+#include "tags.hpp"
+#include "error.hpp"
// + standard includes
#include <string>
@@ -53,32 +55,32 @@ namespace Exiv2 {
const Nikon1MakerNote::RegisterMakerNote Nikon1MakerNote::register_;
// Nikon1 MakerNote Tag Info
- static const MakerNote::MnTagInfo nikon1MnTagInfo[] = {
- MakerNote::MnTagInfo(0x0001, "Version", "Nikon Makernote version"),
- MakerNote::MnTagInfo(0x0002, "ISOSpeed", "ISO speed setting"),
- MakerNote::MnTagInfo(0x0003, "ColorMode", "Color mode"),
- MakerNote::MnTagInfo(0x0004, "Quality", "Image quality setting"),
- MakerNote::MnTagInfo(0x0005, "WhiteBalance", "White balance"),
- MakerNote::MnTagInfo(0x0006, "Sharpening", "Image sharpening setting"),
- MakerNote::MnTagInfo(0x0007, "Focus", "Focus mode"),
- MakerNote::MnTagInfo(0x0008, "Flash", "Flash mode"),
- MakerNote::MnTagInfo(0x000f, "ISOSelection", "ISO selection"),
- MakerNote::MnTagInfo(0x0080, "ImageAdjustment", "Image adjustment setting"),
- MakerNote::MnTagInfo(0x0082, "Adapter", "Adapter used"),
- MakerNote::MnTagInfo(0x0085, "FocusDistance", "Manual focus distance"),
- MakerNote::MnTagInfo(0x0086, "DigitalZoom", "Digital zoom setting"),
- MakerNote::MnTagInfo(0x0088, "AFFocusPos", "AF focus position"),
+ const TagInfo Nikon1MakerNote::tagInfo_[] = {
+ TagInfo(0x0001, "Version", "Nikon Makernote version", nikon1IfdId, makerTags, printValue),
+ TagInfo(0x0002, "ISOSpeed", "ISO speed setting", nikon1IfdId, makerTags, print0x0002),
+ TagInfo(0x0003, "ColorMode", "Color mode", nikon1IfdId, makerTags, printValue),
+ TagInfo(0x0004, "Quality", "Image quality setting", nikon1IfdId, makerTags, printValue),
+ TagInfo(0x0005, "WhiteBalance", "White balance", nikon1IfdId, makerTags, printValue),
+ TagInfo(0x0006, "Sharpening", "Image sharpening setting", nikon1IfdId, makerTags, printValue),
+ TagInfo(0x0007, "Focus", "Focus mode", nikon1IfdId, makerTags, print0x0007),
+ TagInfo(0x0008, "Flash", "Flash mode", nikon1IfdId, makerTags, printValue),
+ TagInfo(0x000f, "ISOSelection", "ISO selection", nikon1IfdId, makerTags, printValue),
+ TagInfo(0x0080, "ImageAdjustment", "Image adjustment setting", nikon1IfdId, makerTags, printValue),
+ TagInfo(0x0082, "Adapter", "Adapter used", nikon1IfdId, makerTags, printValue),
+ TagInfo(0x0085, "FocusDistance", "Manual focus distance", nikon1IfdId, makerTags, print0x0085),
+ TagInfo(0x0086, "DigitalZoom", "Digital zoom setting", nikon1IfdId, makerTags, print0x0086),
+ TagInfo(0x0088, "AFFocusPos", "AF focus position", nikon1IfdId, makerTags, print0x0088),
// End of list marker
- MakerNote::MnTagInfo(0xffff, "(UnknownNikon1MnTag)", "Unknown Nikon1MakerNote tag")
+ TagInfo(0xffff, "(UnknownNikon1MnTag)", "Unknown Nikon1MakerNote tag", nikon1IfdId, makerTags, printValue)
};
Nikon1MakerNote::Nikon1MakerNote(bool alloc)
- : IfdMakerNote(nikon1MnTagInfo, alloc), ifdItem_("Nikon1")
+ : IfdMakerNote(nikon1IfdId, alloc)
{
}
Nikon1MakerNote::Nikon1MakerNote(const Nikon1MakerNote& rhs)
- : IfdMakerNote(rhs), ifdItem_(rhs.ifdItem_)
+ : IfdMakerNote(rhs)
{
}
@@ -102,24 +104,6 @@ namespace Exiv2 {
return new Nikon1MakerNote(*this);
}
- std::ostream& Nikon1MakerNote::printTag(std::ostream& os,
- uint16_t tag,
- const Value& value) const
- {
- switch (tag) {
- case 0x0002: print0x0002(os, value); break;
- case 0x0007: print0x0007(os, value); break;
- case 0x0085: print0x0085(os, value); break;
- case 0x0086: print0x0086(os, value); break;
- case 0x0088: print0x0088(os, value); break;
- default:
- // All other tags (known or unknown) go here
- os << value;
- break;
- }
- return os;
- }
-
std::ostream& Nikon1MakerNote::print0x0002(std::ostream& os,
const Value& value)
{
@@ -206,21 +190,21 @@ namespace Exiv2 {
const Nikon2MakerNote::RegisterMakerNote Nikon2MakerNote::register_;
// Nikon2 MakerNote Tag Info
- static const MakerNote::MnTagInfo nikon2MnTagInfo[] = {
- MakerNote::MnTagInfo(0x0003, "Quality", "Image quality setting"),
- MakerNote::MnTagInfo(0x0004, "ColorMode", "Color mode"),
- MakerNote::MnTagInfo(0x0005, "ImageAdjustment", "Image adjustment setting"),
- MakerNote::MnTagInfo(0x0006, "ISOSpeed", "ISO speed setting"),
- MakerNote::MnTagInfo(0x0007, "WhiteBalance", "White balance"),
- MakerNote::MnTagInfo(0x0008, "Focus", "Focus mode"),
- MakerNote::MnTagInfo(0x000a, "DigitalZoom", "Digital zoom setting"),
- MakerNote::MnTagInfo(0x000b, "Adapter", "Adapter used"),
+ const TagInfo Nikon2MakerNote::tagInfo_[] = {
+ TagInfo(0x0003, "Quality", "Image quality setting", nikon2IfdId, makerTags, print0x0003),
+ TagInfo(0x0004, "ColorMode", "Color mode", nikon2IfdId, makerTags, print0x0004),
+ TagInfo(0x0005, "ImageAdjustment", "Image adjustment setting", nikon2IfdId, makerTags, print0x0005),
+ TagInfo(0x0006, "ISOSpeed", "ISO speed setting", nikon2IfdId, makerTags, print0x0006),
+ TagInfo(0x0007, "WhiteBalance", "White balance", nikon2IfdId, makerTags, print0x0007),
+ TagInfo(0x0008, "Focus", "Focus mode", nikon2IfdId, makerTags, printValue),
+ TagInfo(0x000a, "DigitalZoom", "Digital zoom setting", nikon2IfdId, makerTags, print0x000a),
+ TagInfo(0x000b, "Adapter", "Adapter used", nikon2IfdId, makerTags, printValue),
// End of list marker
- MakerNote::MnTagInfo(0xffff, "(UnknownNikon2MnTag)", "Unknown Nikon2MakerNote tag")
+ TagInfo(0xffff, "(UnknownNikon2MnTag)", "Unknown Nikon2MakerNote tag", nikon2IfdId, makerTags, printValue)
};
Nikon2MakerNote::Nikon2MakerNote(bool alloc)
- : IfdMakerNote(nikon2MnTagInfo, alloc), ifdItem_("Nikon2")
+ : IfdMakerNote(nikon2IfdId, alloc)
{
byte buf[] = {
'N', 'i', 'k', 'o', 'n', '
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list