diff --git a/samples/addmoddel.cpp b/samples/addmoddel.cpp index 69adb8ce..09080fea 100644 --- a/samples/addmoddel.cpp +++ b/samples/addmoddel.cpp @@ -103,9 +103,7 @@ try { // ************************************************************************* // Finally, write the remaining Exif data to the image file - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert(image.get() != 0); - + auto image = Exiv2::ImageFactory::open(file); image->setExifData(exifData); image->writeMetadata(); diff --git a/samples/convert-test.cpp b/samples/convert-test.cpp index 420cf9b2..2d05f740 100644 --- a/samples/convert-test.cpp +++ b/samples/convert-test.cpp @@ -19,8 +19,7 @@ try { return 1; } - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(argv[1]); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(argv[1]); image->readMetadata(); Exiv2::XmpData xmpData; diff --git a/samples/easyaccess-test.cpp b/samples/easyaccess-test.cpp index fee22a57..ea8b7345 100644 --- a/samples/easyaccess-test.cpp +++ b/samples/easyaccess-test.cpp @@ -63,8 +63,7 @@ try { return 1; } - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(argv[1]); - assert (image.get() != 0); + auto image = Exiv2::ImageFactory::open(argv[1]); image->readMetadata(); Exiv2::ExifData& ed = image->exifData(); diff --git a/samples/exifcomment.cpp b/samples/exifcomment.cpp index 89f643a7..880c38ff 100644 --- a/samples/exifcomment.cpp +++ b/samples/exifcomment.cpp @@ -20,8 +20,7 @@ try { return 1; } - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(argv[1]); - assert (image.get() != 0); + auto image = Exiv2::ImageFactory::open(argv[1]); image->readMetadata(); Exiv2::ExifData &exifData = image->exifData(); @@ -37,14 +36,10 @@ try { Following are a few examples of valid comments. The last one is written to the file. */ - exifData["Exif.Photo.UserComment"] - = "charset=Unicode A Unicode Exif comment added with Exiv2"; - exifData["Exif.Photo.UserComment"] - = "charset=Undefined An undefined Exif comment added with Exiv2"; - exifData["Exif.Photo.UserComment"] - = "Another undefined Exif comment added with Exiv2"; - exifData["Exif.Photo.UserComment"] - = "charset=Ascii An ASCII Exif comment added with Exiv2"; + exifData["Exif.Photo.UserComment"] = "charset=Unicode A Unicode Exif comment added with Exiv2"; + exifData["Exif.Photo.UserComment"] = "charset=Undefined An undefined Exif comment added with Exiv2"; + exifData["Exif.Photo.UserComment"] = "Another undefined Exif comment added with Exiv2"; + exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2"; std::cout << "Writing user comment '" << exifData["Exif.Photo.UserComment"] diff --git a/samples/exifdata-test.cpp b/samples/exifdata-test.cpp index 9abe339b..3ae5f6ec 100644 --- a/samples/exifdata-test.cpp +++ b/samples/exifdata-test.cpp @@ -23,8 +23,8 @@ try { } std::string file(argv[1]); - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert (image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); + assert (image); image->readMetadata(); Exiv2::ExifData &ed = image->exifData(); @@ -96,16 +96,14 @@ catch (Exiv2::AnyError& e) { void write(const std::string& file, Exiv2::ExifData& ed) { - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert (image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); image->setExifData(ed); image->writeMetadata(); } void print(const std::string& file) { - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert (image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); image->readMetadata(); Exiv2::ExifData &ed = image->exifData(); diff --git a/samples/exifdata.cpp b/samples/exifdata.cpp index 31e7d57a..18d87940 100644 --- a/samples/exifdata.cpp +++ b/samples/exifdata.cpp @@ -184,8 +184,7 @@ int main(int argc,const char* argv[]) } if ( !result ) try { - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); image->readMetadata(); Exiv2::ExifData &exifData = image->exifData(); diff --git a/samples/exifprint.cpp b/samples/exifprint.cpp index 8d5e80cf..124f37a8 100644 --- a/samples/exifprint.cpp +++ b/samples/exifprint.cpp @@ -63,8 +63,7 @@ try { return rc; } - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); image->readMetadata(); Exiv2::ExifData &exifData = image->exifData(); diff --git a/samples/exifvalue.cpp b/samples/exifvalue.cpp index f87ec599..55ceb02e 100644 --- a/samples/exifvalue.cpp +++ b/samples/exifvalue.cpp @@ -21,8 +21,7 @@ int main(int argc, char* const argv[]) const char* file = argv[1]; const char* key = argv[2]; - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); image->readMetadata(); Exiv2::ExifData &exifData = image->exifData(); diff --git a/samples/geotag.cpp b/samples/geotag.cpp index 3fe01ec0..9a377c87 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -391,14 +391,13 @@ time_t parseTime(const char* arg,bool bAdjust) // West of GMT is negative (PDT = Pacific Daylight = -07:00 == -25200 seconds int timeZoneAdjust() { - time_t now = time(nullptr); + [[maybe_unused]] time_t now = time(nullptr); int offset; #if defined(_MSC_VER) || defined(__MINGW__) TIME_ZONE_INFORMATION TimeZoneInfo; GetTimeZoneInformation( &TimeZoneInfo ); offset = - (((int)TimeZoneInfo.Bias + (int)TimeZoneInfo.DaylightBias) * 60); - UNUSED(now); #elif defined(__CYGWIN__) struct tm lcopy = *localtime(&now); time_t gmt = timegm(&lcopy) ; // timegm modifies lcopy diff --git a/samples/iotest.cpp b/samples/iotest.cpp index ba6ee082..8a538b95 100644 --- a/samples/iotest.cpp +++ b/samples/iotest.cpp @@ -49,7 +49,7 @@ int main(int argc, char* const argv[]) std::vector bytes (blocksize); // copy fileIn from a remote location. - BasicIo::UniquePtr io = Exiv2::ImageFactory::createIo(fr); + auto io = Exiv2::ImageFactory::createIo(fr); if ( io->open() != 0 ) { Error(Exiv2::kerFileOpenFailed, io->path(), "rb", strError()); } diff --git a/samples/iptceasy.cpp b/samples/iptceasy.cpp index ae06c3a5..99afcae0 100644 --- a/samples/iptceasy.cpp +++ b/samples/iptceasy.cpp @@ -37,9 +37,7 @@ try { std::cout << "Time sent: " << iptcData["Iptc.Envelope.TimeSent"] << "\n"; // Open image file - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert (image.get() != 0); - + auto image = Exiv2::ImageFactory::open(file); // Set IPTC data and write it to the file image->setIptcData(iptcData); image->writeMetadata(); diff --git a/samples/iptcprint.cpp b/samples/iptcprint.cpp index 4a685a9f..f7eea57a 100644 --- a/samples/iptcprint.cpp +++ b/samples/iptcprint.cpp @@ -18,8 +18,7 @@ try { return 1; } - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(argv[1]); - assert (image.get() != 0); + auto image = Exiv2::ImageFactory::open(argv[1]); image->readMetadata(); Exiv2::IptcData &iptcData = image->iptcData(); diff --git a/samples/iptctest.cpp b/samples/iptctest.cpp index ed413a31..36703700 100644 --- a/samples/iptctest.cpp +++ b/samples/iptctest.cpp @@ -29,8 +29,7 @@ int main(int argc, char* const argv[]) return 1; } - Image::UniquePtr image = ImageFactory::open(argv[1]); - assert (image.get() != 0); + auto image = ImageFactory::open(argv[1]); image->readMetadata(); // Process commands diff --git a/samples/largeiptc-test.cpp b/samples/largeiptc-test.cpp index d62ae3f9..d4d5b4dc 100644 --- a/samples/largeiptc-test.cpp +++ b/samples/largeiptc-test.cpp @@ -28,7 +28,8 @@ int main(int argc, char* const argv[]) if (io.open() != 0) { throw Exiv2::Error(Exiv2::kerDataSourceOpenFailed, io.path(), Exiv2::strError()); } - Exiv2::DataBuf buf(static_cast(io.size())); + + Exiv2::DataBuf buf(io.size()); std::cout << "Reading " << buf.size() << " bytes from " << data << "\n"; const size_t readBytes = io.read(buf.data(), buf.size()); if (readBytes != buf.size() || io.error() || io.eof()) { @@ -36,8 +37,7 @@ int main(int argc, char* const argv[]) } // Read metadata from file - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); image->readMetadata(); // Set Preview field to the content of the data file diff --git a/samples/metacopy.cpp b/samples/metacopy.cpp index ff376ac5..5062b014 100644 --- a/samples/metacopy.cpp +++ b/samples/metacopy.cpp @@ -34,12 +34,10 @@ try { auto memIo = std::make_unique(); memIo->transfer(fileIo); - Exiv2::Image::UniquePtr readImg = Exiv2::ImageFactory::open(std::move(memIo)); - assert(readImg.get() != 0); + auto readImg = Exiv2::ImageFactory::open(std::move(memIo)); readImg->readMetadata(); - Exiv2::Image::UniquePtr writeImg = Exiv2::ImageFactory::open(params.write_); - assert(writeImg.get() != 0); + auto writeImg = Exiv2::ImageFactory::open(params.write_); if (params.preserve_) { writeImg->readMetadata(); } diff --git a/samples/mmap-test.cpp b/samples/mmap-test.cpp index 17133f18..a12ba7a5 100644 --- a/samples/mmap-test.cpp +++ b/samples/mmap-test.cpp @@ -28,8 +28,7 @@ try { } // Map it to memory const Exiv2::byte* pData = file.mmap(); - auto size = static_cast(file.size()); - DataBuf buf(size); + DataBuf buf(file.size()); // Read from the memory mapped region buf.copyBytes(0, pData, buf.size()); // Reopen file in write mode and write to it diff --git a/samples/mrwthumb.cpp b/samples/mrwthumb.cpp index 8656c51b..323b0346 100644 --- a/samples/mrwthumb.cpp +++ b/samples/mrwthumb.cpp @@ -19,8 +19,7 @@ int main(int argc, char* const argv[]) return 1; } - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(argv[1]); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(argv[1]); image->readMetadata(); Exiv2::ExifData& exifData = image->exifData(); diff --git a/samples/prevtest.cpp b/samples/prevtest.cpp index 25960e33..f4065a3d 100644 --- a/samples/prevtest.cpp +++ b/samples/prevtest.cpp @@ -19,8 +19,7 @@ try { } std::string filename(argv[1]); - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(filename); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(filename); image->readMetadata(); Exiv2::PreviewManager loader(*image); diff --git a/samples/remotetest.cpp b/samples/remotetest.cpp index aa78988d..a08a494e 100644 --- a/samples/remotetest.cpp +++ b/samples/remotetest.cpp @@ -44,15 +44,13 @@ try { Exiv2::ExifKey key("Exif.Image.DateTime"); exifData.add(key, v.get()); - Exiv2::Image::UniquePtr writeTest = Exiv2::ImageFactory::open(file, useCurlFromExiv2TestApps); - assert(writeTest.get() != 0); + auto writeTest = Exiv2::ImageFactory::open(file, useCurlFromExiv2TestApps); writeTest->setExifData(exifData); writeTest->writeMetadata(); // read the result to make sure everything fine std::cout << "Print out the new metadata ...\n"; - Exiv2::Image::UniquePtr readTest = Exiv2::ImageFactory::open(file, useCurlFromExiv2TestApps); - assert(readTest.get() != 0); + auto readTest = Exiv2::ImageFactory::open(file, useCurlFromExiv2TestApps); readTest->readMetadata(); Exiv2::ExifData &exifReadData = readTest->exifData(); if (exifReadData.empty()) { diff --git a/samples/write-test.cpp b/samples/write-test.cpp index 14681aed..2bb1e320 100644 --- a/samples/write-test.cpp +++ b/samples/write-test.cpp @@ -148,8 +148,7 @@ void testCase(const std::string& file1, ExifKey ek(key); //Open first image - Image::UniquePtr image1 = ImageFactory::open(file1); - assert(image1.get() != 0); + auto image1 = ImageFactory::open(file1); // Load existing metadata std::cerr << "---> Reading file " << file1 << "\n"; @@ -164,8 +163,7 @@ void testCase(const std::string& file1, pos->setValue(value); // Open second image - Image::UniquePtr image2 = ImageFactory::open(file2); - assert(image2.get() != 0); + auto image2 = ImageFactory::open(file2); image2->setExifData(image1->exifData()); diff --git a/samples/write2-test.cpp b/samples/write2-test.cpp index a47db8cb..a1a11690 100644 --- a/samples/write2-test.cpp +++ b/samples/write2-test.cpp @@ -27,19 +27,19 @@ int main(int argc, char* const argv[]) Exiv2::ExifData ed1; ed1["Exif.Image.Model"] = "Test 1"; - Exiv2::Value::UniquePtr v1 = Exiv2::Value::create(Exiv2::unsignedShort); + auto v1 = Exiv2::Value::create(Exiv2::unsignedShort); v1->read("160 161 162 163"); ed1.add(Exiv2::ExifKey("Exif.Image.SamplesPerPixel"), v1.get()); - Exiv2::Value::UniquePtr v2 = Exiv2::Value::create(Exiv2::signedLong); + auto v2 = Exiv2::Value::create(Exiv2::signedLong); v2->read("-2 -1 0 1"); ed1.add(Exiv2::ExifKey("Exif.Image.XResolution"), v2.get()); - Exiv2::Value::UniquePtr v3 = Exiv2::Value::create(Exiv2::signedRational); + auto v3 = Exiv2::Value::create(Exiv2::signedRational); v3->read("-2/3 -1/3 0/3 1/3"); ed1.add(Exiv2::ExifKey("Exif.Image.YResolution"), v3.get()); - Exiv2::Value::UniquePtr v4 = Exiv2::Value::create(Exiv2::undefined); + auto v4 = Exiv2::Value::create(Exiv2::undefined); v4->read("255 254 253 252"); ed1.add(Exiv2::ExifKey("Exif.Image.WhitePoint"), v4.get()); @@ -66,8 +66,7 @@ int main(int argc, char* const argv[]) print(file); std::cout <<"\n----- Non-intrusive writing of special Canon MakerNote tags\n"; - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); image->readMetadata(); Exiv2::ExifData& rEd = image->exifData(); @@ -198,8 +197,7 @@ catch (Exiv2::AnyError& e) { void write(const std::string& file, Exiv2::ExifData& ed) { - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); image->setExifData(ed); image->writeMetadata(); @@ -207,8 +205,7 @@ void write(const std::string& file, Exiv2::ExifData& ed) void print(const std::string& file) { - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(file); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(file); image->readMetadata(); Exiv2::ExifData &ed = image->exifData(); diff --git a/samples/xmpdump.cpp b/samples/xmpdump.cpp index 30a1d1c5..27046816 100644 --- a/samples/xmpdump.cpp +++ b/samples/xmpdump.cpp @@ -18,8 +18,7 @@ int main(int argc, char* const argv[]) return 1; } - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(argv[1]); - assert(image.get() != 0); + auto image = Exiv2::ImageFactory::open(argv[1]); image->readMetadata(); const std::string& xmpPacket = image->xmpPacket(); diff --git a/samples/xmpparse.cpp b/samples/xmpparse.cpp index 5ced9765..7a3c4b70 100644 --- a/samples/xmpparse.cpp +++ b/samples/xmpparse.cpp @@ -16,6 +16,7 @@ try { std::cout << "Usage: " << argv[0] << " file\n"; return 1; } + Exiv2::DataBuf buf = Exiv2::readFile(argv[1]); std::string xmpPacket; xmpPacket.assign(buf.c_str(), buf.size()); diff --git a/samples/xmpprint.cpp b/samples/xmpprint.cpp index b739122e..d31be898 100644 --- a/samples/xmpprint.cpp +++ b/samples/xmpprint.cpp @@ -23,8 +23,7 @@ int main(int argc, char** argv) return 1; } - Exiv2::Image::UniquePtr image = Exiv2::ImageFactory::open(argv[1]); - assert (image.get() != 0); + auto image = Exiv2::ImageFactory::open(argv[1]); image->readMetadata(); Exiv2::XmpData &xmpData = image->xmpData(); diff --git a/samples/xmpsample.cpp b/samples/xmpsample.cpp index e2067de5..5c67d954 100644 --- a/samples/xmpsample.cpp +++ b/samples/xmpsample.cpp @@ -107,7 +107,7 @@ try { // properties and language alternatives. // Add a simple XMP property in a known namespace - Exiv2::Value::UniquePtr v = Exiv2::Value::create(Exiv2::xmpText); + auto v = Exiv2::Value::create(Exiv2::xmpText); v->read("image/jpeg"); xmpData.add(Exiv2::XmpKey("Xmp.dc.format"), v.get()); diff --git a/src/futils.cpp b/src/futils.cpp index 438669e5..e5292451 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -4,6 +4,7 @@ #include "futils.hpp" #include "config.h" +#include "error.hpp" // + standard includes #include