Replace Value::toLong with Value::toInt64. (#2062)

* Replace Value::toLong with Value::toInt64.

* Fix compiler warning.

* Fix compile error.

* Fix declaration of canonEv

* Fix compiler warning.

* Fix compiler warning.

* Use int64_t for offsets in tiffcomposite_int.cpp

* Fix compiler warning.

* Fix compiler warnings.

* Fix compiler warning.

* Fix compiler warning.

* Fix compiler warning.

* Fix compiler warning.

* Remove static_cast<long int> in TagDetails initializer.
main
Kevin Backhouse 3 years ago committed by GitHub
parent a8a995f546
commit 2a3dd2def9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -380,18 +380,32 @@ namespace Exiv2 {
EXIV2API std::string ws2s(const std::wstring& s); EXIV2API std::string ws2s(const std::wstring& s);
#endif #endif
/*! /*!
@brief Return a \em long set to the value represented by \em s. @brief Return a \em int64_t set to the value represented by \em s.
Besides strings that represent \em long values, the function also Besides strings that represent \em int64_t values, the function also
handles \em float, \em Rational and boolean handles \em float, \em Rational and boolean
(see also: stringTo(const std::string& s, bool& ok)). (see also: stringTo(const std::string& s, bool& ok)).
@param s String to parse @param s String to parse
@param ok Output variable indicating the success of the operation. @param ok Output variable indicating the success of the operation.
@return Returns the \em long value represented by \em s and sets \em ok @return Returns the \em int64_t value represented by \em s and sets \em ok
to \c true if the conversion was successful or \c false if not. to \c true if the conversion was successful or \c false if not.
*/ */
EXIV2API long parseLong(const std::string& s, bool& ok); EXIV2API int64_t parseInt64(const std::string& s, bool& ok);
/*!
@brief Return a \em uint32_t set to the value represented by \em s.
Besides strings that represent \em uint32_t values, the function also
handles \em float, \em Rational and boolean
(see also: stringTo(const std::string& s, bool& ok)).
@param s String to parse
@param ok Output variable indicating the success of the operation.
@return Returns the \em uint32_t value represented by \em s and sets \em ok
to \c true if the conversion was successful or \c false if not.
*/
EXIV2API uint32_t parseUint32(const std::string& s, bool& ok);
/*! /*!
@brief Return a \em float set to the value represented by \em s. @brief Return a \em float set to the value represented by \em s.

@ -143,13 +143,21 @@ namespace Exiv2 {
*/ */
virtual std::string toString(long n) const; virtual std::string toString(long n) const;
/*! /*!
@brief Convert the <EM>n</EM>-th component of the value to a long. @brief Convert the <EM>n</EM>-th component of the value to an int64_t.
The behaviour of this method may be undefined if there is no The behaviour of this method may be undefined if there is no
<EM>n</EM>-th component. <EM>n</EM>-th component.
@return The converted value. @return The converted value.
*/ */
virtual long toLong(long n =0) const =0; virtual int64_t toInt64(long n =0) const =0;
/*!
@brief Convert the <EM>n</EM>-th component of the value to a float.
The behaviour of this method may be undefined if there is no
<EM>n</EM>-th component.
@return The converted value.
*/
virtual uint32_t toUint32(long n =0) const =0;
/*! /*!
@brief Convert the <EM>n</EM>-th component of the value to a float. @brief Convert the <EM>n</EM>-th component of the value to a float.
The behaviour of this method may be undefined if there is no The behaviour of this method may be undefined if there is no
@ -308,7 +316,8 @@ namespace Exiv2 {
<EM>n</EM>-th component. <EM>n</EM>-th component.
*/ */
std::string toString(long n) const override; std::string toString(long n) const override;
long toLong(long n = 0) const override; int64_t toInt64(long n = 0) const override;
uint32_t toUint32(long n = 0) const override;
float toFloat(long n = 0) const override; float toFloat(long n = 0) const override;
Rational toRational(long n = 0) const override; Rational toRational(long n = 0) const override;
//@} //@}
@ -385,7 +394,8 @@ namespace Exiv2 {
long copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override; long copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
long count() const override; long count() const override;
long size() const override; long size() const override;
long toLong(long n = 0) const override; int64_t toInt64(long n = 0) const override;
uint32_t toUint32(long n = 0) const override;
float toFloat(long n = 0) const override; float toFloat(long n = 0) const override;
Rational toRational(long n = 0) const override; Rational toRational(long n = 0) const override;
std::ostream& write(std::ostream& os) const override; std::ostream& write(std::ostream& os) const override;
@ -739,12 +749,19 @@ namespace Exiv2 {
long size() const override; long size() const override;
long count() const override; long count() const override;
/*! /*!
@brief Convert the value to a long. @brief Convert the value to an int64_t.
The optional parameter \em n is not used and is ignored.
@return The converted value.
*/
int64_t toInt64(long n = 0) const override;
/*!
@brief Convert the value to an uint32_t.
The optional parameter \em n is not used and is ignored. The optional parameter \em n is not used and is ignored.
@return The converted value. @return The converted value.
*/ */
long toLong(long n = 0) const override; uint32_t toUint32(long n = 0) const override;
/*! /*!
@brief Convert the value to a float. @brief Convert the value to a float.
The optional parameter \em n is not used and is ignored. The optional parameter \em n is not used and is ignored.
@ -818,7 +835,8 @@ namespace Exiv2 {
<EM>n</EM>-th component. <EM>n</EM>-th component.
*/ */
std::string toString(long n) const override; std::string toString(long n) const override;
long toLong(long n = 0) const override; int64_t toInt64(long n = 0) const override;
uint32_t toUint32(long n = 0) const override;
float toFloat(long n = 0) const override; float toFloat(long n = 0) const override;
Rational toRational(long n = 0) const override; Rational toRational(long n = 0) const override;
/*! /*!
@ -924,7 +942,8 @@ namespace Exiv2 {
to \c false if there is no entry for the language qualifier. to \c false if there is no entry for the language qualifier.
*/ */
std::string toString(const std::string& qualifier) const; std::string toString(const std::string& qualifier) const;
long toLong(long n = 0) const override; int64_t toInt64(long n = 0) const override;
uint32_t toUint32(long n = 0) const override;
float toFloat(long n = 0) const override; float toFloat(long n = 0) const override;
Rational toRational(long n = 0) const override; Rational toRational(long n = 0) const override;
/*! /*!
@ -1032,8 +1051,10 @@ namespace Exiv2 {
long count() const override; long count() const override;
long size() const override; long size() const override;
std::ostream& write(std::ostream& os) const override; std::ostream& write(std::ostream& os) const override;
//! Return the value as a UNIX calender time converted to long. //! Return the value as a UNIX calender time converted to int64_t.
long toLong(long n = 0) const override; int64_t toInt64(long n = 0) const override;
//! Return the value as a UNIX calender time converted to uint32_t.
uint32_t toUint32(long n = 0) const override;
//! Return the value as a UNIX calender time converted to float. //! Return the value as a UNIX calender time converted to float.
float toFloat(long n = 0) const override; float toFloat(long n = 0) const override;
//! Return the value as a UNIX calender time converted to Rational. //! Return the value as a UNIX calender time converted to Rational.
@ -1138,7 +1159,9 @@ namespace Exiv2 {
long size() const override; long size() const override;
std::ostream& write(std::ostream& os) const override; std::ostream& write(std::ostream& os) const override;
//! Returns number of seconds in the day in UTC. //! Returns number of seconds in the day in UTC.
long toLong(long n = 0) const override; int64_t toInt64(long n = 0) const override;
//! Returns number of seconds in the day in UTC.
uint32_t toUint32(long n = 0) const override;
//! Returns number of seconds in the day in UTC converted to float. //! Returns number of seconds in the day in UTC converted to float.
float toFloat(long n = 0) const override; float toFloat(long n = 0) const override;
//! Returns number of seconds in the day in UTC converted to Rational. //! Returns number of seconds in the day in UTC converted to Rational.
@ -1241,7 +1264,8 @@ namespace Exiv2 {
component. component.
*/ */
std::string toString(long n) const override; std::string toString(long n) const override;
long toLong(long n = 0) const override; int64_t toInt64(long n = 0) const override;
uint32_t toUint32(long n = 0) const override;
float toFloat(long n = 0) const override; float toFloat(long n = 0) const override;
Rational toRational(long n = 0) const override; Rational toRational(long n = 0) const override;
//! Return the size of the data area. //! Return the size of the data area.
@ -1270,6 +1294,62 @@ namespace Exiv2 {
ValueList value_; ValueList value_;
private: private:
//! Utility for toInt64, toUint32, etc.
template<typename I>
inline I float_to_integer_helper(long n) const {
const auto v = value_.at(n);
if (static_cast<decltype(v)>(std::numeric_limits<I>::min()) <= v &&
v <= static_cast<decltype(v)>(std::numeric_limits<I>::max())) {
return static_cast<I>(v);
} else {
return 0;
}
}
//! Utility for toInt64, toUint32, etc.
template<typename I>
inline I rational_to_integer_helper(long n) const {
const auto& t = value_.at(n);
const auto a = t.first;
const auto b = t.second;
// Protect against divide-by-zero.
if (b <= 0) {
return 0;
}
// Check for integer overflow.
if (std::is_signed<I>::value == std::is_signed<decltype(a)>::value) {
// conversion does not change sign
const auto imin = std::numeric_limits<I>::min();
const auto imax = std::numeric_limits<I>::max();
if (imax < b || a < imin || imax < a) {
return 0;
}
} else if (std::is_signed<I>::value) {
// conversion is from unsigned to signed
const auto imax =
static_cast<typename std::make_unsigned<I>::type>(std::numeric_limits<I>::max());
if (imax < b || imax < a) {
return 0;
}
} else {
// conversion is from signed to unsigned
const auto imax = std::numeric_limits<I>::max();
if (a < 0) {
return 0;
}
// Inputs are not negative so convert them to unsigned.
const auto a_u = static_cast<typename std::make_unsigned<decltype(a)>::type>(a);
const auto b_u = static_cast<typename std::make_unsigned<decltype(b)>::type>(b);
if (imax < b_u || imax < a_u) {
return 0;
}
}
return static_cast<I>(a)/static_cast<I>(b);
}
//! Internal virtual copy constructor. //! Internal virtual copy constructor.
ValueType<T>* clone_() const override; ValueType<T>* clone_() const override;
@ -1585,46 +1665,62 @@ namespace Exiv2 {
// Default implementation // Default implementation
template<typename T> template<typename T>
long ValueType<T>::toLong(long n) const int64_t ValueType<T>::toInt64(long n) const
{
ok_ = true;
return static_cast<int64_t>(value_.at(n));
}
template<typename T>
uint32_t ValueType<T>::toUint32(long n) const
{ {
ok_ = true; ok_ = true;
return static_cast<long>(value_.at(n)); return static_cast<uint32_t>(value_.at(n));
} }
// #55 crash when value_.at(n).first == LONG_MIN // #55 crash when value_.at(n).first == LONG_MIN
#define LARGE_INT 1000000 #define LARGE_INT 1000000
// Specialization for double // Specialization for double
template<> template<>
inline long ValueType<double>::toLong(long n) const inline int64_t ValueType<double>::toInt64(long n) const
{
return float_to_integer_helper<int64_t>(n);
}
template<>
inline uint32_t ValueType<double>::toUint32(long n) const
{ {
const double v = value_.at(n); return float_to_integer_helper<uint32_t>(n);
ok_ = (INT_MIN <= v && v <= INT_MAX);
if (!ok_) return 0;
return static_cast<long>(v);
} }
// Specialization for float // Specialization for float
template<> template<>
inline long ValueType<float>::toLong(long n) const inline int64_t ValueType<float>::toInt64(long n) const
{ {
const double v = value_.at(n); return float_to_integer_helper<int64_t>(n);
ok_ = (INT_MIN <= v && v <= INT_MAX); }
if (!ok_) return 0; template<>
return static_cast<long>(v); inline uint32_t ValueType<float>::toUint32(long n) const
{
return float_to_integer_helper<uint32_t>(n);
} }
// Specialization for rational // Specialization for rational
template<> template<>
inline long ValueType<Rational>::toLong(long n) const inline int64_t ValueType<Rational>::toInt64(long n) const
{ {
ok_ = (value_.at(n).second > 0 && INT_MIN < value_.at(n).first && value_.at(n).first < INT_MAX ); return rational_to_integer_helper<int64_t>(n);
if (!ok_) return 0; }
return value_.at(n).first / value_.at(n).second; template<>
inline uint32_t ValueType<Rational>::toUint32(long n) const
{
return rational_to_integer_helper<uint32_t>(n);
} }
// Specialization for unsigned rational // Specialization for unsigned rational
template<> template<>
inline long ValueType<URational>::toLong(long n) const inline int64_t ValueType<URational>::toInt64(long n) const
{
return rational_to_integer_helper<int64_t>(n);
}
template<>
inline uint32_t ValueType<URational>::toUint32(long n) const
{ {
ok_ = (value_.at(n).second > 0 && value_.at(n).first < LARGE_INT); return rational_to_integer_helper<uint32_t>(n);
if (!ok_) return 0;
return value_.at(n).first / value_.at(n).second;
} }
// Default implementation // Default implementation
template<typename T> template<typename T>

@ -78,7 +78,7 @@ int main()
std::cout << std::setw(12) << std::left << s; std::cout << std::setw(12) << std::left << s;
bool ok = false; bool ok = false;
long l = Exiv2::parseLong(s, ok); const auto l = Exiv2::parseInt64(s, ok);
std::cout << std::setw(12) << std::left; std::cout << std::setw(12) << std::left;
if (ok) if (ok)
std::cout << l; std::cout << l;

@ -88,7 +88,7 @@ try {
UNUSED(getv2); UNUSED(getv2);
assert(isEqual(getv2.toFloat(), 3.1415f)); assert(isEqual(getv2.toFloat(), 3.1415f));
assert(getv2.ok()); assert(getv2.ok());
assert(getv2.toLong() == 3); assert(getv2.toInt64() == 3);
assert(getv2.ok()); assert(getv2.ok());
Exiv2::Rational R = getv2.toRational(); Exiv2::Rational R = getv2.toRational();
UNUSED(R); UNUSED(R);
@ -99,14 +99,14 @@ try {
UNUSED(getv3); UNUSED(getv3);
assert(isEqual(getv3.toFloat(), 5.0f/7.0f)); assert(isEqual(getv3.toFloat(), 5.0f/7.0f));
assert(getv3.ok()); assert(getv3.ok());
assert(getv3.toLong() == 0); // long(5.0 / 7.0) assert(getv3.toInt64() == 0); // long(5.0 / 7.0)
assert(getv3.ok()); assert(getv3.ok());
assert(getv3.toRational() == Exiv2::Rational(5, 7)); assert(getv3.toRational() == Exiv2::Rational(5, 7));
assert(getv3.ok()); assert(getv3.ok());
const Exiv2::Value &getv6 = xmpData["Xmp.dc.six"].value(); const Exiv2::Value &getv6 = xmpData["Xmp.dc.six"].value();
UNUSED(getv6); UNUSED(getv6);
assert(getv6.toLong() == 0); assert(getv6.toInt64() == 0);
assert(getv6.ok()); assert(getv6.ok());
assert(getv6.toFloat() == 0.0f); assert(getv6.toFloat() == 0.0f);
assert(getv6.ok()); assert(getv6.ok());
@ -114,12 +114,12 @@ try {
assert(getv6.ok()); assert(getv6.ok());
const Exiv2::Value &getv7 = xmpData["Xmp.dc.seven"].value(); const Exiv2::Value &getv7 = xmpData["Xmp.dc.seven"].value();
getv7.toLong(); // this should fail getv7.toInt64(); // this should fail
assert(!getv7.ok()); assert(!getv7.ok());
const Exiv2::Value &getv8 = xmpData["Xmp.dc.eight"].value(); const Exiv2::Value &getv8 = xmpData["Xmp.dc.eight"].value();
UNUSED(getv8); UNUSED(getv8);
assert(getv8.toLong() == 1); assert(getv8.toInt64() == 1);
assert(getv8.ok()); assert(getv8.ok());
assert(getv8.toFloat() == 1.0f); assert(getv8.toFloat() == 1.0f);
assert(getv8.ok()); assert(getv8.ok());

@ -573,7 +573,7 @@ namespace Action {
// #1114 - show negative values for SByte // #1114 - show negative values for SByte
if (md.typeId() == Exiv2::signedByte) { if (md.typeId() == Exiv2::signedByte) {
for ( long c = 0 ; c < md.value().count() ; c++ ) { for ( long c = 0 ; c < md.value().count() ; c++ ) {
long value = md.value().toLong(c); const auto value = md.value().toInt64(c);
os << (c?" ":"") << std::dec << (value < 128 ? value : value - 256); os << (c?" ":"") << std::dec << (value < 128 ? value : value - 256);
} }
} else { } else {

@ -65,359 +65,359 @@ namespace Exiv2 {
//! ModelId, tag 0x0010 //! ModelId, tag 0x0010
constexpr TagDetails canonModelId[] = { constexpr TagDetails canonModelId[] = {
{ static_cast<long int>(0x00000811), "EOS M6 Mark II"}, { 0x00000811, "EOS M6 Mark II"},
{ static_cast<long int>(0x00000804), "Powershot G5 X Mark II"}, { 0x00000804, "Powershot G5 X Mark II"},
{ static_cast<long int>(0x00000805), "PowerShot SX70 HS"}, { 0x00000805, "PowerShot SX70 HS"},
{ static_cast<long int>(0x00000808), "PowerShot G7 X Mark III"}, { 0x00000808, "PowerShot G7 X Mark III"},
{ static_cast<long int>(0x00000812), "EOS M200"}, { 0x00000812, "EOS M200"},
{ static_cast<long int>(0x1010000), "PowerShot A30" }, { 0x1010000, "PowerShot A30" },
{ static_cast<long int>(0x1040000), "PowerShot S300 / Digital IXUS 300 / IXY Digital 300" }, { 0x1040000, "PowerShot S300 / Digital IXUS 300 / IXY Digital 300" },
{ static_cast<long int>(0x1060000), "PowerShot A20" }, { 0x1060000, "PowerShot A20" },
{ static_cast<long int>(0x1080000), "PowerShot A10" }, { 0x1080000, "PowerShot A10" },
{ static_cast<long int>(0x1090000), "PowerShot S110 / Digital IXUS v / IXY Digital 200" }, { 0x1090000, "PowerShot S110 / Digital IXUS v / IXY Digital 200" },
{ static_cast<long int>(0x1100000), "PowerShot G2" }, { 0x1100000, "PowerShot G2" },
{ static_cast<long int>(0x1110000), "PowerShot S40" }, { 0x1110000, "PowerShot S40" },
{ static_cast<long int>(0x1120000), "PowerShot S30" }, { 0x1120000, "PowerShot S30" },
{ static_cast<long int>(0x1130000), "PowerShot A40" }, { 0x1130000, "PowerShot A40" },
{ static_cast<long int>(0x1140000), "EOS D30" }, { 0x1140000, "EOS D30" },
{ static_cast<long int>(0x1150000), "PowerShot A100" }, { 0x1150000, "PowerShot A100" },
{ static_cast<long int>(0x1160000), "PowerShot S200 / Digital IXUS v2 / IXY Digital 200a" }, { 0x1160000, "PowerShot S200 / Digital IXUS v2 / IXY Digital 200a" },
{ static_cast<long int>(0x1170000), "PowerShot A200" }, { 0x1170000, "PowerShot A200" },
{ static_cast<long int>(0x1180000), "PowerShot S330 / Digital IXUS 330 / IXY Digital 300a" }, { 0x1180000, "PowerShot S330 / Digital IXUS 330 / IXY Digital 300a" },
{ static_cast<long int>(0x1190000), "PowerShot G3" }, { 0x1190000, "PowerShot G3" },
{ static_cast<long int>(0x1210000), "PowerShot S45" }, { 0x1210000, "PowerShot S45" },
{ static_cast<long int>(0x1230000), "PowerShot SD100 / Digital IXUS II / IXY Digital 30" }, { 0x1230000, "PowerShot SD100 / Digital IXUS II / IXY Digital 30" },
{ static_cast<long int>(0x1240000), "PowerShot S230 / Digital IXUS v3 / IXY Digital 320" }, { 0x1240000, "PowerShot S230 / Digital IXUS v3 / IXY Digital 320" },
{ static_cast<long int>(0x1250000), "PowerShot A70" }, { 0x1250000, "PowerShot A70" },
{ static_cast<long int>(0x1260000), "PowerShot A60" }, { 0x1260000, "PowerShot A60" },
{ static_cast<long int>(0x1270000), "PowerShot S400 / Digital IXUS 400 / IXY Digital 400" }, { 0x1270000, "PowerShot S400 / Digital IXUS 400 / IXY Digital 400" },
{ static_cast<long int>(0x1290000), "PowerShot G5" }, { 0x1290000, "PowerShot G5" },
{ static_cast<long int>(0x1300000), "PowerShot A300" }, { 0x1300000, "PowerShot A300" },
{ static_cast<long int>(0x1310000), "PowerShot S50" }, { 0x1310000, "PowerShot S50" },
{ static_cast<long int>(0x1340000), "PowerShot A80" }, { 0x1340000, "PowerShot A80" },
{ static_cast<long int>(0x1350000), "PowerShot SD10 / Digital IXUS i / IXY Digital L" }, { 0x1350000, "PowerShot SD10 / Digital IXUS i / IXY Digital L" },
{ static_cast<long int>(0x1360000), "PowerShot S1 IS" }, { 0x1360000, "PowerShot S1 IS" },
{ static_cast<long int>(0x1370000), "PowerShot Pro1" }, { 0x1370000, "PowerShot Pro1" },
{ static_cast<long int>(0x1380000), "PowerShot S70" }, { 0x1380000, "PowerShot S70" },
{ static_cast<long int>(0x1390000), "PowerShot S60" }, { 0x1390000, "PowerShot S60" },
{ static_cast<long int>(0x1400000), "PowerShot G6" }, { 0x1400000, "PowerShot G6" },
{ static_cast<long int>(0x1410000), "PowerShot S500 / Digital IXUS 500 / IXY Digital 500" }, { 0x1410000, "PowerShot S500 / Digital IXUS 500 / IXY Digital 500" },
{ static_cast<long int>(0x1420000), "PowerShot A75" }, { 0x1420000, "PowerShot A75" },
{ static_cast<long int>(0x1440000), "PowerShot SD110 / Digital IXUS IIs / IXY Digital 30a" }, { 0x1440000, "PowerShot SD110 / Digital IXUS IIs / IXY Digital 30a" },
{ static_cast<long int>(0x1450000), "PowerShot A400" }, { 0x1450000, "PowerShot A400" },
{ static_cast<long int>(0x1470000), "PowerShot A310" }, { 0x1470000, "PowerShot A310" },
{ static_cast<long int>(0x1490000), "PowerShot A85" }, { 0x1490000, "PowerShot A85" },
{ static_cast<long int>(0x1520000), "PowerShot S410 / Digital IXUS 430 / IXY Digital 450" }, { 0x1520000, "PowerShot S410 / Digital IXUS 430 / IXY Digital 450" },
{ static_cast<long int>(0x1530000), "PowerShot A95" }, { 0x1530000, "PowerShot A95" },
{ static_cast<long int>(0x1540000), "PowerShot SD300 / Digital IXUS 40 / IXY Digital 50" }, { 0x1540000, "PowerShot SD300 / Digital IXUS 40 / IXY Digital 50" },
{ static_cast<long int>(0x1550000), "PowerShot SD200 / Digital IXUS 30 / IXY Digital 40" }, { 0x1550000, "PowerShot SD200 / Digital IXUS 30 / IXY Digital 40" },
{ static_cast<long int>(0x1560000), "PowerShot A520" }, { 0x1560000, "PowerShot A520" },
{ static_cast<long int>(0x1570000), "PowerShot A510" }, { 0x1570000, "PowerShot A510" },
{ static_cast<long int>(0x1590000), "PowerShot SD20 / Digital IXUS i5 / IXY Digital L2" }, { 0x1590000, "PowerShot SD20 / Digital IXUS i5 / IXY Digital L2" },
{ static_cast<long int>(0x1640000), "PowerShot S2 IS" }, { 0x1640000, "PowerShot S2 IS" },
{ static_cast<long int>(0x1650000), "PowerShot SD430 / Digital IXUS Wireless / IXY Digital Wireless" }, { 0x1650000, "PowerShot SD430 / Digital IXUS Wireless / IXY Digital Wireless" },
{ static_cast<long int>(0x1660000), "PowerShot SD500 / Digital IXUS 700 / IXY Digital 600" }, { 0x1660000, "PowerShot SD500 / Digital IXUS 700 / IXY Digital 600" },
{ static_cast<long int>(0x1668000), "EOS D60" }, { 0x1668000, "EOS D60" },
{ static_cast<long int>(0x1700000), "PowerShot SD30 / Digital IXUS i Zoom / IXY Digital L3" }, { 0x1700000, "PowerShot SD30 / Digital IXUS i Zoom / IXY Digital L3" },
{ static_cast<long int>(0x1740000), "PowerShot A430" }, { 0x1740000, "PowerShot A430" },
{ static_cast<long int>(0x1750000), "PowerShot A410" }, { 0x1750000, "PowerShot A410" },
{ static_cast<long int>(0x1760000), "PowerShot S80" }, { 0x1760000, "PowerShot S80" },
{ static_cast<long int>(0x1780000), "PowerShot A620" }, { 0x1780000, "PowerShot A620" },
{ static_cast<long int>(0x1790000), "PowerShot A610" }, { 0x1790000, "PowerShot A610" },
{ static_cast<long int>(0x1800000), "PowerShot SD630 / Digital IXUS 65 / IXY Digital 80" }, { 0x1800000, "PowerShot SD630 / Digital IXUS 65 / IXY Digital 80" },
{ static_cast<long int>(0x1810000), "PowerShot SD450 / Digital IXUS 55 / IXY Digital 60" }, { 0x1810000, "PowerShot SD450 / Digital IXUS 55 / IXY Digital 60" },
{ static_cast<long int>(0x1820000), "PowerShot TX1" }, { 0x1820000, "PowerShot TX1" },
{ static_cast<long int>(0x1870000), "PowerShot SD400 / Digital IXUS 50 / IXY Digital 55" }, { 0x1870000, "PowerShot SD400 / Digital IXUS 50 / IXY Digital 55" },
{ static_cast<long int>(0x1880000), "PowerShot A420" }, { 0x1880000, "PowerShot A420" },
{ static_cast<long int>(0x1890000), "PowerShot SD900 / Digital IXUS 900 Ti / IXY Digital 1000" }, { 0x1890000, "PowerShot SD900 / Digital IXUS 900 Ti / IXY Digital 1000" },
{ static_cast<long int>(0x1900000), "PowerShot SD550 / Digital IXUS 750 / IXY Digital 700" }, { 0x1900000, "PowerShot SD550 / Digital IXUS 750 / IXY Digital 700" },
{ static_cast<long int>(0x1920000), "PowerShot A700" }, { 0x1920000, "PowerShot A700" },
{ static_cast<long int>(0x1940000), "PowerShot SD700 IS / Digital IXUS 800 IS / IXY Digital 800 IS" }, { 0x1940000, "PowerShot SD700 IS / Digital IXUS 800 IS / IXY Digital 800 IS" },
{ static_cast<long int>(0x1950000), "PowerShot S3 IS" }, { 0x1950000, "PowerShot S3 IS" },
{ static_cast<long int>(0x1960000), "PowerShot A540" }, { 0x1960000, "PowerShot A540" },
{ static_cast<long int>(0x1970000), "PowerShot SD600 / Digital IXUS 60 / IXY Digital 70" }, { 0x1970000, "PowerShot SD600 / Digital IXUS 60 / IXY Digital 70" },
{ static_cast<long int>(0x1980000), "PowerShot G7" }, { 0x1980000, "PowerShot G7" },
{ static_cast<long int>(0x1990000), "PowerShot A530" }, { 0x1990000, "PowerShot A530" },
{ static_cast<long int>(0x2000000), "PowerShot SD800 IS / Digital IXUS 850 IS / IXY Digital 900 IS" }, { 0x2000000, "PowerShot SD800 IS / Digital IXUS 850 IS / IXY Digital 900 IS" },
{ static_cast<long int>(0x2010000), "PowerShot SD40 / Digital IXUS i7 / IXY Digital L4" }, { 0x2010000, "PowerShot SD40 / Digital IXUS i7 / IXY Digital L4" },
{ static_cast<long int>(0x2020000), "PowerShot A710 IS" }, { 0x2020000, "PowerShot A710 IS" },
{ static_cast<long int>(0x2030000), "PowerShot A640" }, { 0x2030000, "PowerShot A640" },
{ static_cast<long int>(0x2040000), "PowerShot A630" }, { 0x2040000, "PowerShot A630" },
{ static_cast<long int>(0x2090000), "PowerShot S5 IS" }, { 0x2090000, "PowerShot S5 IS" },
{ static_cast<long int>(0x2100000), "PowerShot A460" }, { 0x2100000, "PowerShot A460" },
{ static_cast<long int>(0x2120000), "PowerShot SD850 IS / Digital IXUS 950 IS / IXY Digital 810 IS" }, { 0x2120000, "PowerShot SD850 IS / Digital IXUS 950 IS / IXY Digital 810 IS" },
{ static_cast<long int>(0x2130000), "PowerShot A570 IS" }, { 0x2130000, "PowerShot A570 IS" },
{ static_cast<long int>(0x2140000), "PowerShot A560" }, { 0x2140000, "PowerShot A560" },
{ static_cast<long int>(0x2150000), "PowerShot SD750 / Digital IXUS 75 / IXY Digital 90" }, { 0x2150000, "PowerShot SD750 / Digital IXUS 75 / IXY Digital 90" },
{ static_cast<long int>(0x2160000), "PowerShot SD1000 / Digital IXUS 70 / IXY Digital 10" }, { 0x2160000, "PowerShot SD1000 / Digital IXUS 70 / IXY Digital 10" },
{ static_cast<long int>(0x2180000), "PowerShot A550" }, { 0x2180000, "PowerShot A550" },
{ static_cast<long int>(0x2190000), "PowerShot A450" }, { 0x2190000, "PowerShot A450" },
{ static_cast<long int>(0x2230000), "PowerShot G9" }, { 0x2230000, "PowerShot G9" },
{ static_cast<long int>(0x2240000), "PowerShot A650 IS" }, { 0x2240000, "PowerShot A650 IS" },
{ static_cast<long int>(0x2260000), "PowerShot A720 IS" }, { 0x2260000, "PowerShot A720 IS" },
{ static_cast<long int>(0x2290000), "PowerShot SX100 IS" }, { 0x2290000, "PowerShot SX100 IS" },
{ static_cast<long int>(0x2300000), "PowerShot SD950 IS / Digital IXUS 960 IS / IXY Digital 2000 IS" }, { 0x2300000, "PowerShot SD950 IS / Digital IXUS 960 IS / IXY Digital 2000 IS" },
{ static_cast<long int>(0x2310000), "PowerShot SD870 IS / Digital IXUS 860 IS / IXY Digital 910 IS" }, { 0x2310000, "PowerShot SD870 IS / Digital IXUS 860 IS / IXY Digital 910 IS" },
{ static_cast<long int>(0x2320000), "PowerShot SD890 IS / Digital IXUS 970 IS / IXY Digital 820 IS" }, { 0x2320000, "PowerShot SD890 IS / Digital IXUS 970 IS / IXY Digital 820 IS" },
{ static_cast<long int>(0x2360000), "PowerShot SD790 IS / Digital IXUS 90 IS / IXY Digital 95 IS" }, { 0x2360000, "PowerShot SD790 IS / Digital IXUS 90 IS / IXY Digital 95 IS" },
{ static_cast<long int>(0x2370000), "PowerShot SD770 IS / Digital IXUS 85 IS / IXY Digital 25 IS" }, { 0x2370000, "PowerShot SD770 IS / Digital IXUS 85 IS / IXY Digital 25 IS" },
{ static_cast<long int>(0x2380000), "PowerShot A590 IS" }, { 0x2380000, "PowerShot A590 IS" },
{ static_cast<long int>(0x2390000), "PowerShot A580" }, { 0x2390000, "PowerShot A580" },
{ static_cast<long int>(0x2420000), "PowerShot A470" }, { 0x2420000, "PowerShot A470" },
{ static_cast<long int>(0x2430000), "PowerShot SD1100 IS / Digital IXUS 80 IS / IXY Digital 20 IS" }, { 0x2430000, "PowerShot SD1100 IS / Digital IXUS 80 IS / IXY Digital 20 IS" },
{ static_cast<long int>(0x2460000), "PowerShot SX1 IS" }, { 0x2460000, "PowerShot SX1 IS" },
{ static_cast<long int>(0x2470000), "PowerShot SX10 IS" }, { 0x2470000, "PowerShot SX10 IS" },
{ static_cast<long int>(0x2480000), "PowerShot A1000 IS" }, { 0x2480000, "PowerShot A1000 IS" },
{ static_cast<long int>(0x2490000), "PowerShot G10" }, { 0x2490000, "PowerShot G10" },
{ static_cast<long int>(0x2510000), "PowerShot A2000 IS" }, { 0x2510000, "PowerShot A2000 IS" },
{ static_cast<long int>(0x2520000), "PowerShot SX110 IS" }, { 0x2520000, "PowerShot SX110 IS" },
{ static_cast<long int>(0x2530000), "PowerShot SD990 IS / Digital IXUS 980 IS / IXY Digital 3000 IS" }, { 0x2530000, "PowerShot SD990 IS / Digital IXUS 980 IS / IXY Digital 3000 IS" },
{ static_cast<long int>(0x2540000), "PowerShot SD880 IS / Digital IXUS 870 IS / IXY Digital 920 IS" }, { 0x2540000, "PowerShot SD880 IS / Digital IXUS 870 IS / IXY Digital 920 IS" },
{ static_cast<long int>(0x2550000), "PowerShot E1" }, { 0x2550000, "PowerShot E1" },
{ static_cast<long int>(0x2560000), "PowerShot D10" }, { 0x2560000, "PowerShot D10" },
{ static_cast<long int>(0x2570000), "PowerShot SD960 IS / Digital IXUS 110 IS / IXY Digital 510 IS" }, { 0x2570000, "PowerShot SD960 IS / Digital IXUS 110 IS / IXY Digital 510 IS" },
{ static_cast<long int>(0x2580000), "PowerShot A2100 IS" }, { 0x2580000, "PowerShot A2100 IS" },
{ static_cast<long int>(0x2590000), "PowerShot A480" }, { 0x2590000, "PowerShot A480" },
{ static_cast<long int>(0x2600000), "PowerShot SX200 IS" }, { 0x2600000, "PowerShot SX200 IS" },
{ static_cast<long int>(0x2610000), "PowerShot SD970 IS / Digital IXUS 990 IS / IXY Digital 830 IS" }, { 0x2610000, "PowerShot SD970 IS / Digital IXUS 990 IS / IXY Digital 830 IS" },
{ static_cast<long int>(0x2620000), "PowerShot SD780 IS / Digital IXUS 100 IS / IXY Digital 210 IS" }, { 0x2620000, "PowerShot SD780 IS / Digital IXUS 100 IS / IXY Digital 210 IS" },
{ static_cast<long int>(0x2630000), "PowerShot A1100 IS" }, { 0x2630000, "PowerShot A1100 IS" },
{ static_cast<long int>(0x2640000), "PowerShot SD1200 IS / Digital IXUS 95 IS / IXY Digital 110 IS" }, { 0x2640000, "PowerShot SD1200 IS / Digital IXUS 95 IS / IXY Digital 110 IS" },
{ static_cast<long int>(0x2700000), "PowerShot G11" }, { 0x2700000, "PowerShot G11" },
{ static_cast<long int>(0x2710000), "PowerShot SX120 IS" }, { 0x2710000, "PowerShot SX120 IS" },
{ static_cast<long int>(0x2720000), "PowerShot S90" }, { 0x2720000, "PowerShot S90" },
{ static_cast<long int>(0x2750000), "PowerShot SX20 IS" }, { 0x2750000, "PowerShot SX20 IS" },
{ static_cast<long int>(0x2760000), "PowerShot SD980 IS / Digital IXUS 200 IS / IXY Digital 930 IS" }, { 0x2760000, "PowerShot SD980 IS / Digital IXUS 200 IS / IXY Digital 930 IS" },
{ static_cast<long int>(0x2770000), "PowerShot SD940 IS / Digital IXUS 120 IS / IXY Digital 220 IS" }, { 0x2770000, "PowerShot SD940 IS / Digital IXUS 120 IS / IXY Digital 220 IS" },
{ static_cast<long int>(0x2800000), "PowerShot A495" }, { 0x2800000, "PowerShot A495" },
{ static_cast<long int>(0x2810000), "PowerShot A490" }, { 0x2810000, "PowerShot A490" },
{ static_cast<long int>(0x2820000), "PowerShot A3100/A3150 IS" }, { 0x2820000, "PowerShot A3100/A3150 IS" },
{ static_cast<long int>(0x2830000), "PowerShot A3000 IS" }, { 0x2830000, "PowerShot A3000 IS" },
{ static_cast<long int>(0x2840000), "PowerShot SD1400 IS / IXUS 130 / IXY 400F" }, { 0x2840000, "PowerShot SD1400 IS / IXUS 130 / IXY 400F" },
{ static_cast<long int>(0x2850000), "PowerShot SD1300 IS / IXUS 105 / IXY 200F" }, { 0x2850000, "PowerShot SD1300 IS / IXUS 105 / IXY 200F" },
{ static_cast<long int>(0x2860000), "PowerShot SD3500 IS / IXUS 210 / IXY 10S" }, { 0x2860000, "PowerShot SD3500 IS / IXUS 210 / IXY 10S" },
{ static_cast<long int>(0x2870000), "PowerShot SX210 IS" }, { 0x2870000, "PowerShot SX210 IS" },
{ static_cast<long int>(0x2880000), "PowerShot SD4000 IS / IXUS 300 HS / IXY 30S" }, { 0x2880000, "PowerShot SD4000 IS / IXUS 300 HS / IXY 30S" },
{ static_cast<long int>(0x2890000), "PowerShot SD4500 IS / IXUS 1000 HS / IXY 50S" }, { 0x2890000, "PowerShot SD4500 IS / IXUS 1000 HS / IXY 50S" },
{ static_cast<long int>(0x2920000), "PowerShot G12" }, { 0x2920000, "PowerShot G12" },
{ static_cast<long int>(0x2930000), "PowerShot SX30 IS" }, { 0x2930000, "PowerShot SX30 IS" },
{ static_cast<long int>(0x2940000), "PowerShot SX130 IS" }, { 0x2940000, "PowerShot SX130 IS" },
{ static_cast<long int>(0x2950000), "PowerShot S95" }, { 0x2950000, "PowerShot S95" },
{ static_cast<long int>(0x2980000), "PowerShot A3300 IS" }, { 0x2980000, "PowerShot A3300 IS" },
{ static_cast<long int>(0x2990000), "PowerShot A3200 IS" }, { 0x2990000, "PowerShot A3200 IS" },
{ static_cast<long int>(0x3000000), "PowerShot ELPH 500 HS / IXUS 310 HS / IXY 31S" }, { 0x3000000, "PowerShot ELPH 500 HS / IXUS 310 HS / IXY 31S" },
{ static_cast<long int>(0x3010000), "PowerShot Pro90 IS" }, { 0x3010000, "PowerShot Pro90 IS" },
{ static_cast<long int>(0x3010001), "PowerShot A800" }, { 0x3010001, "PowerShot A800" },
{ static_cast<long int>(0x3020000), "PowerShot ELPH 100 HS / IXUS 115 HS / IXY 210F" }, { 0x3020000, "PowerShot ELPH 100 HS / IXUS 115 HS / IXY 210F" },
{ static_cast<long int>(0x3030000), "PowerShot SX230 HS" }, { 0x3030000, "PowerShot SX230 HS" },
{ static_cast<long int>(0x3040000), "PowerShot ELPH 300 HS / IXUS 220 HS / IXY 410F" }, { 0x3040000, "PowerShot ELPH 300 HS / IXUS 220 HS / IXY 410F" },
{ static_cast<long int>(0x3050000), "PowerShot A2200" }, { 0x3050000, "PowerShot A2200" },
{ static_cast<long int>(0x3060000), "PowerShot A1200" }, { 0x3060000, "PowerShot A1200" },
{ static_cast<long int>(0x3070000), "PowerShot SX220 HS" }, { 0x3070000, "PowerShot SX220 HS" },
{ static_cast<long int>(0x3080000), "PowerShot G1 X" }, { 0x3080000, "PowerShot G1 X" },
{ static_cast<long int>(0x3090000), "PowerShot SX150 IS" }, { 0x3090000, "PowerShot SX150 IS" },
{ static_cast<long int>(0x3100000), "PowerShot ELPH 510 HS / IXUS 1100 HS / IXY 51S" }, { 0x3100000, "PowerShot ELPH 510 HS / IXUS 1100 HS / IXY 51S" },
{ static_cast<long int>(0x3110000), "PowerShot S100 (new)" }, { 0x3110000, "PowerShot S100 (new)" },
{ static_cast<long int>(0x3130000), "PowerShot SX40 HS" }, { 0x3130000, "PowerShot SX40 HS" },
{ static_cast<long int>(0x3120000), "PowerShot ELPH 310 HS / IXUS 230 HS / IXY 600F" }, { 0x3120000, "PowerShot ELPH 310 HS / IXUS 230 HS / IXY 600F" },
{ static_cast<long int>(0x3140000), "IXY 32S" }, { 0x3140000, "IXY 32S" },
{ static_cast<long int>(0x3160000), "PowerShot A1300" }, { 0x3160000, "PowerShot A1300" },
{ static_cast<long int>(0x3170000), "PowerShot A810" }, { 0x3170000, "PowerShot A810" },
{ static_cast<long int>(0x3180000), "PowerShot ELPH 320 HS / IXUS 240 HS / IXY 420F" }, { 0x3180000, "PowerShot ELPH 320 HS / IXUS 240 HS / IXY 420F" },
{ static_cast<long int>(0x3190000), "PowerShot ELPH 110 HS / IXUS 125 HS / IXY 220F" }, { 0x3190000, "PowerShot ELPH 110 HS / IXUS 125 HS / IXY 220F" },
{ static_cast<long int>(0x3200000), "PowerShot D20" }, { 0x3200000, "PowerShot D20" },
{ static_cast<long int>(0x3210000), "PowerShot A4000 IS" }, { 0x3210000, "PowerShot A4000 IS" },
{ static_cast<long int>(0x3220000), "PowerShot SX260 HS" }, { 0x3220000, "PowerShot SX260 HS" },
{ static_cast<long int>(0x3230000), "PowerShot SX240 HS" }, { 0x3230000, "PowerShot SX240 HS" },
{ static_cast<long int>(0x3240000), "PowerShot ELPH 530 HS / IXUS 510 HS / IXY 1" }, { 0x3240000, "PowerShot ELPH 530 HS / IXUS 510 HS / IXY 1" },
{ static_cast<long int>(0x3250000), "PowerShot ELPH 520 HS / IXUS 500 HS / IXY 3" }, { 0x3250000, "PowerShot ELPH 520 HS / IXUS 500 HS / IXY 3" },
{ static_cast<long int>(0x3260000), "PowerShot A3400 IS" }, { 0x3260000, "PowerShot A3400 IS" },
{ static_cast<long int>(0x3270000), "PowerShot A2400 IS" }, { 0x3270000, "PowerShot A2400 IS" },
{ static_cast<long int>(0x3280000), "PowerShot A2300" }, { 0x3280000, "PowerShot A2300" },
{ static_cast<long int>(0x3320000), "PowerShot S100V" }, { 0x3320000, "PowerShot S100V" },
{ static_cast<long int>(0x3330000), "PowerShot G15" }, { 0x3330000, "PowerShot G15" },
{ static_cast<long int>(0x3340000), "PowerShot SX50 HS" }, { 0x3340000, "PowerShot SX50 HS" },
{ static_cast<long int>(0x3350000), "PowerShot SX160 IS" }, { 0x3350000, "PowerShot SX160 IS" },
{ static_cast<long int>(0x3360000), "PowerShot S110 (new)" }, { 0x3360000, "PowerShot S110 (new)" },
{ static_cast<long int>(0x3370000), "PowerShot SX500 IS" }, { 0x3370000, "PowerShot SX500 IS" },
{ static_cast<long int>(0x3380000), "PowerShot N" }, { 0x3380000, "PowerShot N" },
{ static_cast<long int>(0x3390000), "IXUS 245 HS / IXY 430F" }, { 0x3390000, "IXUS 245 HS / IXY 430F" },
{ static_cast<long int>(0x3400000), "PowerShot SX280 HS" }, { 0x3400000, "PowerShot SX280 HS" },
{ static_cast<long int>(0x3410000), "PowerShot SX270 HS" }, { 0x3410000, "PowerShot SX270 HS" },
{ static_cast<long int>(0x3420000), "PowerShot A3500 IS" }, { 0x3420000, "PowerShot A3500 IS" },
{ static_cast<long int>(0x3430000), "PowerShot A2600" }, { 0x3430000, "PowerShot A2600" },
{ static_cast<long int>(0x3440000), "PowerShot SX275 HS" }, { 0x3440000, "PowerShot SX275 HS" },
{ static_cast<long int>(0x3450000), "PowerShot A1400" }, { 0x3450000, "PowerShot A1400" },
{ static_cast<long int>(0x3460000), "PowerShot ELPH 130 IS / IXUS 140 / IXY 110F" }, { 0x3460000, "PowerShot ELPH 130 IS / IXUS 140 / IXY 110F" },
{ static_cast<long int>(0x3470000), "PowerShot ELPH 115/120 IS / IXUS 132/135 / IXY 90F/100F" }, { 0x3470000, "PowerShot ELPH 115/120 IS / IXUS 132/135 / IXY 90F/100F" },
{ static_cast<long int>(0x3490000), "PowerShot ELPH 330 HS / IXUS 255 HS / IXY 610F" }, { 0x3490000, "PowerShot ELPH 330 HS / IXUS 255 HS / IXY 610F" },
{ static_cast<long int>(0x3510000), "PowerShot A2500" }, { 0x3510000, "PowerShot A2500" },
{ static_cast<long int>(0x3540000), "PowerShot G16" }, { 0x3540000, "PowerShot G16" },
{ static_cast<long int>(0x3550000), "PowerShot S120" }, { 0x3550000, "PowerShot S120" },
{ static_cast<long int>(0x3560000), "PowerShot SX170 IS" }, { 0x3560000, "PowerShot SX170 IS" },
{ static_cast<long int>(0x3580000), "PowerShot SX510 HS" }, { 0x3580000, "PowerShot SX510 HS" },
{ static_cast<long int>(0x3590000), "PowerShot S200 (new)" }, { 0x3590000, "PowerShot S200 (new)" },
{ static_cast<long int>(0x3600000), "IXY 620F" }, { 0x3600000, "IXY 620F" },
{ static_cast<long int>(0x3610000), "PowerShot N100" }, { 0x3610000, "PowerShot N100" },
{ static_cast<long int>(0x3640000), "PowerShot G1 X Mark II" }, { 0x3640000, "PowerShot G1 X Mark II" },
{ static_cast<long int>(0x3650000), "PowerShot D30" }, { 0x3650000, "PowerShot D30" },
{ static_cast<long int>(0x3660000), "PowerShot SX700 HS" }, { 0x3660000, "PowerShot SX700 HS" },
{ static_cast<long int>(0x3670000), "PowerShot SX600 HS" }, { 0x3670000, "PowerShot SX600 HS" },
{ static_cast<long int>(0x3680000), "PowerShot ELPH 140 IS / IXUS 150 / IXY 130" }, { 0x3680000, "PowerShot ELPH 140 IS / IXUS 150 / IXY 130" },
{ static_cast<long int>(0x3690000), "PowerShot ELPH 135 / IXUS 145 / IXY 120" }, { 0x3690000, "PowerShot ELPH 135 / IXUS 145 / IXY 120" },
{ static_cast<long int>(0x3700000), "PowerShot ELPH 340 HS / IXUS 265 HS / IXY 630" }, { 0x3700000, "PowerShot ELPH 340 HS / IXUS 265 HS / IXY 630" },
{ static_cast<long int>(0x3710000), "PowerShot ELPH 150 IS / IXUS 155 / IXY 140" }, { 0x3710000, "PowerShot ELPH 150 IS / IXUS 155 / IXY 140" },
{ static_cast<long int>(0x3740000), "EOS M3" }, { 0x3740000, "EOS M3" },
{ static_cast<long int>(0x3750000), "PowerShot SX60 HS" }, { 0x3750000, "PowerShot SX60 HS" },
{ static_cast<long int>(0x3760000), "PowerShot SX520 HS" }, { 0x3760000, "PowerShot SX520 HS" },
{ static_cast<long int>(0x3770000), "PowerShot SX400 IS" }, { 0x3770000, "PowerShot SX400 IS" },
{ static_cast<long int>(0x3780000), "PowerShot G7 X" }, { 0x3780000, "PowerShot G7 X" },
{ static_cast<long int>(0x3790000), "PowerShot N2" }, { 0x3790000, "PowerShot N2" },
{ static_cast<long int>(0x3800000), "PowerShot SX530 HS" }, { 0x3800000, "PowerShot SX530 HS" },
{ static_cast<long int>(0x3820000), "PowerShot SX710 HS" }, { 0x3820000, "PowerShot SX710 HS" },
{ static_cast<long int>(0x3830000), "PowerShot SX610 HS" }, { 0x3830000, "PowerShot SX610 HS" },
{ static_cast<long int>(0x3840000), "EOS M10" }, { 0x3840000, "EOS M10" },
{ static_cast<long int>(0x3850000), "PowerShot G3 X" }, { 0x3850000, "PowerShot G3 X" },
{ static_cast<long int>(0x3860000), "PowerShot ELPH 165 HS / IXUS 165 / IXY 160" }, { 0x3860000, "PowerShot ELPH 165 HS / IXUS 165 / IXY 160" },
{ static_cast<long int>(0x3870000), "PowerShot ELPH 160 / IXUS 160" }, { 0x3870000, "PowerShot ELPH 160 / IXUS 160" },
{ static_cast<long int>(0x3880000), "PowerShot ELPH 350 HS / IXUS 275 HS / IXY 640" }, { 0x3880000, "PowerShot ELPH 350 HS / IXUS 275 HS / IXY 640" },
{ static_cast<long int>(0x3890000), "PowerShot ELPH 170 IS / IXUS 170" }, { 0x3890000, "PowerShot ELPH 170 IS / IXUS 170" },
{ static_cast<long int>(0x3910000), "PowerShot SX410 IS" }, { 0x3910000, "PowerShot SX410 IS" },
{ static_cast<long int>(0x3930000), "PowerShot G9 X" }, { 0x3930000, "PowerShot G9 X" },
{ static_cast<long int>(0x3940000), "EOS M5" }, { 0x3940000, "EOS M5" },
{ static_cast<long int>(0x3950000), "PowerShot G5 X" }, { 0x3950000, "PowerShot G5 X" },
{ static_cast<long int>(0x3970000), "PowerShot G7 X Mark II" }, { 0x3970000, "PowerShot G7 X Mark II" },
{ static_cast<long int>(0x3980000), "EOS M100" }, { 0x3980000, "EOS M100" },
{ static_cast<long int>(0x3990000), "PowerShot ELPH 360 HS / IXUS 285 HS / IXY 650" }, { 0x3990000, "PowerShot ELPH 360 HS / IXUS 285 HS / IXY 650" },
{ static_cast<long int>(0x4010000), "PowerShot SX540 HS" }, { 0x4010000, "PowerShot SX540 HS" },
{ static_cast<long int>(0x4020000), "PowerShot SX420 IS" }, { 0x4020000, "PowerShot SX420 IS" },
{ static_cast<long int>(0x4030000), "PowerShot ELPH 190 IS / IXUS 180 / IXY 190" }, { 0x4030000, "PowerShot ELPH 190 IS / IXUS 180 / IXY 190" },
{ static_cast<long int>(0x4040000), "PowerShot G1" }, { 0x4040000, "PowerShot G1" },
{ static_cast<long int>(0x4040001), "PowerShot ELPH 180 IS / IXUS 175 / IXY 180" }, { 0x4040001, "PowerShot ELPH 180 IS / IXUS 175 / IXY 180" },
{ static_cast<long int>(0x4050000), "PowerShot SX720 HS" }, { 0x4050000, "PowerShot SX720 HS" },
{ static_cast<long int>(0x4060000), "PowerShot SX620 HS" }, { 0x4060000, "PowerShot SX620 HS" },
{ static_cast<long int>(0x4070000), "EOS M6" }, { 0x4070000, "EOS M6" },
{ static_cast<long int>(0x4100000), "PowerShot G9 X Mark II" }, { 0x4100000, "PowerShot G9 X Mark II" },
{ static_cast<long int>(0x412), "EOS M50 / Kiss M" }, { 0x412, "EOS M50 / Kiss M" },
{ static_cast<long int>(0x4150000), "PowerShot ELPH 185 / IXUS 185 / IXY 200" }, { 0x4150000, "PowerShot ELPH 185 / IXUS 185 / IXY 200" },
{ static_cast<long int>(0x4160000), "PowerShot SX430 IS" }, { 0x4160000, "PowerShot SX430 IS" },
{ static_cast<long int>(0x4170000), "PowerShot SX730 HS" }, { 0x4170000, "PowerShot SX730 HS" },
{ static_cast<long int>(0x4180000), "PowerShot G1 X Mark III" }, { 0x4180000, "PowerShot G1 X Mark III" },
{ static_cast<long int>(0x6040000), "PowerShot S100 / Digital IXUS / IXY Digital" }, { 0x6040000, "PowerShot S100 / Digital IXUS / IXY Digital" },
{ static_cast<long int>(0x801), "PowerShot SX740 HS" }, { 0x801, "PowerShot SX740 HS" },
{ static_cast<long int>(0x804), "PowerShot G5 X Mark II" }, { 0x804, "PowerShot G5 X Mark II" },
{ static_cast<long int>(0x805), "PowerShot SX70 HS" }, { 0x805, "PowerShot SX70 HS" },
{ static_cast<long int>(0x808), "PowerShot G7 X Mark III" }, { 0x808, "PowerShot G7 X Mark III" },
{ static_cast<long int>(0x811), "EOS M6 Mark II" }, { 0x811, "EOS M6 Mark II" },
{ static_cast<long int>(0x812), "EOS M200" }, { 0x812, "EOS M200" },
{ static_cast<long int>(0x4007d673), "DC19/DC21/DC22" }, { 0x4007d673, "DC19/DC21/DC22" },
{ static_cast<long int>(0x4007d674), "XH A1" }, { 0x4007d674, "XH A1" },
{ static_cast<long int>(0x4007d675), "HV10" }, { 0x4007d675, "HV10" },
{ static_cast<long int>(0x4007d676), "MD130/MD140/MD150/MD160/ZR850" }, { 0x4007d676, "MD130/MD140/MD150/MD160/ZR850" },
{ static_cast<long int>(0x4007d777), "DC50" }, { 0x4007d777, "DC50" },
{ static_cast<long int>(0x4007d778), "HV20" }, { 0x4007d778, "HV20" },
{ static_cast<long int>(0x4007d779), "DC211" }, { 0x4007d779, "DC211" },
{ static_cast<long int>(0x4007d77a), "HG10" }, { 0x4007d77a, "HG10" },
{ static_cast<long int>(0x4007d77b), "HR10" }, { 0x4007d77b, "HR10" },
{ static_cast<long int>(0x4007d77d), "MD255/ZR950" }, { 0x4007d77d, "MD255/ZR950" },
{ static_cast<long int>(0x4007d81c), "HF11" }, { 0x4007d81c, "HF11" },
{ static_cast<long int>(0x4007d878), "HV30" }, { 0x4007d878, "HV30" },
{ static_cast<long int>(0x4007d87c), "XH A1S" }, { 0x4007d87c, "XH A1S" },
{ static_cast<long int>(0x4007d87e), "DC301/DC310/DC311/DC320/DC330" }, { 0x4007d87e, "DC301/DC310/DC311/DC320/DC330" },
{ static_cast<long int>(0x4007d87f), "FS100" }, { 0x4007d87f, "FS100" },
{ static_cast<long int>(0x4007d880), "HF10" }, { 0x4007d880, "HF10" },
{ static_cast<long int>(0x4007d882), "HG20/HG21" }, { 0x4007d882, "HG20/HG21" },
{ static_cast<long int>(0x4007d925), "HF21" }, { 0x4007d925, "HF21" },
{ static_cast<long int>(0x4007d926), "HF S11" }, { 0x4007d926, "HF S11" },
{ static_cast<long int>(0x4007d978), "HV40" }, { 0x4007d978, "HV40" },
{ static_cast<long int>(0x4007d987), "DC410/DC411/DC420" }, { 0x4007d987, "DC410/DC411/DC420" },
{ static_cast<long int>(0x4007d988), "FS19/FS20/FS21/FS22/FS200" }, { 0x4007d988, "FS19/FS20/FS21/FS22/FS200" },
{ static_cast<long int>(0x4007d989), "HF20/HF200" }, { 0x4007d989, "HF20/HF200" },
{ static_cast<long int>(0x4007d98a), "HF S10/S100" }, { 0x4007d98a, "HF S10/S100" },
{ static_cast<long int>(0x4007da8e), "HF R10/R16/R17/R18/R100/R106" }, { 0x4007da8e, "HF R10/R16/R17/R18/R100/R106" },
{ static_cast<long int>(0x4007da8f), "HF M30/M31/M36/M300/M306" }, { 0x4007da8f, "HF M30/M31/M36/M300/M306" },
{ static_cast<long int>(0x4007da90), "HF S20/S21/S200" }, { 0x4007da90, "HF S20/S21/S200" },
{ static_cast<long int>(0x4007da92), "FS31/FS36/FS37/FS300/FS305/FS306/FS307" }, { 0x4007da92, "FS31/FS36/FS37/FS300/FS305/FS306/FS307" },
{ static_cast<long int>(0x4007dca0), "EOS C300" }, { 0x4007dca0, "EOS C300" },
{ static_cast<long int>(0x4007dda9), "HF G25" }, { 0x4007dda9, "HF G25" },
{ static_cast<long int>(0x4007dfb4), "XC10" }, { 0x4007dfb4, "XC10" },
{ static_cast<long int>(0x4007e1c3), "EOS C200" }, { 0x4007e1c3, "EOS C200" },
{ static_cast<long int>(0x80000001), "EOS-1D" }, { 0x80000001, "EOS-1D" },
{ static_cast<long int>(0x80000167), "EOS-1DS" }, { 0x80000167, "EOS-1DS" },
{ static_cast<long int>(0x80000168), "EOS 10D" }, { 0x80000168, "EOS 10D" },
{ static_cast<long int>(0x80000169), "EOS-1D Mark III" }, { 0x80000169, "EOS-1D Mark III" },
{ static_cast<long int>(0x80000170), "EOS Digital Rebel / 300D / Kiss Digital" }, { 0x80000170, "EOS Digital Rebel / 300D / Kiss Digital" },
{ static_cast<long int>(0x80000174), "EOS-1D Mark II" }, { 0x80000174, "EOS-1D Mark II" },
{ static_cast<long int>(0x80000175), "EOS 20D" }, { 0x80000175, "EOS 20D" },
{ static_cast<long int>(0x80000176), "EOS Digital Rebel XSi / 450D / Kiss X2" }, { 0x80000176, "EOS Digital Rebel XSi / 450D / Kiss X2" },
{ static_cast<long int>(0x80000188), "EOS-1Ds Mark II" }, { 0x80000188, "EOS-1Ds Mark II" },
{ static_cast<long int>(0x80000189), "EOS Digital Rebel XT / 350D / Kiss Digital N" }, { 0x80000189, "EOS Digital Rebel XT / 350D / Kiss Digital N" },
{ static_cast<long int>(0x80000190), "EOS 40D" }, { 0x80000190, "EOS 40D" },
{ static_cast<long int>(0x80000213), "EOS 5D" }, { 0x80000213, "EOS 5D" },
{ static_cast<long int>(0x80000215), "EOS-1Ds Mark III" }, { 0x80000215, "EOS-1Ds Mark III" },
{ static_cast<long int>(0x80000218), "EOS 5D Mark II" }, { 0x80000218, "EOS 5D Mark II" },
{ static_cast<long int>(0x80000219), "WFT-E1" }, { 0x80000219, "WFT-E1" },
{ static_cast<long int>(0x80000232), "EOS-1D Mark II N" }, { 0x80000232, "EOS-1D Mark II N" },
{ static_cast<long int>(0x80000234), "EOS 30D" }, { 0x80000234, "EOS 30D" },
{ static_cast<long int>(0x80000236), "EOS Digital Rebel XTi / 400D / Kiss Digital X" }, { 0x80000236, "EOS Digital Rebel XTi / 400D / Kiss Digital X" },
{ static_cast<long int>(0x80000241), "WFT-E2" }, { 0x80000241, "WFT-E2" },
{ static_cast<long int>(0x80000246), "WFT-E3" }, { 0x80000246, "WFT-E3" },
{ static_cast<long int>(0x80000250), "EOS 7D" }, { 0x80000250, "EOS 7D" },
{ static_cast<long int>(0x80000252), "EOS Rebel T1i / 500D / Kiss X3" }, { 0x80000252, "EOS Rebel T1i / 500D / Kiss X3" },
{ static_cast<long int>(0x80000254), "EOS Rebel XS / 1000D / Kiss F" }, { 0x80000254, "EOS Rebel XS / 1000D / Kiss F" },
{ static_cast<long int>(0x80000261), "EOS 50D" }, { 0x80000261, "EOS 50D" },
{ static_cast<long int>(0x80000269), "EOS-1D X" }, { 0x80000269, "EOS-1D X" },
{ static_cast<long int>(0x80000270), "EOS Rebel T2i / 550D / Kiss X4" }, { 0x80000270, "EOS Rebel T2i / 550D / Kiss X4" },
{ static_cast<long int>(0x80000271), "WFT-E4" }, { 0x80000271, "WFT-E4" },
{ static_cast<long int>(0x80000273), "WFT-E5" }, { 0x80000273, "WFT-E5" },
{ static_cast<long int>(0x80000281), "EOS-1D Mark IV" }, { 0x80000281, "EOS-1D Mark IV" },
{ static_cast<long int>(0x80000285), "EOS 5D Mark III" }, { 0x80000285, "EOS 5D Mark III" },
{ static_cast<long int>(0x80000286), "EOS Rebel T3i / 600D / Kiss X5" }, { 0x80000286, "EOS Rebel T3i / 600D / Kiss X5" },
{ static_cast<long int>(0x80000287), "EOS 60D" }, { 0x80000287, "EOS 60D" },
{ static_cast<long int>(0x80000288), "EOS Rebel T3 / 1100D / Kiss X50" }, { 0x80000288, "EOS Rebel T3 / 1100D / Kiss X50" },
{ static_cast<long int>(0x80000289), "EOS 7D Mark II" }, { 0x80000289, "EOS 7D Mark II" },
{ static_cast<long int>(0x80000297), "WFT-E2 II" }, { 0x80000297, "WFT-E2 II" },
{ static_cast<long int>(0x80000298), "WFT-E4 II" }, { 0x80000298, "WFT-E4 II" },
{ static_cast<long int>(0x80000301), "EOS Rebel T4i / 650D / Kiss X6i" }, { 0x80000301, "EOS Rebel T4i / 650D / Kiss X6i" },
{ static_cast<long int>(0x80000302), "EOS 6D" }, { 0x80000302, "EOS 6D" },
{ static_cast<long int>(0x80000324), "EOS-1D C" }, { 0x80000324, "EOS-1D C" },
{ static_cast<long int>(0x80000325), "EOS 70D" }, { 0x80000325, "EOS 70D" },
{ static_cast<long int>(0x80000326), "EOS Rebel T5i / 700D / Kiss X7i" }, { 0x80000326, "EOS Rebel T5i / 700D / Kiss X7i" },
{ static_cast<long int>(0x80000327), "EOS Rebel T5 / 1200D / Kiss X70 / Hi" }, { 0x80000327, "EOS Rebel T5 / 1200D / Kiss X70 / Hi" },
{ static_cast<long int>(0x80000328), "EOS-1D X MARK II" }, { 0x80000328, "EOS-1D X MARK II" },
{ static_cast<long int>(0x80000331), "EOS M" }, { 0x80000331, "EOS M" },
{ static_cast<long int>(0x80000350), "EOS 80D" }, { 0x80000350, "EOS 80D" },
{ static_cast<long int>(0x80000355), "EOS M2" }, { 0x80000355, "EOS M2" },
{ static_cast<long int>(0x80000346), "EOS Rebel SL1 / 100D / Kiss X7" }, { 0x80000346, "EOS Rebel SL1 / 100D / Kiss X7" },
{ static_cast<long int>(0x80000347), "EOS Rebel T6s / 760D / 8000D" }, { 0x80000347, "EOS Rebel T6s / 760D / 8000D" },
{ static_cast<long int>(0x80000349), "EOS 5D Mark IV" }, { 0x80000349, "EOS 5D Mark IV" },
{ static_cast<long int>(0x80000382), "EOS 5DS" }, { 0x80000382, "EOS 5DS" },
{ static_cast<long int>(0x80000393), "EOS Rebel T6i / 750D / Kiss X8i" }, { 0x80000393, "EOS Rebel T6i / 750D / Kiss X8i" },
{ static_cast<long int>(0x80000401), "EOS 5DS R" }, { 0x80000401, "EOS 5DS R" },
{ static_cast<long int>(0x80000404), "EOS Rebel T6 / 1300D / Kiss X80" }, { 0x80000404, "EOS Rebel T6 / 1300D / Kiss X80" },
{ static_cast<long int>(0x80000405), "EOS Rebel T7i / 800D / Kiss X9i" }, { 0x80000405, "EOS Rebel T7i / 800D / Kiss X9i" },
{ static_cast<long int>(0x80000406), "EOS 6D Mark II" }, { 0x80000406, "EOS 6D Mark II" },
{ static_cast<long int>(0x80000408), "EOS 77D / 9000D" }, { 0x80000408, "EOS 77D / 9000D" },
{ static_cast<long int>(0x80000417), "EOS Rebel SL2 / 200D / Kiss X9" }, { 0x80000417, "EOS Rebel SL2 / 200D / Kiss X9" },
{ static_cast<long int>(0x80000421), "EOS R5" }, { 0x80000421, "EOS R5" },
{ static_cast<long int>(0x80000422), "EOS Rebel T100 / 4000D / 3000D" }, { 0x80000422, "EOS Rebel T100 / 4000D / 3000D" },
{ static_cast<long int>(0x80000424), "EOS R" }, { 0x80000424, "EOS R" },
{ static_cast<long int>(0x80000428), "EOS-1D X Mark III" }, { 0x80000428, "EOS-1D X Mark III" },
{ static_cast<long int>(0x80000432), "EOS Rebel T7 / 2000D / 1500D / Kiss X90" }, { 0x80000432, "EOS Rebel T7 / 2000D / 1500D / Kiss X90" },
{ static_cast<long int>(0x80000433), "EOS RP" }, { 0x80000433, "EOS RP" },
{ static_cast<long int>(0x80000435), "EOS 850D / T8i / Kiss X10i" }, { 0x80000435, "EOS 850D / T8i / Kiss X10i" },
{ static_cast<long int>(0x80000436), "EOS SL3 / 250D / Kiss X10" }, { 0x80000436, "EOS SL3 / 250D / Kiss X10" },
{ static_cast<long int>(0x80000437), "EOS 90D" }, { 0x80000437, "EOS 90D" },
{ static_cast<long int>(0x80000453), "EOS R6" }, { 0x80000453, "EOS R6" },
//{ (long int)tbd, "EOS Ra" }, //{ (long int)tbd, "EOS Ra" },
//{ (long int)tbd, "EOS M50 Mark II" }, //{ (long int)tbd, "EOS M50 Mark II" },
{static_cast<long int>(0x80000520), "EOS D2000C"}, {0x80000520, "EOS D2000C"},
{static_cast<long int>(0x80000560), "EOS D6000C"}}; {0x80000560, "EOS D6000C"}};
//! SerialNumberFormat, tag 0x0015 //! SerialNumberFormat, tag 0x0015
constexpr TagDetails canonSerialNumberFormat[] = { constexpr TagDetails canonSerialNumberFormat[] = {
{ static_cast<long int>(0x90000000), N_("Format 1") }, { 0x90000000, N_("Format 1") },
{ static_cast<long int>(0xa0000000), N_("Format 2") }, { 0xa0000000, N_("Format 2") },
}; };
//! SuperMacro, tag 0x001a //! SuperMacro, tag 0x001a
@ -2621,7 +2621,7 @@ namespace Exiv2 {
std::string model = pos->toString(); std::string model = pos->toString();
if (model.find("20D") != std::string::npos || model.find("350D") != std::string::npos || if (model.find("20D") != std::string::npos || model.find("350D") != std::string::npos ||
model.substr(model.size() - 8, 8) == "REBEL XT" || model.find("Kiss Digital N") != std::string::npos) { model.substr(model.size() - 8, 8) == "REBEL XT" || model.find("Kiss Digital N") != std::string::npos) {
uint32_t val = value.toLong(); uint32_t val = value.toUint32();
uint32_t dn = (val & 0xffc0) >> 6; uint32_t dn = (val & 0xffc0) >> 6;
uint32_t fn = ((val >> 16) & 0xff) + ((val & 0x3f) << 8); uint32_t fn = ((val >> 16) & 0xff) + ((val & 0x3f) << 8);
os << std::dec << dn << "-" << std::setw(4) << std::setfill('0') << fn; os << std::dec << dn << "-" << std::setw(4) << std::setfill('0') << fn;
@ -2631,7 +2631,7 @@ namespace Exiv2 {
if (model.find("30D") != std::string::npos || model.find("400D") != std::string::npos || if (model.find("30D") != std::string::npos || model.find("400D") != std::string::npos ||
model.find("REBEL XTi") != std::string::npos || model.find("Kiss Digital X") != std::string::npos || model.find("REBEL XTi") != std::string::npos || model.find("Kiss Digital X") != std::string::npos ||
model.find("K236") != std::string::npos) { model.find("K236") != std::string::npos) {
uint32_t val = value.toLong(); uint32_t val = value.toUint32();
uint32_t dn = (val & 0xffc00) >> 10; uint32_t dn = (val & 0xffc00) >> 10;
while (dn < 100) while (dn < 100)
dn += 0x40; dn += 0x40;
@ -2703,7 +2703,7 @@ namespace Exiv2 {
if ( value.typeId() != unsignedShort if ( value.typeId() != unsignedShort
|| value.count() == 0) return os << value; || value.count() == 0) return os << value;
long l = value.toLong(); const auto l = value.toInt64();
if (l == 0) { if (l == 0) {
os << "Off"; os << "Off";
} }
@ -2739,7 +2739,7 @@ namespace Exiv2 {
if (!metadata || value.typeId() != unsignedShort || value.count() == 0) if (!metadata || value.typeId() != unsignedShort || value.count() == 0)
return os << value; return os << value;
auto const lensType = value.toLong(); auto const lensType = value.toInt64();
if (lensType == 0xffff){ if (lensType == 0xffff){
return printCsLensFFFF(os, value, metadata); return printCsLensFFFF(os, value, metadata);
@ -2755,8 +2755,8 @@ namespace Exiv2 {
return os; return os;
} }
int const exifFlMin = static_cast<int>(static_cast<float>(pos->value().toLong(1)) / pos->value().toFloat(2)); int const exifFlMin = static_cast<int>(static_cast<float>(pos->value().toInt64(1)) / pos->value().toFloat(2));
int const exifFlMax = static_cast<int>(static_cast<float>(pos->value().toLong(0)) / pos->value().toFloat(2)); int const exifFlMax = static_cast<int>(static_cast<float>(pos->value().toInt64(0)) / pos->value().toFloat(2));
ExifKey aperKey("Exif.CanonCs.MaxAperture"); ExifKey aperKey("Exif.CanonCs.MaxAperture");
pos = metadata->findKey(aperKey); pos = metadata->findKey(aperKey);
@ -2765,7 +2765,7 @@ namespace Exiv2 {
return os; return os;
} }
auto exifAperMax = fnumber(canonEv(static_cast<int16_t>(pos->value().toLong(0)))); auto exifAperMax = fnumber(canonEv(static_cast<int16_t>(pos->value().toInt64(0))));
// regex to extract short and tele focal length, max aperture at short and tele position // regex to extract short and tele focal length, max aperture at short and tele position
// and the teleconverter factor from the lens label // and the teleconverter factor from the lens label
@ -2865,8 +2865,8 @@ namespace Exiv2 {
float fu = value.toFloat(2); float fu = value.toFloat(2);
if (fu == 0.0F) if (fu == 0.0F)
return os << value; return os << value;
float len1 = value.toLong(0) / fu; float len1 = value.toInt64(0) / fu;
float len2 = value.toLong(1) / fu; float len2 = value.toInt64(1) / fu;
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1); os << std::fixed << std::setprecision(1);
@ -2887,7 +2887,7 @@ namespace Exiv2 {
std::ios::fmtflags f( os.flags() ); std::ios::fmtflags f( os.flags() );
if ( value.typeId() == unsignedShort if ( value.typeId() == unsignedShort
&& value.count() > 0) { && value.count() > 0) {
os << std::exp(canonEv(value.toLong()) / 32 * std::log(2.0F)) * 100.0F; os << std::exp(canonEv(value.toInt64()) / 32 * std::log(2.0F)) * 100.0F;
} }
os.flags(f); os.flags(f);
return os; return os;
@ -2901,7 +2901,7 @@ namespace Exiv2 {
if ( value.typeId() == unsignedShort if ( value.typeId() == unsignedShort
&& value.count() > 0) { && value.count() > 0) {
// Ported from Exiftool by Will Stokes // Ported from Exiftool by Will Stokes
os << std::exp(canonEv(value.toLong()) * std::log(2.0F)) * 100.0F / 32.0F; os << std::exp(canonEv(value.toInt64()) * std::log(2.0F)) * 100.0F / 32.0F;
} }
os.flags(f); os.flags(f);
return os; return os;
@ -2919,7 +2919,7 @@ namespace Exiv2 {
// see also printSi0x0017 // see also printSi0x0017
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
int res = static_cast<int>(100.0 * (static_cast<short>(value.toLong()) / 32.0 + 5.0) + 0.5); int res = static_cast<int>(100.0 * (static_cast<short>(value.toInt64()) / 32.0 + 5.0) + 0.5);
os << std::fixed << std::setprecision(2) << res / 100.0; os << std::fixed << std::setprecision(2) << res / 100.0;
os.copyfmt(oss); os.copyfmt(oss);
} }
@ -2933,7 +2933,7 @@ namespace Exiv2 {
if ( value.typeId() != unsignedShort if ( value.typeId() != unsignedShort
|| value.count() == 0) return os << value; || value.count() == 0) return os << value;
long l = value.toLong(); const auto l = value.toInt64();
os << l << ""; os << l << "";
// Todo: determine unit // Todo: determine unit
return os; return os;
@ -2943,18 +2943,18 @@ namespace Exiv2 {
const Value& value, const Value& value,
const ExifData*) const ExifData*)
{ {
if (value.toLong() == 0) return os << "--"; if (value.toInt64() == 0) return os << "--";
return os << value.toLong() - 128 << " °C"; return os << value.toInt64() - 128 << " °C";
} }
std::ostream& CanonMakerNote::printSi0x000d(std::ostream& os, std::ostream& CanonMakerNote::printSi0x000d(std::ostream& os,
const Value& value, const Value& value,
const ExifData*) const ExifData*)
{ {
if (value.toLong() == 65535) return os << "--"; if (value.toInt64() == 65535) return os << "--";
return os << value.toLong() / 32; return os << value.toInt64() / 32;
} }
std::ostream& CanonMakerNote::printSi0x000e(std::ostream& os, std::ostream& CanonMakerNote::printSi0x000e(std::ostream& os,
@ -2964,10 +2964,10 @@ namespace Exiv2 {
if ( value.typeId() != unsignedShort if ( value.typeId() != unsignedShort
|| value.count() == 0) return os << value; || value.count() == 0) return os << value;
long l = value.toLong(); const auto l = value.toInt64();
long num = (l & 0xf000) >> 12; const auto num = (l & 0xf000) >> 12;
os << num << " focus points; "; os << num << " focus points; ";
long used = l & 0x0fff; const auto used = l & 0x0fff;
if (used == 0) { if (used == 0) {
os << "none"; os << "none";
} }
@ -2986,12 +2986,12 @@ namespace Exiv2 {
if ( value.typeId() != unsignedShort if ( value.typeId() != unsignedShort
|| value.count() == 0) return os << value; || value.count() == 0) return os << value;
long l = value.toLong(); const auto l = value.toInt64();
if (l == 0xffff) { if (l == 0xffff) {
os << "Infinite"; os << "Infinite";
} }
else { else {
os << value.toLong()/100.0 << " m"; os << value.toInt64()/100.0 << " m";
} }
os.flags(f); os.flags(f);
return os; return os;
@ -3006,7 +3006,7 @@ namespace Exiv2 {
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
long val = static_cast<int16_t>(value.toLong()); const auto val = static_cast<int16_t>(value.toInt64());
if (val < 0) return os << value; if (val < 0) return os << value;
os << std::setprecision(2) os << std::setprecision(2)
<< "F" << fnumber(canonEv(val)); << "F" << fnumber(canonEv(val));
@ -3022,7 +3022,7 @@ namespace Exiv2 {
if ( value.typeId() != unsignedShort if ( value.typeId() != unsignedShort
|| value.count() == 0) return os << value; || value.count() == 0) return os << value;
URational ur = exposureTime(canonEv(value.toLong())); URational ur = exposureTime(canonEv(value.toInt64()));
os << ur.first; os << ur.first;
if (ur.second > 1) { if (ur.second > 1) {
os << "/" << ur.second; os << "/" << ur.second;
@ -3041,7 +3041,7 @@ namespace Exiv2 {
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(2) os << std::fixed << std::setprecision(2)
<< value.toLong() / 8.0 - 6.0; << value.toInt64() / 8.0 - 6.0;
os.copyfmt(oss); os.copyfmt(oss);
return os; return os;
} }
@ -3050,7 +3050,7 @@ namespace Exiv2 {
const Value& value, const Value& value,
const ExifData*) const ExifData*)
{ {
return os << value.toLong() / 10; return os << value.toInt64() / 10;
} }
std::ostream& CanonMakerNote::printFiFocusDistance(std::ostream& os, std::ostream& CanonMakerNote::printFiFocusDistance(std::ostream& os,
@ -3065,12 +3065,12 @@ namespace Exiv2 {
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(2); os << std::fixed << std::setprecision(2);
long l = value.toLong(); const auto l = value.toInt64();
if (l == -1) { if (l == -1) {
os << "Infinite"; os << "Infinite";
} }
else { else {
os << value.toLong()/100.0 << " m"; os << value.toInt64()/100.0 << " m";
} }
os.copyfmt(oss); os.copyfmt(oss);
@ -3081,7 +3081,7 @@ namespace Exiv2 {
// ***************************************************************************** // *****************************************************************************
// free functions // free functions
float canonEv(long val) float canonEv(int64_t val)
{ {
// temporarily remove sign // temporarily remove sign
int sign = 1; int sign = 1;
@ -3090,8 +3090,9 @@ namespace Exiv2 {
val = -val; val = -val;
} }
// remove fraction // remove fraction
auto frac = static_cast<float>(val & 0x1f); const auto remainder = val & 0x1f;
val -= long(frac); val -= remainder;
float frac = static_cast<float>(remainder);
// convert 1/3 (0x0c) and 2/3 (0x14) codes // convert 1/3 (0x0c) and 2/3 (0x14) codes
if (frac == 0x0c) { if (frac == 0x0c) {
frac = 32.0F / 3; frac = 32.0F / 3;

@ -238,7 +238,7 @@ namespace Exiv2 {
128 -> 4 128 -> 4
143 -> 4.46875 143 -> 4.46875
*/ */
float canonEv(long val); float canonEv(int64_t val);
}} // namespace Internal, Exiv2 }} // namespace Internal, Exiv2

@ -215,7 +215,7 @@ namespace Exiv2 {
std::ios::fmtflags f( os.flags() ); std::ios::fmtflags f( os.flags() );
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(2) << value.toLong() / 1000.0 << _(" m"); os << std::fixed << std::setprecision(2) << value.toInt64() / 1000.0 << _(" m");
os.copyfmt(oss); os.copyfmt(oss);
os.flags(f); os.flags(f);
return os; return os;
@ -227,7 +227,7 @@ namespace Exiv2 {
std::vector<char> numbers; std::vector<char> numbers;
for(long i=0; i<value.size(); i++) for(long i=0; i<value.size(); i++)
{ {
long l=value.toLong(i); const auto l = value.toInt64(i);
if(l!=0) if(l!=0)
{ {
numbers.push_back(static_cast<char>(l)); numbers.push_back(static_cast<char>(l));
@ -546,7 +546,7 @@ namespace Exiv2 {
std::vector<char> numbers; std::vector<char> numbers;
for(long i=0; i<value.size(); i++) for(long i=0; i<value.size(); i++)
{ {
long l=value.toLong(i); const auto l = value.toInt64(i);
if(l!=0) if(l!=0)
{ {
numbers.push_back(static_cast<char>(l)); numbers.push_back(static_cast<char>(l));
@ -578,7 +578,7 @@ namespace Exiv2 {
std::ostream& Casio2MakerNote::print0x2022(std::ostream& os, const Value& value, const ExifData*) std::ostream& Casio2MakerNote::print0x2022(std::ostream& os, const Value& value, const ExifData*)
{ {
std::ios::fmtflags f( os.flags() ); std::ios::fmtflags f( os.flags() );
if(value.toLong()>=0x20000000) if(value.toInt64()>=0x20000000)
{ {
os << N_("Inf"); os << N_("Inf");
os.flags(f); os.flags(f);
@ -586,7 +586,7 @@ namespace Exiv2 {
}; };
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(2) << value.toLong() / 1000.0 << _(" m"); os << std::fixed << std::setprecision(2) << value.toInt64() / 1000.0 << _(" m");
os.copyfmt(oss); os.copyfmt(oss);
os.flags(f); os.flags(f);
return os; return os;

@ -836,8 +836,8 @@ namespace Exiv2 {
return decodeBasic(ciffComponent, pCrwMapping, image, byteOrder); return decodeBasic(ciffComponent, pCrwMapping, image, byteOrder);
} }
long aperture = 0; int64_t aperture = 0;
long shutterSpeed = 0; int64_t shutterSpeed = 0;
IfdId ifdId = ifdIdNotSet; IfdId ifdId = ifdIdNotSet;
switch (pCrwMapping->tag_) { switch (pCrwMapping->tag_) {
@ -861,8 +861,8 @@ namespace Exiv2 {
if (ifdId == canonCsId && c == 23 && component_size >= 52) n = 3; if (ifdId == canonCsId && c == 23 && component_size >= 52) n = 3;
value.read(ciffComponent.pData() + c*2, n*2, byteOrder); value.read(ciffComponent.pData() + c*2, n*2, byteOrder);
image.exifData().add(key, &value); image.exifData().add(key, &value);
if (ifdId == canonSiId && c == 21) aperture = value.toLong(); if (ifdId == canonSiId && c == 21) aperture = value.toInt64();
if (ifdId == canonSiId && c == 22) shutterSpeed = value.toLong(); if (ifdId == canonSiId && c == 22) shutterSpeed = value.toInt64();
c += n; c += n;
} }

@ -128,14 +128,14 @@ namespace Exiv2 {
// Find the first ISO value which is not "0" // Find the first ISO value which is not "0"
const int cnt = EXV_COUNTOF(keys); const int cnt = EXV_COUNTOF(keys);
auto md = ed.end(); auto md = ed.end();
long iso_val = -1; int64_t iso_val = -1;
for (int idx = 0; idx < cnt; ) { for (int idx = 0; idx < cnt; ) {
md = findMetadatum(ed, keys + idx, cnt - idx); md = findMetadatum(ed, keys + idx, cnt - idx);
if (md == ed.end()) break; if (md == ed.end()) break;
std::ostringstream os; std::ostringstream os;
md->write(os, &ed); md->write(os, &ed);
bool ok = false; bool ok = false;
iso_val = parseLong(os.str(), ok); iso_val = parseInt64(os.str(), ok);
if (ok && iso_val > 0) break; if (ok && iso_val > 0) break;
while (strcmp(keys[idx++], md->key().c_str()) != 0 && idx < cnt) {} while (strcmp(keys[idx++], md->key().c_str()) != 0 && idx < cnt) {}
md = ed.end(); md = ed.end();
@ -144,7 +144,7 @@ namespace Exiv2 {
// there is either a possible ISO "overflow" or no legacy // there is either a possible ISO "overflow" or no legacy
// ISO tag at all. Check for SensitivityType tag and the referenced // ISO tag at all. Check for SensitivityType tag and the referenced
// ISO value (see EXIF 2.3 Annex G) // ISO value (see EXIF 2.3 Annex G)
long iso_tmp_val = -1; int64_t iso_tmp_val = -1;
while (iso_tmp_val == -1 && (iso_val == 65535 || md == ed.end())) { while (iso_tmp_val == -1 && (iso_val == 65535 || md == ed.end())) {
auto md_st = findMetadatum(ed, sensitivityType, 1); auto md_st = findMetadatum(ed, sensitivityType, 1);
// no SensitivityType? exit with existing data // no SensitivityType? exit with existing data
@ -154,7 +154,7 @@ namespace Exiv2 {
std::ostringstream os; std::ostringstream os;
md_st->write(os, &ed); md_st->write(os, &ed);
bool ok = false; bool ok = false;
const long st_val = parseLong(os.str(), ok); const int64_t st_val = parseInt64(os.str(), ok);
// SensitivityType out of range or cannot be parsed properly // SensitivityType out of range or cannot be parsed properly
if (!ok || st_val < 1 || st_val > 7) if (!ok || st_val < 1 || st_val > 7)
break; break;
@ -169,7 +169,7 @@ namespace Exiv2 {
std::ostringstream os_iso; std::ostringstream os_iso;
md_st->write(os_iso, &ed); md_st->write(os_iso, &ed);
ok = false; ok = false;
iso_tmp_val = parseLong(os_iso.str(), ok); iso_tmp_val = parseInt64(os_iso.str(), ok);
// something wrong with the value // something wrong with the value
if (ok || iso_tmp_val > 0) { if (ok || iso_tmp_val > 0) {
md = md_st; md = md_st;

@ -420,7 +420,7 @@ namespace Exiv2 {
long Exifdatum::toLong(long n) const long Exifdatum::toLong(long n) const
{ {
return value_.get() == nullptr ? -1 : value_->toLong(n); return value_.get() == nullptr ? -1 : static_cast<long>(value_->toInt64(n));
} }
float Exifdatum::toFloat(long n) const float Exifdatum::toFloat(long n) const

@ -183,7 +183,7 @@ namespace Exiv2 {
long Iptcdatum::toLong(long n) const long Iptcdatum::toLong(long n) const
{ {
return value_.get() == nullptr ? -1 : value_->toLong(n); return value_.get() == nullptr ? -1 : static_cast<long>(value_->toInt64(n));
} }
float Iptcdatum::toFloat(long n) const float Iptcdatum::toFloat(long n) const

@ -1174,7 +1174,7 @@ namespace Exiv2 {
pRoot->accept(finder); pRoot->accept(finder);
auto te = dynamic_cast<TiffEntryBase*>(finder.result()); auto te = dynamic_cast<TiffEntryBase*>(finder.result());
if (!te || !te->pValue() || te->pValue()->count() == 0) return buf; if (!te || !te->pValue() || te->pValue()->count() == 0) return buf;
auto count = static_cast<uint32_t>(te->pValue()->toLong()); auto count = te->pValue()->toUint32();
// Find Exif.Nikon3.SerialNumber // Find Exif.Nikon3.SerialNumber
finder.init(0x001d, nikon3Id); finder.init(0x001d, nikon3Id);
@ -1245,13 +1245,13 @@ namespace Exiv2 {
if (value->count() < 4) if (value->count() < 4)
return -1; return -1;
switch (value->toLong(0)) { // Using encrypted values switch (value->toInt64(0)) { // Using encrypted values
case 231: // 231 == 9 case 231: // 231 == 9
case 234: // 234 == 12 case 234: // 234 == 12
case 205: // 205 == 13 case 205: // 205 == 13
case 138: // 138 == 15 case 138: // 138 == 15
case 112: // 112 == 16 case 112: // 112 == 16
return value->toLong(3) == 8 ? 0 : -1; // 8 == 2 return value->toInt64(3) == 8 ? 0 : -1; // 8 == 2
default: default:
break; break;
} }
@ -1273,7 +1273,7 @@ namespace Exiv2 {
if (value->count() < 1) if (value->count() < 1)
return -1; return -1;
switch (value->toLong()) { // Using encrypted values switch (value->toInt64()) { // Using encrypted values
case 35: // 35 == 62 case 35: // 35 == 62
case 36: // 36 == 48 case 36: // 36 == 48
case 38: // 38 == 215 case 38: // 38 == 215

@ -406,75 +406,75 @@ namespace Exiv2 {
std::ostream& MinoltaMakerNote::printMinoltaExposureSpeedStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaExposureSpeedStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << (value.toLong()/8)-1; os << (value.toInt64()/8)-1;
return os; return os;
} }
std::ostream& MinoltaMakerNote::printMinoltaExposureTimeStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaExposureTimeStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << (value.toLong()/8)-6; os << (value.toInt64()/8)-6;
return os; return os;
} }
std::ostream& MinoltaMakerNote::printMinoltaFNumberStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaFNumberStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << (value.toLong()/8)-1; os << (value.toInt64()/8)-1;
return os; return os;
} }
std::ostream& MinoltaMakerNote::printMinoltaExposureCompensationStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaExposureCompensationStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << value.toLong()/256; os << value.toInt64()/256;
return os; return os;
} }
std::ostream& MinoltaMakerNote::printMinoltaFocalLengthStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaFocalLengthStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << (value.toLong()/3)-2; os << (value.toInt64()/3)-2;
return os; return os;
} }
std::ostream& MinoltaMakerNote::printMinoltaDateStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaDateStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << value.toLong() / 65536 << ":" << std::right << std::setw(2) << std::setfill('0') os << value.toInt64() / 65536 << ":" << std::right << std::setw(2) << std::setfill('0')
<< (value.toLong() - value.toLong() / 65536 * 65536) / 256 << ":" << (value.toInt64() - value.toInt64() / 65536 * 65536) / 256 << ":"
<< std::right << std::setw(2) << std::setfill('0') << value.toLong() % 256; << std::right << std::setw(2) << std::setfill('0') << value.toInt64() % 256;
return os; return os;
} }
std::ostream& MinoltaMakerNote::printMinoltaTimeStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaTimeStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << std::right << std::setw(2) << std::setfill('0') << value.toLong() / 65536 os << std::right << std::setw(2) << std::setfill('0') << value.toInt64() / 65536
<< ":" << std::right << std::setw(2) << std::setfill('0') << ":" << std::right << std::setw(2) << std::setfill('0')
<< (value.toLong() - value.toLong() / 65536 * 65536) / 256 << ":" << (value.toInt64() - value.toInt64() / 65536 * 65536) / 256 << ":"
<< std::right << std::setw(2) << std::setfill('0') << value.toLong() % 256; << std::right << std::setw(2) << std::setfill('0') << value.toInt64() % 256;
return os; return os;
} }
std::ostream& MinoltaMakerNote::printMinoltaFlashExposureCompStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaFlashExposureCompStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << (value.toLong()-6)/3; os << (value.toInt64()-6)/3;
return os; return os;
} }
std::ostream& MinoltaMakerNote::printMinoltaWhiteBalanceStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaWhiteBalanceStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << value.toLong()/256; os << value.toInt64()/256;
return os; return os;
} }
std::ostream& MinoltaMakerNote::printMinoltaBrightnessStd(std::ostream& os, const Value& value, const ExifData*) std::ostream& MinoltaMakerNote::printMinoltaBrightnessStd(std::ostream& os, const Value& value, const ExifData*)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
os << (value.toLong()/8)-6; os << (value.toInt64()/8)-6;
return os; return os;
} }
@ -957,7 +957,7 @@ namespace Exiv2 {
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(2) os << std::fixed << std::setprecision(2)
<< (float (value.toLong()-128)/24); << (float (value.toInt64()-128)/24);
os.copyfmt(oss); os.copyfmt(oss);
os.flags(f); os.flags(f);
return os; return os;
@ -970,7 +970,7 @@ namespace Exiv2 {
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(2) os << std::fixed << std::setprecision(2)
<< (float (value.toLong()-300)/100); << (float (value.toInt64()-300)/100);
os.copyfmt(oss); os.copyfmt(oss);
os.flags(f); os.flags(f);
return os; return os;
@ -2203,7 +2203,7 @@ namespace Exiv2 {
} }
struct LensIdFct { struct LensIdFct {
long id_; //!< Lens id uint32_t id_; //!< Lens id
PrintFct fct_; //!< Pretty-print function PrintFct fct_; //!< Pretty-print function
//! Comparison operator for find template //! Comparison operator for find template
bool operator==(long id) const { return id_ == id; } bool operator==(long id) const { return id_ == id; }
@ -2236,7 +2236,7 @@ namespace Exiv2 {
} }
// #1145 - respect lenses with shared LensID // #1145 - respect lenses with shared LensID
unsigned long index = value.toLong(); uint32_t index = value.toUint32();
const LensIdFct* lif = find(lensIdFct,index); const LensIdFct* lif = find(lensIdFct,index);
if ( lif && metadata ) { if ( lif && metadata ) {
if ( lif->fct_ ) if ( lif->fct_ )

@ -275,7 +275,7 @@ namespace Exiv2 {
const ExifData*) const ExifData*)
{ {
if (value.count() > 1) { if (value.count() > 1) {
os << value.toLong(1); os << value.toInt64(1);
} }
else { else {
os << "(" << value << ")"; os << "(" << value << ")";
@ -303,7 +303,7 @@ namespace Exiv2 {
ByteOrder bo = getKeyString("Exif.MakerNote.ByteOrder",exifData) == "MM" ? bigEndian : littleEndian; ByteOrder bo = getKeyString("Exif.MakerNote.ByteOrder",exifData) == "MM" ? bigEndian : littleEndian;
byte p[4]; byte p[4];
for (int n = 0; n < 4; n++) for (int n = 0; n < 4; n++)
p[n] = static_cast<byte>(value.toLong(6 + n)); p[n] = static_cast<byte>(value.toInt64(6 + n));
os << getLong(p, bo); os << getLong(p, bo);
} }
@ -371,7 +371,7 @@ namespace Exiv2 {
const ExifData*) const ExifData*)
{ {
if (value.count() >= 1) { if (value.count() >= 1) {
const unsigned long focusArea = value.toLong(0); const uint32_t focusArea = value.toUint32(0);
if (focusArea >= EXV_COUNTOF(nikonFocusarea)) { if (focusArea >= EXV_COUNTOF(nikonFocusarea)) {
os << "Invalid value"; os << "Invalid value";
} else { } else {
@ -380,7 +380,7 @@ namespace Exiv2 {
} }
if (value.count() >= 2) { if (value.count() >= 2) {
os << "; "; os << "; ";
unsigned long focusPoint = value.toLong(1); const uint32_t focusPoint = value.toUint32(1);
switch (focusPoint) { switch (focusPoint) {
// Could use array nikonFocuspoints // Could use array nikonFocuspoints
@ -399,8 +399,8 @@ namespace Exiv2 {
} }
} }
if (value.count() >= 3) { if (value.count() >= 3) {
unsigned long focusPointsUsed1 = value.toLong(2); const uint32_t focusPointsUsed1 = value.toUint32(2);
unsigned long focusPointsUsed2 = value.toLong(3); const uint32_t focusPointsUsed2 = value.toUint32(3);
if (focusPointsUsed1 != 0 && focusPointsUsed2 != 0) if (focusPointsUsed1 != 0 && focusPointsUsed2 != 0)
{ {
@ -1526,7 +1526,7 @@ namespace Exiv2 {
const Value& value, const Value& value,
const ExifData*) const ExifData*)
{ {
double v = 100 * exp((value.toLong() / 12.0 - 5) * log(2.0)); double v = 100 * exp((value.toInt64() / 12.0 - 5) * log(2.0));
return os << static_cast<int>(v + 0.5); return os << static_cast<int>(v + 0.5);
} }
@ -1535,7 +1535,7 @@ namespace Exiv2 {
const ExifData*) const ExifData*)
{ {
if (value.count() > 1) { if (value.count() > 1) {
os << value.toLong(1); os << value.toInt64(1);
} }
else { else {
os << "(" << value << ")"; os << "(" << value << ")";
@ -1559,7 +1559,7 @@ namespace Exiv2 {
const Value& value, const Value& value,
const ExifData*) const ExifData*)
{ {
long lensType = value.toLong(); const uint32_t lensType = value.toUint32();
bool valid=false; bool valid=false;
if (lensType & 1) if (lensType & 1)
@ -1600,8 +1600,8 @@ namespace Exiv2 {
os << "(" << value << ")"; os << "(" << value << ")";
return os; return os;
} }
long len1 = value.toLong(0); const int64_t len1 = value.toInt64(0);
long len2 = value.toLong(1); const int64_t len2 = value.toInt64(1);
Rational fno1 = value.toRational(2); Rational fno1 = value.toRational(2);
Rational fno2 = value.toRational(3); Rational fno2 = value.toRational(3);
@ -1676,12 +1676,12 @@ namespace Exiv2 {
} }
else { else {
// Mapping by Roger Larsson // Mapping by Roger Larsson
unsigned focusmetering = value.toLong(0); const uint32_t focusmetering = value.toUint32(0);
unsigned focuspoint = value.toLong(1); const uint32_t focuspoint = value.toUint32(1);
unsigned focusused = (value.toLong(2) << 8) + value.toLong(3); const uint32_t focusused = (value.toUint32(2) << 8) + value.toUint32(3);
// TODO: enum {standard, wide} combination = standard; // TODO: enum {standard, wide} combination = standard;
const unsigned focuspoints = sizeof(nikonFocuspoints) const size_t focuspoints = sizeof(nikonFocuspoints)
/ sizeof(nikonFocuspoints[0]); / sizeof(nikonFocuspoints[0]);
if (focusmetering == 0 && focuspoint == 0 && focusused == 0) { if (focusmetering == 0 && focuspoint == 0 && focusused == 0) {
// Special case, in Manual focus and with Nikon compacts // Special case, in Manual focus and with Nikon compacts
@ -1725,7 +1725,7 @@ namespace Exiv2 {
// selected point was not the actually used one // selected point was not the actually used one
// (Roger Larsson: my interpretation, verify) // (Roger Larsson: my interpretation, verify)
os << sep; os << sep;
for (unsigned fpid=0; fpid<focuspoints; fpid++) for (size_t fpid=0; fpid<focuspoints; fpid++)
if (focusused & 1<<fpid) if (focusused & 1<<fpid)
os << ' ' << nikonFocuspoints[fpid]; os << ' ' << nikonFocuspoints[fpid];
} }
@ -1753,7 +1753,7 @@ namespace Exiv2 {
} }
} }
auto val = static_cast<uint16_t>(value.toLong()); auto val = static_cast<uint16_t>(value.toInt64());
if (dModel) val = (val >> 8) | ((val & 0x00ff) << 8); if (dModel) val = (val >> 8) | ((val & 0x00ff) << 8);
if (val == 0x07ff) return os << _("All 11 Points"); if (val == 0x07ff) return os << _("All 11 Points");
@ -1770,7 +1770,7 @@ namespace Exiv2 {
if (value.count() != 1 || value.typeId() != unsignedShort) { if (value.count() != 1 || value.typeId() != unsignedShort) {
return os << "(" << value << ")"; return os << "(" << value << ")";
} }
long l = value.toLong(0); const auto l = value.toInt64(0);
if (l == 0) return os << _("Single-frame"); if (l == 0) return os << _("Single-frame");
if (!(l & 0x87)) os << _("Single-frame") << ", "; if (!(l & 0x87)) os << _("Single-frame") << ", ";
bool d70 = false; bool d70 = false;
@ -1803,8 +1803,8 @@ namespace Exiv2 {
return os << "(" << value << ")"; return os << "(" << value << ")";
} }
float a = value.toFloat(0); float a = value.toFloat(0);
long b = value.toLong(1); const auto b = value.toInt64(1);
long c = value.toLong(2); const auto c = value.toInt64(2);
if (c == 0) return os << "(" << value << ")"; if (c == 0) return os << "(" << value << ")";
return os << a * b / c; return os << a * b / c;
} }
@ -2621,7 +2621,7 @@ fmountlens[] = {
*/ */
if (metadata == nullptr) if (metadata == nullptr)
{ {
const unsigned char vid = static_cast<unsigned>(value.toLong(0)); const unsigned char vid = static_cast<unsigned char>(value.toInt64(0));
/* the 'FMntLens' name is added to the anonymous struct for /* the 'FMntLens' name is added to the anonymous struct for
* fmountlens[] * fmountlens[]
@ -2716,7 +2716,7 @@ fmountlens[] = {
os.flags(f); os.flags(f);
return os; return os;
} }
double dist = 0.01 * pow(10.0, value.toLong()/40.0); double dist = 0.01 * pow(10.0, value.toInt64()/40.0);
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(2) << dist << " m"; os << std::fixed << std::setprecision(2) << dist << " m";
@ -2735,7 +2735,7 @@ fmountlens[] = {
os.flags(f); os.flags(f);
return os; return os;
} }
double aperture = pow(2.0, value.toLong()/24.0); double aperture = pow(2.0, value.toInt64()/24.0);
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) << "F" << aperture; os << std::fixed << std::setprecision(1) << "F" << aperture;
@ -2751,7 +2751,7 @@ fmountlens[] = {
if (value.count() != 1 || value.typeId() != unsignedByte) { if (value.count() != 1 || value.typeId() != unsignedByte) {
return os << "(" << value << ")"; return os << "(" << value << ")";
} }
double focal = 5.0 * pow(2.0, value.toLong()/24.0); double focal = 5.0 * pow(2.0, value.toInt64()/24.0);
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) << focal << " mm"; os << std::fixed << std::setprecision(1) << focal << " mm";
@ -2769,7 +2769,7 @@ fmountlens[] = {
os.flags(f); os.flags(f);
return os; return os;
} }
double fstops = value.toLong()/12.0; double fstops = value.toInt64()/12.0;
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) << "F" << fstops; os << std::fixed << std::setprecision(1) << "F" << fstops;
@ -2783,12 +2783,12 @@ fmountlens[] = {
const ExifData*) const ExifData*)
{ {
std::ios::fmtflags f( os.flags() ); std::ios::fmtflags f( os.flags() );
if (value.count() != 1 || value.typeId() != unsignedByte || value.toLong() == 0) { if (value.count() != 1 || value.typeId() != unsignedByte || value.toInt64() == 0) {
os << "(" << value << ")"; os << "(" << value << ")";
os.flags(f); os.flags(f);
return os; return os;
} }
double epp = 2048.0/value.toLong(); double epp = 2048.0/value.toInt64();
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) << epp << " mm"; os << std::fixed << std::setprecision(1) << epp << " mm";
@ -2807,7 +2807,7 @@ fmountlens[] = {
os.flags(f); os.flags(f);
return os; return os;
} }
auto temp = value.toLong(); auto temp = value.toInt64();
if (temp == 0 || temp == 255) if (temp == 0 || temp == 255)
return os << _("n/a"); return os << _("n/a");
@ -2827,7 +2827,7 @@ fmountlens[] = {
if (value.count() != 1 || value.typeId() != unsignedByte) { if (value.count() != 1 || value.typeId() != unsignedByte) {
return os << "(" << value << ")"; return os << "(" << value << ")";
} }
auto temp = value.toLong(); auto temp = value.toInt64();
if (temp == 0 || temp == 255) if (temp == 0 || temp == 255)
return os << _("n/a"); return os << _("n/a");
@ -2847,7 +2847,7 @@ fmountlens[] = {
if (value.count() != 1 || value.typeId() != unsignedByte) { if (value.count() != 1 || value.typeId() != unsignedByte) {
return os << "(" << value << ")"; return os << "(" << value << ")";
} }
auto temp = value.toLong(); auto temp = value.toInt64();
if (temp == 0 || temp == 255) if (temp == 0 || temp == 255)
return os << _("n/a"); return os << _("n/a");
@ -2871,9 +2871,9 @@ fmountlens[] = {
} }
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << (value.toLong() & 0x80 ? _("External flash zoom override") : _("No external flash zoom override")); os << (value.toInt64() & 0x80 ? _("External flash zoom override") : _("No external flash zoom override"));
os << ", "; os << ", ";
os << (value.toLong() & 0x01 ? _("external flash attached") : _("external flash not attached")); os << (value.toInt64() & 0x01 ? _("external flash attached") : _("external flash not attached"));
os.copyfmt(oss); os.copyfmt(oss);
os.flags(f); os.flags(f);
@ -2893,7 +2893,7 @@ fmountlens[] = {
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
long temp = value.toLong(); const auto temp = value.toInt64();
switch (temp & 0x07) { switch (temp & 0x07) {
case 0: case 0:
@ -2959,7 +2959,7 @@ fmountlens[] = {
} }
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
long temp = value.toLong(); const auto temp = value.toInt64();
printTag<EXV_COUNTOF(nikonFlashControlMode), nikonFlashControlMode>(os, (temp >> 4), data); printTag<EXV_COUNTOF(nikonFlashControlMode), nikonFlashControlMode>(os, (temp >> 4), data);
os << ", "; os << ", ";
@ -3105,7 +3105,7 @@ fmountlens[] = {
} }
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
char sign = value.toLong() < 0 ? '-' : '+'; char sign = value.toInt64() < 0 ? '-' : '+';
long h = long(std::abs(static_cast<int>(value.toFloat() / 60.0F))) % 24; long h = long(std::abs(static_cast<int>(value.toFloat() / 60.0F))) % 24;
long min = long(std::abs(static_cast<int>(value.toFloat() - h * 60))) % 60; long min = long(std::abs(static_cast<int>(value.toFloat() - h * 60))) % 60;
os << std::fixed << "UTC " << sign << std::setw(2) << std::setfill('0') << h << ":" os << std::fixed << "UTC " << sign << std::setw(2) << std::setfill('0') << h << ":"
@ -3122,7 +3122,7 @@ fmountlens[] = {
if (value.count() != 1 || value.typeId() != unsignedByte) { if (value.count() != 1 || value.typeId() != unsignedByte) {
return os << "(" << value << ")"; return os << "(" << value << ")";
} }
long pcval = value.toLong() - 0x80; const auto pcval = value.toInt64() - 0x80;
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
switch(pcval) switch(pcval)
@ -3169,7 +3169,7 @@ fmountlens[] = {
std::string s; std::string s;
bool trim = true; bool trim = true;
for (int i = 9; i >= 0; --i) { for (int i = 9; i >= 0; --i) {
long l = value.toLong(i); const auto l = value.toInt64(i);
if (i > 0 && l == 0 && trim) continue; if (i > 0 && l == 0 && trim) continue;
if (l != 0) trim = false; if (l != 0) trim = false;
std::string d = s.empty() ? "" : "; "; std::string d = s.empty() ? "" : "; ";
@ -3216,7 +3216,7 @@ fmountlens[] = {
{23, "Nikon", "Nikkor Z 14-24mm f/2.8 S"}, // IB {23, "Nikon", "Nikkor Z 14-24mm f/2.8 S"}, // IB
}; };
auto lid = static_cast<uint16_t>(value.toLong()); auto lid = static_cast<uint16_t>(value.toInt64());
auto it = auto it =
std::find_if(std::begin(zmountlens), std::end(zmountlens), [=](const ZMntLens& z) { return z.lid == lid; }); std::find_if(std::begin(zmountlens), std::end(zmountlens), [=](const ZMntLens& z) { return z.lid == lid; });
if (it != std::end(zmountlens)) if (it != std::end(zmountlens))
@ -3232,7 +3232,7 @@ fmountlens[] = {
return os << "(" << value << ")"; return os << "(" << value << ")";
} }
double aperture = pow(2.0, value.toLong()/384.0 - 1.0); double aperture = pow(2.0, value.toInt64()/384.0 - 1.0);
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) << "F" << aperture; os << std::fixed << std::setprecision(1) << "F" << aperture;
@ -3248,7 +3248,7 @@ fmountlens[] = {
} }
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) << value.toLong() << " mm"; os << std::fixed << std::setprecision(1) << value.toInt64() << " mm";
os.copyfmt(oss); os.copyfmt(oss);
return os; return os;
} }

@ -1108,16 +1108,16 @@ namespace Exiv2 {
return os << value; return os << value;
} }
if (value.toLong(0) == -1 && value.toLong(1) == -1 && value.toLong(2) == 1) os << _("Low Key"); if (value.toInt64(0) == -1 && value.toInt64(1) == -1 && value.toInt64(2) == 1) os << _("Low Key");
else if (value.toLong(0) == 0 && value.toLong(1) == -1 && value.toLong(2) == 1) os << _("Normal"); else if (value.toInt64(0) == 0 && value.toInt64(1) == -1 && value.toInt64(2) == 1) os << _("Normal");
else if (value.toLong(0) == 1 && value.toLong(1) == -1 && value.toLong(2) == 1) os << _("High Key"); else if (value.toInt64(0) == 1 && value.toInt64(1) == -1 && value.toInt64(2) == 1) os << _("High Key");
else os << value.toLong(0) << " " << value.toLong(1) << " " << value.toLong(2); else os << value.toInt64(0) << " " << value.toInt64(1) << " " << value.toInt64(2);
if (value.count() == 4) { if (value.count() == 4) {
switch (value.toLong(3)) { switch (value.toInt64(3)) {
case 0: os << ", " << _("User-Selected"); break; case 0: os << ", " << _("User-Selected"); break;
case 1: os << ", " << _("Auto-Override"); break; case 1: os << ", " << _("Auto-Override"); break;
default: os << value.toLong(3); break; default: os << value.toInt64(3); break;
} }
} }
return os; return os;
@ -1128,17 +1128,17 @@ namespace Exiv2 {
{ {
if ( value.count() != 3 if ( value.count() != 3
|| value.typeId() != signedShort || value.typeId() != signedShort
|| value.toLong(1) != -2 || value.toInt64(1) != -2
|| value.toLong(2) != 1) { || value.toInt64(2) != 1) {
return os << value; return os << value;
} }
switch (value.toLong(0)) { switch (value.toInt64(0)) {
case -2: os << _("Off"); break; case -2: os << _("Off"); break;
case -1: os << _("Low"); break; case -1: os << _("Low"); break;
case 0: os << _("Standard"); break; case 0: os << _("Standard"); break;
case 1: os << _("High"); break; case 1: os << _("High"); break;
default: os << value.toLong(0); break; default: os << value.toInt64(0); break;
} }
return os; return os;
@ -1149,7 +1149,7 @@ namespace Exiv2 {
if (value.count() != 3 || value.typeId() != unsignedLong) { if (value.count() != 3 || value.typeId() != unsignedLong) {
return os << value; return os << value;
} }
long l0 = value.toLong(0); const auto l0 = value.toInt64(0);
switch (l0) { switch (l0) {
case 0: os << _("Normal"); break; case 0: os << _("Normal"); break;
case 2: os << _("Fast"); break; case 2: os << _("Fast"); break;
@ -1158,12 +1158,12 @@ namespace Exiv2 {
} }
if (l0 != 0) { if (l0 != 0) {
os << ", "; os << ", ";
long l1 = value.toLong(1); const auto l1 = value.toInt64(1);
os << _("Sequence number") << " " << l1; os << _("Sequence number") << " " << l1;
} }
if (l0 != 0 && l0 != 2) { if (l0 != 0 && l0 != 2) {
os << ", "; os << ", ";
long l2 = value.toLong(2); const auto l2 = value.toInt64(2);
switch (l2) { switch (l2) {
case 1: os << _("Left to right"); break; case 1: os << _("Left to right"); break;
case 2: os << _("Right to left"); break; case 2: os << _("Right to left"); break;
@ -1199,7 +1199,7 @@ namespace Exiv2 {
return os << value; return os << value;
} }
if (value.count() == 1) { if (value.count() == 1) {
auto l0 = static_cast<short>(value.toLong(0)); auto l0 = static_cast<short>(value.toInt64(0));
if (l0 == 1) { if (l0 == 1) {
os << _("Auto"); os << _("Auto");
} }
@ -1208,8 +1208,8 @@ namespace Exiv2 {
} }
} }
else if (value.count() == 2) { else if (value.count() == 2) {
auto l0 = static_cast<short>(value.toLong(0)); auto l0 = static_cast<short>(value.toInt64(0));
auto l1 = static_cast<short>(value.toLong(1)); auto l1 = static_cast<short>(value.toInt64(1));
if (l0 == 1) { if (l0 == 1) {
switch (l1) { switch (l1) {
case 0: os << _("Auto"); break; case 0: os << _("Auto"); break;
@ -1380,9 +1380,9 @@ namespace Exiv2 {
return os << value; return os << value;
} }
byte v0 = static_cast<byte>(value.toLong(0)); byte v0 = static_cast<byte>(value.toInt64(0));
byte v2 = static_cast<byte>(value.toLong(2)); byte v2 = static_cast<byte>(value.toInt64(2));
byte v3 = static_cast<byte>(value.toLong(3)); byte v3 = static_cast<byte>(value.toInt64(3));
for (auto&& type : lensTypes) { for (auto&& type : lensTypes) {
if (type.val[0] == v0 && type.val[1] == v2 && type.val[2] == v3) { if (type.val[0] == v0 && type.val[1] == v2 && type.val[2] == v3) {
@ -1401,7 +1401,7 @@ namespace Exiv2 {
char ch; char ch;
int size = value.size(); int size = value.size();
for (int i = 0; i < size && ((ch = static_cast<char>(value.toLong(i))) != '\0'); i++) { for (int i = 0; i < size && ((ch = static_cast<char>(value.toInt64(i))) != '\0'); i++) {
os << ch; os << ch;
} }
return os; return os;
@ -1426,8 +1426,8 @@ namespace Exiv2 {
return os << value; return os << value;
} }
byte v0 = static_cast<byte>(value.toLong(0)); byte v0 = static_cast<byte>(value.toInt64(0));
byte v2 = static_cast<byte>(value.toLong(2)); byte v2 = static_cast<byte>(value.toInt64(2));
for (auto&& model : extenderModels) { for (auto&& model : extenderModels) {
if (model.val[0] == v0 && model.val[1] == v2) { if (model.val[0] == v0 && model.val[1] == v2) {
@ -1467,13 +1467,13 @@ namespace Exiv2 {
if (value.count() < 1 || value.typeId() != unsignedShort) { if (value.count() < 1 || value.typeId() != unsignedShort) {
return os << "(" << value << ")"; return os << "(" << value << ")";
} }
auto v = static_cast<uint16_t>(value.toLong(0)); auto v = static_cast<uint16_t>(value.toInt64(0));
// If value 2 is present, it is used instead of value 1. // If value 2 is present, it is used instead of value 1.
if (value.count() > 1) { if (value.count() > 1) {
std::string p; // Used to enable ',' separation std::string p; // Used to enable ',' separation
v = static_cast<uint16_t>(value.toLong(1)); v = static_cast<uint16_t>(value.toInt64(1));
for (auto&& mode : focusModes1) { for (auto&& mode : focusModes1) {
if ((v &mode.val) != 0) { if ((v &mode.val) != 0) {
if (!p.empty()) { if (!p.empty()) {
@ -1547,8 +1547,8 @@ namespace Exiv2 {
return os << value; return os << value;
} }
auto v0 = static_cast<uint16_t>(value.toLong(0)); auto v0 = static_cast<uint16_t>(value.toInt64(0));
auto v1 = static_cast<uint16_t>(value.toLong(1)); auto v1 = static_cast<uint16_t>(value.toInt64(1));
for (auto&& filter : artFilters) { for (auto&& filter : artFilters) {
if (filter.val[0] == v0 && filter.val[1] == v1) { if (filter.val[0] == v0 && filter.val[1] == v1) {
@ -1565,13 +1565,13 @@ namespace Exiv2 {
return os << value; return os << value;
} }
switch (value.toLong(0)) { switch (value.toInt64(0)) {
case 0: os << _("Off"); break; case 0: os << _("Off"); break;
case 1: os << _("On"); break; case 1: os << _("On"); break;
default: os << value.toLong(0); break; default: os << value.toInt64(0); break;
} }
os << " "; os << " ";
os << value.toLong(1); os << value.toInt64(1);
return os; return os;
} // OlympusMakerNote::print0x1209 } // OlympusMakerNote::print0x1209
@ -1660,7 +1660,7 @@ value, const ExifData* metadata)
} }
} }
auto v = static_cast<uint16_t>(value.toLong(0)); auto v = static_cast<uint16_t>(value.toInt64(0));
if (!E3_E30model) { if (!E3_E30model) {
for (auto&& point : afPoints) { for (auto&& point : afPoints) {

@ -544,8 +544,8 @@ namespace Exiv2 {
if (value.count() < 2 || value.typeId() != unsignedByte) { if (value.count() < 2 || value.typeId() != unsignedByte) {
return os << value; return os << value;
} }
long l0 = value.toLong(0); const auto l0 = value.toInt64(0);
long l1 = value.toLong(1); const auto l1 = value.toInt64(1);
if (l0 == 0 && l1 == 1) os << _("Spot mode on or 9 area"); if (l0 == 0 && l1 == 1) os << _("Spot mode on or 9 area");
else if (l0 == 0 && l1 == 16) os << _("Spot mode off or 3-area (high speed)"); else if (l0 == 0 && l1 == 16) os << _("Spot mode off or 3-area (high speed)");
else if (l0 == 0 && l1 == 23) os << _("23-area"); else if (l0 == 0 && l1 == 23) os << _("23-area");
@ -575,7 +575,7 @@ namespace Exiv2 {
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) os << std::fixed << std::setprecision(1)
<< value.toLong() / 3 << _(" EV"); << value.toInt64() / 3 << _(" EV");
os.copyfmt(oss); os.copyfmt(oss);
os.flags(f); os.flags(f);
@ -590,7 +590,7 @@ namespace Exiv2 {
{ {
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
long time=value.toLong(); const auto time=value.toInt64();
os << std::setw(2) << std::setfill('0') << time / 360000 << ":" os << std::setw(2) << std::setfill('0') << time / 360000 << ":"
<< std::setw(2) << std::setfill('0') << (time % 360000) / 6000 << ":" << std::setw(2) << std::setfill('0') << (time % 360000) / 6000 << ":"
<< std::setw(2) << std::setfill('0') << (time % 6000) / 100 << "." << std::setw(2) << std::setfill('0') << (time % 6000) / 100 << "."
@ -622,7 +622,7 @@ namespace Exiv2 {
const Value& value, const Value& value,
const ExifData*) const ExifData*)
{ {
if(value.toLong()==65535) if(value.toInt64()==65535)
{ {
os << N_("not set"); os << N_("not set");
} }
@ -638,7 +638,7 @@ namespace Exiv2 {
const Value& value, const Value& value,
const ExifData*) const ExifData*)
{ {
switch(value.toLong()) switch(value.toInt64())
{ {
case 65534: case 65534:
os << N_("Intelligent ISO"); os << N_("Intelligent ISO");
@ -661,11 +661,11 @@ namespace Exiv2 {
{ {
for(long i=0; i< value.size(); i++) for(long i=0; i< value.size(); i++)
{ {
if(value.toLong(i)==0) if(value.toInt64(i)==0)
{ {
break; break;
}; };
os << static_cast<char>(value.toLong(i)); os << static_cast<char>(value.toInt64(i));
}; };
return os; return os;
} }
@ -677,7 +677,7 @@ namespace Exiv2 {
// Manometer Pressure // Manometer Pressure
std::ostream& PanasonicMakerNote::printPressure(std::ostream& os, const Value& value, const ExifData*) std::ostream& PanasonicMakerNote::printPressure(std::ostream& os, const Value& value, const ExifData*)
{ {
switch(value.toLong()) switch(value.toInt64())
{ {
case 65535: case 65535:
os << N_("infinite"); os << N_("infinite");
@ -692,14 +692,14 @@ namespace Exiv2 {
std::ostream& PanasonicMakerNote::printAccelerometer(std::ostream& os, const Value& value, const ExifData*) std::ostream& PanasonicMakerNote::printAccelerometer(std::ostream& os, const Value& value, const ExifData*)
{ {
// value is stored as unsigned int, but should be read as int16_t. // value is stored as unsigned int, but should be read as int16_t.
const int16_t i = static_cast<int16_t>(value.toLong()); const int16_t i = static_cast<int16_t>(value.toInt64());
return os << i; return os << i;
} // PanasonicMakerNote::printAccelerometer } // PanasonicMakerNote::printAccelerometer
std::ostream& PanasonicMakerNote::printRollAngle(std::ostream& os, const Value& value, const ExifData*) std::ostream& PanasonicMakerNote::printRollAngle(std::ostream& os, const Value& value, const ExifData*)
{ {
// value is stored as unsigned int, but should be read as int16_t. // value is stored as unsigned int, but should be read as int16_t.
const int16_t i = static_cast<int16_t>(value.toLong()); const int16_t i = static_cast<int16_t>(value.toInt64());
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) << i / 10.0; os << std::fixed << std::setprecision(1) << i / 10.0;
@ -711,7 +711,7 @@ namespace Exiv2 {
std::ostream& PanasonicMakerNote::printPitchAngle(std::ostream& os, const Value& value, const ExifData*) std::ostream& PanasonicMakerNote::printPitchAngle(std::ostream& os, const Value& value, const ExifData*)
{ {
// value is stored as unsigned int, but should be read as int16_t. // value is stored as unsigned int, but should be read as int16_t.
const int16_t i = static_cast<int16_t>(value.toLong()); const int16_t i = static_cast<int16_t>(value.toInt64());
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) << -i / 10.0; os << std::fixed << std::setprecision(1) << -i / 10.0;

@ -1036,29 +1036,29 @@ namespace Exiv2 {
std::ostream& PentaxMakerNote::printDate(std::ostream& os, const Value& value, const ExifData*) std::ostream& PentaxMakerNote::printDate(std::ostream& os, const Value& value, const ExifData*)
{ {
/* I choose same format as is used inside EXIF itself */ /* I choose same format as is used inside EXIF itself */
os << ((static_cast<uint16_t>(value.toLong(0)) << 8) + value.toLong(1)); os << ((static_cast<uint16_t>(value.toInt64(0)) << 8) + value.toInt64(1));
os << ":"; os << ":";
os << std::setw(2) << std::setfill('0') << value.toLong(2); os << std::setw(2) << std::setfill('0') << value.toInt64(2);
os << ":"; os << ":";
os << std::setw(2) << std::setfill('0') << value.toLong(3); os << std::setw(2) << std::setfill('0') << value.toInt64(3);
return os; return os;
} }
std::ostream& PentaxMakerNote::printTime(std::ostream& os, const Value& value, const ExifData*) std::ostream& PentaxMakerNote::printTime(std::ostream& os, const Value& value, const ExifData*)
{ {
std::ios::fmtflags f( os.flags() ); std::ios::fmtflags f( os.flags() );
os << std::setw(2) << std::setfill('0') << value.toLong(0); os << std::setw(2) << std::setfill('0') << value.toInt64(0);
os << ":"; os << ":";
os << std::setw(2) << std::setfill('0') << value.toLong(1); os << std::setw(2) << std::setfill('0') << value.toInt64(1);
os << ":"; os << ":";
os << std::setw(2) << std::setfill('0') << value.toLong(2); os << std::setw(2) << std::setfill('0') << value.toInt64(2);
os.flags(f); os.flags(f);
return os; return os;
} }
std::ostream& PentaxMakerNote::printExposure(std::ostream& os, const Value& value, const ExifData*) std::ostream& PentaxMakerNote::printExposure(std::ostream& os, const Value& value, const ExifData*)
{ {
os << static_cast<float>(value.toLong()) / 100 << " ms"; os << static_cast<float>(value.toInt64()) / 100 << " ms";
return os; return os;
} }
@ -1066,7 +1066,7 @@ namespace Exiv2 {
{ {
std::ios::fmtflags f( os.flags() ); std::ios::fmtflags f( os.flags() );
os << "F" << std::setprecision(2) os << "F" << std::setprecision(2)
<< static_cast<float>(value.toLong()) / 10; << static_cast<float>(value.toInt64()) / 10;
os.flags(f); os.flags(f);
return os; return os;
} }
@ -1075,7 +1075,7 @@ namespace Exiv2 {
{ {
std::ios::fmtflags f( os.flags() ); std::ios::fmtflags f( os.flags() );
os << std::fixed << std::setprecision(1) os << std::fixed << std::setprecision(1)
<< static_cast<float>(value.toLong()) / 100 << static_cast<float>(value.toInt64()) / 100
<< " mm"; << " mm";
os.flags(f); os.flags(f);
return os; return os;
@ -1085,7 +1085,7 @@ namespace Exiv2 {
{ {
std::ios::fmtflags f( os.flags() ); std::ios::fmtflags f( os.flags() );
os << std::setprecision(2) os << std::setprecision(2)
<< (static_cast<float>(value.toLong()) - 50) / 10 << (static_cast<float>(value.toInt64()) - 50) / 10
<< " EV"; << " EV";
os.flags(f); os.flags(f);
return os; return os;
@ -1093,7 +1093,7 @@ namespace Exiv2 {
std::ostream& PentaxMakerNote::printTemperature(std::ostream& os, const Value& value, const ExifData*) std::ostream& PentaxMakerNote::printTemperature(std::ostream& os, const Value& value, const ExifData*)
{ {
os << value.toLong() << " C"; os << value.toInt64() << " C";
return os; return os;
} }
@ -1101,7 +1101,7 @@ namespace Exiv2 {
{ {
std::ios::fmtflags f( os.flags() ); std::ios::fmtflags f( os.flags() );
os << std::setprecision(2) os << std::setprecision(2)
<< static_cast<float>(value.toLong()) / 256 << static_cast<float>(value.toInt64()) / 256
<< " EV"; << " EV";
os.flags(f); os.flags(f);
return os; return os;
@ -1109,7 +1109,7 @@ namespace Exiv2 {
std::ostream& PentaxMakerNote::printBracketing(std::ostream& os, const Value& value, const ExifData*) std::ostream& PentaxMakerNote::printBracketing(std::ostream& os, const Value& value, const ExifData*)
{ {
long l0 = value.toLong(0); const auto l0 = value.toInt64(0);
if (l0 < 10) { if (l0 < 10) {
os << std::setprecision(2) os << std::setprecision(2)
@ -1120,13 +1120,13 @@ namespace Exiv2 {
} }
if (value.count() == 2) { if (value.count() == 2) {
long l1 = value.toLong(1); const auto l1 = value.toInt64(1);
os << " ("; os << " (";
if (l1 == 0) { if (l1 == 0) {
os << _("No extended bracketing"); os << _("No extended bracketing");
} else { } else {
long type = l1 >> 8; auto type = l1 >> 8;
long range = l1 & 0xff; auto range = l1 & 0xff;
switch (type) { switch (type) {
case 1: case 1:
os << _("WB-BA"); os << _("WB-BA");
@ -1181,8 +1181,8 @@ namespace Exiv2 {
(timeIt->toLong(0) << 24) + (timeIt->toLong(1) << 16) + (timeIt->toLong(0) << 24) + (timeIt->toLong(1) << 16) +
(timeIt->toLong(2) << 8); (timeIt->toLong(2) << 8);
const uint32_t countEnc = const uint32_t countEnc =
(value.toLong(0) << 24) + (value.toLong(1) << 16) + (value.toUint32(0) << 24) + (value.toUint32(1) << 16) +
(value.toLong(2) << 8) + (value.toLong(3) << 0); (value.toUint32(2) << 8) + (value.toUint32(3) << 0);
// The shutter count is encoded using date and time values stored // The shutter count is encoded using date and time values stored
// in Pentax-specific tags. The prototype for the encoding/decoding // in Pentax-specific tags. The prototype for the encoding/decoding
// function is taken from Phil Harvey's ExifTool: Pentax.pm file, // function is taken from Phil Harvey's ExifTool: Pentax.pm file,
@ -1412,7 +1412,7 @@ namespace Exiv2 {
return os << Internal::readExiv2Config(section,value.toString(),undefined); return os << Internal::readExiv2Config(section,value.toString(),undefined);
} }
unsigned long index = value.toLong(0)*256+value.toLong(1); const auto index = value.toUint32(0)*256+value.toUint32(1);
// std::cout << std::endl << "printLensType value =" << value.toLong() << " index = " << index << std::endl; // std::cout << std::endl << "printLensType value =" << value.toLong() << " index = " << index << std::endl;
const LensIdFct* lif = find(lensIdFct, index); const LensIdFct* lif = find(lensIdFct, index);

@ -85,12 +85,12 @@ namespace Exiv2 {
if ((value.count() != count && (value.count() < (count + ignoredcount) || value.count() > (count + ignoredcountmax))) || count > 4) { if ((value.count() != count && (value.count() < (count + ignoredcount) || value.count() > (count + ignoredcountmax))) || count > 4) {
return printValue(os, value, metadata); return printValue(os, value, metadata);
} }
unsigned long l = 0; uint32_t l = 0;
for (int c = 0; c < count; ++c) { for (int c = 0; c < count; ++c) {
if (value.toLong(c) < 0 || value.toLong(c) > 255) { if (value.toInt64(c) < 0 || value.toInt64(c) > 255) {
return printValue(os, value, metadata); return printValue(os, value, metadata);
} }
l += (value.toLong(c) << ((count - c - 1) * 8)); l += (value.toUint32(c) << ((count - c - 1) * 8));
} }
const TagDetails* td = find(array, l); const TagDetails* td = find(array, l);
if (td) { if (td) {

@ -798,8 +798,8 @@ namespace {
if (sizes.count() == dataValue.count()) { if (sizes.count() == dataValue.count()) {
if (sizes.count() == 1) { if (sizes.count() == 1) {
// this saves one copying of the buffer // this saves one copying of the buffer
uint32_t offset = dataValue.toLong(0); uint32_t offset = dataValue.toUint32(0);
uint32_t size = sizes.toLong(0); uint32_t size = sizes.toUint32(0);
if (Safe::add(offset, size) <= static_cast<uint32_t>(io.size())) if (Safe::add(offset, size) <= static_cast<uint32_t>(io.size()))
dataValue.setDataArea(base + offset, size); dataValue.setDataArea(base + offset, size);
} }
@ -809,8 +809,8 @@ namespace {
DataBuf buf(size_); DataBuf buf(size_);
uint32_t idxBuf = 0; uint32_t idxBuf = 0;
for (long i = 0; i < sizes.count(); i++) { for (long i = 0; i < sizes.count(); i++) {
uint32_t offset = dataValue.toLong(i); uint32_t offset = dataValue.toUint32(i);
uint32_t size = sizes.toLong(i); uint32_t size = sizes.toUint32(i);
// the size_ parameter is originally computed by summing all values inside sizes // the size_ parameter is originally computed by summing all values inside sizes
// see the constructor of LoaderTiff // see the constructor of LoaderTiff

@ -3890,9 +3890,9 @@ namespace Exiv2 {
{"Xmp.exif.WhiteBalance", print0xa403 }, {"Xmp.exif.WhiteBalance", print0xa403 },
{"Xmp.tiff.Orientation", print0x0112 }, {"Xmp.tiff.Orientation", print0x0112 },
{"Xmp.tiff.ResolutionUnit", printExifUnit }, {"Xmp.tiff.ResolutionUnit", printExifUnit },
{"Xmp.tiff.XResolution", printLong }, {"Xmp.tiff.XResolution", printInt64 },
{"Xmp.tiff.YCbCrPositioning", print0x0213 }, {"Xmp.tiff.YCbCrPositioning", print0x0213 },
{"Xmp.tiff.YResolution", printLong }, {"Xmp.tiff.YResolution", printInt64 },
{"Xmp.iptc.Scene", EXV_PRINT_VOCABULARY_MULTI(iptcScene) }, {"Xmp.iptc.Scene", EXV_PRINT_VOCABULARY_MULTI(iptcScene) },
{"Xmp.iptc.SubjectCode", EXV_PRINT_VOCABULARY_MULTI(iptcSubjectCode) }, {"Xmp.iptc.SubjectCode", EXV_PRINT_VOCABULARY_MULTI(iptcSubjectCode) },
{"Xmp.iptcExt.DigitalSourcefileType", EXV_PRINT_VOCABULARY(iptcExtDigitalSourcefileType) }, {"Xmp.iptcExt.DigitalSourcefileType", EXV_PRINT_VOCABULARY(iptcExtDigitalSourcefileType) },

@ -87,7 +87,7 @@ namespace Exiv2 {
if (value.count() != 1 || value.typeId() != unsignedLong) { if (value.count() != 1 || value.typeId() != unsignedLong) {
return os << value; return os << value;
} }
long length = value.toLong(); const auto length = value.toInt64();
if (length == 0) { if (length == 0) {
os << _("Unknown"); os << _("Unknown");
} }
@ -165,11 +165,11 @@ namespace Exiv2 {
return os << value; return os << value;
} }
// Special case where no color modification is done // Special case where no color modification is done
if (value.toLong() == 65535) { if (value.toInt64() == 65535) {
return os << _("Neutral"); return os << _("Neutral");
} }
// Output seems to represent Hue in degrees // Output seems to represent Hue in degrees
return os << value.toLong(); return os << value.toInt64();
} }
//! Print the tag value minus 4 //! Print the tag value minus 4
@ -178,7 +178,7 @@ namespace Exiv2 {
if (value.count() != 1 || value.typeId() != unsignedShort) { if (value.count() != 1 || value.typeId() != unsignedShort) {
return os << value; return os << value;
} }
return os << value.toLong(0) - 4; return os << value.toInt64(0) - 4;
} }
// Samsung PictureWizard Tag Info // Samsung PictureWizard Tag Info

@ -868,7 +868,7 @@ namespace Exiv2 {
if (value.count() != 1) if (value.count() != 1)
os << value; os << value;
else { else {
long val = (value.toLong() & 0x7F); const auto val = (value.toInt64() & 0x7F);
switch (val) { switch (val) {
case 0: case 0:
os << N_("Manual"); os << N_("Manual");
@ -910,7 +910,7 @@ namespace Exiv2 {
return os; return os;
} }
} }
long val = value.toLong(); const auto val = value.toInt64();
switch (val) { switch (val) {
case 255: case 255:
os << N_("Infinity"); os << N_("Infinity");
@ -1028,7 +1028,7 @@ namespace Exiv2 {
return os << N_("n/a"); return os << N_("n/a");
} }
os << std::round((value.toLong()/10.24)) << "%"; os << std::round((value.toInt64()/10.24)) << "%";
return os; return os;
} }
@ -1156,7 +1156,7 @@ namespace Exiv2 {
std::string model = pos->toString(); std::string model = pos->toString();
for (auto& m : models) { for (auto& m : models) {
if (m == model) if (m == model)
return os << value.toLong(); return os << value.toInt64();
} }
return os << N_("n/a"); return os << N_("n/a");
@ -1164,7 +1164,7 @@ namespace Exiv2 {
std::ostream& SonyMakerNote::printSonyMisc3cSequenceNumber(std::ostream& os, const Value& value, const ExifData*) std::ostream& SonyMakerNote::printSonyMisc3cSequenceNumber(std::ostream& os, const Value& value, const ExifData*)
{ {
return (value.count() != 1) ? os << "(" << value << ")" : os << (value.toLong()+1); return (value.count() != 1) ? os << "(" << value << ")" : os << (value.toInt64()+1);
} }
std::ostream& SonyMakerNote::printSonyMisc3cQuality2(std::ostream& os, const Value& value, const ExifData* metadata) std::ostream& SonyMakerNote::printSonyMisc3cQuality2(std::ostream& os, const Value& value, const ExifData* metadata)
@ -1176,7 +1176,7 @@ namespace Exiv2 {
if (pos == metadata->end()) if (pos == metadata->end())
return os << "(" << value << ")"; return os << "(" << value << ")";
long val = value.toLong(); const auto val = value.toInt64();
std::string model = pos->toString(); std::string model = pos->toString();
// Value is interpreted differently if model is in list or not // Value is interpreted differently if model is in list or not
@ -1231,7 +1231,7 @@ namespace Exiv2 {
return os << N_("n/a"); return os << N_("n/a");
} }
long val = value.toLong(); const auto val = value.toInt64();
return val > 0 ? os << (8*val) : os << N_("n/a"); return val > 0 ? os << (8*val) : os << N_("n/a");
} }
@ -1252,7 +1252,7 @@ namespace Exiv2 {
return os << N_("n/a"); return os << N_("n/a");
} }
long val = value.toLong(); const auto val = value.toInt64();
if (val > 99) if (val > 99)
return os << "(" << val << ")"; return os << "(" << val << ")";

@ -591,11 +591,11 @@ namespace Exiv2 {
{0x011a, "XResolution", N_("X-Resolution"), {0x011a, "XResolution", N_("X-Resolution"),
N_("The number of pixels per <ResolutionUnit> in the <ImageWidth> " N_("The number of pixels per <ResolutionUnit> in the <ImageWidth> "
"direction. When the image resolution is unknown, 72 [dpi] is designated."), "direction. When the image resolution is unknown, 72 [dpi] is designated."),
ifd0Id, imgStruct, unsignedRational, 1, printLong}, ifd0Id, imgStruct, unsignedRational, 1, printInt64},
{0x011b, "YResolution", N_("Y-Resolution"), {0x011b, "YResolution", N_("Y-Resolution"),
N_("The number of pixels per <ResolutionUnit> in the <ImageLength> " N_("The number of pixels per <ResolutionUnit> in the <ImageLength> "
"direction. The same value as <XResolution> is designated."), "direction. The same value as <XResolution> is designated."),
ifd0Id, imgStruct, unsignedRational, 1, printLong}, ifd0Id, imgStruct, unsignedRational, 1, printInt64},
{0x011c, "PlanarConfiguration", N_("Planar Configuration"), {0x011c, "PlanarConfiguration", N_("Planar Configuration"),
N_("Indicates whether pixel components are recorded in a chunky " N_("Indicates whether pixel components are recorded in a chunky "
"or planar format. In JPEG compressed files a JPEG marker " "or planar format. In JPEG compressed files a JPEG marker "
@ -2591,7 +2591,7 @@ namespace Exiv2 {
uint16_t bit = 0; uint16_t bit = 0;
uint16_t comma = 0; uint16_t comma = 0;
for (long i = 0; i < value.count(); i++ ) { // for each element in value array for (long i = 0; i < value.count(); i++ ) { // for each element in value array
auto bits = static_cast<uint16_t>(value.toLong(i)); auto bits = static_cast<uint16_t>(value.toInt64(i));
for (uint16_t b = 0; b < 16; ++b) { // for every bit for (uint16_t b = 0; b < 16; ++b) { // for every bit
if (bits & (1 << b)) { if (bits & (1 << b)) {
if ( comma++ ) { if ( comma++ ) {
@ -2651,10 +2651,10 @@ namespace Exiv2 {
return tag; return tag;
} // tagNumber } // tagNumber
std::ostream& printLong(std::ostream& os, const Value& value, const ExifData*) std::ostream& printInt64(std::ostream& os, const Value& value, const ExifData*)
{ {
Rational r = value.toRational(); Rational r = value.toRational();
if (r.second > 0) return os << static_cast<long>(r.first) / r.second; if (r.second > 0) return os << static_cast<int64_t>(r.first) / r.second;
return os << "(" << value << ")"; return os << "(" << value << ")";
} // printLong } // printLong
@ -2745,10 +2745,10 @@ namespace Exiv2 {
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
os << value.toLong(i); os << value.toInt64(i);
os << "."; os << ".";
} }
os << value.toLong(3); os << value.toInt64(3);
return os; return os;
} }
@ -2933,13 +2933,13 @@ namespace Exiv2 {
std::ostream& print0x8827(std::ostream& os, const Value& value, const ExifData*) std::ostream& print0x8827(std::ostream& os, const Value& value, const ExifData*)
{ {
return os << value.toLong(); return os << value.toInt64();
} }
std::ostream& print0x9101(std::ostream& os, const Value& value, const ExifData*) std::ostream& print0x9101(std::ostream& os, const Value& value, const ExifData*)
{ {
for (long i = 0; i < value.count(); ++i) { for (long i = 0; i < value.count(); ++i) {
long l = value.toLong(i); const auto l = value.toInt64(i);
switch (l) { switch (l) {
case 0: break; case 0: break;
case 1: os << "Y"; break; case 1: os << "Y"; break;
@ -3169,7 +3169,7 @@ namespace Exiv2 {
std::ostream& print0xa405(std::ostream& os, const Value& value, const ExifData*) std::ostream& print0xa405(std::ostream& os, const Value& value, const ExifData*)
{ {
long length = value.toLong(); const auto length = value.toInt64();
if (length == 0) { if (length == 0) {
os << _("Unknown"); os << _("Unknown");
} }
@ -3258,7 +3258,7 @@ namespace Exiv2 {
char s[5]; char s[5];
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
s[i] = static_cast<char>(value.toLong(i)); s[i] = static_cast<char>(value.toInt64(i));
} }
s[4] = '\0'; s[4] = '\0';

@ -232,7 +232,7 @@ namespace Exiv2 {
const char* label_; //!< Translation of the tag value const char* label_; //!< Translation of the tag value
//! Comparison operator for use with the find template //! Comparison operator for use with the find template
bool operator==(long key) const { return val_ == key; } bool operator==(int64_t key) const { return val_ == key; }
}; // struct TagDetails }; // struct TagDetails
/*! /*!
@ -267,7 +267,7 @@ namespace Exiv2 {
by looking up a reference table. by looking up a reference table.
*/ */
template <int N, const TagDetails (&array)[N]> template <int N, const TagDetails (&array)[N]>
std::ostream& printTag(std::ostream& os, const long& value, const ExifData*) std::ostream& printTag(std::ostream& os, const int64_t value, const ExifData*)
{ {
const TagDetails* td = find(array, value); const TagDetails* td = find(array, value);
if (td) { if (td) {
@ -286,7 +286,7 @@ namespace Exiv2 {
template <int N, const TagDetails (&array)[N]> template <int N, const TagDetails (&array)[N]>
std::ostream& printTag(std::ostream& os, const Value& value, const ExifData* data) std::ostream& printTag(std::ostream& os, const Value& value, const ExifData* data)
{ {
return printTag<N, array>(os, value.toLong(), data); return printTag<N, array>(os, value.toInt64(), data);
} }
//! Shortcut for the printTag template which requires typing the array name only once. //! Shortcut for the printTag template which requires typing the array name only once.
@ -299,7 +299,7 @@ namespace Exiv2 {
template <int N, const TagDetailsBitmask (&array)[N]> template <int N, const TagDetailsBitmask (&array)[N]>
std::ostream& printTagBitmask(std::ostream& os, const Value& value, const ExifData*) std::ostream& printTagBitmask(std::ostream& os, const Value& value, const ExifData*)
{ {
const auto val = static_cast<uint32_t>(value.toLong()); const auto val = value.toUint32();
if (val == 0 && N > 0) { if (val == 0 && N > 0) {
const TagDetailsBitmask* td = *(&array); const TagDetailsBitmask* td = *(&array);
if (td->mask_ == 0) return os << exvGettext(td->label_); if (td->mask_ == 0) return os << exvGettext(td->label_);
@ -423,8 +423,8 @@ namespace Exiv2 {
//@{ //@{
//! Default print function, using the Value output operator //! Default print function, using the Value output operator
std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*); std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*);
//! Print the value converted to a long //! Print the value converted to a int64_t
std::ostream& printLong(std::ostream& os, const Value& value, const ExifData*); std::ostream& printInt64(std::ostream& os, const Value& value, const ExifData*);
//! Print a Rational or URational value in floating point format //! Print a Rational or URational value in floating point format
std::ostream& printFloat(std::ostream& os, const Value& value, const ExifData*); std::ostream& printFloat(std::ostream& os, const Value& value, const ExifData*);
//! Print a longitude or latitude value //! Print a longitude or latitude value

@ -81,9 +81,12 @@ namespace Exiv2 {
return io_.putb(data); return io_.putb(data);
} }
void IoWrapper::setTarget(int id, uint32_t target) void IoWrapper::setTarget(int id, int64_t target)
{ {
if (pow_) pow_->setTarget(OffsetWriter::OffsetId(id), target); if (target < 0 || target > std::numeric_limits<uint32_t>::max()) {
throw Error(kerOffsetOutOfRange);
}
if (pow_) pow_->setTarget(OffsetWriter::OffsetId(id), static_cast<uint32_t>(target));
} }
TiffComponent::TiffComponent(uint16_t tag, IfdId group) : tag_(tag), group_(group), pStart_(nullptr) TiffComponent::TiffComponent(uint16_t tag, IfdId group) : tag_(tag), group_(group), pStart_(nullptr)
@ -319,7 +322,7 @@ namespace Exiv2 {
size_ = buf->size(); size_ = buf->size();
} }
void TiffEntryBase::setData(byte* pData, int32_t size, void TiffEntryBase::setData(byte* pData, uint32_t size,
const std::shared_ptr<DataBuf>& storage) const std::shared_ptr<DataBuf>& storage)
{ {
pData_ = pData; pData_ = pData;
@ -390,13 +393,13 @@ namespace Exiv2 {
} }
uint32_t size = 0; uint32_t size = 0;
for (long i = 0; i < pSize->count(); ++i) { for (long i = 0; i < pSize->count(); ++i) {
size += static_cast<uint32_t>(pSize->toLong(i)); size += pSize->toUint32(i);
} }
auto offset = static_cast<uint32_t>(pValue()->toLong(0)); auto offset = pValue()->toUint32(0);
// Todo: Remove limitation of JPEG writer: strips must be contiguous // Todo: Remove limitation of JPEG writer: strips must be contiguous
// Until then we check: last offset + last size - first offset == size? // Until then we check: last offset + last size - first offset == size?
if ( static_cast<uint32_t>(pValue()->toLong(pValue()->count()-1)) if ( pValue()->toUint32(pValue()->count()-1)
+ static_cast<uint32_t>(pSize->toLong(pSize->count()-1)) + pSize->toUint32(pSize->count()-1)
- offset != size) { - offset != size) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Directory " << groupName(group()) EXV_WARNING << "Directory " << groupName(group())
@ -447,9 +450,9 @@ namespace Exiv2 {
return; return;
} }
for (long i = 0; i < pValue()->count(); ++i) { for (long i = 0; i < pValue()->count(); ++i) {
const auto offset = static_cast<uint32_t>(pValue()->toLong(i)); const auto offset = pValue()->toUint32(i);
const byte* pStrip = pData + baseOffset + offset; const byte* pStrip = pData + baseOffset + offset;
const auto size = static_cast<uint32_t>(pSize->toLong(i)); const auto size = pSize->toUint32(i);
if ( offset > sizeData if ( offset > sizeData
|| size > sizeData || size > sizeData
@ -1038,7 +1041,7 @@ namespace Exiv2 {
uint32_t TiffComponent::write(IoWrapper& ioWrapper, uint32_t TiffComponent::write(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t valueIdx, uint32_t valueIdx,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) uint32_t& imageIdx)
@ -1048,7 +1051,7 @@ namespace Exiv2 {
uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper, uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t valueIdx, uint32_t valueIdx,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) uint32_t& imageIdx)
@ -1104,7 +1107,7 @@ namespace Exiv2 {
valueIdx = sizeDir; // Offset to the current IFD value valueIdx = sizeDir; // Offset to the current IFD value
dataIdx = sizeDir + sizeValue; // Offset to the entry's data area dataIdx = sizeDir + sizeValue; // Offset to the entry's data area
if (isRootDir) { // Absolute offset to the image data if (isRootDir) { // Absolute offset to the image data
imageIdx = offset + dataIdx + sizeData + sizeNext; imageIdx = static_cast<uint32_t>(offset + dataIdx + sizeData + sizeNext);
imageIdx += imageIdx & 1; // Align image data to word boundary imageIdx += imageIdx & 1; // Align image data to word boundary
} }
@ -1129,7 +1132,7 @@ namespace Exiv2 {
if (hasNext_) { if (hasNext_) {
memset(buf, 0x0, 4); memset(buf, 0x0, 4);
if (pNext_ && sizeNext) { if (pNext_ && sizeNext) {
l2Data(buf, offset + dataIdx, byteOrder); l2Data(buf, static_cast<uint32_t>(offset + dataIdx), byteOrder);
} }
ioWrapper.write(buf, 4); ioWrapper.write(buf, 4);
idx += 4; idx += 4;
@ -1174,7 +1177,7 @@ namespace Exiv2 {
return idx; return idx;
} // TiffDirectory::doWrite } // TiffDirectory::doWrite
uint32_t TiffDirectory::writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t TiffDirectory::writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset,
TiffComponent* pTiffComponent, uint32_t valueIdx, uint32_t dataIdx, TiffComponent* pTiffComponent, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) uint32_t& imageIdx)
{ {
@ -1188,7 +1191,7 @@ namespace Exiv2 {
ioWrapper.write(buf, 8); ioWrapper.write(buf, 8);
if (pDirEntry->size() > 4) { if (pDirEntry->size() > 4) {
pDirEntry->setOffset(offset + static_cast<int32_t>(valueIdx)); pDirEntry->setOffset(offset + static_cast<int32_t>(valueIdx));
l2Data(buf, pDirEntry->offset(), byteOrder); l2Data(buf, static_cast<uint32_t>(pDirEntry->offset()), byteOrder);
ioWrapper.write(buf, 4); ioWrapper.write(buf, 4);
} }
else { else {
@ -1214,7 +1217,7 @@ namespace Exiv2 {
uint32_t TiffEntryBase::doWrite(IoWrapper& ioWrapper, uint32_t TiffEntryBase::doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t /*offset*/, int64_t /*offset*/,
uint32_t /*valueIdx*/, uint32_t /*valueIdx*/,
uint32_t /*dataIdx*/, uint32_t /*dataIdx*/,
uint32_t& /*imageIdx*/) uint32_t& /*imageIdx*/)
@ -1228,7 +1231,7 @@ namespace Exiv2 {
} // TiffEntryBase::doWrite } // TiffEntryBase::doWrite
uint32_t TiffEntryBase::writeOffset(byte* buf, uint32_t TiffEntryBase::writeOffset(byte* buf,
int32_t offset, int64_t offset,
TiffType tiffType, TiffType tiffType,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -1241,7 +1244,7 @@ namespace Exiv2 {
break; break;
case ttUnsignedLong: case ttUnsignedLong:
case ttSignedLong: case ttSignedLong:
rc = l2Data(buf, offset, byteOrder); rc = l2Data(buf, static_cast<uint32_t>(offset), byteOrder);
break; break;
default: default:
throw Error(kerUnsupportedDataAreaOffsetType); throw Error(kerUnsupportedDataAreaOffsetType);
@ -1252,7 +1255,7 @@ namespace Exiv2 {
uint32_t TiffDataEntry::doWrite(IoWrapper& ioWrapper, uint32_t TiffDataEntry::doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t /*valueIdx*/, uint32_t /*valueIdx*/,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& /*imageIdx*/) uint32_t& /*imageIdx*/)
@ -1261,10 +1264,10 @@ namespace Exiv2 {
DataBuf buf(pValue()->size()); DataBuf buf(pValue()->size());
uint32_t idx = 0; uint32_t idx = 0;
const long prevOffset = pValue()->toLong(0); const auto prevOffset = pValue()->toInt64(0);
for (uint32_t i = 0; i < count(); ++i) { for (uint32_t i = 0; i < count(); ++i) {
const long newDataIdx = pValue()->toLong(i) - prevOffset const int64_t newDataIdx = pValue()->toInt64(i) - prevOffset
+ static_cast<long>(dataIdx); + static_cast<int64_t>(dataIdx);
idx += writeOffset(buf.data(idx), idx += writeOffset(buf.data(idx),
offset + newDataIdx, offset + newDataIdx,
tiffType(), tiffType(),
@ -1276,14 +1279,14 @@ namespace Exiv2 {
uint32_t TiffImageEntry::doWrite(IoWrapper& ioWrapper, uint32_t TiffImageEntry::doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t /*valueIdx*/, uint32_t /*valueIdx*/,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) uint32_t& imageIdx)
{ {
uint32_t o2 = imageIdx; uint32_t o2 = imageIdx;
// For makernotes, write TIFF image data to the data area // For makernotes, write TIFF image data to the data area
if (group() > mnId) o2 = offset + dataIdx; if (group() > mnId) o2 = static_cast<uint32_t>(offset + dataIdx);
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "TiffImageEntry, Directory " << groupName(group()) std::cerr << "TiffImageEntry, Directory " << groupName(group())
<< ", entry 0x" << std::setw(4) << ", entry 0x" << std::setw(4)
@ -1308,7 +1311,7 @@ namespace Exiv2 {
uint32_t TiffSubIfd::doWrite(IoWrapper& ioWrapper, uint32_t TiffSubIfd::doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t /*valueIdx*/, uint32_t /*valueIdx*/,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& /*imageIdx*/) uint32_t& /*imageIdx*/)
@ -1327,7 +1330,7 @@ namespace Exiv2 {
uint32_t TiffMnEntry::doWrite(IoWrapper& ioWrapper, uint32_t TiffMnEntry::doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t valueIdx, uint32_t valueIdx,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) uint32_t& imageIdx)
@ -1340,12 +1343,12 @@ namespace Exiv2 {
uint32_t TiffIfdMakernote::doWrite(IoWrapper& ioWrapper, uint32_t TiffIfdMakernote::doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t /*valueIdx*/, uint32_t /*valueIdx*/,
uint32_t /*dataIdx*/, uint32_t /*dataIdx*/,
uint32_t& imageIdx) uint32_t& imageIdx)
{ {
mnOffset_ = offset; mnOffset_ = static_cast<uint32_t>(offset);
setImageByteOrder(byteOrder); setImageByteOrder(byteOrder);
uint32_t len = writeHeader(ioWrapper, this->byteOrder()); uint32_t len = writeHeader(ioWrapper, this->byteOrder());
len += ifd_.write(ioWrapper, this->byteOrder(), len += ifd_.write(ioWrapper, this->byteOrder(),
@ -1357,7 +1360,7 @@ namespace Exiv2 {
uint32_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper, uint32_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t valueIdx, uint32_t valueIdx,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) uint32_t& imageIdx)
@ -1420,7 +1423,7 @@ namespace Exiv2 {
uint32_t TiffBinaryElement::doWrite(IoWrapper& ioWrapper, uint32_t TiffBinaryElement::doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t /*offset*/, int64_t /*offset*/,
uint32_t /*valueIdx*/, uint32_t /*valueIdx*/,
uint32_t /*dataIdx*/, uint32_t /*dataIdx*/,
uint32_t& /*imageIdx*/) uint32_t& /*imageIdx*/)
@ -1435,7 +1438,7 @@ namespace Exiv2 {
uint32_t TiffComponent::writeData(IoWrapper& ioWrapper, uint32_t TiffComponent::writeData(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) const uint32_t& imageIdx) const
{ {
@ -1444,7 +1447,7 @@ namespace Exiv2 {
uint32_t TiffDirectory::doWriteData(IoWrapper& ioWrapper, uint32_t TiffDirectory::doWriteData(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) const uint32_t& imageIdx) const
{ {
@ -1457,7 +1460,7 @@ namespace Exiv2 {
uint32_t TiffEntryBase::doWriteData(IoWrapper&/*ioWrapper*/, uint32_t TiffEntryBase::doWriteData(IoWrapper&/*ioWrapper*/,
ByteOrder /*byteOrder*/, ByteOrder /*byteOrder*/,
int32_t /*offset*/, int64_t /*offset*/,
uint32_t /*dataIdx*/, uint32_t /*dataIdx*/,
uint32_t& /*imageIdx*/) const uint32_t& /*imageIdx*/) const
{ {
@ -1466,7 +1469,7 @@ namespace Exiv2 {
uint32_t TiffImageEntry::doWriteData(IoWrapper& ioWrapper, uint32_t TiffImageEntry::doWriteData(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t /*offset*/, int64_t /*offset*/,
uint32_t /*dataIdx*/, uint32_t /*dataIdx*/,
uint32_t& /*imageIdx*/) const uint32_t& /*imageIdx*/) const
{ {
@ -1480,7 +1483,7 @@ namespace Exiv2 {
uint32_t TiffDataEntry::doWriteData(IoWrapper& ioWrapper, uint32_t TiffDataEntry::doWriteData(IoWrapper& ioWrapper,
ByteOrder /*byteOrder*/, ByteOrder /*byteOrder*/,
int32_t /*offset*/, int64_t /*offset*/,
uint32_t /*dataIdx*/, uint32_t /*dataIdx*/,
uint32_t& /*imageIdx*/) const uint32_t& /*imageIdx*/) const
{ {
@ -1497,7 +1500,7 @@ namespace Exiv2 {
uint32_t TiffSubIfd::doWriteData(IoWrapper& ioWrapper, uint32_t TiffSubIfd::doWriteData(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) const uint32_t& imageIdx) const
{ {
@ -1514,7 +1517,7 @@ namespace Exiv2 {
uint32_t TiffIfdMakernote::doWriteData(IoWrapper&/*ioWrapper*/, uint32_t TiffIfdMakernote::doWriteData(IoWrapper&/*ioWrapper*/,
ByteOrder /*byteOrder*/, ByteOrder /*byteOrder*/,
int32_t /*offset*/, int64_t /*offset*/,
uint32_t /*dataIdx*/, uint32_t /*dataIdx*/,
uint32_t& /*imageIdx*/) const uint32_t& /*imageIdx*/) const
{ {

@ -149,7 +149,7 @@ namespace Exiv2 {
*/ */
int putb(byte data); int putb(byte data);
//! Wrapper for OffsetWriter::setTarget(), using an int instead of the enum to reduce include deps //! Wrapper for OffsetWriter::setTarget(), using an int instead of the enum to reduce include deps
void setTarget(int id, uint32_t target); void setTarget(int id, int64_t target);
//@} //@}
private: private:
@ -244,7 +244,7 @@ namespace Exiv2 {
*/ */
uint32_t write(IoWrapper& ioWrapper, uint32_t write(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t valueIdx, uint32_t valueIdx,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx); uint32_t& imageIdx);
@ -271,7 +271,7 @@ namespace Exiv2 {
*/ */
uint32_t writeData(IoWrapper& ioWrapper, uint32_t writeData(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) const; uint32_t& imageIdx) const;
/*! /*!
@ -329,7 +329,7 @@ namespace Exiv2 {
//! Implements write(). //! Implements write().
virtual uint32_t doWrite(IoWrapper& ioWrapper, virtual uint32_t doWrite(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t valueIdx, uint32_t valueIdx,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) =0; uint32_t& imageIdx) =0;
@ -342,7 +342,7 @@ namespace Exiv2 {
//! Implements writeData(). //! Implements writeData().
virtual uint32_t doWriteData(IoWrapper& ioWrapper, virtual uint32_t doWriteData(IoWrapper& ioWrapper,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t offset, int64_t offset,
uint32_t dataIdx, uint32_t dataIdx,
uint32_t& imageIdx) const =0; uint32_t& imageIdx) const =0;
//! Implements writeImage(). //! Implements writeImage().
@ -435,7 +435,7 @@ namespace Exiv2 {
*/ */
void encode(TiffEncoder& encoder, const Exifdatum* datum); void encode(TiffEncoder& encoder, const Exifdatum* datum);
//! Set the offset //! Set the offset
void setOffset(int32_t offset) { offset_ = offset; } void setOffset(int64_t offset) { offset_ = offset; }
/*! /*!
@brief Set pointer and size of the entry's data (not taking ownership of the data). @brief Set pointer and size of the entry's data (not taking ownership of the data).
@ -451,7 +451,7 @@ namespace Exiv2 {
you should pass std::shared_ptr<DataBuf>(), which is essentially you should pass std::shared_ptr<DataBuf>(), which is essentially
a nullptr. a nullptr.
*/ */
void setData(byte* pData, int32_t size, const std::shared_ptr<DataBuf>& storage); void setData(byte* pData, uint32_t size, const std::shared_ptr<DataBuf>& storage);
/*! /*!
@brief Set the entry's data buffer. A shared_ptr is used to manage the DataBuf @brief Set the entry's data buffer. A shared_ptr is used to manage the DataBuf
because TiffEntryBase has a clone method so it is possible (in theory) for because TiffEntryBase has a clone method so it is possible (in theory) for
@ -480,7 +480,7 @@ namespace Exiv2 {
@brief Return the offset to the data area relative to the base @brief Return the offset to the data area relative to the base
for the component (usually the start of the TIFF header) for the component (usually the start of the TIFF header)
*/ */
int32_t offset() const { return offset_; } int64_t offset() const { return offset_; }
/*! /*!
@brief Return the unique id of the entry in the image @brief Return the unique id of the entry in the image
*/ */
@ -514,7 +514,7 @@ namespace Exiv2 {
the \em ioWrapper, return the number of bytes written. Only the the \em ioWrapper, return the number of bytes written. Only the
\em ioWrapper and \em byteOrder arguments are used. \em ioWrapper and \em byteOrder arguments are used.
*/ */
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) override; uint32_t& imageIdx) override;
//@} //@}
@ -526,7 +526,7 @@ namespace Exiv2 {
@brief Implements writeData(). Standard TIFF entries have no data: @brief Implements writeData(). Standard TIFF entries have no data:
write nothing and return 0. write nothing and return 0.
*/ */
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t dataIdx,
uint32_t& imageIdx) const override; uint32_t& imageIdx) const override;
/*! /*!
@brief Implements writeImage(). Standard TIFF entries have no image data: @brief Implements writeImage(). Standard TIFF entries have no image data:
@ -543,7 +543,7 @@ namespace Exiv2 {
//! Helper function to write an \em offset to a preallocated binary buffer //! Helper function to write an \em offset to a preallocated binary buffer
static uint32_t writeOffset(byte* buf, static uint32_t writeOffset(byte* buf,
int32_t offset, int64_t offset,
TiffType tiffType, TiffType tiffType,
ByteOrder byteOrder); ByteOrder byteOrder);
@ -560,7 +560,7 @@ namespace Exiv2 {
// DATA // DATA
TiffType tiffType_; //!< Field TIFF type TiffType tiffType_; //!< Field TIFF type
uint32_t count_; //!< The number of values of the indicated type uint32_t count_; //!< The number of values of the indicated type
int32_t offset_; //!< Offset to the data area int64_t offset_; //!< Offset to the data area
/*! /*!
Size of the data buffer holding the value in bytes, there is no Size of the data buffer holding the value in bytes, there is no
minimum size. minimum size.
@ -708,7 +708,7 @@ namespace Exiv2 {
on write. The type of the value can only be signed or unsigned short or on write. The type of the value can only be signed or unsigned short or
long. long.
*/ */
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) override; uint32_t& imageIdx) override;
//@} //@}
@ -719,7 +719,7 @@ namespace Exiv2 {
@brief Implements writeData(). Write the data area to the \em ioWrapper. @brief Implements writeData(). Write the data area to the \em ioWrapper.
Return the number of bytes written. Return the number of bytes written.
*/ */
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t dataIdx,
uint32_t& imageIdx) const override; uint32_t& imageIdx) const override;
// Using doWriteImage from base class // Using doWriteImage from base class
// Using doSize() from base class // Using doSize() from base class
@ -774,7 +774,7 @@ namespace Exiv2 {
\em ioWrapper. Return the number of bytes written. The \em valueIdx \em ioWrapper. Return the number of bytes written. The \em valueIdx
and \em dataIdx arguments are not used. and \em dataIdx arguments are not used.
*/ */
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) override; uint32_t& imageIdx) override;
//@} //@}
@ -789,7 +789,7 @@ namespace Exiv2 {
directory. It is used for TIFF image entries in the makernote (large directory. It is used for TIFF image entries in the makernote (large
preview images) so that the image data remains in the makernote IFD. preview images) so that the image data remains in the makernote IFD.
*/ */
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t dataIdx,
uint32_t& imageIdx) const override; uint32_t& imageIdx) const override;
/*! /*!
@brief Implements writeImage(). Write the image data area to the \em ioWrapper. @brief Implements writeImage(). Write the image data area to the \em ioWrapper.
@ -899,7 +899,7 @@ namespace Exiv2 {
additional data, including the next-IFD, if any, to the additional data, including the next-IFD, if any, to the
\em ioWrapper, return the number of bytes written. \em ioWrapper, return the number of bytes written.
*/ */
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) override; uint32_t& imageIdx) override;
//@} //@}
@ -910,7 +910,7 @@ namespace Exiv2 {
@brief This class does not really implement writeData(), it only has @brief This class does not really implement writeData(), it only has
write(). This method must not be called; it commits suicide. write(). This method must not be called; it commits suicide.
*/ */
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t dataIdx,
uint32_t& imageIdx) const override; uint32_t& imageIdx) const override;
/*! /*!
@brief Implements writeImage(). Write the image data of the TIFF @brief Implements writeImage(). Write the image data of the TIFF
@ -951,7 +951,7 @@ namespace Exiv2 {
//! @name Private Accessors //! @name Private Accessors
//@{ //@{
//! Write a binary directory entry for a TIFF component. //! Write a binary directory entry for a TIFF component.
static uint32_t writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, static uint32_t writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset,
TiffComponent* pTiffComponent, uint32_t valueIdx, uint32_t dataIdx, TiffComponent* pTiffComponent, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx); uint32_t& imageIdx);
//@} //@}
@ -1001,7 +1001,7 @@ namespace Exiv2 {
return the number of bytes written. The \em valueIdx and return the number of bytes written. The \em valueIdx and
\em imageIdx arguments are not used. \em imageIdx arguments are not used.
*/ */
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) override; uint32_t& imageIdx) override;
//@} //@}
@ -1012,7 +1012,7 @@ namespace Exiv2 {
@brief Implements writeData(). Write the sub-IFDs to the \em ioWrapper. @brief Implements writeData(). Write the sub-IFDs to the \em ioWrapper.
Return the number of bytes written. Return the number of bytes written.
*/ */
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t dataIdx,
uint32_t& imageIdx) const override; uint32_t& imageIdx) const override;
/*! /*!
@brief Implements writeImage(). Write the image data of each sub-IFD to @brief Implements writeImage(). Write the image data of each sub-IFD to
@ -1076,7 +1076,7 @@ namespace Exiv2 {
@brief Implements write() by forwarding the call to the actual @brief Implements write() by forwarding the call to the actual
concrete Makernote, if there is one. concrete Makernote, if there is one.
*/ */
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) override; uint32_t& imageIdx) override;
//@} //@}
@ -1202,7 +1202,7 @@ namespace Exiv2 {
values and additional data to the \em ioWrapper, return the values and additional data to the \em ioWrapper, return the
number of bytes written. number of bytes written.
*/ */
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) override; uint32_t& imageIdx) override;
//@} //@}
@ -1213,7 +1213,7 @@ namespace Exiv2 {
@brief This class does not really implement writeData(), it only has @brief This class does not really implement writeData(), it only has
write(). This method must not be called; it commits suicide. write(). This method must not be called; it commits suicide.
*/ */
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t dataIdx, uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t dataIdx,
uint32_t& imageIdx) const override; uint32_t& imageIdx) const override;
/*! /*!
@brief Implements writeImage(). Write the image data of the IFD of @brief Implements writeImage(). Write the image data of the IFD of
@ -1407,7 +1407,7 @@ namespace Exiv2 {
/*! /*!
@brief Implements write(). Todo: Document it! @brief Implements write(). Todo: Document it!
*/ */
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) override; uint32_t& imageIdx) override;
//@} //@}
@ -1492,7 +1492,7 @@ namespace Exiv2 {
/*! /*!
@brief Implements write(). Todo: Document it! @brief Implements write(). Todo: Document it!
*/ */
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int32_t offset, uint32_t valueIdx, uint32_t dataIdx, uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset, uint32_t valueIdx, uint32_t dataIdx,
uint32_t& imageIdx) override; uint32_t& imageIdx) override;
//@} //@}

@ -2033,7 +2033,7 @@ namespace Exiv2 {
pSourceDir->accept(finder); pSourceDir->accept(finder);
auto te = dynamic_cast<TiffEntryBase*>(finder.result()); auto te = dynamic_cast<TiffEntryBase*>(finder.result());
const Value* pV = te != nullptr ? te->pValue() : nullptr; const Value* pV = te != nullptr ? te->pValue() : nullptr;
if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toLong() & 1) == 0) { if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toInt64() & 1) == 0) {
primaryGroups.push_back(te->group()); primaryGroups.push_back(te->group());
} }
} }

@ -457,8 +457,8 @@ namespace Exiv2 {
std::vector<int16_t> ints; std::vector<int16_t> ints;
std::vector<uint16_t> uint; std::vector<uint16_t> uint;
for (long i = 0; i < object->pValue()->count(); i++) { for (long i = 0; i < object->pValue()->count(); i++) {
ints.push_back(static_cast<int16_t>(object->pValue()->toLong(i))); ints.push_back(static_cast<int16_t>(object->pValue()->toInt64(i)));
uint.push_back(static_cast<uint16_t>(object->pValue()->toLong(i))); uint.push_back(static_cast<uint16_t>(object->pValue()->toInt64(i)));
} }
// Check this is AFInfo2 (ints[0] = bytes in object) // Check this is AFInfo2 (ints[0] = bytes in object)
if ( ints.at(0) != object->pValue()->count()*2 ) return ; if ( ints.at(0) != object->pValue()->count()*2 ) return ;

@ -713,30 +713,39 @@ namespace Exiv2 {
return false; return false;
} }
long parseLong(const std::string& s, bool& ok) int64_t parseInt64(const std::string& s, bool& ok)
{ {
long ret = stringTo<long>(s, ok); int64_t ret = stringTo<int64_t>(s, ok);
if (ok) return ret; if (ok) return ret;
auto f = stringTo<float>(s, ok); auto f = stringTo<float>(s, ok);
if (ok) return static_cast<long>(f); if (ok) return static_cast<int64_t>(f);
Rational r = stringTo<Rational>(s, ok); Rational r = stringTo<Rational>(s, ok);
if (ok) { if (ok) {
if (r.second == 0) { if (r.second <= 0) {
ok = false; ok = false;
return 0; return 0;
} }
return static_cast<long>(static_cast<float>(r.first) / r.second); return static_cast<int64_t>(static_cast<float>(r.first) / r.second);
} }
bool b = stringTo<bool>(s, ok); bool b = stringTo<bool>(s, ok);
if (ok) return b ? 1 : 0; if (ok) return b ? 1 : 0;
// everything failed, return from stringTo<long> is probably the best fit // everything failed, return from stringTo<int64_t> is probably the best fit
return ret; return ret;
} }
uint32_t parseUint32(const std::string& s, bool& ok)
{
const int64_t x = parseInt64(s, ok);
if (ok && 0 <= x && x <= std::numeric_limits<uint32_t>::max()) {
return static_cast<uint32_t>(x);
}
return 0;
}
float parseFloat(const std::string& s, bool& ok) float parseFloat(const std::string& s, bool& ok)
{ {
auto ret = stringTo<float>(s, ok); auto ret = stringTo<float>(s, ok);

@ -218,7 +218,13 @@ namespace Exiv2 {
return os.str(); return os.str();
} }
long DataValue::toLong(long n) const int64_t DataValue::toInt64(long n) const
{
ok_ = true;
return value_.at(n);
}
uint32_t DataValue::toUint32(long n) const
{ {
ok_ = true; ok_ = true;
return value_.at(n); return value_.at(n);
@ -294,7 +300,13 @@ namespace Exiv2 {
return os << value_; return os << value_;
} }
long StringValueBase::toLong(long n) const int64_t StringValueBase::toInt64(long n) const
{
ok_ = true;
return value_.at(n);
}
uint32_t StringValueBase::toUint32(long n) const
{ {
ok_ = true; ok_ = true;
return value_.at(n); return value_.at(n);
@ -688,9 +700,14 @@ namespace Exiv2 {
return os << value_; return os << value_;
} }
long XmpTextValue::toLong(long /*n*/) const int64_t XmpTextValue::toInt64(long /*n*/) const
{
return parseInt64(value_, ok_);
}
uint32_t XmpTextValue::toUint32(long /*n*/) const
{ {
return parseLong(value_, ok_); return parseUint32(value_, ok_);
} }
float XmpTextValue::toFloat(long /*n*/) const float XmpTextValue::toFloat(long /*n*/) const
@ -745,9 +762,14 @@ namespace Exiv2 {
return value_.at(n); return value_.at(n);
} }
long XmpArrayValue::toLong(long n) const int64_t XmpArrayValue::toInt64(long n) const
{
return parseInt64(value_.at(n), ok_);
}
uint32_t XmpArrayValue::toUint32(long n) const
{ {
return parseLong(value_.at(n), ok_); return parseUint32(value_.at(n), ok_);
} }
float XmpArrayValue::toFloat(long n) const float XmpArrayValue::toFloat(long n) const
@ -869,7 +891,13 @@ namespace Exiv2 {
return ""; return "";
} }
long LangAltValue::toLong(long /*n*/) const int64_t LangAltValue::toInt64(long /*n*/) const
{
ok_ = false;
return 0;
}
uint32_t LangAltValue::toUint32(long /*n*/) const
{ {
ok_ = false; ok_ = false;
return 0; return 0;
@ -984,7 +1012,7 @@ namespace Exiv2 {
return os; return os;
} }
long DateValue::toLong(long /*n*/) const int64_t DateValue::toInt64(long /*n*/) const
{ {
// Range of tm struct is limited to about 1970 to 2038 // Range of tm struct is limited to about 1970 to 2038
// This will return -1 if outside that range // This will return -1 if outside that range
@ -993,19 +1021,28 @@ namespace Exiv2 {
tms.tm_mday = date_.day; tms.tm_mday = date_.day;
tms.tm_mon = date_.month - 1; tms.tm_mon = date_.month - 1;
tms.tm_year = date_.year - 1900; tms.tm_year = date_.year - 1900;
long l = static_cast<long>(std::mktime(&tms)); int64_t l = static_cast<int64_t>(std::mktime(&tms));
ok_ = (l != -1); ok_ = (l != -1);
return l; return l;
} }
uint32_t DateValue::toUint32(long /*n*/) const
{
const int64_t t = toInt64();
if (t < 0 || t > std::numeric_limits<uint32_t>::max()) {
return 0;
}
return static_cast<uint32_t>(t);
}
float DateValue::toFloat(long n) const float DateValue::toFloat(long n) const
{ {
return static_cast<float>(toLong(n)); return static_cast<float>(toInt64(n));
} }
Rational DateValue::toRational(long n) const Rational DateValue::toRational(long n) const
{ {
return {toLong(n), 1}; return {static_cast<int32_t>(toInt64(n)), 1};
} }
TimeValue::TimeValue() TimeValue::TimeValue()
@ -1136,10 +1173,10 @@ namespace Exiv2 {
return os; return os;
} }
long TimeValue::toLong(long /*n*/) const int64_t TimeValue::toInt64(long /*n*/) const
{ {
// Returns number of seconds in the day in UTC. // Returns number of seconds in the day in UTC.
long result = (time_.hour - time_.tzHour) * 60 * 60; int64_t result = (time_.hour - time_.tzHour) * 60 * 60;
result += (time_.minute - time_.tzMinute) * 60; result += (time_.minute - time_.tzMinute) * 60;
result += time_.second; result += time_.second;
if (result < 0) { if (result < 0) {
@ -1149,14 +1186,23 @@ namespace Exiv2 {
return result; return result;
} }
uint32_t TimeValue::toUint32(long /*n*/) const
{
const int64_t t = toInt64();
if (t < 0 || t > std::numeric_limits<uint32_t>::max()) {
return 0;
}
return static_cast<uint32_t>(t);
}
float TimeValue::toFloat(long n) const float TimeValue::toFloat(long n) const
{ {
return static_cast<float>(toLong(n)); return static_cast<float>(toInt64(n));
} }
Rational TimeValue::toRational(long n) const Rational TimeValue::toRational(long n) const
{ {
return {toLong(n), 1}; return {static_cast<int32_t>(toInt64(n)), 1};
} }
} // namespace Exiv2 } // namespace Exiv2

@ -405,7 +405,7 @@ namespace Exiv2 {
long Xmpdatum::toLong(long n) const long Xmpdatum::toLong(long n) const
{ {
return p_->value_.get() == nullptr ? -1 : p_->value_->toLong(n); return p_->value_.get() == nullptr ? -1 : static_cast<long>(p_->value_->toInt64(n));
} }
float Xmpdatum::toFloat(long n) const float Xmpdatum::toFloat(long n) const

Loading…
Cancel
Save