Exiv2: Exiv2::Value Class Reference

# Exiv2::Value Class Reference

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

`#include <value.hpp>`

Inheritance diagram for Exiv2::Value:
[legend]

List of all members.

## 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.
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.
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.
Accessors
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.
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.
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.
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.
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.
bool | ok () const
| Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversion was successful.
## Static Public Member Functions
static AutoPtr | create (TypeId typeId)
| A (simple) factory to create a Value type.
## Protected Member Functions
Value & | operator= (const Value &rhs)
| Assignment operator. Protected so that it can only be used by subclasses but not directly.
## Protected Attributes
bool | ok_
| Indicates the status of the previous to<Type> conversion.

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

## Member Function Documentation

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::DataValue, Exiv2::StringValueBase, Exiv2::XmpValue, Exiv2::DateValue, Exiv2::TimeValue, and Exiv2::ValueType< T >.

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::DataValue, Exiv2::StringValueBase, Exiv2::AsciiValue, Exiv2::CommentValue, Exiv2::XmpValue, Exiv2::XmpTextValue, Exiv2::XmpArrayValue, Exiv2::LangAltValue, Exiv2::DateValue, Exiv2::TimeValue, and Exiv2::ValueType< T >.

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

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::DataValue, Exiv2::StringValueBase, Exiv2::XmpValue, Exiv2::DateValue, Exiv2::TimeValue, and Exiv2::ValueType< T >.

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::DataValue, Exiv2::StringValueBase, Exiv2::XmpTextValue, Exiv2::XmpArrayValue, Exiv2::LangAltValue, Exiv2::DateValue, Exiv2::TimeValue, Exiv2::ValueType< T >, Exiv2::ValueType< T >, and Exiv2::ValueType< T >.

Referenced by Exiv2::printCombiTag(), Exiv2::printTag(), and Exiv2::printTagBitmask().

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::DataValue, Exiv2::StringValueBase, Exiv2::XmpTextValue, Exiv2::XmpArrayValue, Exiv2::LangAltValue, Exiv2::DateValue, Exiv2::TimeValue, Exiv2::ValueType< T >, Exiv2::ValueType< T >, and Exiv2::ValueType< T >.

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::DataValue, Exiv2::StringValueBase, Exiv2::XmpTextValue, Exiv2::XmpArrayValue, Exiv2::LangAltValue, Exiv2::DateValue, Exiv2::TimeValue, Exiv2::ValueType< T >, Exiv2::ValueType< T >, and Exiv2::ValueType< T >.

virtual DataBuf Exiv2::Value::dataArea | ( |  | ) | const`[inline, 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 >.

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

Referenced by Exiv2::CiffComponent::doPrint(), Exiv2::Xmpdatum::setValue(), and Exiv2::Exifdatum::setValue().

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

- value.hpp