Exiv2
Loading...
Searching...
No Matches
Exiv2::XmpData Class Reference

A container for XMP data. This is a top-level class of the Exiv2 library. More...

#include <xmp_exiv2.hpp>

Public Types

using iterator = XmpMetadata::iterator
 XmpMetadata iterator type.
using const_iterator = XmpMetadata::const_iterator
 XmpMetadata const iterator type.

Public Member Functions

 XmpData ()=default
 Default constructor.
Manipulators
Xmpdatumoperator[] (const std::string &key)
 Returns a reference to the Xmpdatum that is associated with a particular key. If XmpData does not already contain such an Xmpdatum, operator[] adds object Xmpdatum(key).
int add (const XmpKey &key, const Value *value)
 Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value.
int add (const Xmpdatum &xmpdatum)
 Add a copy of the Xmpdatum to the XMP metadata.
iterator erase (XmpData::iterator pos)
void eraseFamily (XmpData::iterator &pos)
 Delete the Xmpdatum at iterator position pos and update pos erases all following keys from the same family See: https://github.com/Exiv2/exiv2/issues/521.
void clear ()
 Delete all Xmpdatum instances resulting in an empty container.
void sortByKey ()
 Sort metadata by key.
iterator begin ()
 Begin of the metadata.
iterator end ()
 End of the metadata.
iterator findKey (const XmpKey &key)
 Find the first Xmpdatum with the given key, return an iterator to it.

Accessors

const_iterator begin () const
 Begin of the metadata.
const_iterator end () const
 End of the metadata.
const_iterator findKey (const XmpKey &key) const
 Find the first Xmpdatum with the given key, return a const iterator to it.
bool empty () const
 Return true if there is no XMP metadata.
long count () const
 Get the number of metadata entries.
bool usePacket () const
 are we to use the packet?
bool usePacket (bool b)
 set usePacket_
void setPacket (std::string xmpPacket)
 setPacket
const std::string & xmpPacket () const

Detailed Description

A container for XMP data. This is a top-level class of the Exiv2 library.

Provide high-level access to the XMP data of an image:

  • read XMP information from an XML block
  • access metadata through keys and standard C++ iterators
  • add, modify and delete metadata
  • serialize XMP data to an XML block
Examples
xmpparse.cpp, xmpprint.cpp, and xmpsample.cpp.

Member Function Documentation

◆ add() [1/2]

int Exiv2::XmpData::add ( const Xmpdatum & xmpdatum)

Add a copy of the Xmpdatum to the XMP metadata.

Returns
0 if successful.

◆ add() [2/2]

int Exiv2::XmpData::add ( const XmpKey & key,
const Value * value )

Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value.

Returns
0 if successful.
Examples
xmpsample.cpp.

References add(), and Exiv2::Xmpdatum::Xmpdatum().

Referenced by add().

◆ clear()

void Exiv2::XmpData::clear ( )

Delete all Xmpdatum instances resulting in an empty container.

Referenced by Exiv2::Image::clearXmpData(), and Exiv2::XmpParser::decode().

◆ empty()

bool Exiv2::XmpData::empty ( ) const
nodiscard

Return true if there is no XMP metadata.

Examples
xmpparse.cpp, and xmpprint.cpp.

Referenced by Exiv2::ExifParser::decode(), Exiv2::XmpParser::encode(), and Exiv2::Image::xmpPacket().

◆ end()

XmpData::iterator Exiv2::XmpData::end ( )

End of the metadata.

Examples
xmpsample.cpp.

Referenced by operator[]().

◆ erase()

XmpData::iterator Exiv2::XmpData::erase ( XmpData::iterator pos)
Examples
xmpsample.cpp.

◆ eraseFamily()

void Exiv2::XmpData::eraseFamily ( XmpData::iterator & pos)

Delete the Xmpdatum at iterator position pos and update pos erases all following keys from the same family See: https://github.com/Exiv2/exiv2/issues/521.

References findKey().

◆ findKey()

XmpData::iterator Exiv2::XmpData::findKey ( const XmpKey & key)

Find the first Xmpdatum with the given key, return an iterator to it.

Examples
xmpsample.cpp.

Referenced by eraseFamily(), and operator[]().

◆ operator[]()

Xmpdatum & Exiv2::XmpData::operator[] ( const std::string & key)

Returns a reference to the Xmpdatum that is associated with a particular key. If XmpData does not already contain such an Xmpdatum, operator[] adds object Xmpdatum(key).

Note
Since operator[] might insert a new element, it can't be a const member function.

References end(), and findKey().

◆ setPacket()

void Exiv2::XmpData::setPacket ( std::string xmpPacket)
inline

setPacket

References usePacket().

◆ sortByKey()

void Exiv2::XmpData::sortByKey ( )

Sort metadata by key.

References Exiv2::cmpMetadataByKey().

◆ usePacket()

bool Exiv2::XmpData::usePacket ( ) const
inlinenodiscard

are we to use the packet?

Referenced by setPacket(), and Exiv2::TiffImage::writeMetadata().


The documentation for this class was generated from the following files: