exif.hpp
Go to the documentation of this file.
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004-2021 Exiv2 authors
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
#ifndef EXIF_HPP_
#define EXIF_HPP_
// *****************************************************************************
#include "exiv2lib_export.h"
// included header files
#include "metadatum.hpp"
#include "tags.hpp"
// + standard includes
#include <list>
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
// *****************************************************************************
// class declarations
class ExifData;
// *****************************************************************************
// class definitions
class EXIV2API Exifdatum : public Metadatum {
template<typename T> friend Exifdatum& setValue(Exifdatum&, const T&);
public:
explicit Exifdatum(const ExifKey& key, const Value* pValue =0);
Exifdatum(const Exifdatum& rhs);
virtual ~Exifdatum();
Exifdatum& operator=(const Exifdatum& rhs);
Exifdatum& operator=(const uint16_t& value);
Exifdatum& operator=(const uint32_t& value);
Exifdatum& operator=(const URational& value);
Exifdatum& operator=(const int16_t& value);
Exifdatum& operator=(const int32_t& value);
Exifdatum& operator=(const Rational& value);
Exifdatum& operator=(const std::string& value);
Exifdatum& operator=(const Value& value);
void setValue(const Value* pValue);
int setValue(const std::string& value);
int setDataArea(const byte* buf, long len);
std::string key() const;
const char* familyName() const;
std::string groupName() const;
std::string tagName() const;
std::string tagLabel() const;
uint16_t tag() const;
int ifdId() const;
const char* ifdName() const;
int idx() const;
long copy(byte* buf, ByteOrder byteOrder) const;
std::ostream& write(std::ostream& os, const ExifData* pMetadata =0) const;
TypeId typeId() const;
const char* typeName() const;
long typeSize() const;
long count() const;
long size() const;
std::string toString() const;
std::string toString(long n) const;
long toLong(long n =0) const;
float toFloat(long n =0) const;
Rational toRational(long n =0) const;
Value::AutoPtr getValue() const;
const Value& value() const;
long sizeDataArea() const;
DataBuf dataArea() const;
private:
// DATA
ExifKey::AutoPtr key_;
Value::AutoPtr value_;
}; // class Exifdatum
class EXIV2API ExifThumbC {
public:
explicit ExifThumbC(const ExifData& exifData);
DataBuf copy() const;
long writeFile(const std::string& path) const;
#ifdef EXV_UNICODE_PATH
long writeFile(const std::wstring& wpath) const;
#endif
const char* mimeType() const;
const char* extension() const;
#ifdef EXV_UNICODE_PATH
const wchar_t* wextension() const;
#endif
private:
// DATA
const ExifData& exifData_;
}; // class ExifThumb
class EXIV2API ExifThumb : public ExifThumbC {
public:
explicit ExifThumb(ExifData& exifData);
void setJpegThumbnail(
const std::string& path,
URational xres,
URational yres,
uint16_t unit
);
#ifdef EXV_UNICODE_PATH
void setJpegThumbnail(
const std::wstring& wpath,
URational xres,
URational yres,
uint16_t unit
);
#endif
void setJpegThumbnail(
const byte* buf,
long size,
URational xres,
URational yres,
uint16_t unit
);
void setJpegThumbnail(const std::string& path);
#ifdef EXV_UNICODE_PATH
void setJpegThumbnail(const std::wstring& wpath);
#endif
void setJpegThumbnail(const byte* buf, long size);
void erase();
private:
// DATA
ExifData& exifData_;
}; // class ExifThumb
typedef std::list<Exifdatum> ExifMetadata;
class EXIV2API ExifData {
public:
typedef ExifMetadata::iterator iterator;
typedef ExifMetadata::const_iterator const_iterator;
Exifdatum& operator[](const std::string& key);
void add(const ExifKey& key, const Value* pValue);
void add(const Exifdatum& exifdatum);
iterator erase(iterator pos);
iterator erase(iterator beg, iterator end);
void clear();
void sortByKey();
void sortByTag();
iterator begin() { return exifMetadata_.begin(); }
iterator end() { return exifMetadata_.end(); }
iterator findKey(const ExifKey& key);
const_iterator begin() const { return exifMetadata_.begin(); }
const_iterator end() const { return exifMetadata_.end(); }
const_iterator findKey(const ExifKey& key) const;
bool empty() const { return count() == 0; }
long count() const { return static_cast<long>(exifMetadata_.size()); }
private:
// DATA
ExifMetadata exifMetadata_;
}; // class ExifData
class EXIV2API ExifParser {
public:
static ByteOrder decode(
ExifData& exifData,
const byte* pData,
uint32_t size
);
static WriteMethod encode(
Blob& blob,
const byte* pData,
uint32_t size,
ByteOrder byteOrder,
const ExifData& exifData
);
static void encode(
Blob& blob,
ByteOrder byteOrder,
const ExifData& exifData
)
{
encode(blob, 0, 0, byteOrder, exifData);
}
}; // class ExifParser
} // namespace Exiv2
#endif // #ifndef EXIF_HPP_
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:193
Exiv2::ExifData
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition: exif.hpp:434
Exiv2::ExifData::iterator
ExifMetadata::iterator iterator
ExifMetadata iterator type.
Definition: exif.hpp:437
Exiv2::ExifData::empty
bool empty() const
Return true if there is no Exif metadata.
Definition: exif.hpp:512
Exiv2::ExifData::const_iterator
ExifMetadata::const_iterator const_iterator
ExifMetadata const iterator type.
Definition: exif.hpp:439
Exiv2::ExifData::count
long count() const
Get the number of metadata entries.
Definition: exif.hpp:514
Exiv2::ExifData::begin
iterator begin()
Begin of the metadata.
Definition: exif.hpp:490
Exiv2::ExifData::end
const_iterator end() const
End of the metadata.
Definition: exif.hpp:505
Exiv2::ExifData::end
iterator end()
End of the metadata.
Definition: exif.hpp:492
Exiv2::ExifKey
Concrete keys for Exif metadata and access to Exif tag reference data.
Definition: tags.hpp:140
Exiv2::ExifKey::AutoPtr
std::auto_ptr< ExifKey > AutoPtr
Shortcut for an ExifKey auto pointer.
Definition: tags.hpp:143
Exiv2::ExifParser
Stateless parser class for Exif data. Images use this class to decode and encode binary Exif data.
Definition: exif.hpp:529
Exiv2::ExifParser::encode
static void encode(Blob &blob, ByteOrder byteOrder, const ExifData &exifData)
Encode metadata from the provided metadata to Exif format.
Definition: exif.hpp:614
Exiv2::ExifThumbC
Access to a Exif thumbnail image. This class provides higher level accessors to the thumbnail image t...
Definition: exif.hpp:232
Exiv2::ExifThumb
Access and modify an Exif thumbnail image. This class implements manipulators to set and erase the th...
Definition: exif.hpp:301
Exiv2::Exifdatum
An Exif metadatum, consisting of an ExifKey and a Value and methods to manipulate these.
Definition: exif.hpp:59
Exiv2::Metadatum
Abstract base class defining the interface to access information related to one metadata tag.
Definition: metadatum.hpp:115
Exiv2::Value
Common interface for all types of values used with metadata.
Definition: value.hpp:51
Exiv2::Value::AutoPtr
std::auto_ptr< Value > AutoPtr
Shortcut for a Value auto pointer.
Definition: value.hpp:54
Exiv2::Internal::groupName
const char * groupName(IfdId ifdId)
Return the group name for a group id.
Definition: tags_int.cpp:2540
Exiv2::Internal::ifdName
const char * ifdName(IfdId ifdId)
Return the name of the IFD.
Definition: tags_int.cpp:2533
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::getValue
T getValue(const byte *buf, ByteOrder byteOrder)
Read a value of type T from the data buffer.
Definition: value.hpp:1363
Exiv2::TypeId
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:119
Exiv2::setValue
Exiv2::Exifdatum & setValue(Exiv2::Exifdatum &exifDatum, const T &value)
Set the value of exifDatum to value. If the object already has a value, it is replaced....
Definition: exif.cpp:193
Exiv2::writeFile
EXIV2API long writeFile(const DataBuf &buf, const std::string &path)
Write DataBuf buf to file path.
Definition: basicio.cpp:2703
Exiv2::Blob
std::vector< byte > Blob
Container for binary data.
Definition: types.hpp:151
Exiv2::ExifMetadata
std::list< Exifdatum > ExifMetadata
Container type to hold all metadata.
Definition: exif.hpp:420
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:102
Exiv2::Rational
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition: types.hpp:99
Exiv2::WriteMethod
WriteMethod
Type to indicate write method used by TIFF parsers.
Definition: types.hpp:105
Exiv2::toString
std::string toString(const T &arg)
Utility function to convert the argument of any type to a string.
Definition: types.hpp:510
Exiv2::URational
std::pair< uint32_t, uint32_t > URational
8 byte unsigned rational type.
Definition: types.hpp:97