#include <value.hpp>
Inheritance diagram for Exiv2::Value:
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. | |
Value (const Value &rhs) | |
Copy constructor. | |
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). | |
std::string | toString () const |
Return the value as a string. Implemented in terms of write(std::ostream& os) const of the concrete class. | |
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). | |
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. | |
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. |
The interface provides a uniform way to access values independent from 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 the actual subclass of Value so that you can access the subclass specific interface.
Write value to a data buffer.
The user must ensure that the buffer has enough memory. Otherwise the call results in undefined behaviour.
buf | Data buffer to write to. | |
byteOrder | Applicable byte order (little or big endian). |
Implemented in Exiv2::DataValue, Exiv2::StringValueBase, Exiv2::DateValue, Exiv2::TimeValue, and Exiv2::ValueType< T >.
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 |
default: | DataValue(typeId) |
typeId | Type of the value. |
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.
Reimplemented in 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.
buf | The string to read from. |
Implemented in Exiv2::DataValue, Exiv2::StringValueBase, Exiv2::AsciiValue, Exiv2::CommentValue, Exiv2::DateValue, Exiv2::TimeValue, and Exiv2::ValueType< T >.
Read the value from a character buffer.
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). |
Implemented in Exiv2::DataValue, Exiv2::StringValueBase, 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.
buf | Pointer to the source data area | |
len | Size of the data area |
Reimplemented in Exiv2::ValueType< T >.
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.
Implemented in Exiv2::DataValue, Exiv2::StringValueBase, Exiv2::DateValue, Exiv2::TimeValue, Exiv2::ValueType< T >, Exiv2::ValueType< T >, 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.
Implemented in Exiv2::DataValue, Exiv2::StringValueBase, 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.
Implemented in Exiv2::DataValue, Exiv2::StringValueBase, Exiv2::DateValue, Exiv2::TimeValue, Exiv2::ValueType< T >, Exiv2::ValueType< T >, and Exiv2::ValueType< T >.