33 #include "exiv2lib_export.h" 83 virtual int read(
const byte* buf,
long len,
ByteOrder byteOrder) =0;
107 virtual int setDataArea(
const byte* buf,
long len);
112 TypeId typeId()
const {
return type_; }
132 virtual long count()
const =0;
134 virtual long size()
const =0;
141 virtual std::ostream& write(std::ostream& os)
const =0;
161 virtual long toLong(
long n =0)
const =0;
169 virtual float toFloat(
long n =0)
const =0;
177 virtual Rational toRational(
long n =0)
const =0;
179 virtual long sizeDataArea()
const;
192 virtual DataBuf dataArea()
const;
197 bool ok()
const {
return ok_; }
236 static AutoPtr create(
TypeId typeId);
249 virtual Value* clone_()
const =0;
258 return value.
write(os);
270 long len,
ByteOrder byteOrder =invalidByteOrder,
289 virtual int read(
const byte* buf,
312 virtual long copy(
byte* buf,
ByteOrder byteOrder =invalidByteOrder)
const;
313 virtual long count()
const;
314 virtual long size()
const;
315 virtual std::ostream& write(std::ostream& os)
const;
322 virtual long toLong(
long n =0)
const;
323 virtual float toFloat(
long n =0)
const;
324 virtual Rational toRational(
long n =0)
const;
347 typedef std::auto_ptr<StringValueBase>
AutoPtr;
377 virtual int read(
const byte* buf,
398 virtual long copy(
byte* buf,
ByteOrder byteOrder =invalidByteOrder)
const;
399 virtual long count()
const;
400 virtual long size()
const;
401 virtual long toLong(
long n =0)
const;
402 virtual float toFloat(
long n =0)
const;
403 virtual Rational toRational(
long n =0)
const;
404 virtual std::ostream& write(std::ostream& os)
const;
492 virtual std::ostream& write(std::ostream& os)
const;
513 invalidCharsetId, lastCharsetId };
536 static const char* name(
CharsetId charsetId);
538 static const char* code(
CharsetId charsetId);
590 std::ostream& write(std::ostream& os)
const;
617 CharsetId charsetId()
const;
650 XmpArrayType xmpArrayType()
const;
653 XmpStruct xmpStruct()
const;
654 virtual long size()
const;
668 virtual long copy(
byte* buf,
ByteOrder byteOrder =invalidByteOrder)
const;
673 void setXmpArrayType(XmpArrayType xmpArrayType);
676 void setXmpStruct(XmpStruct xmpStruct =xsStruct);
691 virtual int read(
const byte* buf,
701 static XmpArrayType xmpArrayType(
TypeId typeId);
712 XmpArrayType xmpArrayType_;
713 XmpStruct xmpStruct_;
762 virtual long count()
const;
769 virtual long toLong(
long n =0)
const;
776 virtual float toFloat(
long n =0)
const;
783 virtual Rational toRational(
long n =0)
const;
784 virtual std::ostream& write(std::ostream& os)
const;
836 virtual long count()
const;
843 virtual long toLong(
long n =0)
const;
844 virtual float toFloat(
long n =0)
const;
845 virtual Rational toRational(
long n =0)
const;
852 virtual std::ostream& write(std::ostream& os)
const;
859 std::vector<std::string> value_;
874 int result = str1.size() < str2.size() ? 1
875 : str1.size() > str2.size() ? -1
878 std::string::const_iterator c1 = str1.begin();
879 std::string::const_iterator c2 = str2.begin();
880 if ( result==0 )
for (
881 ; result==0 && c1 != str1.end()
884 result = tolower(*c1) < tolower(*c2) ? 1
885 : tolower(*c1) > tolower(*c2) ? -1
938 virtual long count()
const;
953 virtual long toLong(
long n =0)
const;
954 virtual float toFloat(
long n =0)
const;
955 virtual Rational toRational(
long n =0)
const;
962 virtual std::ostream& write(std::ostream& os)
const;
971 typedef std::map<std::string, std::string,LangAltValueComparator>
ValueType;
1004 Date() : year(0), month(0), day(0) {}
1025 virtual int read(
const byte* buf,
1038 void setDate(
const Date& src);
1057 virtual long copy(
byte* buf,
ByteOrder byteOrder =invalidByteOrder)
const;
1059 virtual const Date& getDate()
const;
1060 virtual long count()
const;
1061 virtual long size()
const;
1062 virtual std::ostream& write(std::ostream& os)
const;
1064 virtual long toLong(
long n =0)
const;
1066 virtual float toFloat(
long n =0)
const;
1068 virtual Rational toRational(
long n =0)
const;
1098 TimeValue(
int hour,
int minute,
int second =0,
1099 int tzHour =0,
int tzMinute =0);
1108 Time() : hour(0), minute(0), second(0), tzHour(0), tzMinute(0) {}
1132 virtual int read(
const byte* buf,
1145 void setTime(
const Time& src);
1164 virtual long copy(
byte* buf,
ByteOrder byteOrder =invalidByteOrder)
const;
1166 virtual const Time& getTime()
const;
1167 virtual long count()
const;
1168 virtual long size()
const;
1169 virtual std::ostream& write(std::ostream& os)
const;
1171 virtual long toLong(
long n =0)
const;
1173 virtual float toFloat(
long n =0)
const;
1175 virtual Rational toRational(
long n =0)
const;
1191 int scanTime3(
const char* buf,
const char* format);
1202 int scanTime6(
const char* buf,
const char* format);
1243 template<
typename T>
1289 virtual long count()
const;
1290 virtual long size()
const;
1291 virtual std::ostream&
write(std::ostream& os)
const;
1299 virtual long toLong(
long n =0)
const;
1300 virtual float toFloat(
long n =0)
const;
1398 return getLong(buf, byteOrder);
1439 return us2Data(buf, t, byteOrder);
1448 return ul2Data(buf, t, byteOrder);
1457 return ur2Data(buf, t, byteOrder);
1466 return s2Data(buf, t, byteOrder);
1475 return l2Data(buf, t, byteOrder);
1484 return r2Data(buf, t, byteOrder);
1493 return f2Data(buf, t, byteOrder);
1502 return d2Data(buf, t, byteOrder);
1505 template<
typename T>
1511 template<
typename T>
1513 :
Value(typeId), pDataArea_(0), sizeDataArea_(0)
1517 template<
typename T>
1519 :
Value(typeId), pDataArea_(0), sizeDataArea_(0)
1521 read(buf, len, byteOrder);
1524 template<
typename T>
1526 :
Value(typeId), pDataArea_(0), sizeDataArea_(0)
1531 template<
typename T>
1533 :
Value(rhs), value_(rhs.value_), pDataArea_(0), sizeDataArea_(0)
1535 if (rhs.sizeDataArea_ > 0) {
1536 pDataArea_ =
new byte[rhs.sizeDataArea_];
1537 std::memcpy(pDataArea_, rhs.pDataArea_, rhs.sizeDataArea_);
1538 sizeDataArea_ = rhs.sizeDataArea_;
1542 template<
typename T>
1545 delete[] pDataArea_;
1548 template<
typename T>
1551 if (
this == &rhs)
return *
this;
1556 if (rhs.sizeDataArea_ > 0) {
1557 tmp =
new byte[rhs.sizeDataArea_];
1558 std::memcpy(tmp, rhs.pDataArea_, rhs.sizeDataArea_);
1560 delete[] pDataArea_;
1562 sizeDataArea_ = rhs.sizeDataArea_;
1567 template<
typename T>
1573 if (len % ts != 0) len = (len / ts) * ts;
1574 for (
long i = 0; i < len; i += ts) {
1575 value_.push_back(getValue<T>(buf + i, byteOrder));
1580 template<
typename T>
1583 std::istringstream is(buf);
1586 while (!(is.eof())) {
1588 if (is.fail())
return 1;
1595 template<
typename T>
1599 typename ValueList::const_iterator end = value_.end();
1600 for (
typename ValueList::const_iterator i = value_.begin(); i != end; ++i) {
1601 offset +=
toData(buf + offset, *i, byteOrder);
1606 template<
typename T>
1609 return static_cast<long>(value_.size());
1612 template<
typename T>
1618 template<
typename T>
1624 template<
typename T>
1627 typename ValueList::const_iterator end = value_.end();
1628 typename ValueList::const_iterator i = value_.begin();
1630 os << std::setprecision(15) << *i;
1631 if (++i != end) os <<
" ";
1636 template<
typename T>
1640 return Exiv2::toString<T>(value_[n]);
1644 template<
typename T>
1648 return static_cast<long>(value_[n]);
1651 #define LARGE_INT 1000000 1656 ok_ = (value_[n].second != 0 && INT_MIN < value_[n].first && value_[n].first < INT_MAX );
1658 return value_[n].first / value_[n].second;
1664 ok_ = (value_[n].second != 0 && value_[n].first < LARGE_INT);
1666 return value_[n].first / value_[n].second;
1669 template<
typename T>
1673 return static_cast<float>(value_[n]);
1679 ok_ = (value_[n].second != 0);
1680 if (!ok_)
return 0.0f;
1681 return static_cast<float>(value_[n].first) / value_[n].second;
1687 ok_ = (value_[n].second != 0);
1688 if (!ok_)
return 0.0f;
1689 return static_cast<float>(value_[n].first) / value_[n].second;
1692 template<
typename T>
1703 return Rational(value_[n].first, value_[n].second);
1710 return Rational(value_[n].first, value_[n].second);
1729 template<
typename T>
1732 return sizeDataArea_;
1735 template<
typename T>
1738 return DataBuf(pDataArea_, sizeDataArea_);
1741 template<
typename T>
1746 tmp =
new byte[len];
1747 std::memcpy(tmp, buf, len);
1749 delete[] pDataArea_;
1751 sizeDataArea_ = len;
1756 #endif // #ifndef VALUE_HPP_ Exif SHORT type, 16-bit (2-byte) unsigned integer.
Definition: types.hpp:133
virtual float toFloat(long n=0) const
Convert the n-th component of the value to a float. The behaviour of this method may be undefined if ...
Definition: value.hpp:1670
Exif SLONG type, a 32-bit (4-byte) signed (twos-complement) integer.
Definition: types.hpp:139
TypeId typeId() const
Return the type identifier (Exif data format type).
Definition: value.hpp:113
EXIV2API Rational floatToRationalCast(float f)
Very simple conversion of a float to a Rational.
Definition: types.cpp:694
std::auto_ptr< DateValue > AutoPtr
Shortcut for a DateValue auto pointer.
Definition: value.hpp:990
ValueType value_
Map to store the language alternative values. The language qualifier is used as the key for the map e...
Definition: value.hpp:977
TypeId getType< uint16_t >()
Specialization for an unsigned short.
Definition: value.hpp:1220
XmpArrayType
XMP array types.
Definition: value.hpp:639
std::auto_ptr< DataValue > AutoPtr
Shortcut for a DataValue auto pointer.
Definition: value.hpp:265
Exif SRATIONAL type, two SLONGs: numerator and denumerator of a fraction.
Definition: types.hpp:140
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:113
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:204
std::vector< T > ValueList
Container for values.
Definition: value.hpp:1312
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition: types.hpp:110
Template for a Value of a basic type. This is used for unsigned and signed short, long and rationals...
Definition: value.hpp:1244
std::auto_ptr< XmpArrayValue > AutoPtr
Shortcut for a XmpArrayValue auto pointer.
Definition: value.hpp:809
Value type suitable for simple XMP properties and XMP nodes of complex types which are not parsed int...
Definition: value.hpp:724
EXIV2API long l2Data(byte *buf, int32_t l, ByteOrder byteOrder)
Convert a signed long to data, write the data to the buffer, return number of bytes written...
Definition: types.cpp:445
T getValue(const byte *buf, ByteOrder byteOrder)
Read a value of type T from the data buffer.
Definition: value.hpp:1372
Simple Date helper structure.
Definition: value.hpp:1003
bool operator()(const std::string &str1, const std::string &str2) const
LangAltValueComparator comparison case insensitive function.
Definition: value.hpp:872
std::auto_ptr< TimeValue > AutoPtr
Shortcut for a TimeValue auto pointer.
Definition: value.hpp:1091
int second
Second.
Definition: value.hpp:1112
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:130
virtual long toLong(long n=0) const
Convert the n-th component of the value to a long. The behaviour of this method may be undefined if t...
Definition: value.hpp:1645
int tzHour
Hours ahead or behind UTC.
Definition: value.hpp:1113
long toData(byte *buf, T t, ByteOrder byteOrder)
Convert a value of type T to data, write the data to the data buffer.
EXIV2API double getDouble(const byte *buf, ByteOrder byteOrder)
Read an 8 byte double precision floating point value (IEEE 754 binary64) from the data buffer...
Definition: types.cpp:361
EXIV2API long d2Data(byte *buf, double d, ByteOrder byteOrder)
Convert a double precision floating point (IEEE 754 binary64) double to data, write the data to the b...
Definition: types.cpp:483
EXIV2API long r2Data(byte *buf, Rational l, ByteOrder byteOrder)
Convert a signed rational to data, write the data to the buffer, return number of bytes written...
Definition: types.cpp:462
std::vector< T >::const_iterator const_iterator
Const iterator type defined for convenience.
Definition: value.hpp:1316
EXIV2API int16_t getShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte signed short value from the data buffer.
Definition: types.cpp:318
Value for simple ISO 8601 times.
Definition: value.hpp:1088
ValueType< int32_t > LongValue
Signed long value type.
Definition: value.hpp:1347
virtual long count() const
Return the number of components of the value.
Definition: value.hpp:1607
virtual int read(const byte *buf, long len, ByteOrder byteOrder=invalidByteOrder)
Read the value from a character buffer.
Definition: value.cpp:665
uint8_t byte
1 byte unsigned integer type.
Definition: types.hpp:105
Value for an Ascii string type.
Definition: value.hpp:458
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.
Definition: value.hpp:806
std::string toString(const T &arg)
Utility function to convert the argument of any type to a string.
Definition: types.hpp:521
Exif UNDEFINED type, an 8-bit byte that may contain anything.
Definition: types.hpp:137
bool ok() const
Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversi...
Definition: value.hpp:197
virtual int read(const byte *buf, long len, ByteOrder byteOrder)
Read the value from a character buffer.
Definition: value.hpp:1568
int minute
Minute.
Definition: value.hpp:1111
std::auto_ptr< XmpValue > AutoPtr
Shortcut for a XmpValue auto pointer.
Definition: value.hpp:636
Type definitions for Exiv2 and related functionality.
Value type for XMP language alternative properties.
Definition: value.hpp:899
ValueList value_
The container for all values. In your application, if you know what subclass of Value you're dealing ...
Definition: value.hpp:1325
virtual long sizeDataArea() const
Return the size of the data area.
Definition: value.hpp:1730
EXIV2API long s2Data(byte *buf, int16_t s, ByteOrder byteOrder)
Convert a signed short to data, write the data to the buffer, return number of bytes written...
Definition: types.cpp:432
ValueType< uint32_t > ULongValue
Unsigned long value type.
Definition: value.hpp:1341
XMP bag type.
Definition: types.hpp:154
virtual long copy(byte *buf, ByteOrder byteOrder) const
Write value to a data buffer.
Definition: value.hpp:1596
Exif LONG type, 32-bit (4-byte) unsigned integer.
Definition: types.hpp:134
std::vector< T >::iterator iterator
Iterator type defined for convenience.
Definition: value.hpp:1314
EXIV2API URational getURational(const byte *buf, ByteOrder byteOrder)
Read an 8 byte unsigned rational value from the data buffer.
Definition: types.cpp:311
EXIV2API long f2Data(byte *buf, float f, ByteOrder byteOrder)
Convert a single precision floating point (IEEE 754 binary32) float to data, write the data to the bu...
Definition: types.cpp:469
virtual ~ValueType()
Virtual destructor.
Definition: value.hpp:1543
std::map< std::string, std::string, LangAltValueComparator > ValueType
Type used to store language alternative arrays.
Definition: value.hpp:971
std::string value_
Stores the string value.
Definition: value.hpp:415
TypeId getType< int16_t >()
Specialization for a signed short.
Definition: value.hpp:1226
LangAltValueComparator
Definition: value.hpp:870
virtual int setDataArea(const byte *buf, long len)
Set the data area. This method copies (clones) the buffer pointed to by buf.
Definition: value.hpp:1742
TypeId getType()
Template to determine the TypeId for a type T.
virtual int read(const std::string &buf)
Read the value from buf. This default implementation uses buf as it is.
Definition: value.cpp:321
Exif RATIONAL type, two LONGs: numerator and denumerator of a fraction.
Definition: types.hpp:135
virtual DataBuf dataArea() const
Return a copy of the data area in a DataBuf. The caller owns this copy and DataBuf ensures that it wi...
Definition: value.hpp:1736
TypeId getType< uint32_t >()
Specialization for an unsigned long.
Definition: value.hpp:1222
Value for an undefined data type.
Definition: value.hpp:262
std::auto_ptr< StringValueBase > AutoPtr
Shortcut for a StringValueBase auto pointer.
Definition: value.hpp:347
AutoPtr clone() const
Return an auto-pointer to a copy of itself (deep copy). The caller owns this copy and the auto-pointe...
Definition: value.hpp:119
ValueType()
Default Constructor.
Definition: value.hpp:1506
TIFF DOUBLE type, double precision (8-byte) IEEE format.
Definition: types.hpp:142
virtual Rational toRational(long n=0) const
Convert the n-th component of the value to a Rational. The behaviour of this method may be undefined ...
Definition: value.hpp:1693
EXIV2API long ul2Data(byte *buf, uint32_t l, ByteOrder byteOrder)
Convert an unsigned long to data, write the data to the buffer, return number of bytes written...
Definition: types.cpp:408
Exif SSHORT type, a 16-bit (2-byte) signed (twos-complement) integer.
Definition: types.hpp:138
ValueType< uint16_t > UShortValue
Unsigned short value type.
Definition: value.hpp:1339
ValueType< int16_t > ShortValue
Signed short value type.
Definition: value.hpp:1345
XmpStruct
XMP structure indicator.
Definition: value.hpp:641
std::string value_
Stores the string values.
Definition: value.hpp:793
ValueType< double > DoubleValue
Double value type.
Definition: value.hpp:1353
TIFF FLOAT type, single precision (4-byte) IEEE format.
Definition: types.hpp:141
std::pair< uint32_t, uint32_t > URational
8 byte unsigned rational type.
Definition: types.hpp:108
EXIV2API long us2Data(byte *buf, uint16_t s, ByteOrder byteOrder)
Convert an unsigned short to data, write the data to the buffer, return number of bytes written...
Definition: types.cpp:395
Base class for all Exiv2 values used to store XMP property values.
Definition: value.hpp:633
EXIV2API long ur2Data(byte *buf, URational l, ByteOrder byteOrder)
Convert an unsigned rational to data, write the data to the buffer, return number of bytes written...
Definition: types.cpp:425
EXIV2API int32_t getLong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte signed long value from the data buffer.
Definition: types.cpp:328
EXIV2API uint32_t getULong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte unsigned long value from the data buffer.
Definition: types.cpp:283
IPTC string type.
Definition: types.hpp:147
Common interface for all types of values used with metadata.
Definition: value.hpp:60
std::auto_ptr< Value > AutoPtr
Shortcut for a Value auto pointer.
Definition: value.hpp:63
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...
std::auto_ptr< ValueType< T > > AutoPtr
Shortcut for a ValueType<T> auto pointer.
Definition: value.hpp:1247
std::auto_ptr< LangAltValue > AutoPtr
Shortcut for a LangAltValue auto pointer.
Definition: value.hpp:902
ValueType< float > FloatValue
Float value type.
Definition: value.hpp:1351
virtual long size() const
Return the size of the value in bytes.
Definition: value.hpp:1613
ValueType< T > & operator=(const ValueType< T > &rhs)
Assignment operator.
Definition: value.hpp:1549
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
int day
Day.
Definition: value.hpp:1007
std::auto_ptr< StringValue > AutoPtr
Shortcut for a StringValue auto pointer.
Definition: value.hpp:429
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition: datasets.cpp:709
int month
Month.
Definition: value.hpp:1006
bool ok_
Indicates the status of the previous to<Type> conversion.
Definition: value.hpp:245
Exiv2 type for the Exif user comment.
Definition: types.hpp:150
int year
Year.
Definition: value.hpp:1005
int tzMinute
Minutes ahead or behind UTC.
Definition: value.hpp:1114
TypeId getType< double >()
Specialization for a double.
Definition: value.hpp:1234
int hour
Hour.
Definition: value.hpp:1110
std::string toString() const
Return the value as a string. Implemented in terms of write(std::ostream& os) const of the concrete c...
Definition: value.cpp:175
Abstract base class for a string based Value type.
Definition: value.hpp:344
Value for simple ISO 8601 dates
Definition: value.hpp:987
EXIV2API Rational getRational(const byte *buf, ByteOrder byteOrder)
Read an 8 byte signed rational value from the data buffer.
Definition: types.cpp:340
static long typeSize(TypeId typeId)
Return the size in bytes of one element of this type.
Definition: types.cpp:121
Value for string type.
Definition: value.hpp:426
TypeId getType< Rational >()
Specialization for a signed rational.
Definition: value.hpp:1230
virtual std::ostream & write(std::ostream &os) const
Write the value to an output stream. You do not usually have to use this function; it is used for the...
Definition: value.hpp:1625
ValueType< URational > URationalValue
Unsigned rational value type.
Definition: value.hpp:1343
std::auto_ptr< XmpTextValue > AutoPtr
Shortcut for a XmpTextValue auto pointer.
Definition: value.hpp:727
std::auto_ptr< AsciiValue > AutoPtr
Shortcut for a AsciiValue auto pointer.
Definition: value.hpp:461
ValueType< Rational > RationalValue
Signed rational value type.
Definition: value.hpp:1349
Value & operator=(const Value &rhs)
Assignment operator. Protected so that it can only be used by subclasses but not directly.
Definition: value.cpp:92
Simple Time helper structure.
Definition: value.hpp:1106
TypeId getType< float >()
Specialization for a float.
Definition: value.hpp:1232
EXIV2API float getFloat(const byte *buf, ByteOrder byteOrder)
Read a 4 byte single precision floating point value (IEEE 754 binary32) from the data buffer...
Definition: types.cpp:347
TypeId getType< int32_t >()
Specialization for a signed long.
Definition: value.hpp:1228
EXIV2API uint16_t getUShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte unsigned short value from the data buffer.
Definition: types.cpp:278
TypeId getType< URational >()
Specialization for an unsigned rational.
Definition: value.hpp:1224