|
Packit |
01d647 |
// ***************************************************************** -*- C++ -*-
|
|
Packit |
01d647 |
/*
|
|
Packit |
01d647 |
* Copyright (C) 2004-2018 Exiv2 authors
|
|
Packit |
01d647 |
* This program is part of the Exiv2 distribution.
|
|
Packit |
01d647 |
*
|
|
Packit |
01d647 |
* This program is free software; you can redistribute it and/or
|
|
Packit |
01d647 |
* modify it under the terms of the GNU General Public License
|
|
Packit |
01d647 |
* as published by the Free Software Foundation; either version 2
|
|
Packit |
01d647 |
* of the License, or (at your option) any later version.
|
|
Packit |
01d647 |
*
|
|
Packit |
01d647 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
01d647 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
01d647 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
01d647 |
* GNU General Public License for more details.
|
|
Packit |
01d647 |
*
|
|
Packit |
01d647 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
01d647 |
* along with this program; if not, write to the Free Software
|
|
Packit |
01d647 |
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@file tags.hpp
|
|
Packit |
01d647 |
@brief Exif tag and type information
|
|
Packit |
01d647 |
@author Andreas Huggel (ahu)
|
|
Packit |
01d647 |
ahuggel@gmx.net
|
|
Packit |
01d647 |
@date 15-Jan-04, ahu: created
|
|
Packit |
01d647 |
11-Feb-04, ahu: isolated as a component
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
#ifndef TAGS_HPP_
|
|
Packit |
01d647 |
#define TAGS_HPP_
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
#include "exiv2lib_export.h"
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// included header files
|
|
Packit |
01d647 |
#include "metadatum.hpp"
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// + standard includes
|
|
Packit |
01d647 |
#include <string>
|
|
Packit |
01d647 |
#include <iosfwd>
|
|
Packit |
01d647 |
#include <memory>
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
// namespace extensions
|
|
Packit |
01d647 |
namespace Exiv2 {
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
// class declarations
|
|
Packit |
01d647 |
class ExifData;
|
|
Packit |
01d647 |
class ExifKey;
|
|
Packit |
01d647 |
class Value;
|
|
Packit |
01d647 |
struct TagInfo;
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
// type definitions
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Type for a function pointer for functions interpreting the tag value
|
|
Packit |
01d647 |
typedef std::ostream& (*PrintFct)(std::ostream&, const Value&, const ExifData* pExifData);
|
|
Packit |
01d647 |
//! A function returning a tag list.
|
|
Packit |
01d647 |
typedef const TagInfo* (*TagListFct)();
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
// class definitions
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! The details of an Exif group. Groups include IFDs and binary arrays.
|
|
Packit |
01d647 |
struct EXIV2API GroupInfo {
|
|
Packit |
01d647 |
struct GroupName;
|
|
Packit |
01d647 |
bool operator==(int ifdId) const; //!< Comparison operator for IFD id
|
|
Packit |
01d647 |
bool operator==(const GroupName& groupName) const; //!< Comparison operator for group name
|
|
Packit |
01d647 |
int ifdId_; //!< IFD id
|
|
Packit |
01d647 |
const char* ifdName_; //!< IFD name
|
|
Packit |
01d647 |
const char* groupName_; //!< Group name, unique for each group.
|
|
Packit |
01d647 |
TagListFct tagList_; //!< Tag list
|
|
Packit |
01d647 |
};
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Search key to find a GroupInfo by its group name.
|
|
Packit |
01d647 |
struct EXIV2API GroupInfo::GroupName {
|
|
Packit |
01d647 |
explicit GroupName(const std::string& groupName);
|
|
Packit |
01d647 |
std::string g_; //!< Group name
|
|
Packit |
01d647 |
};
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Tag information
|
|
Packit |
01d647 |
struct EXIV2API TagInfo {
|
|
Packit |
01d647 |
//! Constructor
|
|
Packit |
01d647 |
TagInfo(
|
|
Packit |
01d647 |
uint16_t tag,
|
|
Packit |
01d647 |
const char* name,
|
|
Packit |
01d647 |
const char* title,
|
|
Packit |
01d647 |
const char* desc,
|
|
Packit |
01d647 |
int ifdId,
|
|
Packit |
01d647 |
int sectionId,
|
|
Packit |
01d647 |
TypeId typeId,
|
|
Packit |
01d647 |
int16_t count,
|
|
Packit |
01d647 |
PrintFct printFct
|
|
Packit |
01d647 |
);
|
|
Packit |
01d647 |
uint16_t tag_; //!< Tag
|
|
Packit |
01d647 |
const char* name_; //!< One word tag label
|
|
Packit |
01d647 |
const char* title_; //!< Tag title
|
|
Packit |
01d647 |
const char* desc_; //!< Short tag description
|
|
Packit |
01d647 |
int ifdId_; //!< Link to the (preferred) IFD
|
|
Packit |
01d647 |
int sectionId_; //!< Section id
|
|
Packit |
01d647 |
TypeId typeId_; //!< Type id
|
|
Packit |
01d647 |
int16_t count_; //!< The number of values (not bytes!), 0=any, -1=count not known.
|
|
Packit |
01d647 |
PrintFct printFct_; //!< Pointer to tag print function
|
|
Packit |
01d647 |
}; // struct TagInfo
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Access to Exif group and tag lists and misc. tag reference methods, implemented as a static class.
|
|
Packit |
01d647 |
class EXIV2API ExifTags {
|
|
Packit |
01d647 |
//! Prevent construction: not implemented.
|
|
Packit |
01d647 |
ExifTags();
|
|
Packit |
01d647 |
//! Prevent copy-construction: not implemented.
|
|
Packit |
01d647 |
ExifTags(const ExifTags& rhs);
|
|
Packit |
01d647 |
//! Prevent assignment: not implemented.
|
|
Packit |
01d647 |
ExifTags& operator=(const ExifTags& rhs);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
public:
|
|
Packit |
01d647 |
//! Return read-only list of built-in groups
|
|
Packit |
01d647 |
static const GroupInfo* groupList();
|
|
Packit |
01d647 |
//! Return read-only list of built-in \em groupName tags.
|
|
Packit |
01d647 |
static const TagInfo* tagList(const std::string& groupName);
|
|
Packit |
01d647 |
//! Print a list of all standard Exif tags to output stream
|
|
Packit |
01d647 |
static void taglist(std::ostream& os);
|
|
Packit |
01d647 |
//! Print the list of tags for \em groupName
|
|
Packit |
01d647 |
static void taglist(std::ostream& os, const std::string& groupName);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Return the name of the section for an Exif \em key.
|
|
Packit |
01d647 |
static const char* sectionName(const ExifKey& key);
|
|
Packit |
01d647 |
//! Return the default number of components (not bytes!) \em key has. (0=any, -1=count not known)
|
|
Packit |
01d647 |
static uint16_t defaultCount(const ExifKey& key);
|
|
Packit |
01d647 |
//! Return the name of the IFD for the group.
|
|
Packit |
01d647 |
static const char* ifdName(const std::string& groupName);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return true if \em groupName is a makernote group.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
static bool isMakerGroup(const std::string& groupName);
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Return true if \em groupName is a TIFF or Exif IFD, else false.
|
|
Packit |
01d647 |
This is used to differentiate between standard Exif IFDs
|
|
Packit |
01d647 |
and IFDs associated with the makernote.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
static bool isExifGroup(const std::string& groupName);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
}; // class ExifTags
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Concrete keys for Exif metadata and access to Exif tag reference data.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
class EXIV2API ExifKey : public Key {
|
|
Packit |
01d647 |
public:
|
|
Packit |
01d647 |
//! Shortcut for an %ExifKey auto pointer.
|
|
Packit |
01d647 |
typedef std::auto_ptr<ExifKey> AutoPtr;
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Creators
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Constructor to create an Exif key from a key string.
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
@param key The key string.
|
|
Packit |
01d647 |
@throw Error if the first part of the key is not 'Exif' or
|
|
Packit |
01d647 |
the remainin parts of the key cannot be parsed and
|
|
Packit |
01d647 |
converted to a group name and tag name.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
explicit ExifKey(const std::string& key);
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Constructor to create an Exif key from the tag number and
|
|
Packit |
01d647 |
group name.
|
|
Packit |
01d647 |
@param tag The tag value
|
|
Packit |
01d647 |
@param groupName The name of the group, i.e., the second part of
|
|
Packit |
01d647 |
the Exif key.
|
|
Packit |
01d647 |
@throw Error if the key cannot be constructed from the tag number
|
|
Packit |
01d647 |
and group name.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
ExifKey(uint16_t tag, const std::string& groupName);
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Constructor to create an Exif key from a TagInfo instance.
|
|
Packit |
01d647 |
@param ti The TagInfo instance
|
|
Packit |
01d647 |
@throw Error if the key cannot be constructed from the tag number
|
|
Packit |
01d647 |
and group name.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
explicit ExifKey(const TagInfo& ti);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Copy constructor
|
|
Packit |
01d647 |
ExifKey(const ExifKey& rhs);
|
|
Packit |
01d647 |
//! Destructor
|
|
Packit |
01d647 |
virtual ~ExifKey();
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Manipulators
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
/*!
|
|
Packit |
01d647 |
@brief Assignment operator.
|
|
Packit |
01d647 |
*/
|
|
Packit |
01d647 |
ExifKey& operator=(const ExifKey& rhs);
|
|
Packit |
01d647 |
//! Set the index.
|
|
Packit |
01d647 |
void setIdx(int idx);
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! @name Accessors
|
|
Packit |
01d647 |
//@{
|
|
Packit |
01d647 |
virtual std::string key() const;
|
|
Packit |
01d647 |
virtual const char* familyName() const;
|
|
Packit |
01d647 |
virtual std::string groupName() const;
|
|
Packit |
01d647 |
//! Return the IFD id as an integer. (Do not use, this is meant for library internal use.)
|
|
Packit |
01d647 |
int ifdId() const;
|
|
Packit |
01d647 |
virtual std::string tagName() const;
|
|
Packit |
01d647 |
virtual uint16_t tag() const;
|
|
Packit |
01d647 |
virtual std::string tagLabel() const;
|
|
Packit |
01d647 |
//! Return the tag description.
|
|
Packit |
01d647 |
std::string tagDesc() const; // Todo: should be in the base class
|
|
Packit |
01d647 |
//! Return the default type id for this tag.
|
|
Packit |
01d647 |
TypeId defaultTypeId() const; // Todo: should be in the base class
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
AutoPtr clone() const;
|
|
Packit |
01d647 |
//! Return the index (unique id of this key within the original Exif data, 0 if not set)
|
|
Packit |
01d647 |
int idx() const;
|
|
Packit |
01d647 |
//@}
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
private:
|
|
Packit |
01d647 |
//! Internal virtual copy constructor.
|
|
Packit |
01d647 |
virtual ExifKey* clone_() const;
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
private:
|
|
Packit |
01d647 |
// Pimpl idiom
|
|
Packit |
01d647 |
struct Impl;
|
|
Packit |
01d647 |
std::auto_ptr<Impl> p_;
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
}; // class ExifKey
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
// *****************************************************************************
|
|
Packit |
01d647 |
// free functions
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
//! Output operator for TagInfo
|
|
Packit |
01d647 |
EXIV2API std::ostream& operator<<(std::ostream& os, const TagInfo& ti);
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
} // namespace Exiv2
|
|
Packit |
01d647 |
|
|
Packit |
01d647 |
#endif // #ifndef TAGS_HPP_
|