Exiv2::Value Class Referenceabstract

Common interface for all types of values used with metadata. More...

`#include <value.hpp>`

Inheritance diagram for Exiv2::Value:
[legend]

## Public Types

typedef std::auto_ptr< Value > | AutoPtr
| Shortcut for a Value auto pointer.

## Public Member Functions

Creators
| Value (TypeId typeId)
| Constructor, taking a type id to initialize the base class with.
virtual | ~Value ()
| Virtual destructor.
Manipulators
virtual int | read (const byte *buf, long len, ByteOrder byteOrder)=0
| Read the value from a character buffer. More...
virtual int | read (const std::string &buf)=0
| Set the value from a string buffer. The format of the string corresponds to that of the write() method, i.e., a string obtained through the write() method can be read by this function. More...
virtual int | setDataArea (const byte *buf, long len)
| Set the data area, if the value has one by copying (cloning) the buffer pointed to by buf. More...

## Accessors

bool | ok_
| Indicates the status of the previous to<Type> conversion.
TypeId | typeId () const
| Return the type identifier (Exif data format type).
AutoPtr | clone () const
| Return an auto-pointer to a copy of itself (deep copy). The caller owns this copy and the auto-pointer ensures that it will be deleted.
virtual long | copy (byte *buf, ByteOrder byteOrder) const =0
| Write value to a data buffer. More...
virtual long | count () const =0
| Return the number of components of the value.
virtual long | size () const =0
| Return the size of the value in bytes.
virtual std::ostream & | write (std::ostream &os) const =0
| Write the value to an output stream. You do not usually have to use this function; it is used for the implementation of the output operator for Value, operator<<(std::ostream &os, const Value &value).
std::string | toString () const
| Return the value as a string. Implemented in terms of write(std::ostream& os) const of the concrete class.
virtual std::string | toString (long n) const
| Return the n-th component of the value as a string. The default implementation returns toString(). The behaviour of this method may be undefined if there is no n-th component.
virtual long | toLong (long n=0) const =0
| Convert the n-th component of the value to a long. The behaviour of this method may be undefined if there is no n-th component. More...
virtual float | toFloat (long n=0) const =0
| Convert the n-th component of the value to a float. The behaviour of this method may be undefined if there is no n-th component. More...
virtual Rational | toRational (long n=0) const =0
| Convert the n-th component of the value to a Rational. The behaviour of this method may be undefined if there is no n-th component. More...
virtual long | sizeDataArea () const
| Return the size of the data area, 0 if there is none.
virtual DataBuf | dataArea () const
| Return a copy of the data area if the value has one. The caller owns this copy and DataBuf ensures that it will be deleted. More...
bool | ok () const
| Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversion was successful.
static AutoPtr | create (TypeId typeId)
| A (simple) factory to create a Value type. More...
Value & | operator= (const Value &rhs)
| Assignment operator. Protected so that it can only be used by subclasses but not directly.

## Detailed Description

Common interface for all types of values used with metadata.

The interface provides a uniform way to access values independent of their actual C++ type for simple tasks like reading the values from a string or data buffer. For other tasks, like modifying values you may need to downcast it to a specific subclass to access its interface.

Examples
  xmpsample.cpp.

## Member Function Documentation

## copy()

virtual long Exiv2::Value::copy | ( | byte * | buf,
|  | ByteOrder | byteOrder
| ) |  | const

pure virtual

Write value to a data buffer.

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

Implemented in Exiv2::TimeValue, Exiv2::DateValue, Exiv2::XmpValue, Exiv2::StringValueBase, Exiv2::DataValue, Exiv2::ValueType< T >, and Exiv2::CommentValue.

Referenced by Exiv2::Internal::TiffEntryBase::doWrite(), Exiv2::Internal::TiffBinaryElement::doWrite(), and Exiv2::Internal::printUcs2().

## create()

Value::AutoPtr Exiv2::Value::create | ( | TypeId | typeId | ) |

static

A (simple) factory to create a Value type.

The following Value subclasses are created depending on typeId:

typeId | Value subclass
`invalidTypeId` | DataValue(invalidTypeId)
`unsignedByte` | DataValue(unsignedByte)
`asciiString` | AsciiValue
`string` | StringValue
`unsignedShort` | ValueType < uint16_t >
`unsignedLong` | ValueType < uint32_t >
`unsignedRational` | ValueType < URational >
`invalid6` | DataValue(invalid6)
`undefined` | DataValue
`signedShort` | ValueType < int16_t >
`signedLong` | ValueType < int32_t >
`signedRational` | ValueType < Rational >
`tiffFloat` | ValueType < float >
`tiffDouble` | ValueType < double >
`tiffIfd` | ValueType < uint32_t >
`date` | DateValue
`time` | TimeValue
`comment` | CommentValue
`xmpText` | XmpTextValue
`xmpBag` | XmpArrayValue
`xmpSeq` | XmpArrayValue
`xmpAlt` | XmpArrayValue
`langAlt` | LangAltValue
default | DataValue(typeId)

Parameters

  typeId | Type of the value.

Returns
  Auto-pointer to the newly created Value. The caller owns this copy and the auto-pointer ensures that it will be deleted.

Examples
  addmoddel.cpp, and xmpsample.cpp.

References Exiv2::asciiString, Exiv2::comment, Exiv2::date, Exiv2::invalidTypeId, Exiv2::langAlt, Exiv2::signedByte, Exiv2::signedLong, Exiv2::signedRational, Exiv2::signedShort, Exiv2::string, Exiv2::tiffDouble, Exiv2::tiffFloat, Exiv2::tiffIfd, Exiv2::time, typeId(), Exiv2::undefined, Exiv2::unsignedByte, Exiv2::unsignedLong, Exiv2::unsignedRational, Exiv2::unsignedShort, Exiv2::xmpAlt, Exiv2::xmpBag, Exiv2::xmpSeq, and Exiv2::xmpText.

Referenced by Exiv2::Internal::TiffDecoder::decodeCanonAFInfo(), Exiv2::Internal::CiffComponent::doPrint(), Exiv2::Internal::TiffReader::readTiffEntry(), Exiv2::Exifdatum::setValue(), Exiv2::Iptcdatum::setValue(), Exiv2::Xmpdatum::setValue(), and Exiv2::Internal::TiffReader::visitBinaryElement().

## dataArea()

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

virtual

Return a copy of the data area if the value has one. 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.

Reimplemented in Exiv2::ValueType< T >.

Referenced by Exiv2::Internal::TiffDataEntry::doWriteData(), and Exiv2::Internal::TiffImageEntry::doWriteImage().

## read() [1/2]

virtual int Exiv2::Value::read | ( | const byte * | buf,
|  | long | len,
|  | ByteOrder | byteOrder
| ) |  |

pure virtual

Read the value from a character buffer.

Parameters

  buf | Pointer to the data buffer to read from
  len | Number of bytes in the data buffer
  byteOrder | Applicable byte order (little or big endian).

Returns
  0 if successful.

Implemented in Exiv2::TimeValue, Exiv2::DateValue, Exiv2::XmpValue, Exiv2::StringValueBase, Exiv2::DataValue, Exiv2::ValueType< T >, and Exiv2::CommentValue.

## read() [2/2]

virtual int Exiv2::Value::read | ( | const std::string & | buf | ) |

pure virtual

Set the value from a string buffer. The format of the string corresponds to that of the write() method, i.e., a string obtained through the write() method can be read by this function.

Parameters

  buf | The string to read from.

Returns
  0 if successful.

Implemented in Exiv2::CommentValue, Exiv2::XmpValue, Exiv2::ValueType< T >, Exiv2::TimeValue, Exiv2::DateValue, Exiv2::LangAltValue, Exiv2::XmpArrayValue, Exiv2::XmpTextValue, Exiv2::AsciiValue, Exiv2::StringValueBase, and Exiv2::DataValue.

## setDataArea()

int Exiv2::Value::setDataArea | ( | const byte * | buf,
|  | long | len
| ) |  |

virtual

Set the data area, if the value has one 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 value has no data area, else 0.

Reimplemented in Exiv2::ValueType< T >.

## toFloat()

virtual float Exiv2::Value::toFloat | ( | long | n = `0` | ) | const

pure virtual

Convert the n-th component of the value to a float. The behaviour of this method may be undefined if there is no n-th component.

Returns
  The converted value.

Implemented in Exiv2::ValueType< T >, Exiv2::TimeValue, Exiv2::DateValue, Exiv2::LangAltValue, Exiv2::XmpArrayValue, Exiv2::XmpTextValue, Exiv2::StringValueBase, Exiv2::DataValue, Exiv2::ValueType< T >, and Exiv2::ValueType< T >.

Examples
  xmpsample.cpp.

Referenced by Exiv2::Internal::extractLensFocalLength(), Exiv2::Internal::print0x0006(), Exiv2::Internal::print0x0007(), Exiv2::Internal::Nikon3MakerNote::print0x008b(), Exiv2::Internal::Nikon3MakerNote::print0x009a(), Exiv2::Internal::OlympusMakerNote::print0x0204(), Exiv2::Internal::print0x9202(), Exiv2::Internal::printCameraTemperature(), Exiv2::Internal::CanonMakerNote::printCsLens(), Exiv2::Internal::printDegrees(), Exiv2::Internal::printFloat(), Exiv2::Internal::CanonMakerNote::printFocalLength(), Exiv2::Internal::printMinoltaSonyFlashExposureComp(), and Exiv2::Internal::Nikon3MakerNote::printTimeZone().

## toLong()

virtual long Exiv2::Value::toLong | ( | long | n = `0` | ) | const

pure virtual

Convert the n-th component of the value to a long. The behaviour of this method may be undefined if there is no n-th component.

Returns
  The converted value.

Implemented in Exiv2::ValueType< T >, Exiv2::TimeValue, Exiv2::DateValue, Exiv2::LangAltValue, Exiv2::XmpArrayValue, Exiv2::XmpTextValue, Exiv2::StringValueBase, Exiv2::DataValue, Exiv2::ValueType< T >, Exiv2::ValueType< T >, Exiv2::ValueType< T >, and Exiv2::ValueType< T >.

Examples
  xmpsample.cpp.

Referenced by Exiv2::Internal::TiffDecoder::decodeCanonAFInfo(), Exiv2::Internal::TiffDataEntry::doWrite(), Exiv2::Internal::extractLensFocalLength(), Exiv2::Internal::nikonCrypt(), Exiv2::Internal::print0x0000(), Exiv2::Internal::Nikon1MakerNote::print0x0002(), Exiv2::Internal::Nikon3MakerNote::print0x0002(), Exiv2::Internal::CasioMakerNote::print0x0006(), Exiv2::Internal::PanasonicMakerNote::print0x000f(), Exiv2::Internal::CasioMakerNote::print0x0015(), Exiv2::Internal::PanasonicMakerNote::print0x0023(), Exiv2::Internal::PanasonicMakerNote::print0x0029(), Exiv2::Internal::PanasonicMakerNote::print0x0036(), Exiv2::Internal::PanasonicMakerNote::print0x003c(), Exiv2::Internal::Nikon3MakerNote::print0x0083(), Exiv2::Internal::Nikon3MakerNote::print0x0084(), Exiv2::Internal::Nikon1MakerNote::print0x0088(), Exiv2::Internal::Nikon3MakerNote::print0x0088(), Exiv2::Internal::Nikon3MakerNote::print0x0089(), Exiv2::Internal::Nikon3MakerNote::print0x008b(), Exiv2::Internal::Nikon3MakerNote::print0x009e(), Exiv2::Internal::OlympusMakerNote::print0x0200(), Exiv2::Internal::OlympusMakerNote::print0x0201(), Exiv2::Internal::OlympusMakerNote::print0x0209(), Exiv2::Internal::OlympusMakerNote::print0x0308(), Exiv2::Internal::OlympusMakerNote::print0x050f(), Exiv2::Internal::OlympusMakerNote::print0x0527(), Exiv2::Internal::OlympusMakerNote::print0x0529(), Exiv2::Internal::OlympusMakerNote::print0x1015(), Exiv2::Internal::OlympusMakerNote::print0x1209(), Exiv2::Internal::Casio2MakerNote::print0x2001(), Exiv2::Internal::Casio2MakerNote::print0x2022(), Exiv2::Internal::print0x8827(), Exiv2::Internal::print0x9101(), Exiv2::Internal::print0xa405(), Exiv2::Internal::PanasonicMakerNote::printAccelerometer(), Exiv2::Internal::Nikon3MakerNote::printAfPointsInFocus(), Exiv2::Internal::Nikon3MakerNote::printAperture(), Exiv2::Internal::Nikon3MakerNote::printApertureLd4(), Exiv2::Internal::Nikon1MakerNote::printBarValue(), Exiv2::Internal::printBitmask(), Exiv2::Internal::PentaxMakerNote::printBracketing(), Exiv2::Internal::printCombiTag(), Exiv2::Internal::PentaxMakerNote::printCompensation(), Exiv2::Internal::CanonMakerNote::printCs0x0002(), Exiv2::Internal::OlympusMakerNote::printCs0x0301(), Exiv2::Internal::CanonMakerNote::printCsLens(), Exiv2::Internal::printCsLensByFocalLength(), Exiv2::Internal::printCsLensByFocalLengthAndMaxAperture(), Exiv2::Internal::printCsLensByFocalLengthTC(), Exiv2::Internal::CanonMakerNote::printCsLensType(), Exiv2::Internal::PentaxMakerNote::printDate(), Exiv2::Internal::OlympusMakerNote::printEq0x0301(), Exiv2::Internal::printExifVersion(), Exiv2::Internal::Nikon3MakerNote::printExitPupilPosition(), Exiv2::Internal::PentaxMakerNote::printExposure(), Exiv2::Internal::CanonMakerNote::printFiFileNumber(), Exiv2::Internal::CanonMakerNote::printFiFocusDistance(), Exiv2::Internal::PentaxMakerNote::printFlashCompensation(), Exiv2::Internal::Nikon3MakerNote::printFlashFocalLength(), Exiv2::Internal::Nikon3MakerNote::printFocal(), Exiv2::Internal::Nikon3MakerNote::printFocalLd4(), Exiv2::Internal::PentaxMakerNote::printFocalLength(), Exiv2::Internal::printFocalLength35(), Exiv2::Internal::Nikon3MakerNote::printFocusDistance(), Exiv2::Internal::Nikon3MakerNote::printFStops(), Exiv2::Internal::PentaxMakerNote::printFValue(), Exiv2::Internal::Nikon3MakerNote::printIiIso(), Exiv2::Internal::Nikon3MakerNote::printLensId(), Exiv2::Internal::Nikon3MakerNote::printLensId4ZMount(), Exiv2::Internal::printLensType(), Exiv2::Internal::MinoltaMakerNote::printMinoltaBrightnessStd(), Exiv2::Internal::MinoltaMakerNote::printMinoltaDateStd(), Exiv2::Internal::MinoltaMakerNote::printMinoltaExposureCompensation5D(), Exiv2::Internal::MinoltaMakerNote::printMinoltaExposureCompensationStd(), Exiv2::Internal::MinoltaMakerNote::printMinoltaExposureManualBias5D(), Exiv2::Internal::MinoltaMakerNote::printMinoltaExposureSpeedStd(), Exiv2::Internal::MinoltaMakerNote::printMinoltaExposureTimeStd(), Exiv2::Internal::MinoltaMakerNote::printMinoltaFlashExposureCompStd(), Exiv2::Internal::MinoltaMakerNote::printMinoltaFNumberStd(), Exiv2::Internal::MinoltaMakerNote::printMinoltaFocalLengthStd(), Exiv2::Internal::printMinoltaSonyLensID(), Exiv2::Internal::MinoltaMakerNote::printMinoltaTimeStd(), Exiv2::Internal::MinoltaMakerNote::printMinoltaWhiteBalanceStd(), Exiv2::Internal::PanasonicMakerNote::printPanasonicText(), Exiv2::Internal::Nikon3MakerNote::printPictureControl(), Exiv2::Internal::PanasonicMakerNote::printPitchAngle(), Exiv2::Internal::PanasonicMakerNote::printPressure(), Exiv2::Internal::printPwColor(), Exiv2::Internal::Nikon3MakerNote::printRepeatingFlashCount(), Exiv2::Internal::Nikon3MakerNote::printRepeatingFlashRate(), Exiv2::Internal::PanasonicMakerNote::printRollAngle(), Exiv2::Internal::PentaxMakerNote::printShutterCount(), Exiv2::Internal::CanonMakerNote::printSi0x0001(), Exiv2::Internal::CanonMakerNote::printSi0x0002(), Exiv2::Internal::CanonMakerNote::printSi0x0003(), Exiv2::Internal::CanonMakerNote::printSi0x0009(), Exiv2::Internal::CanonMakerNote::printSi0x000c(), Exiv2::Internal::CanonMakerNote::printSi0x000d(), Exiv2::Internal::CanonMakerNote::printSi0x000e(), Exiv2::Internal::CanonMakerNote::printSi0x0013(), Exiv2::Internal::CanonMakerNote::printSi0x0015(), Exiv2::Internal::CanonMakerNote::printSi0x0016(), Exiv2::Internal::CanonMakerNote::printSi0x0017(), Exiv2::Internal::CanonMakerNote::printSi0x0018(), Exiv2::Internal::printTag(), Exiv2::Internal::printTagBitmask(), Exiv2::Internal::PentaxMakerNote::printTemperature(), Exiv2::Internal::PentaxMakerNote::printTime(), Exiv2::Internal::Nikon3MakerNote::printTimeZone(), Exiv2::Internal::printValueMinus4(), Exiv2::Internal::TiffDataEntry::setStrips(), and Exiv2::Internal::TiffImageEntry::setStrips().

## toRational()

virtual Rational Exiv2::Value::toRational | ( | long | n = `0` | ) | const

pure virtual

Convert the n-th component of the value to a Rational. The behaviour of this method may be undefined if there is no n-th component.

Returns
  The converted value.

Implemented in Exiv2::ValueType< T >, Exiv2::TimeValue, Exiv2::DateValue, Exiv2::LangAltValue, Exiv2::XmpArrayValue, Exiv2::XmpTextValue, Exiv2::StringValueBase, Exiv2::DataValue, Exiv2::ValueType< T >, Exiv2::ValueType< T >, Exiv2::ValueType< T >, and Exiv2::ValueType< T >.

Examples
  xmpsample.cpp.

Referenced by Exiv2::Internal::print0x0006(), Exiv2::Internal::print0x0007(), Exiv2::Internal::Nikon2MakerNote::print0x000a(), Exiv2::Internal::Nikon3MakerNote::print0x0084(), Exiv2::Internal::Nikon1MakerNote::print0x0085(), Exiv2::Internal::Nikon3MakerNote::print0x0085(), Exiv2::Internal::Nikon1MakerNote::print0x0086(), Exiv2::Internal::Nikon3MakerNote::print0x0086(), Exiv2::Internal::OlympusMakerNote::print0x0204(), Exiv2::Internal::OlympusMakerNote::print0x0305(), Exiv2::Internal::print0x829a(), Exiv2::Internal::print0x829d(), Exiv2::Internal::print0x9201(), Exiv2::Internal::print0x9202(), Exiv2::Internal::print0x9204(), Exiv2::Internal::print0x9206(), Exiv2::Internal::print0x920a(), Exiv2::Internal::print0xa404(), Exiv2::Internal::printFloat(), and Exiv2::Internal::printLong().

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

- value.hpp
- value.cpp