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

An Exif metadatum, consisting of an ExifKey and a Value and methods to manipulate these. More...

`#include <exif.hpp>`

Inheritance diagram for Exiv2::Exifdatum:
[legend]

## Public Member Functions

Creators
| Exifdatum (const ExifKey &key, const Value *pValue=nullptr)
| Constructor for new tags created by an application. The Exifdatum is created from a key / value pair. Exifdatum copies (clones) the key and value if one is provided. Alternatively, a program can create an 'empty' Exifdatum with only a key and set the value using setValue().
| Exifdatum (const Exifdatum &rhs)
| Copy constructor.
| ~Exifdatum () override=default
| Destructor.
Manipulators
Exifdatum & | operator= (const Exifdatum &rhs)
| Assignment operator.
Exifdatum & | operator= (const uint16_t &value)
| Assign value to the Exifdatum. The type of the new Value is set to UShortValue.
Exifdatum & | operator= (const uint32_t &value)
| Assign value to the Exifdatum. The type of the new Value is set to ULongValue.
Exifdatum & | operator= (const URational &value)
| Assign value to the Exifdatum. The type of the new Value is set to URationalValue.
Exifdatum & | operator= (const int16_t &value)
| Assign value to the Exifdatum. The type of the new Value is set to ShortValue.
Exifdatum & | operator= (const int32_t &value)
| Assign value to the Exifdatum. The type of the new Value is set to LongValue.
Exifdatum & | operator= (const Rational &value)
| Assign value to the Exifdatum. The type of the new Value is set to RationalValue.
Exifdatum & | operator= (const std::string &value)
| Assign value to the Exifdatum. Calls setValue(const std::string&).
Exifdatum & | operator= (const Value &value)
| Assign value to the Exifdatum. 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 Exifdatum does not have a Value yet, then a Value of the correct type for this Exifdatum is created. An AsciiValue is created for unknown tags. Return 0 if the value was read successfully.
int | setDataArea (const byte *buf, size_t len) const
| Set the data area by copying (cloning) the buffer pointed to by buf.
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.

## Friends

template<typename T>
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. Otherwise a new ValueType<T> value is created and set to value.

## Accessors

std::string | key () const override
| Return the key of the Exifdatum.
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 (which is also the third part of the key).
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.
IfdId | ifdId () const
| Return the IFD id as an integer. (Do not use, this is meant for library internal use.).
const char * | ifdName () const
| Return the name of the IFD.
int | idx () const
| Return the index (unique id of this key within the original IFD).
size_t | copy (byte *buf, ByteOrder byteOrder) const override
| Write value to a data buffer and return the number of bytes written.
std::ostream & | write (std::ostream &os, const ExifData *pMetadata=nullptr) const override
| Write the interpreted value to an output stream, return the stream.
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.
const Value & | value () const override
| Return a constant reference to the value.
size_t | sizeDataArea () const
| Return the size of the data area.
DataBuf | dataArea () const
| Return a copy of the data area of the value. The caller owns this copy and DataBuf ensures that it will be deleted.

## 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

An Exif metadatum, consisting of an ExifKey and a Value and methods to manipulate these.

Examples
  addmoddel.cpp.

## Constructor & Destructor Documentation

## Exifdatum()

Exiv2::Exifdatum::Exifdatum | ( | const ExifKey & | key,
|  | const Value * | pValue = nullptr )

explicit

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

Parameters

  key | ExifKey.
  pValue | Pointer to an Exifdatum value.

Exceptions

  Error | if the key cannot be parsed and converted.

References Exiv2::Value::clone(), and key().

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

## Member Function Documentation

## copy()

size_t Exiv2::Exifdatum::copy | ( | byte * | buf,
|  | ByteOrder | byteOrder ) const

override 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.

Implements Exiv2::Metadatum.

Referenced by ~Exifdatum().

## count()

size_t Exiv2::Exifdatum::count | ( |  | ) | const

nodiscard override virtual

Return the number of components in the value.

Implements Exiv2::Metadatum.

Referenced by write(), and ~Exifdatum().

## dataArea()

DataBuf Exiv2::Exifdatum::dataArea | ( |  | ) | const

nodiscard

Return a copy of the data area of the value. The caller owns this copy and DataBuf ensures that it will be deleted.

Values may have a data area, which can contain additional information besides the actual value. This method is used to access such a data area.

Returns
  A DataBuf containing a copy of the data area or an empty DataBuf if the value does not have a data area assigned or the value is not set.

Referenced by ~Exifdatum().

## familyName()

const char * Exiv2::Exifdatum::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 ~Exifdatum().

## getValue()

Value::UniquePtr Exiv2::Exifdatum::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 Exiv2::Internal::TiffEncoder::encodeOffsetEntry(), Exiv2::Internal::TiffEncoder::encodeTiffEntryBase(), and ~Exifdatum().

## groupName()

std::string Exiv2::Exifdatum::groupName | ( |  | ) | const

nodiscard override virtual

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

Implements Exiv2::Metadatum.

Referenced by ~Exifdatum().

## key()

std::string Exiv2::Exifdatum::key | ( |  | ) | const

nodiscard override virtual

Return the key of the Exifdatum.

Implements Exiv2::Metadatum.

Examples
  addmoddel.cpp.

Referenced by Exifdatum(), value(), and ~Exifdatum().

## setDataArea()

int Exiv2::Exifdatum::setDataArea | ( | const byte * | buf,
|  | size_t | len ) const

Set the data area by copying (cloning) the buffer pointed to by buf.

Values may have a data area, which can contain additional information besides the actual value. This method is used to set such a data area.

Parameters

  buf | Pointer to the source data area
  len | Size of the data area

Returns
  Return -1 if the Exifdatum does not have a value yet or the value has no data area, else 0.

References setDataArea().

Referenced by setDataArea(), Exiv2::ExifThumb::setJpegThumbnail(), and ~Exifdatum().

## setValue() [1/2]

int Exiv2::Exifdatum::setValue | ( | const std::string & | value | ) |

override virtual

Set the value to the string value. Uses Value::read(const std::string&). If the Exifdatum does not have a Value yet, then a Value of the correct type for this Exifdatum is created. An AsciiValue is created for unknown tags. Return 0 if the value was read successfully.

Implements Exiv2::Metadatum.

References Exiv2::Value::create(), and value().

## setValue() [2/2]

void Exiv2::Exifdatum::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().

## size()

size_t Exiv2::Exifdatum::size | ( |  | ) | const

nodiscard override virtual

Return the size of the value in bytes.

Implements Exiv2::Metadatum.

Referenced by Exiv2::Internal::TiffEncoder::encodeOffsetEntry(), Exiv2::Internal::TiffEncoder::encodeTiffEntryBase(), and ~Exifdatum().

## tag()

uint16_t Exiv2::Exifdatum::tag | ( |  | ) | const

nodiscard override virtual

Return the tag.

Implements Exiv2::Metadatum.

Referenced by write(), and ~Exifdatum().

## tagDesc()

std::string Exiv2::Exifdatum::tagDesc | ( |  | ) | const

nodiscard override virtual

Return a description for the tag.

Implements Exiv2::Metadatum.

Referenced by ~Exifdatum().

## tagLabel()

std::string Exiv2::Exifdatum::tagLabel | ( |  | ) | const

nodiscard override virtual

Return a label for the tag.

Implements Exiv2::Metadatum.

Referenced by ~Exifdatum().

## tagName()

std::string Exiv2::Exifdatum::tagName | ( |  | ) | const

nodiscard override virtual

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

Implements Exiv2::Metadatum.

Referenced by ~Exifdatum().

## toFloat()

float Exiv2::Exifdatum::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 ~Exifdatum().

## toInt64()

int64_t Exiv2::Exifdatum::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 ~Exifdatum().

## toRational()

Rational Exiv2::Exifdatum::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 ~Exifdatum().

## toString() [1/2]

std::string Exiv2::Exifdatum::toString | ( |  | ) | const

nodiscard override virtual

Return the value as a string.

Implements Exiv2::Metadatum.

Examples
  addmoddel.cpp.

Referenced by ~Exifdatum().

## toString() [2/2]

std::string Exiv2::Exifdatum::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::Exifdatum::typeId | ( |  | ) | const

nodiscard override virtual

Return the type id of the value.

Implements Exiv2::Metadatum.

References Exiv2::invalidTypeId.

Referenced by typeName(), typeSize(), and ~Exifdatum().

## typeName()

const char * Exiv2::Exifdatum::typeName | ( |  | ) | const

nodiscard override virtual

Return the name of the type.

Implements Exiv2::Metadatum.

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

Referenced by ~Exifdatum().

## typeSize()

size_t Exiv2::Exifdatum::typeSize | ( |  | ) | const

nodiscard override virtual

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

Implements Exiv2::Metadatum.

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

Referenced by ~Exifdatum().

## value()

const Value & Exiv2::Exifdatum::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.

Examples
  addmoddel.cpp.

References key().

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

## write()

std::ostream & Exiv2::Exifdatum::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 Exiv2::comment, count(), ifdId(), Exiv2::Internal::printValue(), tag(), Exiv2::Internal::tagInfo(), Exiv2::Value::toString(), and value().

Referenced by ~Exifdatum().

## Friends And Related Symbol Documentation

## setValue

template<typename T>

Exifdatum & setValue | ( | Exiv2::Exifdatum & | exifDatum,
|  | const T & | value )

friend

Set the value of exifDatum to value. If the object already has a value, it is replaced. Otherwise a new ValueType<T> value is created and set to value.

This is a helper function, called from Exifdatum members. It is meant to be used with T = (u)int16_t, (u)int32_t or (U)Rational. Do not use directly.

Examples
  addmoddel.cpp.

References value().

Referenced by Exiv2::Converter::cnvXmpValue(), operator=(), operator=(), and ~Exifdatum().

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

- exif.hpp
- exif.cpp