Added taglist and related functions

v0.27.3
Andreas Huggel 22 years ago
parent 4407d0b25f
commit 7cc41d14d3

@ -23,7 +23,7 @@
# #
# RCS information # RCS information
# $Name: $ # $Name: $
# $Revision: 1.7 $ # $Revision: 1.8 $
# #
# Description: # Description:
# Do NOT change this file! All system specific settings and configs # 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 CCSRC = exif.cpp tags.cpp utils.cpp
# Add source files of applications to this list # 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 # Library

@ -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) <ahuggel@gmx.net>
History: 07-Jan-04, ahu: created
*/
// *****************************************************************************
#include "rcsid.hpp"
EXIV2_RCSID("@(#) $Name: $ $Revision: 1.1 $ $RCSfile: taglist.cpp,v $")
#include "tags.hpp"
#include <iostream>
using namespace Exif;
int main()
try {
ExifTags::taglist();
return 0;
}
catch (Error& e) {
std::cout << "Caught Exif exception '" << e << "'\n";
return 1;
}

@ -20,19 +20,20 @@
*/ */
/* /*
File: tags.cpp File: tags.cpp
Version: $Name: $ $Revision: 1.9 $ Version: $Name: $ $Revision: 1.10 $
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.9 $ $RCSfile: tags.cpp,v $") EXIV2_RCSID("@(#) $Name: $ $Revision: 1.10 $ $RCSfile: tags.cpp,v $")
// ***************************************************************************** // *****************************************************************************
// included header files // included header files
#include "tags.hpp" #include "tags.hpp"
#include <iostream> #include <iostream>
#include <iomanip>
// ***************************************************************************** // *****************************************************************************
// class member definitions // class member definitions
@ -304,6 +305,13 @@ namespace Exif {
return tagInfos_[ifdId][idx].name_; 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) const char* ExifTags::sectionName(uint16 tag, IfdId ifdId)
{ {
int idx = tagInfoIdx(tag, ifdId); int idx = tagInfoIdx(tag, ifdId);
@ -312,6 +320,14 @@ namespace Exif {
return sectionInfo_[tagInfo[idx].sectionId_].name_; 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) const char* ExifTags::typeName(TypeId typeId)
{ {
return tagFormat_[typeId].name_; return tagFormat_[typeId].name_;
@ -390,9 +406,37 @@ namespace Exif {
return std::make_pair(tag, ifdId); return std::make_pair(tag, ifdId);
} // ExifTags::decomposeKey } // 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 // 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) std::ostream& operator<<(std::ostream& os, const Rational& r)
{ {
return os << r.first << "/" << r.second; return os << r.first << "/" << r.second;

@ -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.9 $ @version $Name: $ $Revision: 1.10 $
@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
@ -170,6 +170,16 @@ namespace Exif {
data for the given IFD id in the lookup tables. data for the given IFD id in the lookup tables.
*/ */
static const char* tagName(uint16 tag, IfdId ifdId); 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 //! Return the tag for one combination of IFD id and tagName
static uint16 tag(const std::string& tagName, IfdId ifdId); static uint16 tag(const std::string& tagName, IfdId ifdId);
//! Return the name of the type //! Return the name of the type
@ -193,6 +203,17 @@ namespace Exif {
data for the given IFD id in the lookup tables. data for the given IFD id in the lookup tables.
*/ */
static const char* sectionName(uint16 tag, IfdId ifdId); 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 //! Return the section id for a section name
static SectionId sectionId(const std::string& sectionName); static SectionId sectionId(const std::string& sectionName);
/*! /*!
@ -208,6 +229,9 @@ namespace Exif {
*/ */
static std::pair<uint16, IfdId> decomposeKey(const std::string& key); static std::pair<uint16, IfdId> decomposeKey(const std::string& key);
//! Print a list of all tags to standart output
static void taglist();
private: private:
static int tagInfoIdx(uint16 tag, IfdId ifdId); static int tagInfoIdx(uint16 tag, IfdId ifdId);
static int tagInfoIdx(const std::string& tagName, IfdId ifdId); static int tagInfoIdx(const std::string& tagName, IfdId ifdId);
@ -223,6 +247,9 @@ namespace Exif {
// ***************************************************************************** // *****************************************************************************
// free functions // free functions
//! Output operator for TagInfo
std::ostream& operator<<(std::ostream& os, const TagInfo& ti);
//! Output operator for our fake rational //! Output operator for our fake rational
std::ostream& operator<<(std::ostream& os, const Rational& r); std::ostream& operator<<(std::ostream& os, const Rational& r);
//! Input operator for our fake rational //! Input operator for our fake rational

Loading…
Cancel
Save