| Exiv2

Loading...
Searching...
No Matches
Classes | List of all members
Exiv2::Xmpdatum Class Reference

Information related to an XMP property. An XMP metadatum consists of an XmpKey and a Value and provides methods to manipulate these. More...

`#include <xmp_exiv2.hpp>`

Inheritance diagram for Exiv2::Xmpdatum:
[legend]

## Classes
struct | Impl
| Internal Pimpl structure of class Xmpdatum. More...

## Public Member Functions
Creators
| Xmpdatum (const XmpKey &key, const Value *pValue=nullptr)
| Constructor for new tags created by an application. The Xmpdatum is created from a key / value pair. Xmpdatum copies (clones) the value if one is provided. Alternatively, a program can create an 'empty' Xmpdatum with only a key and set the value using setValue().
| Xmpdatum (const Xmpdatum &rhs)
| Copy constructor.
| ~Xmpdatum () override
| Destructor.
Manipulators
Xmpdatum & | operator= (const Xmpdatum &rhs)
| Assignment operator.
Xmpdatum & | operator= (const std::string &value)
| Assign std::string value to the Xmpdatum. Calls setValue(const std::string&).
template<typename T>
Xmpdatum & | operator= (const T &value)
| Assign a value of any type with an output operator to the Xmpdatum. Calls operator=(const std::string&).
Xmpdatum & | operator= (const Value &value)
| Assign Value value to the Xmpdatum. 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. Uses Value::read(const std::string&). If the Xmpdatum does not have a Value yet, then a Value of the correct type for this Xmpdatum is created. If the key is unknown, a XmpTextValue is used as default. 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.
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
| Not implemented. Calling this method will raise an exception.
std::ostream & | write (std::ostream &os, const ExifData *pMetadata=nullptr) const override
| Write the interpreted value to an output stream, return the stream.
std::string | key () const override
| Return the key of the Xmpdatum. The key is of the form 'Xmp.prefix.property'. Note however that the key is not necessarily unique, i.e., an XmpData object may contain multiple metadata with the same key.
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 (preferred) schema namespace prefix.
std::string | tagName () const override
| Return the property name.
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
| Properties don't have a tag number. Return 0.
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
| The Exif typeSize doesn't make sense here. Return 0.
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.
const Value & | value () const override
| Return a constant reference to the value.

## Additional Inherited Members
Metadatum & | operator= (const Metadatum &)=default
| Assignment operator. Protected so that it can only be used by subclasses but not directly.
| Metadatum (const Metadatum &)=default

## Detailed Description

Information related to an XMP property. An XMP metadatum consists of an XmpKey and a Value and provides methods to manipulate these.

## Constructor & Destructor Documentation

## ◆ Xmpdatum()

Exiv2::Xmpdatum::Xmpdatum | ( | const XmpKey & | key,
|  | const Value * | pValue = nullptr )
| explicit

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

Parameters

  key | The key of the Xmpdatum.
  pValue | Pointer to a Xmpdatum value.

Exceptions

  Error | if the key cannot be parsed and converted to a known schema namespace prefix and property name.

References key().

Referenced by operator=(), operator=(), operator=(), operator=(), Xmpdatum(), and ~Xmpdatum().

## Member Function Documentation

## ◆ copy()

size_t Exiv2::Xmpdatum::copy | ( | byte * | buf,
|  | ByteOrder | byteOrder ) const
| override virtual

Not implemented. Calling this method will raise an exception.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ count()

size_t Exiv2::Xmpdatum::count | ( |  | ) | const
| nodiscard override virtual

Return the number of components in the value.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ familyName()

const char * Exiv2::Xmpdatum::familyName | ( |  | ) | const
| nodiscard override virtual

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

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ getValue()

Value::UniquePtr Exiv2::Xmpdatum::getValue | ( |  | ) | const
| nodiscard override 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.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ groupName()

std::string Exiv2::Xmpdatum::groupName | ( |  | ) | const
| nodiscard override virtual

Return the (preferred) schema namespace prefix.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ key()

std::string Exiv2::Xmpdatum::key | ( |  | ) | const
| nodiscard override virtual

Return the key of the Xmpdatum. The key is of the form 'Xmp.prefix.property'. Note however that the key is not necessarily unique, i.e., an XmpData object may contain multiple metadata with the same key.

Implements Exiv2::Metadatum.

Referenced by Exiv2::Xmpdatum::Impl::Impl(), value(), write(), Xmpdatum(), and ~Xmpdatum().

## ◆ setValue() [1/2]

int Exiv2::Xmpdatum::setValue | ( | const std::string & | value | ) |
| override virtual

Set the value to the string value. Uses Value::read(const std::string&). If the Xmpdatum does not have a Value yet, then a Value of the correct type for this Xmpdatum is created. If the key is unknown, a XmpTextValue is used as default. Return 0 if the value was read successfully.

Implements Exiv2::Metadatum.

References Exiv2::Value::create(), Exiv2::XmpProperties::propertyType(), value(), and Exiv2::xmpText.

## ◆ setValue() [2/2]

void Exiv2::Xmpdatum::setValue | ( | const Value * | pValue | ) |
| override virtual

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

Implements Exiv2::Metadatum.

References Exiv2::Value::clone().

Referenced by operator=(), operator=(), operator=(), and ~Xmpdatum().

## ◆ size()

size_t Exiv2::Xmpdatum::size | ( |  | ) | const
| nodiscard override virtual

Return the size of the value in bytes.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ tag()

uint16_t Exiv2::Xmpdatum::tag | ( |  | ) | const
| nodiscard override virtual

Properties don't have a tag number. Return 0.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ tagDesc()

std::string Exiv2::Xmpdatum::tagDesc | ( |  | ) | const
| nodiscard override virtual

Return a description for the tag.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ tagLabel()

std::string Exiv2::Xmpdatum::tagLabel | ( |  | ) | const
| nodiscard override virtual

Return a label for the tag.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ tagName()

std::string Exiv2::Xmpdatum::tagName | ( |  | ) | const
| nodiscard override virtual

Return the property name.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ toFloat()

float Exiv2::Xmpdatum::toFloat | ( | size_t | n = 0 | ) | const
| nodiscard override 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.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ toInt64()

int64_t Exiv2::Xmpdatum::toInt64 | ( | size_t | n = 0 | ) | const
| nodiscard override 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.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ toRational()

Rational Exiv2::Xmpdatum::toRational | ( | size_t | n = 0 | ) | const
| nodiscard override 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.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ toString() [1/2]

std::string Exiv2::Xmpdatum::toString | ( |  | ) | const
| nodiscard override virtual

Return the value as a string.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ toString() [2/2]

std::string Exiv2::Xmpdatum::toString | ( | size_t | n | ) | const
| nodiscard override 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.

Implements Exiv2::Metadatum.

## ◆ typeId()

TypeId Exiv2::Xmpdatum::typeId | ( |  | ) | const
| nodiscard override virtual

Return the type id of the value.

Implements Exiv2::Metadatum.

References Exiv2::invalidTypeId.

Referenced by typeName(), and ~Xmpdatum().

## ◆ typeName()

const char * Exiv2::Xmpdatum::typeName | ( |  | ) | const
| nodiscard override virtual

Return the name of the type.

Implements Exiv2::Metadatum.

References typeId(), and Exiv2::TypeInfo::typeName().

Referenced by ~Xmpdatum().

## ◆ typeSize()

size_t Exiv2::Xmpdatum::typeSize | ( |  | ) | const
| nodiscard override virtual

The Exif typeSize doesn't make sense here. Return 0.

Implements Exiv2::Metadatum.

Referenced by ~Xmpdatum().

## ◆ value()

const Value & Exiv2::Xmpdatum::value | ( |  | ) | const
| nodiscard override 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.

Implements Exiv2::Metadatum.

References key().

Referenced by operator=(), operator=(), operator=(), setValue(), write(), and ~Xmpdatum().

## ◆ write()

std::ostream & Exiv2::Xmpdatum::write | ( | std::ostream & | os,
|  | const ExifData * | pMetadata = nullptr ) const
| override 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.

Implements Exiv2::Metadatum.

References key(), Exiv2::XmpProperties::printProperty(), and value().

Referenced by ~Xmpdatum().

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

- xmp_exiv2.hpp
- xmp.cpp