From 11577c0f77d31d78580043d18c56c58ef8182416 Mon Sep 17 00:00:00 2001 From: Andreas Huggel Date: Wed, 28 Apr 2004 16:30:03 +0000 Subject: [PATCH] Added makernote taglists --- src/makernote.cpp | 38 ++++++++++++++++++++++++++++++++++++-- src/makernote.hpp | 20 ++++++++++++++++++-- src/taglist.cpp | 41 ++++++++++++++++++++++++++++++++++++----- src/tags.awk | 8 ++++---- src/tags.cpp | 5 ++--- 5 files changed, 96 insertions(+), 16 deletions(-) diff --git a/src/makernote.cpp b/src/makernote.cpp index 75fc37fa..f9fb06b2 100644 --- a/src/makernote.cpp +++ b/src/makernote.cpp @@ -20,13 +20,13 @@ */ /* File: makernote.cpp - Version: $Name: $ $Revision: 1.14 $ + Version: $Name: $ $Revision: 1.15 $ Author(s): Andreas Huggel (ahu) History: 18-Feb-04, ahu: created */ // ***************************************************************************** #include "rcsid.hpp" -EXIV2_RCSID("@(#) $Name: $ $Revision: 1.14 $ $RCSfile: makernote.cpp,v $") +EXIV2_RCSID("@(#) $Name: $ $Revision: 1.15 $ $RCSfile: makernote.cpp,v $") // Define DEBUG_MAKERNOTE to output debug information to std::cerr #undef DEBUG_MAKERNOTE @@ -116,6 +116,40 @@ namespace Exif { return tag; } // MakerNote::tag + std::string MakerNote::tagDesc(uint16 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 tag) const + { + return os << tagName(tag) << ", " + << std::dec << tag << ", " + << "0x" << std::setw(4) << std::setfill('0') + << std::right << std::hex << tag << ", " + << ExifTags::ifdItem(makerIfd) << ", " + << makeKey(tag) << ", " + << tagDesc(tag); + } // MakerNote::writeMnTagInfo + int IfdMakerNote::read(const char* buf, long len, ByteOrder byteOrder, diff --git a/src/makernote.hpp b/src/makernote.hpp index 51cf2668..e94b6a54 100644 --- a/src/makernote.hpp +++ b/src/makernote.hpp @@ -22,7 +22,7 @@ @file makernote.hpp @brief Contains the %Exif %MakerNote interface, IFD %MakerNote and a MakerNote factory - @version $Name: $ $Revision: 1.13 $ + @version $Name: $ $Revision: 1.14 $ @author Andreas Huggel (ahu) ahuggel@gmx.net @date 18-Feb-04, ahu: created @@ -167,13 +167,29 @@ namespace Exif { the tag. */ virtual std::string tagName(uint16 tag) 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 uint16 tag(const std::string& tagName) 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 std::string tagDesc(uint16 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 tag(const std::string& tagName) const; + 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 tag) const; /*! @brief Return a pointer to an newly created, empty instance of the same type as this. The makernote entries are not copied. diff --git a/src/taglist.cpp b/src/taglist.cpp index 4b13cc1e..e4969bdc 100644 --- a/src/taglist.cpp +++ b/src/taglist.cpp @@ -3,25 +3,56 @@ Abstract: Print a simple comma separated list of tags defined in Exiv2 File: taglist.cpp - Version: $Name: $ $Revision: 1.3 $ + Version: $Name: $ $Revision: 1.4 $ Author(s): Andreas Huggel (ahu) History: 07-Jan-04, ahu: created */ // ***************************************************************************** #include "rcsid.hpp" -EXIV2_RCSID("@(#) $Name: $ $Revision: 1.3 $ $RCSfile: taglist.cpp,v $") +EXIV2_RCSID("@(#) $Name: $ $Revision: 1.4 $ $RCSfile: taglist.cpp,v $") +#include "makernote.hpp" #include "tags.hpp" #include "error.hpp" +#include #include using namespace Exif; -int main() +int main(int argc, char* argv[]) try { - ExifTags::taglist(std::cout); - return 0; + int rc = 0; + + std::string make("any"); + std::string model("any"); + switch (argc) { + case 3: + model = argv[2]; + // fallthrough + case 2: + { + make = argv[1]; + MakerNoteFactory& mnf = MakerNoteFactory::instance(); + MakerNote* pMakerNote = mnf.create(make, model); + if (pMakerNote) { + pMakerNote->taglist(std::cout); + } + else { + rc = -1; + } + break; + } + case 1: + ExifTags::taglist(std::cout); + break; + default: + std::cout << "Usage: " << argv[0] << " [Make [Model]]\n"; + rc = 1; + break; + } + + return rc; } catch (Error& e) { std::cout << "Caught Exif exception '" << e << "'\n"; diff --git a/src/tags.awk b/src/tags.awk index 6bf7b301..f593df7f 100644 --- a/src/tags.awk +++ b/src/tags.awk @@ -1,9 +1,9 @@ ################################################################################ # File tags.awk -# Brief Awk script to convert the taglist from ExifTags::taglist to XML -# format used in the documentation. -# $ taglist | awk -f tags.awk > tags.xml -# Version $Name: $ $Revision: 1.1 $ +# Brief Awk script to convert a taglist to XML format used in the +# documentation. +# $ taglist [make [model]] | awk -f tags.awk > tags.xml +# Version $Name: $ $Revision: 1.2 $ # Author Andreas Huggel (ahu) # ahuggel@gmx.net # Date 07-Feb-04, ahu: created diff --git a/src/tags.cpp b/src/tags.cpp index 830ef82a..c3e71ba7 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -20,13 +20,13 @@ */ /* File: tags.cpp - Version: $Name: $ $Revision: 1.23 $ + Version: $Name: $ $Revision: 1.24 $ Author(s): Andreas Huggel (ahu) History: 15-Jan-04, ahu: created */ // ***************************************************************************** #include "rcsid.hpp" -EXIV2_RCSID("@(#) $Name: $ $Revision: 1.23 $ $RCSfile: tags.cpp,v $") +EXIV2_RCSID("@(#) $Name: $ $Revision: 1.24 $ $RCSfile: tags.cpp,v $") // ***************************************************************************** // included header files @@ -415,7 +415,6 @@ namespace Exif { os << gpsTagInfo[i] << "\n"; } } // ExifTags::taglist - // ************************************************************************* // free functions