- Main Page
- Namespaces
- Classes
- Files
- Examples

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Exiv2::Exifdatum Class Reference

Information related to one Exif tag. An Exif metadatum consists of an ExifKey and a Value and provides methods to manipulate these. More...

`#include <exif.hpp>`

Inheritance diagram for Exiv2::Exifdatum:

[legend]
Collaboration diagram for Exiv2::Exifdatum:

[legend]
List of all members.

## Public Member Functions
Creators
| Exifdatum (const ExifKey &key, const Value *pValue=0)
| 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 Entry &e, ByteOrder byteOrder)
| Constructor to build an Exifdatum from an IFD entry.
| Exifdatum (const Exifdatum &rhs)
| Copy constructor.
virtual | ~Exifdatum ()
| 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)
| Set the value. This method copies (clones) the value pointed to by pValue.
void | setValue (const std::string &value)
| 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.
void | setValue (const Entry &e, ByteOrder byteOrder)
| Set the value from an IFD entry.
int | setDataArea (const byte *buf, long len)
| Set the data area by copying (cloning) the buffer pointed to by buf.
Accessors
std::string | key () const
| Return the key of the Exifdatum.
std::string | groupName () const
std::string | tagName () const
| Return the name of the tag (which is also the third part of the key).
std::string | tagLabel () const
| Return a label for the tag.
uint16_t | tag () const
| Return the tag.
IfdId | ifdId () const
| Return the IFD id.
const char * | ifdName () const
| Return the name of the IFD.
std::string | ifdItem () const
| Return the related image item (deprecated).
int | idx () const
| Return the index (unique id of this key within the original IFD).
long | copy (byte *buf, ByteOrder byteOrder) const
| Write value to a data buffer and return the number of bytes written.
TypeId | typeId () const
| Return the type id of the value.
const char * | typeName () const
| Return the name of the type.
long | typeSize () const
| Return the size in bytes of one component of this type.
long | count () const
| Return the number of components in the value.
long | size () const
| Return the size of the value in bytes.
std::string | toString () const
| Return the value as a string.
long | toLong (long n=0) const
| Return the n-th component of the value converted to long. The return value is -1 if the value of the Exifdatum is not set and the behaviour of the method is undefined if there is no n-th component.
float | toFloat (long n=0) const
| Return the n-th component of the value converted to float. The return value is -1 if the value of the Exifdatum is not set and the behaviour of the method is undefined if there is no n-th component.
Rational | toRational (long n=0) const
| Return the n-th component of the value converted to Rational. The return value is -1/1 if the value of the Exifdatum is not set and the behaviour of the method is undefined if there is no n-th component.
Value::AutoPtr | getValue () const
| Return an auto-pointer to a copy (clone) of the value. The caller owns this copy and the auto-pointer ensures that it will be deleted.
const Value & | value () const
| Return a constant reference to the value.
long | 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.
## Friends
std::ostream & | operator<< (std::ostream &, const Exifdatum &)
| Output operator for Exifdatum types, prints the interpreted tag value.
template<typename T>
Exifdatum & | setValue (Exifdatum &, const T &)
| 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.

## Detailed Description

Information related to one Exif tag. An Exif metadatum consists of an ExifKey and a Value and provides methods to manipulate these.

Examples:

  addmoddel.cpp.

## Constructor & Destructor Documentation

Exiv2::Exifdatum::Exifdatum | ( | const ExifKey & | key,
|  | const Value * | pValue = `0`
| ) | `[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.

## Member Function Documentation

long Exiv2::Exifdatum::copy | ( | byte * | buf,
|  | ByteOrder | byteOrder
| ) | const`[inline, 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.

DataBuf Exiv2::Exifdatum::dataArea | ( |  | ) | const`[inline]`

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

Value::AutoPtr Exiv2::Exifdatum::getValue | ( |  | ) | const`[inline, virtual]`

| Return an auto-pointer to a copy (clone) of the value. The caller owns this copy and the auto-pointer 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 to a copy (clone) of the value, 0 if the value is not set. Implements Exiv2::Metadatum.

int Exiv2::Exifdatum::setDataArea | ( | const byte * | buf,
|  | long | len
| ) | `[inline]`

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

const Value & Exiv2::Exifdatum::value | ( |  | ) | const`[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. Example:
              ExifData::const_iterator i = exifData.findKey(key);
              if (i != exifData.end()) {
                  std::cout << i->key() << " " << std::hex << i->value() << "\n";
              }
  Returns: A constant reference to the value. Exceptions:
  | Error | if the value is not set.
Implements Exiv2::Metadatum. Examples: addmoddel.cpp.

## Friends And Related Function Documentation

template<typename T>
Exifdatum& setValue | ( | Exifdatum & | ,
|  | const T & |
| ) | `[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.

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

- exif.hpp
- exif.cpp