value.hpp
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004-2021 Exiv2 authors
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
#ifndef VALUE_HPP_
#define VALUE_HPP_
// *****************************************************************************
#include "exiv2lib_export.h"
// included header files
#include "types.hpp"
// + standard includes
#include <map>
#include <iomanip>
#include <memory>
#include <cstring>
#include <climits>
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
// *****************************************************************************
// class definitions
class EXIV2API Value {
public:
typedef std::auto_ptr<Value> AutoPtr;
explicit Value(TypeId typeId);
virtual ~Value();
virtual int read(const byte* buf, long len, ByteOrder byteOrder) =0;
virtual int read(const std::string& buf) =0;
virtual int setDataArea(const byte* buf, long len);
TypeId typeId() const { return type_; }
AutoPtr clone() const { return AutoPtr(clone_()); }
virtual long copy(byte* buf, ByteOrder byteOrder) const =0;
virtual long count() const =0;
virtual long size() const =0;
virtual std::ostream& write(std::ostream& os) const =0;
std::string toString() const;
virtual std::string toString(long n) const;
virtual long toLong(long n =0) const =0;
virtual float toFloat(long n =0) const =0;
virtual Rational toRational(long n =0) const =0;
virtual long sizeDataArea() const;
virtual DataBuf dataArea() const;
bool ok() const { return ok_; }
static AutoPtr create(TypeId typeId);
protected:
Value& operator=(const Value& rhs);
// DATA
mutable bool ok_;
private:
virtual Value* clone_() const =0;
// DATA
TypeId type_;
}; // class Value
inline std::ostream& operator<<(std::ostream& os, const Value& value)
{
return value.write(os);
}
class EXIV2API DataValue : public Value {
public:
typedef std::auto_ptr<DataValue> AutoPtr;
explicit DataValue(TypeId typeId =undefined);
DataValue(const byte* buf,
long len, ByteOrder byteOrder =invalidByteOrder,
TypeId typeId =undefined);
virtual ~DataValue();
virtual int read(const byte* buf,
long len,
ByteOrder byteOrder =invalidByteOrder);
virtual int read(const std::string& buf);
AutoPtr clone() const { return AutoPtr(clone_()); }
virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
virtual long count() const;
virtual long size() const;
virtual std::ostream& write(std::ostream& os) const;
virtual std::string toString(long n) const;
virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const;
virtual Rational toRational(long n =0) const;
private:
virtual DataValue* clone_() const;
typedef std::vector<byte> ValueType;
// DATA
ValueType value_;
}; // class DataValue
class EXIV2API StringValueBase : public Value {
public:
typedef std::auto_ptr<StringValueBase> AutoPtr;
explicit StringValueBase(TypeId typeId);
StringValueBase(TypeId typeId, const std::string& buf);
StringValueBase(const StringValueBase& rhs);
virtual ~StringValueBase();
virtual int read(const std::string& buf);
virtual int read(const byte* buf,
long len,
ByteOrder byteOrder =invalidByteOrder);
AutoPtr clone() const { return AutoPtr(clone_()); }
virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
virtual long count() const;
virtual long size() const;
virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const;
virtual Rational toRational(long n =0) const;
virtual std::ostream& write(std::ostream& os) const;
protected:
StringValueBase& operator=(const StringValueBase& rhs);
virtual StringValueBase* clone_() const =0;
public:
// DATA
std::string value_;
}; // class StringValueBase
class EXIV2API StringValue : public StringValueBase {
public:
typedef std::auto_ptr<StringValue> AutoPtr;
StringValue();
explicit StringValue(const std::string& buf);
virtual ~StringValue();
AutoPtr clone() const { return AutoPtr(clone_()); }
private:
virtual StringValue* clone_() const;
}; // class StringValue
class EXIV2API AsciiValue : public StringValueBase {
public:
typedef std::auto_ptr<AsciiValue> AutoPtr;
AsciiValue();
explicit AsciiValue(const std::string& buf);
virtual ~AsciiValue();
using StringValueBase::read;
virtual int read(const std::string& buf);
AutoPtr clone() const { return AutoPtr(clone_()); }
virtual std::ostream& write(std::ostream& os) const;
private:
virtual AsciiValue* clone_() const;
}; // class AsciiValue
class EXIV2API CommentValue : public StringValueBase {
public:
enum CharsetId { ascii, jis, unicode, undefined,
invalidCharsetId, lastCharsetId };
struct CharsetTable {
CharsetTable(CharsetId charsetId,
const char* name,
const char* code);
CharsetId charsetId_;
const char* name_;
const char* code_;
}; // struct CharsetTable
class EXIV2API CharsetInfo {
CharsetInfo() {}
CharsetInfo(const CharsetInfo&);
CharsetInfo& operator=(const CharsetInfo&);
public:
static const char* name(CharsetId charsetId);
static const char* code(CharsetId charsetId);
static CharsetId charsetIdByName(const std::string& name);
static CharsetId charsetIdByCode(const std::string& code);
private:
static const CharsetTable charsetTable_[];
}; // class CharsetInfo
typedef std::auto_ptr<CommentValue> AutoPtr;
CommentValue();
explicit CommentValue(const std::string& comment);
virtual ~CommentValue();
int read(const std::string& comment);
int read(const byte* buf, long len, ByteOrder byteOrder);
AutoPtr clone() const { return AutoPtr(clone_()); }
long copy(byte* buf, ByteOrder byteOrder) const;
std::ostream& write(std::ostream& os) const;
std::string comment(const char* encoding =0) const;
const char* detectCharset(std::string& c) const;
CharsetId charsetId() const;
private:
virtual CommentValue* clone_() const;
public:
// DATA
ByteOrder byteOrder_;
}; // class CommentValue
class EXIV2API XmpValue : public Value {
public:
typedef std::auto_ptr<XmpValue> AutoPtr;
enum XmpArrayType { xaNone, xaAlt, xaBag, xaSeq };
enum XmpStruct { xsNone, xsStruct };
explicit XmpValue(TypeId typeId);
XmpArrayType xmpArrayType() const;
XmpStruct xmpStruct() const;
virtual long size() const;
virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
void setXmpArrayType(XmpArrayType xmpArrayType);
void setXmpStruct(XmpStruct xmpStruct =xsStruct);
virtual int read(const byte* buf,
long len,
ByteOrder byteOrder =invalidByteOrder);
virtual int read(const std::string& buf) =0;
static XmpArrayType xmpArrayType(TypeId typeId);
protected:
XmpValue& operator=(const XmpValue& rhs);
private:
// DATA
XmpArrayType xmpArrayType_;
XmpStruct xmpStruct_;
}; // class XmpValue
class EXIV2API XmpTextValue : public XmpValue {
public:
typedef std::auto_ptr<XmpTextValue> AutoPtr;
XmpTextValue();
explicit XmpTextValue(const std::string& buf);
using XmpValue::read;
virtual int read(const std::string& buf);
AutoPtr clone() const;
long size() const;
virtual long count() const;
virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const;
virtual Rational toRational(long n =0) const;
virtual std::ostream& write(std::ostream& os) const;
private:
virtual XmpTextValue* clone_() const;
public:
// DATA
std::string value_;
}; // class XmpTextValue
class EXIV2API XmpArrayValue : public XmpValue {
public:
typedef std::auto_ptr<XmpArrayValue> AutoPtr;
explicit XmpArrayValue(TypeId typeId =xmpBag);
using XmpValue::read;
virtual int read(const std::string& buf);
AutoPtr clone() const;
virtual long count() const;
virtual std::string toString(long n) const;
virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const;
virtual Rational toRational(long n =0) const;
virtual std::ostream& write(std::ostream& os) const;
private:
virtual XmpArrayValue* clone_() const;
std::vector<std::string> value_;
}; // class XmpArrayValue
struct LangAltValueComparator {
bool operator() (const std::string& str1, const std::string& str2) const
{
int result = str1.size() < str2.size() ? 1
: str1.size() > str2.size() ? -1
: 0
;
std::string::const_iterator c1 = str1.begin();
std::string::const_iterator c2 = str2.begin();
if ( result==0 ) for (
; result==0 && c1 != str1.end()
; ++c1, ++c2
) {
result = tolower(*c1) < tolower(*c2) ? 1
: tolower(*c1) > tolower(*c2) ? -1
: 0
;
}
return result < 0 ;
}
};
class EXIV2API LangAltValue : public XmpValue {
public:
typedef std::auto_ptr<LangAltValue> AutoPtr;
LangAltValue();
explicit LangAltValue(const std::string& buf);
using XmpValue::read;
virtual int read(const std::string& buf);
AutoPtr clone() const;
virtual long count() const;
virtual std::string toString(long n) const;
std::string toString(const std::string& qualifier) const;
virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const;
virtual Rational toRational(long n =0) const;
virtual std::ostream& write(std::ostream& os) const;
private:
virtual LangAltValue* clone_() const;
public:
typedef std::map<std::string, std::string,LangAltValueComparator> ValueType;
// DATA
ValueType value_;
}; // class LangAltValue
class EXIV2API DateValue : public Value {
public:
typedef std::auto_ptr<DateValue> AutoPtr;
DateValue();
DateValue(int year, int month, int day);
virtual ~DateValue();
struct EXIV2API Date {
Date() : year(0), month(0), day(0) {}
int year;
int month;
int day;
};
virtual int read(const byte* buf,
long len,
ByteOrder byteOrder =invalidByteOrder);
virtual int read(const std::string& buf);
void setDate(const Date& src);
AutoPtr clone() const { return AutoPtr(clone_()); }
virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
virtual const Date& getDate() const;
virtual long count() const;
virtual long size() const;
virtual std::ostream& write(std::ostream& os) const;
virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const;
virtual Rational toRational(long n =0) const;
private:
virtual DateValue* clone_() const;
// DATA
Date date_;
}; // class DateValue
class EXIV2API TimeValue : public Value {
public:
typedef std::auto_ptr<TimeValue> AutoPtr;
TimeValue();
TimeValue(int hour, int minute, int second =0,
int tzHour =0, int tzMinute =0);
virtual ~TimeValue();
struct Time
{
Time() : hour(0), minute(0), second(0), tzHour(0), tzMinute(0) {}
int hour;
int minute;
int second;
int tzHour;
int tzMinute;
};
virtual int read(const byte* buf,
long len,
ByteOrder byteOrder =invalidByteOrder);
virtual int read(const std::string& buf);
void setTime(const Time& src);
AutoPtr clone() const { return AutoPtr(clone_()); }
virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
virtual const Time& getTime() const;
virtual long count() const;
virtual long size() const;
virtual std::ostream& write(std::ostream& os) const;
virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const;
virtual Rational toRational(long n =0) const;
private:
int scanTime3(const char* buf, const char* format);
int scanTime6(const char* buf, const char* format);
virtual TimeValue* clone_() const;
// DATA
Time time_;
}; // class TimeValue
template<typename T> TypeId getType();
template<> inline TypeId getType<uint16_t>() { return unsignedShort; }
template<> inline TypeId getType<uint32_t>() { return unsignedLong; }
template<> inline TypeId getType<URational>() { return unsignedRational; }
template<> inline TypeId getType<int16_t>() { return signedShort; }
template<> inline TypeId getType<int32_t>() { return signedLong; }
template<> inline TypeId getType<Rational>() { return signedRational; }
template<> inline TypeId getType<float>() { return tiffFloat; }
template<> inline TypeId getType<double>() { return tiffDouble; }
// No default implementation: let the compiler/linker complain
// template<typename T> inline TypeId getType() { return invalid; }
template<typename T>
class ValueType : public Value {
public:
typedef std::auto_ptr<ValueType<T> > AutoPtr;
ValueType();
// The default c'tor and this one can be combined, but that causes MSVC 7.1 to fall on its nose
explicit ValueType(TypeId typeId);
ValueType(const byte* buf, long len, ByteOrder byteOrder, TypeId typeId =getType<T>());
explicit ValueType(const T& val, TypeId typeId =getType<T>());
ValueType(const ValueType<T>& rhs);
virtual ~ValueType();
ValueType<T>& operator=(const ValueType<T>& rhs);
virtual int read(const byte* buf, long len, ByteOrder byteOrder);
virtual int read(const std::string& buf);
virtual int setDataArea(const byte* buf, long len);
AutoPtr clone() const { return AutoPtr(clone_()); }
virtual long copy(byte* buf, ByteOrder byteOrder) const;
virtual long count() const;
virtual long size() const;
virtual std::ostream& write(std::ostream& os) const;
virtual std::string toString(long n) const;
virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const;
virtual Rational toRational(long n =0) const;
virtual long sizeDataArea() const;
virtual DataBuf dataArea() const;
typedef std::vector<T> ValueList;
typedef typename std::vector<T>::iterator iterator;
typedef typename std::vector<T>::const_iterator const_iterator;
// DATA
ValueList value_;
private:
virtual ValueType<T>* clone_() const;
// DATA
byte* pDataArea_;
long sizeDataArea_;
}; // class ValueType
typedef ValueType<uint16_t> UShortValue;
typedef ValueType<uint32_t> ULongValue;
typedef ValueType<URational> URationalValue;
typedef ValueType<int16_t> ShortValue;
typedef ValueType<int32_t> LongValue;
typedef ValueType<Rational> RationalValue;
typedef ValueType<float> FloatValue;
typedef ValueType<double> DoubleValue;
// *****************************************************************************
// free functions, template and inline definitions
template<typename T> T getValue(const byte* buf, ByteOrder byteOrder);
// Specialization for a 2 byte unsigned short value.
template<>
inline uint16_t getValue(const byte* buf, ByteOrder byteOrder)
{
return getUShort(buf, byteOrder);
}
// Specialization for a 4 byte unsigned long value.
template<>
inline uint32_t getValue(const byte* buf, ByteOrder byteOrder)
{
return getULong(buf, byteOrder);
}
// Specialization for an 8 byte unsigned rational value.
template<>
inline URational getValue(const byte* buf, ByteOrder byteOrder)
{
return getURational(buf, byteOrder);
}
// Specialization for a 2 byte signed short value.
template<>
inline int16_t getValue(const byte* buf, ByteOrder byteOrder)
{
return getShort(buf, byteOrder);
}
// Specialization for a 4 byte signed long value.
template<>
inline int32_t getValue(const byte* buf, ByteOrder byteOrder)
{
return getLong(buf, byteOrder);
}
// Specialization for an 8 byte signed rational value.
template<>
inline Rational getValue(const byte* buf, ByteOrder byteOrder)
{
return getRational(buf, byteOrder);
}
// Specialization for a 4 byte float value.
template<>
inline float getValue(const byte* buf, ByteOrder byteOrder)
{
return getFloat(buf, byteOrder);
}
// Specialization for a 8 byte double value.
template<>
inline double getValue(const byte* buf, ByteOrder byteOrder)
{
return getDouble(buf, byteOrder);
}
template<typename T> long toData(byte* buf, T t, ByteOrder byteOrder);
template<>
inline long toData(byte* buf, uint16_t t, ByteOrder byteOrder)
{
return us2Data(buf, t, byteOrder);
}
template<>
inline long toData(byte* buf, uint32_t t, ByteOrder byteOrder)
{
return ul2Data(buf, t, byteOrder);
}
template<>
inline long toData(byte* buf, URational t, ByteOrder byteOrder)
{
return ur2Data(buf, t, byteOrder);
}
template<>
inline long toData(byte* buf, int16_t t, ByteOrder byteOrder)
{
return s2Data(buf, t, byteOrder);
}
template<>
inline long toData(byte* buf, int32_t t, ByteOrder byteOrder)
{
return l2Data(buf, t, byteOrder);
}
template<>
inline long toData(byte* buf, Rational t, ByteOrder byteOrder)
{
return r2Data(buf, t, byteOrder);
}
template<>
inline long toData(byte* buf, float t, ByteOrder byteOrder)
{
return f2Data(buf, t, byteOrder);
}
template<>
inline long toData(byte* buf, double t, ByteOrder byteOrder)
{
return d2Data(buf, t, byteOrder);
}
template<typename T>
ValueType<T>::ValueType()
: Value(getType<T>()), pDataArea_(0), sizeDataArea_(0)
{
}
template<typename T>
ValueType<T>::ValueType(TypeId typeId)
: Value(typeId), pDataArea_(0), sizeDataArea_(0)
{
}
template<typename T>
ValueType<T>::ValueType(const byte* buf, long len, ByteOrder byteOrder, TypeId typeId)
: Value(typeId), pDataArea_(0), sizeDataArea_(0)
{
read(buf, len, byteOrder);
}
template<typename T>
ValueType<T>::ValueType(const T& val, TypeId typeId)
: Value(typeId), pDataArea_(0), sizeDataArea_(0)
{
value_.push_back(val);
}
template<typename T>
ValueType<T>::ValueType(const ValueType<T>& rhs)
: Value(rhs), value_(rhs.value_), pDataArea_(0), sizeDataArea_(0)
{
if (rhs.sizeDataArea_ > 0) {
pDataArea_ = new byte[rhs.sizeDataArea_];
std::memcpy(pDataArea_, rhs.pDataArea_, rhs.sizeDataArea_);
sizeDataArea_ = rhs.sizeDataArea_;
}
}
template<typename T>
ValueType<T>::~ValueType()
{
delete[] pDataArea_;
}
template<typename T>
ValueType<T>& ValueType<T>::operator=(const ValueType<T>& rhs)
{
if (this == &rhs) return *this;
Value::operator=(rhs);
value_ = rhs.value_;
byte* tmp = 0;
if (rhs.sizeDataArea_ > 0) {
tmp = new byte[rhs.sizeDataArea_];
std::memcpy(tmp, rhs.pDataArea_, rhs.sizeDataArea_);
}
delete[] pDataArea_;
pDataArea_ = tmp;
sizeDataArea_ = rhs.sizeDataArea_;
return *this;
}
template<typename T>
int ValueType<T>::read(const byte* buf, long len, ByteOrder byteOrder)
{
value_.clear();
long ts = TypeInfo::typeSize(typeId());
if (ts > 0)
if (len % ts != 0) len = (len / ts) * ts;
for (long i = 0; i < len; i += ts) {
value_.push_back(getValue<T>(buf + i, byteOrder));
}
return 0;
}
template<typename T>
int ValueType<T>::read(const std::string& buf)
{
std::istringstream is(buf);
T tmp = T();
ValueList val;
while (!(is.eof())) {
is >> tmp;
if (is.fail()) return 1;
val.push_back(tmp);
}
value_.swap(val);
return 0;
}
template<typename T>
long ValueType<T>::copy(byte* buf, ByteOrder byteOrder) const
{
long offset = 0;
typename ValueList::const_iterator end = value_.end();
for (typename ValueList::const_iterator i = value_.begin(); i != end; ++i) {
offset += toData(buf + offset, *i, byteOrder);
}
return offset;
}
template<typename T>
long ValueType<T>::count() const
{
return static_cast<long>(value_.size());
}
template<typename T>
long ValueType<T>::size() const
{
return static_cast<long>(TypeInfo::typeSize(typeId()) * value_.size());
}
template<typename T>
ValueType<T>* ValueType<T>::clone_() const
{
return new ValueType<T>(*this);
}
template<typename T>
std::ostream& ValueType<T>::write(std::ostream& os) const
{
typename ValueList::const_iterator end = value_.end();
typename ValueList::const_iterator i = value_.begin();
while (i != end) {
os << std::setprecision(15) << *i;
if (++i != end) os << " ";
}
return os;
}
template<typename T>
std::string ValueType<T>::toString(long n) const
{
ok_ = true;
return Exiv2::toString<T>(value_.at(n));
}
// Default implementation
template<typename T>
long ValueType<T>::toLong(long n) const
{
ok_ = true;
return static_cast<long>(value_.at(n));
}
// #55 crash when value_.at(n).first == LONG_MIN
#define LARGE_INT 1000000
// Specialization for double
template<>
inline long ValueType<double>::toLong(long n) const
{
const double v = value_.at(n);
ok_ = (INT_MIN <= v && v <= INT_MAX);
if (!ok_) return 0;
return static_cast<long>(v);
}
// Specialization for float
template<>
inline long ValueType<float>::toLong(long n) const
{
const double v = value_.at(n);
ok_ = (INT_MIN <= v && v <= INT_MAX);
if (!ok_) return 0;
return static_cast<long>(v);
}
// Specialization for rational
template<>
inline long ValueType<Rational>::toLong(long n) const
{
ok_ = (value_.at(n).second > 0 && INT_MIN < value_.at(n).first && value_.at(n).first < INT_MAX );
if (!ok_) return 0;
return value_.at(n).first / value_.at(n).second;
}
// Specialization for unsigned rational
template<>
inline long ValueType<URational>::toLong(long n) const
{
ok_ = (value_.at(n).second > 0 && value_.at(n).first < LARGE_INT);
if (!ok_) return 0;
return value_.at(n).first / value_.at(n).second;
}
// Default implementation
template<typename T>
float ValueType<T>::toFloat(long n) const
{
ok_ = true;
return static_cast<float>(value_.at(n));
}
// Specialization for rational
template<>
inline float ValueType<Rational>::toFloat(long n) const
{
ok_ = (value_.at(n).second != 0);
if (!ok_) return 0.0f;
return static_cast<float>(value_.at(n).first) / value_.at(n).second;
}
// Specialization for unsigned rational
template<>
inline float ValueType<URational>::toFloat(long n) const
{
ok_ = (value_.at(n).second != 0);
if (!ok_) return 0.0f;
return static_cast<float>(value_.at(n).first) / value_.at(n).second;
}
// Default implementation
template<typename T>
Rational ValueType<T>::toRational(long n) const
{
ok_ = true;
return Rational(value_.at(n), 1);
}
// Specialization for rational
template<>
inline Rational ValueType<Rational>::toRational(long n) const
{
ok_ = true;
return Rational(value_.at(n).first, value_.at(n).second);
}
// Specialization for unsigned rational
template<>
inline Rational ValueType<URational>::toRational(long n) const
{
ok_ = true;
return Rational(value_.at(n).first, value_.at(n).second);
}
// Specialization for float.
template<>
inline Rational ValueType<float>::toRational(long n) const
{
ok_ = true;
// Warning: This is a very simple conversion, see floatToRationalCast()
return floatToRationalCast(value_.at(n));
}
// Specialization for double.
template<>
inline Rational ValueType<double>::toRational(long n) const
{
ok_ = true;
// Warning: This is a very simple conversion, see floatToRationalCast()
return floatToRationalCast(static_cast<float>(value_.at(n)));
}
template<typename T>
long ValueType<T>::sizeDataArea() const
{
return sizeDataArea_;
}
template<typename T>
DataBuf ValueType<T>::dataArea() const
{
return DataBuf(pDataArea_, sizeDataArea_);
}
template<typename T>
int ValueType<T>::setDataArea(const byte* buf, long len)
{
byte* tmp = 0;
if (len > 0) {
tmp = new byte[len];
std::memcpy(tmp, buf, len);
}
delete[] pDataArea_;
pDataArea_ = tmp;
sizeDataArea_ = len;
return 0;
}
} // namespace Exiv2
#endif // #ifndef VALUE_HPP_
Exiv2::AsciiValue
Value for an Ascii string type.
Definition: value.hpp:449
Exiv2::AsciiValue::AutoPtr
std::auto_ptr< AsciiValue > AutoPtr
Shortcut for a AsciiValue auto pointer.
Definition: value.hpp:452
Exiv2::CommentValue::CharsetInfo
Charset information lookup functions. Implemented as a static class.
Definition: value.hpp:517
Exiv2::CommentValue
Value for an Exif comment.
Definition: value.hpp:500
Exiv2::CommentValue::byteOrder_
ByteOrder byteOrder_
Byte order of the comment string that was read.
Definition: value.hpp:617
Exiv2::CommentValue::AutoPtr
std::auto_ptr< CommentValue > AutoPtr
Shortcut for a CommentValue auto pointer.
Definition: value.hpp:540
Exiv2::CommentValue::CharsetId
CharsetId
Character set identifiers for the character sets defined by Exif.
Definition: value.hpp:503
Exiv2::DataBuf
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:193
Exiv2::DataValue
Value for an undefined data type.
Definition: value.hpp:253
Exiv2::DataValue::AutoPtr
std::auto_ptr< DataValue > AutoPtr
Shortcut for a DataValue auto pointer.
Definition: value.hpp:256
Exiv2::DateValue
Value for simple ISO 8601 dates
Definition: value.hpp:978
Exiv2::DateValue::AutoPtr
std::auto_ptr< DateValue > AutoPtr
Shortcut for a DateValue auto pointer.
Definition: value.hpp:981
Exiv2::LangAltValue
Value type for XMP language alternative properties.
Definition: value.hpp:890
Exiv2::LangAltValue::AutoPtr
std::auto_ptr< LangAltValue > AutoPtr
Shortcut for a LangAltValue auto pointer.
Definition: value.hpp:893
Exiv2::LangAltValue::ValueType
std::map< std::string, std::string, LangAltValueComparator > ValueType
Type used to store language alternative arrays.
Definition: value.hpp:962
Exiv2::LangAltValue::value_
ValueType value_
Map to store the language alternative values. The language qualifier is used as the key for the map e...
Definition: value.hpp:968
Exiv2::StringValueBase
Abstract base class for a string based Value type.
Definition: value.hpp:335
Exiv2::StringValueBase::value_
std::string value_
Stores the string value.
Definition: value.hpp:406
Exiv2::StringValueBase::AutoPtr
std::auto_ptr< StringValueBase > AutoPtr
Shortcut for a StringValueBase auto pointer.
Definition: value.hpp:338
Exiv2::StringValueBase::read
virtual int read(const std::string &buf)
Read the value from buf. This default implementation uses buf as it is.
Definition: value.cpp:314
Exiv2::StringValueBase::clone_
virtual StringValueBase * clone_() const =0
Internal virtual copy constructor.
Exiv2::StringValue
Value for string type.
Definition: value.hpp:417
Exiv2::StringValue::AutoPtr
std::auto_ptr< StringValue > AutoPtr
Shortcut for a StringValue auto pointer.
Definition: value.hpp:420
Exiv2::TimeValue
Value for simple ISO 8601 times.
Definition: value.hpp:1079
Exiv2::TimeValue::AutoPtr
std::auto_ptr< TimeValue > AutoPtr
Shortcut for a TimeValue auto pointer.
Definition: value.hpp:1082
Exiv2::TypeInfo::typeSize
static long typeSize(TypeId typeId)
Return the size in bytes of one element of this type.
Definition: types.cpp:116
Exiv2::ValueType
Template for a Value of a basic type. This is used for unsigned and signed short, long and rationals.
Definition: value.hpp:1235
Exiv2::ValueType::operator=
ValueType< T > & operator=(const ValueType< T > &rhs)
Assignment operator.
Definition: value.hpp:1540
Exiv2::ValueType::AutoPtr
std::auto_ptr< ValueType< T > > AutoPtr
Shortcut for a ValueType<T> auto pointer.
Definition: value.hpp:1238
Exiv2::ValueType::toLong
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:1636
Exiv2::ValueType::count
virtual long count() const
Return the number of components of the value.
Definition: value.hpp:1598
Exiv2::ValueType::setDataArea
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:1751
Exiv2::ValueType::iterator
std::vector< T >::iterator iterator
Iterator type defined for convenience.
Definition: value.hpp:1305
Exiv2::ValueType::size
virtual long size() const
Return the size of the value in bytes.
Definition: value.hpp:1604
Exiv2::ValueType::sizeDataArea
virtual long sizeDataArea() const
Return the size of the data area.
Definition: value.hpp:1739
Exiv2::ValueType::~ValueType
virtual ~ValueType()
Virtual destructor.
Definition: value.hpp:1534
Exiv2::ValueType::read
virtual int read(const byte *buf, long len, ByteOrder byteOrder)
Read the value from a character buffer.
Definition: value.hpp:1559
Exiv2::ValueType::ValueList
std::vector< T > ValueList
Container for values.
Definition: value.hpp:1303
Exiv2::ValueType::dataArea
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:1745
Exiv2::ValueType::ValueType
ValueType()
Default Constructor.
Definition: value.hpp:1497
Exiv2::ValueType::toRational
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:1702
Exiv2::ValueType::write
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:1616
Exiv2::ValueType::const_iterator
std::vector< T >::const_iterator const_iterator
Const iterator type defined for convenience.
Definition: value.hpp:1307
Exiv2::ValueType::toFloat
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:1679
Exiv2::ValueType::value_
ValueList value_
The container for all values. In your application, if you know what subclass of Value you're dealing ...
Definition: value.hpp:1316
Exiv2::ValueType::copy
virtual long copy(byte *buf, ByteOrder byteOrder) const
Write value to a data buffer.
Definition: value.hpp:1587
Exiv2::Value
Common interface for all types of values used with metadata.
Definition: value.hpp:51
Exiv2::Value::typeId
TypeId typeId() const
Return the type identifier (Exif data format type).
Definition: value.hpp:104
Exiv2::Value::AutoPtr
std::auto_ptr< Value > AutoPtr
Shortcut for a Value auto pointer.
Definition: value.hpp:54
Exiv2::Value::clone
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:110
Exiv2::Value::toFloat
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 ...
Exiv2::Value::write
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...
Exiv2::Value::read
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() metho...
Exiv2::Value::size
virtual long size() const =0
Return the size of the value in bytes.
Exiv2::Value::copy
virtual long copy(byte *buf, ByteOrder byteOrder) const =0
Write value to a data buffer.
Exiv2::Value::toLong
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 t...
Exiv2::Value::ok_
bool ok_
Indicates the status of the previous to<Type> conversion.
Definition: value.hpp:236
Exiv2::Value::ok
bool ok() const
Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversi...
Definition: value.hpp:188
Exiv2::Value::toRational
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 ...
Exiv2::Value::toString
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:168
Exiv2::Value::operator=
Value & operator=(const Value &rhs)
Assignment operator. Protected so that it can only be used by subclasses but not directly.
Definition: value.cpp:85
Exiv2::Value::read
virtual int read(const byte *buf, long len, ByteOrder byteOrder)=0
Read the value from a character buffer.
Exiv2::Value::count
virtual long count() const =0
Return the number of components of the value.
Exiv2::XmpArrayValue
Value type for simple arrays. Each item in the array is a simple value, without qualifiers....
Definition: value.hpp:797
Exiv2::XmpArrayValue::AutoPtr
std::auto_ptr< XmpArrayValue > AutoPtr
Shortcut for a XmpArrayValue auto pointer.
Definition: value.hpp:800
Exiv2::XmpTextValue
Value type suitable for simple XMP properties and XMP nodes of complex types which are not parsed int...
Definition: value.hpp:715
Exiv2::XmpTextValue::AutoPtr
std::auto_ptr< XmpTextValue > AutoPtr
Shortcut for a XmpTextValue auto pointer.
Definition: value.hpp:718
Exiv2::XmpTextValue::value_
std::string value_
Stores the string values.
Definition: value.hpp:784
Exiv2::XmpValue
Base class for all Exiv2 values used to store XMP property values.
Definition: value.hpp:624
Exiv2::XmpValue::AutoPtr
std::auto_ptr< XmpValue > AutoPtr
Shortcut for a XmpValue auto pointer.
Definition: value.hpp:627
Exiv2::XmpValue::read
virtual int read(const byte *buf, long len, ByteOrder byteOrder=invalidByteOrder)
Read the value from a character buffer.
Definition: value.cpp:664
Exiv2::XmpValue::XmpStruct
XmpStruct
XMP structure indicator.
Definition: value.hpp:632
Exiv2::XmpValue::read
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() metho...
Exiv2::XmpValue::XmpArrayType
XmpArrayType
XMP array types.
Definition: value.hpp:630
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::operator<<
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition: datasets.cpp:709
Exiv2::getDouble
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:356
Exiv2::getType< int32_t >
TypeId getType< int32_t >()
Specialization for a signed long.
Definition: value.hpp:1219
Exiv2::f2Data
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:464
Exiv2::d2Data
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:478
Exiv2::URationalValue
ValueType< URational > URationalValue
Unsigned rational value type.
Definition: value.hpp:1334
Exiv2::getFloat
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:342
Exiv2::getType< int16_t >
TypeId getType< int16_t >()
Specialization for a signed short.
Definition: value.hpp:1217
Exiv2::floatToRationalCast
EXIV2API Rational floatToRationalCast(float f)
Very simple conversion of a float to a Rational.
Definition: types.cpp:689
Exiv2::l2Data
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:440
Exiv2::getShort
EXIV2API int16_t getShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte signed short value from the data buffer.
Definition: types.cpp:313
Exiv2::UShortValue
ValueType< uint16_t > UShortValue
Unsigned short value type.
Definition: value.hpp:1330
Exiv2::getType< uint32_t >
TypeId getType< uint32_t >()
Specialization for an unsigned long.
Definition: value.hpp:1213
Exiv2::getULong
EXIV2API uint32_t getULong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte unsigned long value from the data buffer.
Definition: types.cpp:278
Exiv2::ul2Data
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:403
Exiv2::LongValue
ValueType< int32_t > LongValue
Signed long value type.
Definition: value.hpp:1338
Exiv2::getValue
T getValue(const byte *buf, ByteOrder byteOrder)
Read a value of type T from the data buffer.
Definition: value.hpp:1363
Exiv2::TypeId
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:119
Exiv2::unsignedShort
@ unsignedShort
Exif SHORT type, 16-bit (2-byte) unsigned integer.
Definition: types.hpp:122
Exiv2::signedRational
@ signedRational
Exif SRATIONAL type, two SLONGs: numerator and denumerator of a fraction.
Definition: types.hpp:129
Exiv2::unsignedLong
@ unsignedLong
Exif LONG type, 32-bit (4-byte) unsigned integer.
Definition: types.hpp:123
Exiv2::signedShort
@ signedShort
Exif SSHORT type, a 16-bit (2-byte) signed (twos-complement) integer.
Definition: types.hpp:127
Exiv2::signedLong
@ signedLong
Exif SLONG type, a 32-bit (4-byte) signed (twos-complement) integer.
Definition: types.hpp:128
Exiv2::comment
@ comment
Exiv2 type for the Exif user comment.
Definition: types.hpp:139
Exiv2::tiffDouble
@ tiffDouble
TIFF DOUBLE type, double precision (8-byte) IEEE format.
Definition: types.hpp:131
Exiv2::undefined
@ undefined
Exif UNDEFINED type, an 8-bit byte that may contain anything.
Definition: types.hpp:126
Exiv2::xmpBag
@ xmpBag
XMP bag type.
Definition: types.hpp:143
Exiv2::tiffFloat
@ tiffFloat
TIFF FLOAT type, single precision (4-byte) IEEE format.
Definition: types.hpp:130
Exiv2::unsignedRational
@ unsignedRational
Exif RATIONAL type, two LONGs: numerator and denumerator of a fraction.
Definition: types.hpp:124
Exiv2::toData
long toData(byte *buf, T t, ByteOrder byteOrder)
Convert a value of type T to data, write the data to the data buffer.
Exiv2::getUShort
EXIV2API uint16_t getUShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte unsigned short value from the data buffer.
Definition: types.cpp:273
Exiv2::ShortValue
ValueType< int16_t > ShortValue
Signed short value type.
Definition: value.hpp:1336
Exiv2::FloatValue
ValueType< float > FloatValue
Float value type.
Definition: value.hpp:1342
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:102
Exiv2::Rational
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition: types.hpp:99
Exiv2::getType< uint16_t >
TypeId getType< uint16_t >()
Specialization for an unsigned short.
Definition: value.hpp:1211
Exiv2::ULongValue
ValueType< uint32_t > ULongValue
Unsigned long value type.
Definition: value.hpp:1332
Exiv2::RationalValue
ValueType< Rational > RationalValue
Signed rational value type.
Definition: value.hpp:1340
Exiv2::getRational
EXIV2API Rational getRational(const byte *buf, ByteOrder byteOrder)
Read an 8 byte signed rational value from the data buffer.
Definition: types.cpp:335
Exiv2::r2Data
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:457
Exiv2::getType< URational >
TypeId getType< URational >()
Specialization for an unsigned rational.
Definition: value.hpp:1215
Exiv2::getType< float >
TypeId getType< float >()
Specialization for a float.
Definition: value.hpp:1223
Exiv2::ur2Data
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:420
Exiv2::getLong
EXIV2API int32_t getLong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte signed long value from the data buffer.
Definition: types.cpp:323
Exiv2::getType< Rational >
TypeId getType< Rational >()
Specialization for a signed rational.
Definition: value.hpp:1221
Exiv2::getType< double >
TypeId getType< double >()
Specialization for a double.
Definition: value.hpp:1225
Exiv2::s2Data
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:427
Exiv2::toString
std::string toString(const T &arg)
Utility function to convert the argument of any type to a string.
Definition: types.hpp:510
Exiv2::URational
std::pair< uint32_t, uint32_t > URational
8 byte unsigned rational type.
Definition: types.hpp:97
Exiv2::getType
TypeId getType()
Template to determine the TypeId for a type T.
Exiv2::getURational
EXIV2API URational getURational(const byte *buf, ByteOrder byteOrder)
Read an 8 byte unsigned rational value from the data buffer.
Definition: types.cpp:306
Exiv2::DoubleValue
ValueType< double > DoubleValue
Double value type.
Definition: value.hpp:1344
Exiv2::us2Data
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:390
Exiv2::CommentValue::CharsetTable
Information pertaining to the defined character sets.
Definition: value.hpp:506
Exiv2::CommentValue::CharsetTable::charsetId_
CharsetId charsetId_
Charset id.
Definition: value.hpp:511
Exiv2::CommentValue::CharsetTable::name_
const char * name_
Name of the charset.
Definition: value.hpp:512
Exiv2::CommentValue::CharsetTable::code_
const char * code_
Code of the charset.
Definition: value.hpp:513
Exiv2::DateValue::Date
Simple Date helper structure.
Definition: value.hpp:994
Exiv2::DateValue::Date::year
int year
Year.
Definition: value.hpp:996
Exiv2::DateValue::Date::month
int month
Month.
Definition: value.hpp:997
Exiv2::DateValue::Date::day
int day
Day.
Definition: value.hpp:998
Exiv2::LangAltValueComparator
LangAltValueComparator
Definition: value.hpp:861
Exiv2::LangAltValueComparator::operator()
bool operator()(const std::string &str1, const std::string &str2) const
LangAltValueComparator comparison case insensitive function.
Definition: value.hpp:863
Exiv2::TimeValue::Time
Simple Time helper structure.
Definition: value.hpp:1098
Exiv2::TimeValue::Time::minute
int minute
Minute.
Definition: value.hpp:1102
Exiv2::TimeValue::Time::second
int second
Second.
Definition: value.hpp:1103
Exiv2::TimeValue::Time::hour
int hour
Hour.
Definition: value.hpp:1101
Exiv2::TimeValue::Time::tzHour
int tzHour
Hours ahead or behind UTC.
Definition: value.hpp:1104
Exiv2::TimeValue::Time::tzMinute
int tzMinute
Minutes ahead or behind UTC.
Definition: value.hpp:1105