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:

Public Member Functions

Creators
 Metadatum ()
 Default Constructor.
 
 Metadatum (const Metadatum &rhs)
 Copy constructor.
 
virtual ~Metadatum ()
 Destructor.
 
Accessors
std::string print (const ExifData *pMetadata=0) const
 Write the interpreted value to a string. More...
 
virtual long copy (byte *buf, ByteOrder byteOrder) const =0
 Write value to a data buffer and return the number of bytes written. More...
 
virtual std::ostream & write (std::ostream &os, const ExifData *pMetadata=0) const =0
 Write the interpreted value to an output stream, return the stream. More...
 
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 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 long typeSize () const =0
 Return the size in bytes of one component of this type.
 
virtual long count () const =0
 Return the number of components in the value.
 
virtual long 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 (long 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 long toLong (long n=0) const =0
 Return the n-th component of the value converted to long. 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 float toFloat (long 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 (long 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::AutoPtr 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. More...
 
virtual const Valuevalue () const =0
 Return a constant reference to the value. More...
 

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.
 
Metadatumoperator= (const Metadatum &rhs)
 Assignment operator. Protected so that it can only be used by subclasses but not directly.
 

Detailed Description

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

Member Function Documentation

◆ copy()

virtual long 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
bufData buffer to write to.
byteOrderApplicable byte order (little or big endian).
Returns
Number of characters written.

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

◆ getValue()

virtual Value::AutoPtr Exiv2::Metadatum::getValue ( ) const
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.

◆ print()

std::string Exiv2::Metadatum::print ( const ExifData pMetadata = 0) const

Write the interpreted value to a string.

Implemented in terms of write(), see there.

◆ value()

virtual const Value& Exiv2::Metadatum::value ( ) const
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
Errorif 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 = 0 
) 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::Xmpdatum, and Exiv2::Iptcdatum.

Referenced by Exiv2::operator<<().


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