Minor clean-ups

v0.27.3
Andreas Huggel 22 years ago
parent fdd338981a
commit f6c0f9371a

@ -20,13 +20,13 @@
*/ */
/* /*
File: tags.cpp File: tags.cpp
Version: $Name: $ $Revision: 1.17 $ Version: $Name: $ $Revision: 1.18 $
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net> Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
History: 15-Jan-04, ahu: created History: 15-Jan-04, ahu: created
*/ */
// ***************************************************************************** // *****************************************************************************
#include "rcsid.hpp" #include "rcsid.hpp"
EXIV2_RCSID("@(#) $Name: $ $Revision: 1.17 $ $RCSfile: tags.cpp,v $") EXIV2_RCSID("@(#) $Name: $ $Revision: 1.18 $ $RCSfile: tags.cpp,v $")
// ***************************************************************************** // *****************************************************************************
// included header files // included header files
@ -54,13 +54,9 @@ namespace Exif {
IfdInfo(ifd0, "IFD0", "Image"), IfdInfo(ifd0, "IFD0", "Image"),
IfdInfo(exifIfd, "Exif", "Image"), IfdInfo(exifIfd, "Exif", "Image"),
IfdInfo(gpsIfd, "GPSInfo", "Image"), IfdInfo(gpsIfd, "GPSInfo", "Image"),
IfdInfo(makerIfd, "MakerNote", "Image"), IfdInfo(makerIfd, "Makernote", "Makernote"),
IfdInfo(iopIfd, "Iop", "Image"), IfdInfo(iopIfd, "Iop", "Image"),
IfdInfo(ifd1, "IFD1", "Thumbnail"), IfdInfo(ifd1, "IFD1", "Thumbnail"),
IfdInfo(ifd1ExifIfd, "Exif", "Thumbnail"),
IfdInfo(ifd1GpsIfd, "GPSInfo", "Thumbnail"),
IfdInfo(ifd1MakerIfd, "MakerNote", "Thumbnail"),
IfdInfo(ifd1IopIfd, "Iop", "Thumbnail"),
IfdInfo(lastIfdId, "(Last IFD info)", "(Last IFD info)") IfdInfo(lastIfdId, "(Last IFD info)", "(Last IFD info)")
}; };
@ -253,13 +249,19 @@ namespace Exif {
TagInfo(0xffff, "(UnknownIopTag)", "Unknown Exif Interoperability tag", ifdIdNotSet, sectionIdNotSet, printValue) TagInfo(0xffff, "(UnknownIopTag)", "Unknown Exif Interoperability tag", ifdIdNotSet, sectionIdNotSet, printValue)
}; };
// MakerNote Tags
static const TagInfo makerNoteTagInfo[] = {
// End of list marker
TagInfo(0xffff, "(UnknownMakerNoteTag)", "Unknown MakerNote tag", ifdIdNotSet, sectionIdNotSet, printValue)
};
// Tag lookup lists with tag names, desc and where they (preferably) belong to; // Tag lookup lists with tag names, desc and where they (preferably) belong to;
// this is an array with pointers to one list per IFD. The IfdId is used as the // this is an array with pointers to one list per IFD. The IfdId is used as the
// index into the array. // index into the array.
const TagInfo* ExifTags::tagInfos_[] = { const TagInfo* ExifTags::tagInfos_[] = {
0, 0,
ifdTagInfo, exifTagInfo, gpsTagInfo, 0, iopTagInfo, ifdTagInfo, exifTagInfo, gpsTagInfo, makerNoteTagInfo, iopTagInfo, ifdTagInfo,
ifdTagInfo, exifTagInfo, gpsTagInfo, 0, iopTagInfo 0
}; };
int ExifTags::tagInfoIdx(uint16 tag, IfdId ifdId) int ExifTags::tagInfoIdx(uint16 tag, IfdId ifdId)
@ -345,9 +347,8 @@ namespace Exif {
+ "." + std::string(tagName(tag, ifdId)); + "." + std::string(tagName(tag, ifdId));
} }
// The uniqueness that we promise in this 'database lookup' function // This 'database lookup' function returns the first match that
// holds only implicitely. The function returns the first match that // we find, it doesn't verify whether this is the only match.
// we find, it doesn't verify the uniqueness.
std::pair<uint16, IfdId> ExifTags::decomposeKey(const std::string& key) std::pair<uint16, IfdId> ExifTags::decomposeKey(const std::string& key)
{ {
// Get the IFD, section name and tag name parts of the key // Get the IFD, section name and tag name parts of the key
@ -362,6 +363,11 @@ namespace Exif {
std::string tagName = key.substr(pos0); std::string tagName = key.substr(pos0);
if (tagName == "") throw Error("Invalid key"); if (tagName == "") throw Error("Invalid key");
// Check if this is a MakerNote key, stop processing if it is
if (ifdItem == ifdInfo_[makerIfd].item_) {
return std::make_pair(0xffff, makerIfd);
}
// Use the parts of the key to find tag and IFD id // Use the parts of the key to find tag and IFD id
IfdId ifdId = ifdIdNotSet; IfdId ifdId = ifdIdNotSet;
uint16 tag = 0xffff; uint16 tag = 0xffff;
@ -382,11 +388,15 @@ namespace Exif {
return std::make_pair(tag, ifdId); return std::make_pair(tag, ifdId);
} // ExifTags::decomposeKey } // ExifTags::decomposeKey
PrintFct ExifTags::printFct(uint16 tag, IfdId ifdId) std::ostream& ExifTags::printTag(std::ostream& os,
uint16 tag,
IfdId ifdId,
const Value& value)
{ {
int idx = tagInfoIdx(tag, ifdId); int idx = tagInfoIdx(tag, ifdId);
if (idx == -1) throw Error("No taginfo for IFD"); if (idx == -1) throw Error("No taginfo for IFD");
return tagInfos_[ifdId][idx].printFct_; PrintFct fct = tagInfos_[ifdId][idx].printFct_;
return fct(os, value);
} }
void ExifTags::taglist(std::ostream& os) void ExifTags::taglist(std::ostream& os)

@ -21,7 +21,7 @@
/*! /*!
@file tags.hpp @file tags.hpp
@brief %Exif tag and type information @brief %Exif tag and type information
@version $Name: $ $Revision: 1.16 $ @version $Name: $ $Revision: 1.17 $
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@date 15-Jan-04, ahu: created @date 15-Jan-04, ahu: created
@ -166,19 +166,22 @@ namespace Exif {
//! Return the section id for a section name //! Return the section id for a section name
static SectionId sectionId(const std::string& sectionName); static SectionId sectionId(const std::string& sectionName);
/*! /*!
@brief Return a unique key for the tag and IFD id. @brief Return the key for the tag and IFD id. The key is of the form
The key is of the form 'ifdItem.sectionName.tagName'. 'ifdItem.sectionName.tagName'.
*/ */
static std::string makeKey(uint16 tag, IfdId ifdId); static std::string makeKey(uint16 tag, IfdId ifdId);
/*! /*!
@brief Return the unique tag and IFD id pair for the key. @brief Return tag and IFD id pair for the key.
@return A pair consisting of the tag and IFD id. @return A pair consisting of the tag and IFD id.
@throw Error ("Invalid key") if the key cannot be parsed into @throw Error ("Invalid key") if the key cannot be parsed into
item item, section name and tag name parts. item item, section name and tag name parts.
*/ */
static std::pair<uint16, IfdId> decomposeKey(const std::string& key); static std::pair<uint16, IfdId> decomposeKey(const std::string& key);
//! Return the print function for the tag, IFD id combination //! Interpret and print the value of an %Exif tag
static PrintFct printFct(uint16 tag, IfdId ifdId); static std::ostream& printTag(std::ostream& os,
uint16 tag,
IfdId ifdId,
const Value& value);
//! Print a list of all tags to standart output //! Print a list of all tags to standart output
static void taglist(std::ostream& os); static void taglist(std::ostream& os);

Loading…
Cancel
Save