Skip to content

Commit

Permalink
Replace Metadatum::toLong() with Metadatum::toInt64().
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbackhouse committed Feb 18, 2022
1 parent 15c91b4 commit 2563658
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 76 deletions.
2 changes: 1 addition & 1 deletion include/exiv2/exif.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace Exiv2 {
//! Return the value as a string.
std::string toString() const override;
std::string toString(long n) const override;
long toLong(long n = 0) const override;
int64_t toInt64(long n = 0) const override;
float toFloat(long n = 0) const override;
Rational toRational(long n = 0) const override;
Value::UniquePtr getValue() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/iptc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace Exiv2 {
long size() const override;
std::string toString() const override;
std::string toString(long n) const override;
long toLong(long n = 0) const override;
int64_t toInt64(long n = 0) const override;
float toFloat(long n = 0) const override;
Rational toRational(long n = 0) const override;
Value::UniquePtr getValue() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/metadatum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ namespace Exiv2 {
The return value is -1 if the value is not set and the behaviour
of the method is undefined if there is no <EM>n</EM>-th component.
*/
virtual long toLong(long n =0) const =0;
virtual int64_t toInt64(long n =0) const =0;
/*!
@brief Return the <EM>n</EM>-th component of the value converted to float.
The return value is -1 if the value is not set and the behaviour
Expand Down
4 changes: 2 additions & 2 deletions include/exiv2/tiffimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ namespace Exiv2 {
// DATA
mutable std::string primaryGroup_; //!< The primary group
mutable std::string mimeType_; //!< The MIME type
mutable int pixelWidthPrimary_; //!< Width of the primary image in pixels
mutable int pixelHeightPrimary_; //!< Height of the primary image in pixels
mutable int64_t pixelWidthPrimary_; //!< Width of the primary image in pixels
mutable int64_t pixelHeightPrimary_; //!< Height of the primary image in pixels

}; // class TiffImage

Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/xmp_exiv2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace Exiv2 {
long size() const override;
std::string toString() const override;
std::string toString(long n) const override;
long toLong(long n = 0) const override;
int64_t toInt64(long n = 0) const override;
float toFloat(long n = 0) const override;
Rational toRational(long n = 0) const override;
Value::UniquePtr getValue() const override;
Expand Down
2 changes: 1 addition & 1 deletion samples/xmpsample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ try {
xmpData["Xmp.dc.eight"] = true;

// Extracting values
assert(xmpData["Xmp.dc.one"].toLong() == -1);
assert(xmpData["Xmp.dc.one"].toInt64() == -1);
assert(xmpData["Xmp.dc.one"].value().ok());

const Exiv2::Value &getv1 = xmpData["Xmp.dc.one"].value();
Expand Down
4 changes: 2 additions & 2 deletions src/bmffimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace Exiv2
{
auto imageWidth = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelXDimension"));
if (imageWidth != exifData_.end() && imageWidth->count() > 0) {
return imageWidth->toLong();
return imageWidth->toInt64();
}
return pixelWidth_;
}
Expand All @@ -170,7 +170,7 @@ namespace Exiv2
{
auto imageHeight = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelYDimension"));
if (imageHeight != exifData_.end() && imageHeight->count() > 0) {
return imageHeight->toLong();
return imageHeight->toInt64();
}
return pixelHeight_;
}
Expand Down
16 changes: 8 additions & 8 deletions src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ namespace Exiv2 {
if (!prepareXmpTarget(to)) return;
std::ostringstream value;
for (long i = 0; i < pos->count(); ++i) {
value << static_cast<char>(pos->toLong(i));
value << static_cast<char>(pos->toInt64(i));
}
(*xmpData_)[to] = value.str();
if (erase_) exifData_->erase(pos);
Expand All @@ -712,7 +712,7 @@ namespace Exiv2 {
std::ostringstream value;
for (long i = 0; i < pos->count(); ++i) {
if (i > 0) value << '.';
value << pos->toLong(i);
value << pos->toInt64(i);
}
(*xmpData_)[to] = value.str();
if (erase_) exifData_->erase(pos);
Expand All @@ -723,7 +723,7 @@ namespace Exiv2 {
auto pos = exifData_->findKey(ExifKey(from));
if (pos == exifData_->end() || pos->count() == 0) return;
if (!prepareXmpTarget(to)) return;
int value = pos->toLong();
auto value = pos->toInt64();
if (!pos->value().ok()) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
Expand Down Expand Up @@ -991,7 +991,7 @@ namespace Exiv2 {
unsigned short value = 0;

if (pos != xmpData_->end() && pos->count() > 0) {
int fired = pos->toLong();
auto fired = pos->toInt64();
if (pos->value().ok())
value |= fired & 1;
#ifndef SUPPRESS_WARNINGS
Expand All @@ -1001,7 +1001,7 @@ namespace Exiv2 {
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Return"));
if (pos != xmpData_->end() && pos->count() > 0) {
int ret = pos->toLong();
auto ret = pos->toInt64();
if (pos->value().ok())
value |= (ret & 3) << 1;
#ifndef SUPPRESS_WARNINGS
Expand All @@ -1011,7 +1011,7 @@ namespace Exiv2 {
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Mode"));
if (pos != xmpData_->end() && pos->count() > 0) {
int mode = pos->toLong();
auto mode = pos->toInt64();
if (pos->value().ok())
value |= (mode & 3) << 3;
#ifndef SUPPRESS_WARNINGS
Expand All @@ -1021,7 +1021,7 @@ namespace Exiv2 {
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Function"));
if (pos != xmpData_->end() && pos->count() > 0) {
int function = pos->toLong();
auto function = pos->toInt64();
if (pos->value().ok())
value |= (function & 1) << 5;
#ifndef SUPPRESS_WARNINGS
Expand All @@ -1032,7 +1032,7 @@ namespace Exiv2 {
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:RedEyeMode"));
if (pos != xmpData_->end()) {
if (pos->count() > 0) {
int red = pos->toLong();
auto red = pos->toInt64();
if (pos->value().ok())
value |= (red & 1) << 6;
#ifndef SUPPRESS_WARNINGS
Expand Down
4 changes: 2 additions & 2 deletions src/cr2image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace Exiv2 {
{
auto imageWidth = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelXDimension"));
if (imageWidth != exifData_.end() && imageWidth->count() > 0) {
return imageWidth->toLong();
return imageWidth->toInt64();
}
return 0;
}
Expand All @@ -69,7 +69,7 @@ namespace Exiv2 {
{
auto imageHeight = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelYDimension"));
if (imageHeight != exifData_.end() && imageHeight->count() > 0) {
return imageHeight->toLong();
return imageHeight->toInt64();
}
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/crwimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace Exiv2 {
{
auto widthIter = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelXDimension"));
if (widthIter != exifData_.end() && widthIter->count() > 0) {
return widthIter->toLong();
return widthIter->toInt64();
}
return 0;
}
Expand All @@ -75,7 +75,7 @@ namespace Exiv2 {
{
auto heightIter = exifData_.findKey(Exiv2::ExifKey("Exif.Photo.PixelYDimension"));
if (heightIter != exifData_.end() && heightIter->count() > 0) {
return heightIter->toLong();
return heightIter->toInt64();
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ namespace Exiv2 {
}
int32_t d = 0;
if (edO != edEnd && edO->count() > 0 && edO->typeId() == unsignedShort) {
d = RotationMap::degrees(static_cast<uint16_t>(edO->toLong()));
d = RotationMap::degrees(static_cast<uint16_t>(edO->toInt64()));
}
buf.write_uint32(12, d, pHead->byteOrder());
pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf));
Expand Down
14 changes: 7 additions & 7 deletions src/exif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace {
}; // class JpegThumbnail

//! Helper function to sum all components of the value of a metadatum
long sumToLong(const Exiv2::Exifdatum& md);
int64_t sumToLong(const Exiv2::Exifdatum& md);

//! Helper function to delete all tags of a specific IFD from the metadata.
void eraseIfd(Exiv2::ExifData& ed, Exiv2::Internal::IfdId ifdId);
Expand Down Expand Up @@ -405,9 +405,9 @@ namespace Exiv2 {
return value_.get() == nullptr ? "" : value_->toString(n);
}

long Exifdatum::toLong(long n) const
int64_t Exifdatum::toInt64(long n) const
{
return value_.get() == nullptr ? -1 : static_cast<long>(value_->toInt64(n));
return value_.get() == nullptr ? -1 : value_->toInt64(n);
}

float Exifdatum::toFloat(long n) const
Expand Down Expand Up @@ -825,7 +825,7 @@ namespace {
if (pos != exifData.end()) {
if (pos->count() == 0)
return thumbnail;
long compression = pos->toLong();
auto compression = pos->toInt64();
if (compression == 6) {
thumbnail = std::make_unique<JpegThumbnail>();
}
Expand Down Expand Up @@ -889,11 +889,11 @@ namespace {
return format->dataArea();
}

long sumToLong(const Exiv2::Exifdatum& md)
int64_t sumToLong(const Exiv2::Exifdatum& md)
{
long sum = 0;
int64_t sum = 0;
for (long i = 0; i < md.count(); ++i) {
sum += md.toLong(i);
sum += md.toInt64(i);
}
return sum;
}
Expand Down
4 changes: 2 additions & 2 deletions src/iptc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ namespace Exiv2 {
return value_.get() == nullptr ? "" : value_->toString(n);
}

long Iptcdatum::toLong(long n) const
int64_t Iptcdatum::toInt64(long n) const
{
return value_.get() == nullptr ? -1 : static_cast<long>(value_->toInt64(n));
return value_.get() == nullptr ? -1 : value_->toInt64(n);
}

float Iptcdatum::toFloat(long n) const
Expand Down
4 changes: 2 additions & 2 deletions src/mrwimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace Exiv2 {
{
auto imageWidth = exifData_.findKey(Exiv2::ExifKey("Exif.Image.ImageWidth"));
if (imageWidth != exifData_.end() && imageWidth->count() > 0) {
return imageWidth->toLong();
return imageWidth->toInt64();
}
return 0;
}
Expand All @@ -62,7 +62,7 @@ namespace Exiv2 {
{
auto imageHeight = exifData_.findKey(Exiv2::ExifKey("Exif.Image.ImageLength"));
if (imageHeight != exifData_.end() && imageHeight->count() > 0) {
return imageHeight->toLong();
return imageHeight->toInt64();
}
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions src/nikonmn_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2665,14 +2665,14 @@ fmountlens[] = {
if (md == metadata->end() || md->typeId() != unsignedByte || md->count() == 0) {
return os << value;
}
raw[i] = static_cast<byte>(md->toLong());
raw[i] = static_cast<byte>(md->toInt64());
}

auto md = metadata->findKey(ExifKey("Exif.Nikon3.LensType"));
if (md == metadata->end() || md->typeId() != unsignedByte || md->count() == 0) {
return os << value;
}
raw[7] = static_cast<byte>(md->toLong());
raw[7] = static_cast<byte>(md->toInt64());

for (int i = 0; fmountlens[i].lensname != nullptr; ++i) {
if ( raw[0] == fmountlens[i].lid ) {
Expand Down Expand Up @@ -2990,7 +2990,7 @@ fmountlens[] = {
os << "(" << value << ")";
}
else {
if (pos->toLong() < 0x06) {
if (pos->toInt64() < 0x06) {
// FlashGroupACompensation value
if (temp == 0)
os << 0;
Expand Down Expand Up @@ -3031,7 +3031,7 @@ fmountlens[] = {
os << "(" << value << ")";
}
else {
if (pos->toLong() < 0x06) {
if (pos->toInt64() < 0x06) {
// FlashGroupBCompensation value
if (temp == 0)
os << 0;
Expand Down Expand Up @@ -3072,7 +3072,7 @@ fmountlens[] = {
os << "(" << value << ")";
}
else {
if (pos->toLong() < 0x06) {
if (pos->toInt64() < 0x06) {
// FlashGroupCCompensation value
if (temp == 0)
os << 0;
Expand Down
4 changes: 2 additions & 2 deletions src/orfimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace Exiv2 {
{
auto imageWidth = exifData_.findKey(Exiv2::ExifKey("Exif.Image.ImageWidth"));
if (imageWidth != exifData_.end() && imageWidth->count() > 0) {
return imageWidth->toLong();
return imageWidth->toInt64();
}
return 0;
}
Expand All @@ -67,7 +67,7 @@ namespace Exiv2 {
{
auto imageHeight = exifData_.findKey(Exiv2::ExifKey("Exif.Image.ImageLength"));
if (imageHeight != exifData_.end() && imageHeight->count() > 0) {
return imageHeight->toLong();
return imageHeight->toInt64();
}
return 0;
}
Expand Down
Loading

0 comments on commit 2563658

Please sign in to comment.