exiv2._value
Exiv2 metadata value classes.
Classes
|
|
|
|
|
|
Simple Date helper structure |
|
|
|
Sequence of double values. |
|
Sequence of float values. |
|
|
|
Sequence of int32_t values. |
|
Sequence of Exiv2::Rational values. |
|
Sequence of int16_t values. |
|
|
|
Abstract base class for a string based |
|
Simple Time helper structure |
|
|
|
Sequence of uint32_t values. |
|
Sequence of Exiv2::URational values. |
|
Sequence of uint16_t values. |
|
Common interface for all types of values used with metadata. |
|
|
|
|
|
Base class for all Exiv2 values used to store XMP property values. |
- class AsciiValue
Bases:
StringValueBase
Value
for an Ascii string type.This class is for null terminated single byte Ascii strings. This class also ensures that the string is null terminated.
- clone()
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.
- read()
Read the value from buf. This default implementation uses buf as it is.
- class CommentValue
Bases:
StringValueBase
Value
for an Exif comment.This can be a plain Ascii string or a multiple byte encoded string. The comment is expected to be encoded in the character set indicated (default undefined), but this is not checked. It is left to caller to decode and encode the string to and from readable text if that is required.
- class CharsetId
Bases:
IntEnum
Character set identifiers for the character sets defined by Exif.
- ascii = 0
- invalidCharsetId = 4
- jis = 1
- lastCharsetId = 5
- undefined = 3
- unicode = 2
- byteOrder_
- charsetId()
Return the Exif charset id of the comment
- clone()
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.
- comment()
Return the comment (without a charset=”…” prefix)
The comment is decoded to UTF-8. For Exif UNICODE comments, the function makes an attempt to correctly determine the character encoding of the value. Alternatively, the optional encoding parameter can be used to specify it.
- Parameters:
encoding (string, optional) – Optional argument to specify the character encoding that the comment is encoded in, as an iconv(3) name. Only used for Exif UNICODE comments.
- Return type:
- Returns:
A string containing the comment converted to UTF-8.
- copy()
Write value to a character data buffer.
The user must ensure that the buffer has enough memory. Otherwise the call results in undefined behaviour.
Note
The byte order is required by the interface but not used by this method, so just use the default.
- Parameters:
buf (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
, optional) – Byte order. Not used.
- Return type:
- Returns:
Number of characters written.
- detectCharset()
Determine the character encoding that was used to encode the UNICODE comment value as an iconv(3) name.
If the comment c starts with a BOM, the BOM is interpreted and removed from the string.
Todo: Implement rules to guess if the comment is UTF-8 encoded.
- class DataValue
Bases:
Value
Value
for an undefined data type.- clone()
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.
- copy()
Write value to a character data buffer.
Note
The byte order is required by the interface but not used by this method, so just use the default.
The user must ensure that the buffer has enough memory. Otherwise the call results in undefined behaviour.
- Parameters:
buf (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
, optional) – Byte order. Not needed.
- Return type:
- Returns:
Number of characters written.
- count()
Return the number of components of the value
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- size()
Return the size of the value in bytes
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class Date
Bases:
SwigPyObject
Simple Date helper structure
- day
Day
- items()
Get structure members.
- keys()
Get structure member names.
- month
Month
- year
Year
- class DateValue
Bases:
Value
Value
for simple ISO 8601 datesThis class is limited to parsing simple date strings in the ISO 8601 format CCYYMMDD (century, year, month, day).
- clone()
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.
- copy()
Write value to a character data buffer.
The user must ensure that the buffer has enough memory. Otherwise the call results in undefined behaviour.
Note
The byte order is required by the interface but not used by this method, so just use the default.
- Parameters:
buf (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
, optional) – Byte order. Not used.
- Return type:
- Returns:
Number of characters written.
- count()
Return the number of components of the value
- getDate()
Return date struct containing date information
- read()
Overload 1:
- Return type:
- Returns:
0 if successful
1 in case of an unsupported date format
Overload 2:
Set the value to that of the string buf.
- setDate()
Set the date
- size()
Return the size of the value in bytes
- toFloat()
Return the value as a UNIX calendar time converted to float.
- toInt64()
Return the value as a UNIX calendar time converted to int64_t.
- toRational()
Return the value as a UNIX calendar time converted to Rational.
- toUint32()
Return the value as a UNIX calendar time converted to uint32_t.
- class DoubleValue
Bases:
Value
Sequence of double values. The data components can be accessed like a Python list.
- append()
Append a double component to the value.
- clone()
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.
- copy()
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 (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
Number of bytes written.
- count()
Return the number of components of the value
- dataArea()
Return a copy of the data area in a DataBuf. The caller owns this copy and DataBuf ensures that it will be deleted.
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- setDataArea()
Set the data area. This method copies (clones) the buffer pointed to by buf.
- size()
Return the size of the value in bytes
- sizeDataArea()
Return the size of the data area.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class FloatValue
Bases:
Value
Sequence of float values. The data components can be accessed like a Python list.
- append()
Append a float component to the value.
- clone()
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.
- copy()
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 (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
Number of bytes written.
- count()
Return the number of components of the value
- dataArea()
Return a copy of the data area in a DataBuf. The caller owns this copy and DataBuf ensures that it will be deleted.
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- setDataArea()
Set the data area. This method copies (clones) the buffer pointed to by buf.
- size()
Return the size of the value in bytes
- sizeDataArea()
Return the size of the data area.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class LangAltValue
Bases:
XmpValue
Value
type for XMP language alternative properties.A language alternative is an array consisting of simple text values, each of which has a language qualifier.
- clone()
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.
- count()
Return the number of components of the value
- items()
Get key, value pairs (i.e. language, text) of the LangAltValue components.
- keys()
Get keys (i.e. languages) of the LangAltValue components.
- read()
Overload 1:
Note
Uses read(const std::string& buf)
Overload 2:
Read a simple property value from buf and append it to the value.
Appends buf to the value after the last existing array element. Subsequent calls will therefore populate multiple array elements in the order they are read.
The format of buf is:
[lang=["]language code["] ]text
The XMP default language code
x-default
is used if buf doesn’t start with the keywordlang
.- Return type:
- Returns:
0 if successful.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Overload 1:
Return the text value associated with the default language qualifier
x-default
. The parameter n is not used, but it is suggested that only 0 is passed in. Returns an empty string and sets the ok-flag tofalse
if there is no default value.Overload 2:
Return the text value associated with the language qualifier qualifier. Returns an empty string and sets the ok-flag to
false
if there is no entry for the language qualifier.
- toUint32()
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.
- Return type:
- Returns:
The converted value.
- values()
Get values (i.e. text strings) of the LangAltValue components.
- class LongValue
Bases:
Value
Sequence of int32_t values. The data components can be accessed like a Python list.
- append()
Append a int32_t component to the value.
- clone()
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.
- copy()
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 (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
Number of bytes written.
- count()
Return the number of components of the value
- dataArea()
Return a copy of the data area in a DataBuf. The caller owns this copy and DataBuf ensures that it will be deleted.
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- setDataArea()
Set the data area. This method copies (clones) the buffer pointed to by buf.
- size()
Return the size of the value in bytes
- sizeDataArea()
Return the size of the data area.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class RationalValue
Bases:
Value
Sequence of Exiv2::Rational values. The data components can be accessed like a Python list.
- append()
Append a Exiv2::Rational component to the value.
- clone()
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.
- copy()
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 (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
Number of bytes written.
- count()
Return the number of components of the value
- dataArea()
Return a copy of the data area in a DataBuf. The caller owns this copy and DataBuf ensures that it will be deleted.
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- setDataArea()
Set the data area. This method copies (clones) the buffer pointed to by buf.
- size()
Return the size of the value in bytes
- sizeDataArea()
Return the size of the data area.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class ShortValue
Bases:
Value
Sequence of int16_t values. The data components can be accessed like a Python list.
- append()
Append a int16_t component to the value.
- clone()
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.
- copy()
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 (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
Number of bytes written.
- count()
Return the number of components of the value
- dataArea()
Return a copy of the data area in a DataBuf. The caller owns this copy and DataBuf ensures that it will be deleted.
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- setDataArea()
Set the data area. This method copies (clones) the buffer pointed to by buf.
- size()
Return the size of the value in bytes
- sizeDataArea()
Return the size of the data area.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class StringValue
Bases:
StringValueBase
Value
for string type.This can be a plain Ascii string or a multiple byte encoded string. It is left to caller to decode and encode the string to and from readable text if that is required.
- clone()
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.
- class StringValueBase
Bases:
Value
Abstract base class for a string based
Value
type.Uses a std::string to store the value and implements defaults for most operations.
- clone()
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.
- copy()
Write value to a character data buffer.
The user must ensure that the buffer has enough memory. Otherwise the call results in undefined behaviour.
Note
The byte order is required by the interface but not used by this method, so just use the default.
- Parameters:
buf (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
, optional) – Byte order. Not used.
- Return type:
- Returns:
Number of characters written.
- count()
Return the number of components of the value
- data()
Returns a temporary Python memoryview of the object’s data.
Warning
do not resize or delete the object while using the view.
- Return type:
- read()
Read the value from buf. This default implementation uses buf as it is.
- size()
Return the size of the value in bytes
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- class Time
Bases:
SwigPyObject
Simple Time helper structure
- hour
Hour
- items()
Get structure members.
- keys()
Get structure member names.
- minute
Minute
- second
Second
- tzHour
Hours ahead or behind UTC
- tzMinute
Minutes ahead or behind UTC
- class TimeValue
Bases:
Value
Value
for simple ISO 8601 times.This class is limited to handling simple time strings in the ISO 8601 format HHMMSS±HHMM where HHMMSS refers to local hour, minute and seconds and ±HHMM refers to hours and minutes ahead or behind Universal Coordinated Time.
- clone()
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.
- copy()
Write value to a character data buffer.
The user must ensure that the buffer has enough memory. Otherwise the call results in undefined behaviour.
Note
The byte order is required by the interface but not used by this method, so just use the default.
- Parameters:
buf (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
, optional) – Byte order. Not used.
- Return type:
- Returns:
Number of characters written.
- count()
Return the number of components of the value
- getTime()
Return time struct containing time information
- read()
Overload 1:
- Return type:
- Returns:
0 if successful
1 in case of an unsupported time format
Overload 2:
Set the value to that of the string buf.
- setTime()
Set the time
- size()
Return the size of the value in bytes
- toFloat()
Returns number of seconds in the day in UTC converted to float.
- toInt64()
Returns number of seconds in the day in UTC.
- toRational()
Returns number of seconds in the day in UTC converted to Rational.
- toUint32()
Returns number of seconds in the day in UTC.
- class ULongValue
Bases:
Value
Sequence of uint32_t values. The data components can be accessed like a Python list.
- append()
Append a uint32_t component to the value.
- clone()
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.
- copy()
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 (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
Number of bytes written.
- count()
Return the number of components of the value
- dataArea()
Return a copy of the data area in a DataBuf. The caller owns this copy and DataBuf ensures that it will be deleted.
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- setDataArea()
Set the data area. This method copies (clones) the buffer pointed to by buf.
- size()
Return the size of the value in bytes
- sizeDataArea()
Return the size of the data area.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class URationalValue
Bases:
Value
Sequence of Exiv2::URational values. The data components can be accessed like a Python list.
- append()
Append a Exiv2::URational component to the value.
- clone()
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.
- copy()
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 (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
Number of bytes written.
- count()
Return the number of components of the value
- dataArea()
Return a copy of the data area in a DataBuf. The caller owns this copy and DataBuf ensures that it will be deleted.
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- setDataArea()
Set the data area. This method copies (clones) the buffer pointed to by buf.
- size()
Return the size of the value in bytes
- sizeDataArea()
Return the size of the data area.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class UShortValue
Bases:
Value
Sequence of uint16_t values. The data components can be accessed like a Python list.
- append()
Append a uint16_t component to the value.
- clone()
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.
- copy()
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 (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
Number of bytes written.
- count()
Return the number of components of the value
- dataArea()
Return a copy of the data area in a DataBuf. The caller owns this copy and DataBuf ensures that it will be deleted.
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- setDataArea()
Set the data area. This method copies (clones) the buffer pointed to by buf.
- size()
Return the size of the value in bytes
- sizeDataArea()
Return the size of the data area.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class Value
Bases:
SwigPyObject
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.
- clone()
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.
- copy()
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 (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
Number of bytes written.
- count()
Return the number of components of the value
- static create()
A (simple) factory to create a Value type.
The following Value subclasses are created depending on typeId:
typeId
Value
subclassinvalidTypeId
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)
- dataArea()
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.
- Return type:
- Returns:
A DataBuf containing a copy of the data area or an empty DataBuf if the value does not have a data area assigned.
- ok()
Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversion was successful.
- read()
Overload 1:
Read the value from a character buffer.
- Parameters:
buf (bytes-like object) – Pointer to the data buffer to read from
len (int) – Number of bytes in the data buffer
byteOrder (
ByteOrder
) – Applicable byte order (little or big endian).
- Return type:
- Returns:
0 if successful.
Overload 2:
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.
- setDataArea()
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 (bytes-like object) – Pointer to the source data area
len (int) – Size of the data area
- Return type:
- Returns:
Return -1 if the value has no data area, else 0.
- size()
Return the size of the value in bytes
- sizeDataArea()
Return the size of the data area, 0 if there is none.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Overload 1:
Return the value as a string. Implemented in terms of write(std::ostream& os) const of the concrete class.
Overload 2:
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.
- toUint32()
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.
- Return type:
- Returns:
The converted value.
- typeId()
Return the type identifier (Exif data format type).
- class XmpArrayValue
Bases:
XmpValue
Value
type for simple arrays. Each item in the array is a simple value, without qualifiers. The array may be an ordered (seq), unordered (bag) or alternative array (alt). The array items must not contain qualifiers. For language alternatives use LangAltValue.Uses a vector of std::string to store the value(s).
- append()
appends another ‘this’ object
- clone()
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.
- count()
Return the number of components of the value
- read()
Overload 1:
Note
Uses read(const std::string& buf)
Overload 2:
Read a simple property value from buf and append it to the value.
Appends buf to the value after the last existing array element. Subsequent calls will therefore populate multiple array elements in the order they are read.
- Return type:
- Returns:
0 if successful.
- toFloat()
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.
- Return type:
- Returns:
The converted value.
- toInt64()
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.
- Return type:
- Returns:
The converted value.
- toRational()
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.
- toString()
Return the n-th component of the value as a string. The behaviour of this method may be undefined if there is no n-th component.
- class XmpTextValue
Bases:
XmpValue
Value
type suitable for simple XMP properties and XMP nodes of complex types which are not parsed into specific values.Uses a std::string to store the value.
- clone()
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.
- count()
Return the number of components of the value
- data()
Returns a temporary Python memoryview of the object’s data.
Warning
do not resize or delete the object while using the view.
- Return type:
- read()
Overload 1:
Note
Uses read(const std::string& buf)
Overload 2:
Read a simple property value from buf to set the value.
Sets the value to the contents of buf. A optional keyword, type is supported to set the XMP value type. This is useful for complex value types for which Exiv2 does not have direct support.
The format of buf is:
[type=["]Alt|Bag|Seq|Struct["] ]text
- Return type:
- Returns:
0 if successful.
- size()
Return the size of the value in bytes
- toFloat()
Convert the value to a float. The optional parameter n is not used and is ignored.
- Return type:
- Returns:
The converted value.
- toInt64()
Convert the value to an int64_t. The optional parameter n is not used and is ignored.
- Return type:
- Returns:
The converted value.
- toRational()
Convert the value to a Rational. The optional parameter n is not used and is ignored.
- class XmpValue
Bases:
Value
Base class for all Exiv2 values used to store XMP property values.
- copy()
Write value to a character data buffer.
The user must ensure that the buffer has enough memory. Otherwise the call results in undefined behaviour.
Note
The byte order is required by the interface but not used by this method, so just use the default.
- Parameters:
buf (writeable bytes-like object) – Data buffer to write to.
byteOrder (
ByteOrder
, optional) – Byte order. Not used.
- Return type:
- Returns:
Number of characters written.
- read()
Note
Uses read(const std::string& buf)
- setXmpArrayType()
Set the XMP array type to indicate that an XMP value is an array.
- setXmpStruct()
Set the XMP struct type to indicate that an XMP value is a structure.
- size()
Return the size of the value in bytes
- xmpArrayType()
Return XMP array type, indicates if an XMP value is an array.
- xmpStruct()
Return XMP struct, indicates if an XMP value is a structure.