diff --git a/src/Makefile b/src/Makefile index c4d087b4..97311182 100644 --- a/src/Makefile +++ b/src/Makefile @@ -23,7 +23,7 @@ # # RCS information # $Name: $ -# $Revision: 1.7 $ +# $Revision: 1.8 $ # # Description: # Do NOT change this file! All system specific settings and configs @@ -58,7 +58,7 @@ CCHDR = rcsid.hpp CCSRC = exif.cpp tags.cpp utils.cpp # Add source files of applications to this list -BINSRC = exiftest.cpp exifprint.cpp example1.cpp +BINSRC = exiftest.cpp exifprint.cpp example1.cpp taglist.cpp # ********************************************************************** # Library diff --git a/src/taglist.cpp b/src/taglist.cpp new file mode 100644 index 00000000..c69cc9d1 --- /dev/null +++ b/src/taglist.cpp @@ -0,0 +1,27 @@ +// ***************************************************************** -*- C++ -*- +/* + Abstract: Print a simple comma separated list of tags defined in Exiv2 + + File: taglist.cpp + Version: $Name: $ $Revision: 1.1 $ + Author(s): Andreas Huggel (ahu) + History: 07-Jan-04, ahu: created + */ +// ***************************************************************************** +#include "rcsid.hpp" +EXIV2_RCSID("@(#) $Name: $ $Revision: 1.1 $ $RCSfile: taglist.cpp,v $") + +#include "tags.hpp" +#include + +using namespace Exif; + +int main() +try { + ExifTags::taglist(); + return 0; +} +catch (Error& e) { + std::cout << "Caught Exif exception '" << e << "'\n"; + return 1; +} diff --git a/src/tags.cpp b/src/tags.cpp index 827e94df..01930a98 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -20,19 +20,20 @@ */ /* File: tags.cpp - Version: $Name: $ $Revision: 1.9 $ + Version: $Name: $ $Revision: 1.10 $ Author(s): Andreas Huggel (ahu) History: 15-Jan-04, ahu: created */ // ***************************************************************************** #include "rcsid.hpp" -EXIV2_RCSID("@(#) $Name: $ $Revision: 1.9 $ $RCSfile: tags.cpp,v $") +EXIV2_RCSID("@(#) $Name: $ $Revision: 1.10 $ $RCSfile: tags.cpp,v $") // ***************************************************************************** // included header files #include "tags.hpp" #include +#include // ***************************************************************************** // class member definitions @@ -304,6 +305,13 @@ namespace Exif { return tagInfos_[ifdId][idx].name_; } + const char* ExifTags::tagDesc(uint16 tag, IfdId ifdId) + { + int idx = tagInfoIdx(tag, ifdId); + if (idx == -1) throw Error("No taginfo for IFD"); + return tagInfos_[ifdId][idx].desc_; + } + const char* ExifTags::sectionName(uint16 tag, IfdId ifdId) { int idx = tagInfoIdx(tag, ifdId); @@ -312,6 +320,14 @@ namespace Exif { return sectionInfo_[tagInfo[idx].sectionId_].name_; } + const char* ExifTags::sectionDesc(uint16 tag, IfdId ifdId) + { + int idx = tagInfoIdx(tag, ifdId); + if (idx == -1) throw Error("No taginfo for IFD"); + const TagInfo* tagInfo = tagInfos_[ifdId]; + return sectionInfo_[tagInfo[idx].sectionId_].desc_; + } + const char* ExifTags::typeName(TypeId typeId) { return tagFormat_[typeId].name_; @@ -390,9 +406,37 @@ namespace Exif { return std::make_pair(tag, ifdId); } // ExifTags::decomposeKey + void ExifTags::taglist() + { + for (int i=0; ifdTagInfo[i].tag_ != 0xffff; ++i) { + std::cout << ifdTagInfo[i] << "\n"; + } + for (int i=0; exifTagInfo[i].tag_ != 0xffff; ++i) { + std::cout << exifTagInfo[i] << "\n"; + } + for (int i=0; iopTagInfo[i].tag_ != 0xffff; ++i) { + std::cout << iopTagInfo[i] << "\n"; + } + for (int i=0; gpsTagInfo[i].tag_ != 0xffff; ++i) { + std::cout << gpsTagInfo[i] << "\n"; + } + } // ExifTags::taglist + + // ************************************************************************* // free functions + std::ostream& operator<<(std::ostream& os, const TagInfo& ti) + { + return os << ExifTags::tagName(ti.tag_, ti.ifdId_) << ", " + << std::dec << ti.tag_ << ", " + << "0x" << std::setw(4) << std::setfill('0') + << std::right << std::hex << ti.tag_ << ", " + << ExifTags::ifdName(ti.ifdId_) << ", " + << ExifTags::makeKey(ti.tag_, ti.ifdId_) << ", " + << ExifTags::tagDesc(ti.tag_, ti.ifdId_); + } + std::ostream& operator<<(std::ostream& os, const Rational& r) { return os << r.first << "/" << r.second; diff --git a/src/tags.hpp b/src/tags.hpp index cc19a517..a3a04959 100644 --- a/src/tags.hpp +++ b/src/tags.hpp @@ -21,7 +21,7 @@ /*! @file tags.hpp @brief %Exif tag and type information - @version $Name: $ $Revision: 1.9 $ + @version $Name: $ $Revision: 1.10 $ @author Andreas Huggel (ahu) ahuggel@gmx.net @date 15-Jan-04, ahu: created @@ -170,6 +170,16 @@ namespace Exif { data for the given IFD id in the lookup tables. */ static const char* tagName(uint16 tag, IfdId ifdId); + /*! + @brief Return the description of the tag. + @param tag The tag + @param ifdId IFD id + @return The description of the tag or a string indicating that + the tag is unknown. + @throw Error ("No taginfo for IFD") if there is no tag info + data for the given IFD id in the lookup tables. + */ + static const char* tagDesc(uint16 tag, IfdId ifdId); //! Return the tag for one combination of IFD id and tagName static uint16 tag(const std::string& tagName, IfdId ifdId); //! Return the name of the type @@ -193,6 +203,17 @@ namespace Exif { data for the given IFD id in the lookup tables. */ static const char* sectionName(uint16 tag, IfdId ifdId); + /*! + @brief Return the description of the section for a combination of + tag and IFD id. + @param tag The tag + @param ifdId IFD id + @return The description of the section or a string indicating that + the section or the tag is unknown. + @throw Error ("No taginfo for IFD") if there is no tag info + data for the given IFD id in the lookup tables. + */ + static const char* sectionDesc(uint16 tag, IfdId ifdId); //! Return the section id for a section name static SectionId sectionId(const std::string& sectionName); /*! @@ -208,6 +229,9 @@ namespace Exif { */ static std::pair decomposeKey(const std::string& key); + //! Print a list of all tags to standart output + static void taglist(); + private: static int tagInfoIdx(uint16 tag, IfdId ifdId); static int tagInfoIdx(const std::string& tagName, IfdId ifdId); @@ -223,6 +247,9 @@ namespace Exif { // ***************************************************************************** // free functions + //! Output operator for TagInfo + std::ostream& operator<<(std::ostream& os, const TagInfo& ti); + //! Output operator for our fake rational std::ostream& operator<<(std::ostream& os, const Rational& r); //! Input operator for our fake rational