Loading...
Searching...
No Matches
xmp_exiv2.hpp
// ***************************************************************** -*- 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 XMP_HPP_
#define XMP_HPP_
// *****************************************************************************
#include "exiv2lib_export.h"
// included header files
#include "metadatum.hpp"
#include "properties.hpp"
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
// *****************************************************************************
// class declarations
class ExifData;
// *****************************************************************************
// class definitions
class EXIV2API Xmpdatum : public Metadatum {
public:
explicit Xmpdatum(const XmpKey& key,
const Value* pValue =0);
Xmpdatum(const Xmpdatum& rhs);
virtual ~Xmpdatum();
Xmpdatum& operator=(const Xmpdatum& rhs);
Xmpdatum& operator=(const std::string& value);
Xmpdatum& operator=(const char* value);
Xmpdatum& operator=(const bool& value);
template<typename T>
Xmpdatum& operator=(const T& value);
Xmpdatum& operator=(const Value& value);
void setValue(const Value* pValue);
int setValue(const std::string& value);
long copy(byte* buf, ByteOrder byteOrder) const;
std::ostream& write(std::ostream& os, const ExifData* pMetadata =0) const;
std::string key() const;
const char* familyName() const;
std::string groupName() const;
std::string tagName() const;
std::string tagLabel() const;
uint16_t tag() const;
TypeId typeId() const;
const char* typeName() const;
// Todo: Remove this method from the baseclass
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;
private:
// Pimpl idiom
struct Impl;
std::auto_ptr<Impl> p_;
}; // class Xmpdatum
typedef std::vector<Xmpdatum> XmpMetadata;
class EXIV2API XmpData {
public:
XmpData() : xmpMetadata_(), xmpPacket_(), usePacket_(0) {}
typedef XmpMetadata::iterator iterator;
typedef XmpMetadata::const_iterator const_iterator;
Xmpdatum& operator[](const std::string& key);
int add(const XmpKey& key, const Value* value);
int add(const Xmpdatum& xmpdatum);
/*
@brief Delete the Xmpdatum at iterator position pos, return the
position of the next Xmpdatum.
@note Iterators into the metadata, including pos, are potentially
invalidated by this call.
@brief Delete the Xmpdatum at iterator position pos and update pos
*/
iterator erase(XmpData::iterator pos);
void eraseFamily(XmpData::iterator& pos);
void clear();
void sortByKey();
iterator begin();
iterator end();
iterator findKey(const XmpKey& key);
const_iterator begin() const;
const_iterator end() const;
const_iterator findKey(const XmpKey& key) const;
bool empty() const;
long count() const;
bool usePacket() const { return usePacket_; } ;
bool usePacket(bool b) { bool r = usePacket_; usePacket_=b ; return r; };
void setPacket(const std::string& xmpPacket) { xmpPacket_ = xmpPacket ; usePacket(false); };
// ! getPacket
const std::string& xmpPacket() const { return xmpPacket_ ; };
private:
// DATA
XmpMetadata xmpMetadata_;
std::string xmpPacket_ ;
bool usePacket_ ;
}; // class XmpData
class EXIV2API XmpParser {
public:
enum XmpFormatFlags {
omitPacketWrapper = 0x0010UL,
readOnlyPacket = 0x0020UL,
useCompactFormat = 0x0040UL,
includeThumbnailPad = 0x0100UL,
exactPacketLength = 0x0200UL,
writeAliasComments = 0x0400UL,
omitAllFormatting = 0x0800UL
};
static int decode( XmpData& xmpData,
const std::string& xmpPacket);
static int encode( std::string& xmpPacket,
const XmpData& xmpData,
uint16_t formatFlags =useCompactFormat,
uint32_t padding =0);
typedef void (*XmpLockFct)(void* pLockData, bool lockUnlock);
static bool initialize(XmpParser::XmpLockFct xmpLockFct =0, void* pLockData =0);
static void terminate();
private:
static void registerNs(const std::string& ns,
const std::string& prefix);
static void unregisterNs(const std::string& ns);
static void registeredNamespaces(Exiv2::Dictionary&);
// DATA
static bool initialized_;
static XmpLockFct xmpLockFct_;
static void* pLockData_;
friend class XmpProperties; // permit XmpProperties -> registerNs() and registeredNamespaces()
}; // class XmpParser
// *****************************************************************************
// free functions, template and inline definitions
inline Xmpdatum& Xmpdatum::operator=(const char* value)
{
return Xmpdatum::operator=(std::string(value));
}
inline Xmpdatum& Xmpdatum::operator=(const bool& value)
{
return operator=(value ? "True" : "False");
}
template<typename T>
Xmpdatum& Xmpdatum::operator=(const T& value)
{
setValue(Exiv2::toString(value));
return *this;
}
} // namespace Exiv2
#endif // #ifndef XMP_HPP_
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::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::XmpData
A container for XMP data. This is a top-level class of the Exiv2 library.
Definition xmp_exiv2.hpp:166
Exiv2::XmpData::XmpData
XmpData()
Default constructor.
Definition xmp_exiv2.hpp:169
Exiv2::XmpData::iterator
XmpMetadata::iterator iterator
XmpMetadata iterator type.
Definition xmp_exiv2.hpp:172
Exiv2::XmpData::usePacket
bool usePacket(bool b)
set usePacket_
Definition xmp_exiv2.hpp:248
Exiv2::XmpData::const_iterator
XmpMetadata::const_iterator const_iterator
XmpMetadata const iterator type.
Definition xmp_exiv2.hpp:174
Exiv2::XmpData::usePacket
bool usePacket() const
are we to use the packet?
Definition xmp_exiv2.hpp:245
Exiv2::XmpData::setPacket
void setPacket(const std::string &xmpPacket)
setPacket
Definition xmp_exiv2.hpp:250
Exiv2::XmpKey
Concrete keys for XMP metadata.
Definition properties.hpp:231
Exiv2::XmpParser
Stateless parser class for XMP packets. Images use this class to parse and serialize XMP packets....
Definition xmp_exiv2.hpp:268
Exiv2::XmpParser::XmpFormatFlags
XmpFormatFlags
Options to control the format of the serialized XMP packet.
Definition xmp_exiv2.hpp:271
Exiv2::XmpProperties
XMP property reference, implemented as a static class.
Definition properties.hpp:85
Exiv2::Xmpdatum
Information related to an XMP property. An XMP metadatum consists of an XmpKey and a Value and provid...
Definition xmp_exiv2.hpp:45
Exiv2::Xmpdatum::operator=
Xmpdatum & operator=(const Xmpdatum &rhs)
Assignment operator.
Definition xmp.cpp:330
Exiv2::Xmpdatum::value
const Value & value() const
Return a constant reference to the value.
Definition xmp.cpp:427
Exiv2::Xmpdatum::setValue
void setValue(const Value *pValue)
Set the value. This method copies (clones) the value pointed to by pValue.
Definition xmp.cpp:456
Exiv2::Internal::groupName
const char * groupName(IfdId ifdId)
Return the group name for a group id.
Definition tags_int.cpp:2569
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.
Exiv2::TypeId
TypeId
Exiv2 value type identifiers.
Definition types.hpp:119
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::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:194
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::XmpMetadata
std::vector< Xmpdatum > XmpMetadata
Container type to hold all metadata.
Definition xmp_exiv2.hpp:154
Exiv2::Dictionary
std::map< std::string, std::string > Dictionary
typedef for string:string map
Definition datasets.hpp:364