| Exiv2

Loading...
Searching...
No Matches
List of all members
Exiv2::Metadatum Class Referenceabstract

Abstract base class defining the interface to access information related to one metadata tag. More...

`#include <metadatum.hpp>`

Inheritance diagram for Exiv2::Metadatum:
[legend]

## Public Member Functions
Creators
virtual | ~Metadatum ()=default
| Destructor.

## Manipulators
virtual void | setValue (const Value *pValue)=0
| Set the value. This method copies (clones) the value pointed to by pValue.
virtual int | setValue (const std::string &buf)=0
| Set the value to the string buf. Uses Value::read(const std::string& buf). If the metadatum does not have a value yet, then one is created. See subclasses for more details. Return 0 if the value was read successfully.
Metadatum & | operator= (const Metadatum &)=default
| Assignment operator. Protected so that it can only be used by subclasses but not directly.

## Accessors
std::string | print (const ExifData *pMetadata=nullptr) const
| Write the interpreted value to a string.
virtual size_t | copy (byte *buf, ByteOrder byteOrder) const =0
| Write value to a data buffer and return the number of bytes written.
virtual std::ostream & | write (std::ostream &os, const ExifData *pMetadata=nullptr) const =0
| Write the interpreted value to an output stream, return the stream.
virtual std::string | key () const =0
| Return the key of the metadatum. The key is of the form 'familyName.groupName.tagName'. Note however that the key is not necessarily unique, e.g., an ExifData object may contain multiple metadata with the same key.
virtual const char * | familyName () const =0
| Return the name of the metadata family (which is also the first part of the key).
virtual std::string | groupName () const =0
| Return the name of the metadata group (which is also the second part of the key).
virtual std::string | tagName () const =0
| Return the name of the tag (which is also the third part of the key).
virtual std::string | tagLabel () const =0
| Return a label for the tag.
virtual std::string | tagDesc () const =0
| Return a description for the tag.
virtual uint16_t | tag () const =0
| Return the tag.
virtual TypeId | typeId () const =0
| Return the type id of the value.
virtual const char * | typeName () const =0
| Return the name of the type.
virtual size_t | typeSize () const =0
| Return the size in bytes of one component of this type.
virtual size_t | count () const =0
| Return the number of components in the value.
virtual size_t | size () const =0
| Return the size of the value in bytes.
virtual std::string | toString () const =0
| Return the value as a string.
virtual std::string | toString (size_t n) const =0
| 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.
virtual int64_t | toInt64 (size_t n=0) const =0
| 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.
uint32_t | toUint32 (size_t n=0) const
| Return the n-th component of the value converted to uint32_t.
virtual float | toFloat (size_t n=0) const =0
| 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.
virtual Rational | toRational (size_t n=0) const =0
| 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.
virtual Value::UniquePtr | getValue () const =0
| 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.
virtual const Value & | value () const =0
| Return a constant reference to the value.
| Metadatum (const Metadatum &)=default

## Detailed Description

Abstract base class defining the interface to access information related to one metadata tag.

## Member Function Documentation

## ◆ copy()

virtual size_t Exiv2::Metadatum::copy | ( | byte * | buf,
|  | ByteOrder | byteOrder ) const
| pure virtual

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

  buf | Data buffer to write to.
  byteOrder | Applicable byte order (little or big endian).

Returns
  Number of characters written.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ count()

virtual size_t Exiv2::Metadatum::count | ( |  | ) | const
| nodiscard pure virtual

Return the number of components in the value.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ familyName()

virtual const char * Exiv2::Metadatum::familyName | ( |  | ) | const
| nodiscard pure virtual

Return the name of the metadata family (which is also the first part of the key).

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ getValue()

virtual Value::UniquePtr Exiv2::Metadatum::getValue | ( |  | ) | const
| nodiscard pure virtual

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.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ groupName()

virtual std::string Exiv2::Metadatum::groupName | ( |  | ) | const
| nodiscard pure virtual

Return the name of the metadata group (which is also the second part of the key).

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ key()

virtual std::string Exiv2::Metadatum::key | ( |  | ) | const
| nodiscard pure virtual

Return the key of the metadatum. The key is of the form 'familyName.groupName.tagName'. Note however that the key is not necessarily unique, e.g., an ExifData object may contain multiple metadata with the same key.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

Referenced by Exiv2::cmpMetadataByKey().

## ◆ print()

std::string Exiv2::Metadatum::print | ( | const ExifData * | pMetadata = nullptr | ) | const

Write the interpreted value to a string.

Implemented in terms of write(), see there.

References write().

Referenced by setValue().

## ◆ setValue() [1/2]

virtual int Exiv2::Metadatum::setValue | ( | const std::string & | buf | ) |
| pure virtual

Set the value to the string buf. Uses Value::read(const std::string& buf). If the metadatum does not have a value yet, then one is created. See subclasses for more details. Return 0 if the value was read successfully.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

References print().

## ◆ setValue() [2/2]

virtual void Exiv2::Metadatum::setValue | ( | const Value * | pValue | ) |
| pure virtual

Set the value. This method copies (clones) the value pointed to by pValue.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ size()

virtual size_t Exiv2::Metadatum::size | ( |  | ) | const
| nodiscard pure virtual

Return the size of the value in bytes.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ tag()

virtual uint16_t Exiv2::Metadatum::tag | ( |  | ) | const
| nodiscard pure virtual

Return the tag.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

Referenced by Exiv2::cmpMetadataByTag().

## ◆ tagDesc()

virtual std::string Exiv2::Metadatum::tagDesc | ( |  | ) | const
| nodiscard pure virtual

Return a description for the tag.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ tagLabel()

virtual std::string Exiv2::Metadatum::tagLabel | ( |  | ) | const
| nodiscard pure virtual

Return a label for the tag.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ tagName()

virtual std::string Exiv2::Metadatum::tagName | ( |  | ) | const
| nodiscard pure virtual

Return the name of the tag (which is also the third part of the key).

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ toFloat()

virtual float Exiv2::Metadatum::toFloat | ( | size_t | n = 0 | ) | const
| nodiscard pure virtual

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.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ toInt64()

virtual int64_t Exiv2::Metadatum::toInt64 | ( | size_t | n = 0 | ) | const
| nodiscard pure virtual

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.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

References toUint32().

Referenced by toUint32().

## ◆ toRational()

virtual Rational Exiv2::Metadatum::toRational | ( | size_t | n = 0 | ) | const
| nodiscard pure virtual

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.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ toString() [1/2]

virtual std::string Exiv2::Metadatum::toString | ( |  | ) | const
| nodiscard pure virtual

Return the value as a string.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ toString() [2/2]

virtual std::string Exiv2::Metadatum::toString | ( | size_t | n | ) | const
| nodiscard pure virtual

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.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ typeId()

virtual TypeId Exiv2::Metadatum::typeId | ( |  | ) | const
| nodiscard pure virtual

Return the type id of the value.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ typeName()

virtual const char * Exiv2::Metadatum::typeName | ( |  | ) | const
| nodiscard pure virtual

Return the name of the type.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ typeSize()

virtual size_t Exiv2::Metadatum::typeSize | ( |  | ) | const
| nodiscard pure virtual

Return the size in bytes of one component of this type.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ value()

virtual const Value & Exiv2::Metadatum::value | ( |  | ) | const
| nodiscard pure virtual

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

  Error | if the value is not set.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

## ◆ write()

virtual std::ostream & Exiv2::Metadatum::write | ( | std::ostream & | os,
|  | const ExifData * | pMetadata = nullptr ) const
| pure virtual

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.

Implemented in Exiv2::Exifdatum, Exiv2::Iptcdatum, and Exiv2::Xmpdatum.

Referenced by Exiv2::operator<<(), and print().

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

- metadatum.hpp
- metadatum.cpp