Common interface for all types of values used with metadata. More...
#include <value.hpp>
Public Types | |
using | UniquePtr = std::unique_ptr< Value > |
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 ()=default |
Virtual destructor. | |
Manipulators | |
virtual int | read (const byte *buf, size_t 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, size_t len) |
Set the data area, if the value has one by copying (cloning) the buffer pointed to by buf. More... | |
Accessors | |
bool | ok_ {true} |
Indicates the status of the previous to<Type> conversion. | |
TypeId | typeId () const |
Return the type identifier (Exif data format type). | |
UniquePtr | 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 size_t | copy (byte *buf, ByteOrder byteOrder) const =0 |
Write value to a data buffer. More... | |
virtual size_t | count () const =0 |
Return the number of components of the value. | |
virtual size_t | 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 (size_t 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 int64_t | toInt64 (size_t n=0) const =0 |
Convert the n-th component of the value to an int64_t. The behaviour of this method may be undefined if there is no n-th component. More... | |
virtual uint32_t | toUint32 (size_t 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 float | toFloat (size_t 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 (size_t 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 size_t | 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 UniquePtr | create (TypeId typeId) |
A (simple) factory to create a Value type. More... | |
Value (const Value &)=default | |
Value & | operator= (const Value &)=default |
Assignment operator. Protected so that it can only be used by subclasses but not directly. | |
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.
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::TimeValue, Exiv2::DateValue, Exiv2::XmpValue, Exiv2::StringValueBase, Exiv2::DataValue, Exiv2::ValueType< T >, and Exiv2::CommentValue.
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) |
typeId | Type of the value. |
|
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 >.
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::TimeValue, Exiv2::DateValue, Exiv2::XmpValue, Exiv2::StringValueBase, Exiv2::DataValue, Exiv2::ValueType< T >, and Exiv2::CommentValue.
|
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::CommentValue, Exiv2::XmpValue, Exiv2::ValueType< T >, Exiv2::TimeValue, Exiv2::DateValue, Exiv2::LangAltValue, Exiv2::XmpArrayValue, Exiv2::XmpTextValue, Exiv2::AsciiValue, Exiv2::StringValueBase, and Exiv2::DataValue.
|
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 >.
|
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::ValueType< T >, Exiv2::TimeValue, Exiv2::DateValue, Exiv2::LangAltValue, Exiv2::XmpArrayValue, Exiv2::XmpTextValue, Exiv2::StringValueBase, Exiv2::DataValue, Exiv2::ValueType< T >, and Exiv2::ValueType< T >.
|
pure virtual |
Convert the n-th component of the value to an int64_t. The behaviour of this method may be undefined if there is no n-th component.
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 >.
|
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::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 >.
|
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::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 >.