Exiv2::Iptcdatum Class Reference

An IPTC metadatum ("dataset"), consisting of an IptcKey and a Value and methods to manipulate these. More...

#include <iptc.hpp>

Inheritance diagram for Exiv2::Iptcdatum:

Public Member Functions

Creators
 Iptcdatum (const IptcKey &key, const Value *pValue=nullptr)
 Constructor for new tags created by an application. The Iptcdatum is created from a key / value pair. Iptcdatum copies (clones) the value if one is provided. Alternatively, a program can create an 'empty' Iptcdatum with only a key and set the value using setValue(). More...
 
 Iptcdatum (const Iptcdatum &rhs)
 Copy constructor.
 
 ~Iptcdatum () override=default
 Destructor.
 
Manipulators
Iptcdatumoperator= (const Iptcdatum &rhs)
 Assignment operator.
 
Iptcdatumoperator= (const uint16_t &value)
 Assign value to the Iptcdatum. The type of the new Value is set to UShortValue.
 
Iptcdatumoperator= (const std::string &value)
 Assign value to the Iptcdatum. Calls setValue(const std::string&).
 
Iptcdatumoperator= (const Value &value)
 Assign value to the Iptcdatum. Calls setValue(const Value*).
 
void setValue (const Value *pValue) override
 Set the value. This method copies (clones) the value pointed to by pValue.
 
int setValue (const std::string &value) override
 Set the value to the string value, using Value::read(const std::string&). If the Iptcdatum does not have a Value yet, then a Value of the correct type for this Iptcdatum is created. If that fails (because of an unknown dataset), a StringValue is created. Return 0 if the value was read successfully.
 
- Public Member Functions inherited from Exiv2::Metadatum
virtual ~Metadatum ()=default
 Destructor.
 
std::string print (const ExifData *pMetadata=nullptr) const
 Write the interpreted value to a string. More...
 
uint32_t toUint32 (size_t n=0) const
 Return the n-th component of the value converted to uint32_t.
 

Accessors

size_t copy (byte *buf, ByteOrder byteOrder) const override
 Write value to a data buffer and return the number of bytes written. More...
 
std::ostream & write (std::ostream &os, const ExifData *pMetadata=nullptr) const override
 Write the interpreted value to an output stream, return the stream. More...
 
std::string key () const override
 Return the key of the Iptcdatum. The key is of the form 'Iptc.recordName.datasetName'. Note however that the key is not necessarily unique, i.e., an IptcData object may contain multiple metadata with the same key.
 
std::string recordName () const
 Return the name of the record (deprecated) More...
 
uint16_t record () const
 Return the record id. More...
 
const char * familyName () const override
 Return the name of the metadata family (which is also the first part of the key)
 
std::string groupName () const override
 Return the name of the metadata group (which is also the second part of the key)
 
std::string tagName () const override
 Return the name of the tag (aka dataset) More...
 
std::string tagLabel () const override
 Return a label for the tag.
 
std::string tagDesc () const override
 Return a description for the tag.
 
uint16_t tag () const override
 Return the tag (aka dataset) number.
 
TypeId typeId () const override
 Return the type id of the value.
 
const char * typeName () const override
 Return the name of the type.
 
size_t typeSize () const override
 Return the size in bytes of one component of this type.
 
size_t count () const override
 Return the number of components in the value.
 
size_t size () const override
 Return the size of the value in bytes.
 
std::string toString () const override
 Return the value as a string.
 
std::string toString (size_t n) const override
 Return the n-th component of the value converted to a string. The behaviour of the method is undefined if there is no n-th component.
 
int64_t toInt64 (size_t n=0) const override
 Return the n-th component of the value converted to int64_t. The return value is -1 if the value is not set and the behaviour of the method is undefined if there is no n-th component.
 
float toFloat (size_t n=0) const override
 Return the n-th component of the value converted to float. The return value is -1 if the value is not set and the behaviour of the method is undefined if there is no n-th component.
 
Rational toRational (size_t n=0) const override
 Return the n-th component of the value converted to Rational. The return value is -1/1 if the value is not set and the behaviour of the method is undefined if there is no n-th component.
 
Value::UniquePtr getValue () const override
 Return an auto-pointer to a copy (clone) of the value. The caller owns this copy and the auto-poiner ensures that it will be deleted. More...
 
const Valuevalue () const override
 Return a constant reference to the value. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Exiv2::Metadatum
Metadatumoperator= (const Metadatum &)=default
 Assignment operator. Protected so that it can only be used by subclasses but not directly.
 
 Metadatum ()=default
 
 Metadatum (const Metadatum &)=default
 

Detailed Description

An IPTC metadatum ("dataset"), consisting of an IptcKey and a Value and methods to manipulate these.

This is referred in the standard as a property.

Constructor & Destructor Documentation

◆ Iptcdatum()

Exiv2::Iptcdatum::Iptcdatum ( const IptcKey key,
const Value pValue = nullptr 
)
explicit

Constructor for new tags created by an application. The Iptcdatum is created from a key / value pair. Iptcdatum copies (clones) the value if one is provided. Alternatively, a program can create an 'empty' Iptcdatum with only a key and set the value using setValue().

Parameters
keyThe key of the Iptcdatum.
pValuePointer to a Iptcdatum value.
Exceptions
Errorif the key cannot be parsed and converted to a tag number and record id.

Member Function Documentation

◆ copy()

size_t Exiv2::Iptcdatum::copy ( byte buf,
ByteOrder  byteOrder 
) const
overridevirtual

Write value to a data buffer and return the number of bytes written.

The user must ensure that the buffer has enough memory. Otherwise the call results in undefined behaviour.

Parameters
bufData buffer to write to.
byteOrderApplicable byte order (little or big endian).
Returns
Number of characters written.

Implements Exiv2::Metadatum.

◆ getValue()

Value::UniquePtr Exiv2::Iptcdatum::getValue ( ) const
overridevirtual

Return an auto-pointer to a copy (clone) of the value. The caller owns this copy and the auto-poiner ensures that it will be deleted.

This method is provided for users who need full control over the value. A caller may, e.g., downcast the pointer to the appropriate subclass of Value to make use of the interface of the subclass to set or modify its contents.

Returns
An auto-pointer containing a pointer to a copy (clone) of the value, 0 if the value is not set.

Implements Exiv2::Metadatum.

◆ record()

uint16_t Exiv2::Iptcdatum::record ( ) const

Return the record id.

Returns
record id

◆ recordName()

std::string Exiv2::Iptcdatum::recordName ( ) const

Return the name of the record (deprecated)

Returns
record name

◆ tagName()

std::string Exiv2::Iptcdatum::tagName ( ) const
overridevirtual

Return the name of the tag (aka dataset)

Returns
tag name

Implements Exiv2::Metadatum.

◆ value()

const Value& Exiv2::Iptcdatum::value ( ) const
overridevirtual

Return a constant reference to the value.

This method is provided mostly for convenient and versatile output of the value which can (to some extent) be formatted through standard stream manipulators. Do not attempt to write to the value through this reference. An Error is thrown if the value is not set; as an alternative to catching it, one can use count() to check if there is any data before calling this method.

Returns
A constant reference to the value.
Exceptions
Errorif the value is not set.

Implements Exiv2::Metadatum.

◆ write()

std::ostream& Exiv2::Iptcdatum::write ( std::ostream &  os,
const ExifData pMetadata = nullptr 
) const
overridevirtual

Write the interpreted value to an output stream, return the stream.

The method takes an optional pointer to a metadata container. Pretty-print functions may use that to refer to other metadata as it is sometimes not sufficient to know only the value of the metadatum that should be interpreted. Thus, it is advisable to always call this method with a pointer to the metadata container if possible.

This functionality is currently only implemented for Exif tags. The pointer is ignored when used to write IPTC datasets or XMP properties.

Without the optional metadata pointer, you do not usually have to use this function; it is used for the implementation of the output operator for Metadatum, operator<<(std::ostream &os, const Metadatum &md).

See also print(), which prints the interpreted value to a string.

Implements Exiv2::Metadatum.


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