diff --git a/include/exiv2/basicio.hpp b/include/exiv2/basicio.hpp index e2a0ce44bd..e9bcae8ebe 100644 --- a/include/exiv2/basicio.hpp +++ b/include/exiv2/basicio.hpp @@ -55,7 +55,11 @@ namespace Exiv2 { class EXIV2API BasicIo { public: //! BasicIo auto_ptr type +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! Seek starting positions enum Position { beg, cur, end }; @@ -521,7 +525,11 @@ namespace Exiv2 { // Pimpl idiom class Impl; +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr p_; +#else std::auto_ptr p_; +#endif }; // class FileIo @@ -721,7 +729,11 @@ namespace Exiv2 { // Pimpl idiom class Impl; +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr p_; +#else std::auto_ptr p_; +#endif }; // class MemIo diff --git a/include/exiv2/config.h b/include/exiv2/config.h index 8c35ec2120..4ec9f814df 100644 --- a/include/exiv2/config.h +++ b/include/exiv2/config.h @@ -105,4 +105,11 @@ typedef int pid_t; using auto_ptr = std::unique_ptr; #endif +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) +# define EXV_NO_AUTO_PTR +# define EXV_NO_AUTO_PTR_MOVE(x) std::move(x) +#else +# define EXV_NO_AUTO_PTR_MOVE(x) (x) +#endif + #endif // _CONFIG_H_ diff --git a/include/exiv2/datasets.hpp b/include/exiv2/datasets.hpp index 0e7c4a4319..67b9f87264 100644 --- a/include/exiv2/datasets.hpp +++ b/include/exiv2/datasets.hpp @@ -275,7 +275,11 @@ namespace Exiv2 { class EXIV2API IptcKey : public Key { public: //! Shortcut for an %IptcKey auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ diff --git a/include/exiv2/image.hpp b/include/exiv2/image.hpp index 7000c51277..0f2c5d4c4e 100644 --- a/include/exiv2/image.hpp +++ b/include/exiv2/image.hpp @@ -78,7 +78,11 @@ namespace Exiv2 { class EXIV2API Image { public: //! Image auto_ptr type +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ diff --git a/include/exiv2/metadatum.hpp b/include/exiv2/metadatum.hpp index 036812ef8f..f276105539 100644 --- a/include/exiv2/metadatum.hpp +++ b/include/exiv2/metadatum.hpp @@ -44,7 +44,11 @@ namespace Exiv2 { class EXIV2API Key { public: //! Shortcut for a %Key auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ diff --git a/include/exiv2/properties.hpp b/include/exiv2/properties.hpp index f56b0c286c..4259b24de3 100644 --- a/include/exiv2/properties.hpp +++ b/include/exiv2/properties.hpp @@ -231,7 +231,11 @@ namespace Exiv2 { { public: //! Shortcut for an %XmpKey auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -294,7 +298,11 @@ namespace Exiv2 { private: // Pimpl idiom struct Impl; +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr p_; +#else std::auto_ptr p_; +#endif }; // class XmpKey diff --git a/include/exiv2/tags.hpp b/include/exiv2/tags.hpp index f6a63a3a7f..3cf5e47798 100644 --- a/include/exiv2/tags.hpp +++ b/include/exiv2/tags.hpp @@ -140,7 +140,11 @@ namespace Exiv2 { class EXIV2API ExifKey : public Key { public: //! Shortcut for an %ExifKey auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -214,7 +218,11 @@ namespace Exiv2 { private: // Pimpl idiom struct Impl; +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr p_; +#else std::auto_ptr p_; +#endif }; // class ExifKey diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp index 3ec1af5060..7ed7f4f882 100644 --- a/include/exiv2/value.hpp +++ b/include/exiv2/value.hpp @@ -51,7 +51,11 @@ namespace Exiv2 { class EXIV2API Value { public: //! Shortcut for a %Value auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -253,7 +257,11 @@ namespace Exiv2 { class EXIV2API DataValue : public Value { public: //! Shortcut for a %DataValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif explicit DataValue(TypeId typeId =undefined); @@ -335,7 +343,11 @@ namespace Exiv2 { class EXIV2API StringValueBase : public Value { public: //! Shortcut for a %StringValueBase auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -417,7 +429,11 @@ namespace Exiv2 { class EXIV2API StringValue : public StringValueBase { public: //! Shortcut for a %StringValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -449,7 +465,11 @@ namespace Exiv2 { class EXIV2API AsciiValue : public StringValueBase { public: //! Shortcut for a %AsciiValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -537,7 +557,11 @@ namespace Exiv2 { }; // class CharsetInfo //! Shortcut for a %CommentValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -624,7 +648,11 @@ namespace Exiv2 { class EXIV2API XmpValue : public Value { public: //! Shortcut for a %XmpValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! XMP array types. enum XmpArrayType { xaNone, xaAlt, xaBag, xaSeq }; @@ -715,7 +743,11 @@ namespace Exiv2 { class EXIV2API XmpTextValue : public XmpValue { public: //! Shortcut for a %XmpTextValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -797,7 +829,11 @@ namespace Exiv2 { class EXIV2API XmpArrayValue : public XmpValue { public: //! Shortcut for a %XmpArrayValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -890,7 +926,11 @@ namespace Exiv2 { class EXIV2API LangAltValue : public XmpValue { public: //! Shortcut for a %LangAltValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -978,7 +1018,11 @@ namespace Exiv2 { class EXIV2API DateValue : public Value { public: //! Shortcut for a %DateValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -1079,7 +1123,11 @@ namespace Exiv2 { class EXIV2API TimeValue : public Value { public: //! Shortcut for a %TimeValue auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -1235,7 +1283,11 @@ namespace Exiv2 { class ValueType : public Value { public: //! Shortcut for a %ValueType\ auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr > AutoPtr; +#else typedef std::auto_ptr > AutoPtr; +#endif //! @name Creators //@{ diff --git a/include/exiv2/xmp_exiv2.hpp b/include/exiv2/xmp_exiv2.hpp index 8934ebe6aa..4f0d97caac 100644 --- a/include/exiv2/xmp_exiv2.hpp +++ b/include/exiv2/xmp_exiv2.hpp @@ -146,7 +146,11 @@ namespace Exiv2 { private: // Pimpl idiom struct Impl; +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr p_; +#else std::auto_ptr p_; +#endif }; // class Xmpdatum diff --git a/src/actions.cpp b/src/actions.cpp index f23448497e..51410d7308 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -223,7 +223,11 @@ namespace Action { Task* t = i->second; return t->clone(); } +#ifdef EXV_NO_AUTO_PTR + return Task::AutoPtr(nullptr); +#else return Task::AutoPtr(0); +#endif } // TaskFactory::create Print::~Print() @@ -1987,7 +1991,7 @@ namespace { if ( bStdin ) Params::instance().getStdin(stdIn); Exiv2::BasicIo::AutoPtr ioStdin = Exiv2::BasicIo::AutoPtr(new Exiv2::MemIo(stdIn.pData_,stdIn.size_)); - Exiv2::Image::AutoPtr sourceImage = bStdin ? Exiv2::ImageFactory::open(ioStdin) : Exiv2::ImageFactory::open(source); + Exiv2::Image::AutoPtr sourceImage = bStdin ? Exiv2::ImageFactory::open(EXV_NO_AUTO_PTR_MOVE(ioStdin)) : Exiv2::ImageFactory::open(source); assert(sourceImage.get() != 0); sourceImage->readMetadata(); diff --git a/src/actions.hpp b/src/actions.hpp index 7bcd8a667f..d5b681ab8b 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -65,7 +65,11 @@ namespace Action { class Task { public: //! Shortcut for an auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! Contructor. Task() : binary_(false) {} //! Virtual destructor. @@ -163,7 +167,11 @@ namespace Action { public: virtual ~Print(); virtual int run(const std::string& path); +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif AutoPtr clone() const; //! Print the Jpeg comment @@ -219,7 +227,11 @@ namespace Action { public: virtual ~Rename(); virtual int run(const std::string& path); +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif AutoPtr clone() const; private: @@ -231,7 +243,11 @@ namespace Action { public: virtual ~Adjust(); virtual int run(const std::string& path); +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif AutoPtr clone() const; private: @@ -254,7 +270,11 @@ namespace Action { public: virtual ~Erase(); virtual int run(const std::string& path); +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif AutoPtr clone() const; /*! @@ -296,7 +316,11 @@ namespace Action { public: virtual ~Extract(); virtual int run(const std::string& path); +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif AutoPtr clone() const; /*! @@ -335,7 +359,11 @@ namespace Action { public: virtual ~Insert(); virtual int run(const std::string& path); +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif AutoPtr clone() const; /*! @@ -376,7 +404,11 @@ namespace Action { public: virtual ~Modify(); virtual int run(const std::string& path); +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif AutoPtr clone() const; Modify() {} //! Apply modification commands to the \em pImage, return 0 if successful. @@ -409,7 +441,11 @@ namespace Action { public: virtual ~FixIso(); virtual int run(const std::string& path); +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif AutoPtr clone() const; private: @@ -427,7 +463,11 @@ namespace Action { public: virtual ~FixCom(); virtual int run(const std::string& path); +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif AutoPtr clone() const; private: diff --git a/src/asfvideo.cpp b/src/asfvideo.cpp index 7f6775266c..108342cc99 100644 --- a/src/asfvideo.cpp +++ b/src/asfvideo.cpp @@ -292,7 +292,7 @@ namespace Exiv2 { using namespace Exiv2::Internal; AsfVideo::AsfVideo(BasicIo::AutoPtr io) - : Image(ImageType::asf, mdNone, io) + : Image(ImageType::asf, mdNone, EXV_NO_AUTO_PTR_MOVE(io)) { } // AsfVideo::AsfVideo @@ -787,7 +787,7 @@ namespace Exiv2 { Image::AutoPtr newAsfInstance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new AsfVideo(io)); + Image::AutoPtr image(new AsfVideo(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); } diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp index fcf9d38a92..0190c0c49e 100644 --- a/src/bmffimage.cpp +++ b/src/bmffimage.cpp @@ -97,7 +97,7 @@ namespace Exiv2 } BmffImage::BmffImage(BasicIo::AutoPtr io, bool /* create */) - : Image(ImageType::bmff, mdExif | mdIptc | mdXmp, io) + : Image(ImageType::bmff, mdExif | mdIptc | mdXmp, EXV_NO_AUTO_PTR_MOVE(io)) , endian_(Exiv2::bigEndian) { pixelWidth_ = 0; @@ -723,7 +723,7 @@ namespace Exiv2 // free functions Image::AutoPtr newBmffInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new BmffImage(io, create)); + Image::AutoPtr image(new BmffImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/src/bmpimage.cpp b/src/bmpimage.cpp index ef82f57e0f..730a74f52c 100644 --- a/src/bmpimage.cpp +++ b/src/bmpimage.cpp @@ -41,7 +41,7 @@ // class member definitions namespace Exiv2 { - BmpImage::BmpImage(BasicIo::AutoPtr io) : Image(ImageType::bmp, mdNone, io) + BmpImage::BmpImage(BasicIo::AutoPtr io) : Image(ImageType::bmp, mdNone, EXV_NO_AUTO_PTR_MOVE(io)) { } @@ -122,7 +122,7 @@ namespace Exiv2 // free functions Image::AutoPtr newBmpInstance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new BmpImage(io)); + Image::AutoPtr image(new BmpImage(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); } diff --git a/src/cr2image.cpp b/src/cr2image.cpp index be4568b863..2f3e53fe5c 100644 --- a/src/cr2image.cpp +++ b/src/cr2image.cpp @@ -47,7 +47,7 @@ namespace Exiv2 { using namespace Internal; Cr2Image::Cr2Image(BasicIo::AutoPtr io, bool /*create*/) - : Image(ImageType::cr2, mdExif | mdIptc | mdXmp, io) + : Image(ImageType::cr2, mdExif | mdIptc | mdXmp, EXV_NO_AUTO_PTR_MOVE(io)) { } // Cr2Image::Cr2Image @@ -183,7 +183,11 @@ namespace Exiv2 { ed.end()); } +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr header(new Cr2Header(byteOrder)); +#else std::auto_ptr header(new Cr2Header(byteOrder)); +#endif OffsetWriter offsetWriter; offsetWriter.setOrigin(OffsetWriter::cr2RawIfdOffset, Cr2Header::offset2addr(), byteOrder); return TiffParserWorker::encode(io, @@ -202,7 +206,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newCr2Instance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new Cr2Image(io, create)); + Image::AutoPtr image(new Cr2Image(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/src/crwimage.cpp b/src/crwimage.cpp index 4bc5b57bfe..22865c8c66 100644 --- a/src/crwimage.cpp +++ b/src/crwimage.cpp @@ -53,7 +53,7 @@ namespace Exiv2 { using namespace Internal; CrwImage::CrwImage(BasicIo::AutoPtr io, bool /*create*/) - : Image(ImageType::crw, mdExif | mdComment, io) + : Image(ImageType::crw, mdExif | mdComment, EXV_NO_AUTO_PTR_MOVE(io)) { } // CrwImage::CrwImage @@ -185,7 +185,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newCrwInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new CrwImage(io, create)); + Image::AutoPtr image(new CrwImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index 2629197851..75dd6cf4be 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -201,7 +201,7 @@ namespace Exiv2 { void CiffComponent::add(AutoPtr component) { - doAdd(component); + doAdd(EXV_NO_AUTO_PTR_MOVE(component)); } void CiffEntry::doAdd(AutoPtr /*component*/) @@ -340,7 +340,7 @@ namespace Exiv2 { } m->setDir(this->tag()); m->read(pData, size, o, byteOrder); - add(m); + add(EXV_NO_AUTO_PTR_MOVE(m)); o += 10; } } // CiffDirectory::readDirectory @@ -712,7 +712,7 @@ namespace Exiv2 { // Directory doesn't exist yet, add it m_ = AutoPtr(new CiffDirectory(csd.crwDir_, csd.parent_)); cc_ = m_.get(); - add(m_); + add(EXV_NO_AUTO_PTR_MOVE(m_)); } // Recursive call to next lower level directory cc_ = cc_->add(crwDirs, crwTagId); @@ -729,7 +729,7 @@ namespace Exiv2 { // Tag doesn't exist yet, add it m_ = AutoPtr(new CiffEntry(crwTagId, tag())); cc_ = m_.get(); - add(m_); + add(EXV_NO_AUTO_PTR_MOVE(m_)); } } return cc_; diff --git a/src/crwimage_int.hpp b/src/crwimage_int.hpp index 8a8dd57c73..332056a962 100644 --- a/src/crwimage_int.hpp +++ b/src/crwimage_int.hpp @@ -84,7 +84,11 @@ namespace Exiv2 { class CiffComponent { public: //! CiffComponent auto_ptr type +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! Container type to hold all metadata typedef std::vector Components; @@ -428,7 +432,11 @@ namespace Exiv2 { class CiffHeader { public: //! CiffHeader auto_ptr type +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ diff --git a/src/epsimage.cpp b/src/epsimage.cpp index 79402e62ee..23123a5523 100644 --- a/src/epsimage.cpp +++ b/src/epsimage.cpp @@ -1076,7 +1076,7 @@ namespace Exiv2 { EpsImage::EpsImage(BasicIo::AutoPtr io, bool create) - : Image(ImageType::eps, mdXmp, io) + : Image(ImageType::eps, mdXmp, EXV_NO_AUTO_PTR_MOVE(io)) { //LogMsg::setLevel(LogMsg::debug); if (create) { @@ -1153,7 +1153,7 @@ namespace Exiv2 // free functions Image::AutoPtr newEpsInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new EpsImage(io, create)); + Image::AutoPtr image(new EpsImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/src/exif.cpp b/src/exif.cpp index 70293f14cc..e8437e4a8c 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -81,7 +81,11 @@ namespace { class Thumbnail { public: //! Shortcut for a %Thumbnail auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Creators //@{ @@ -124,7 +128,11 @@ namespace { class TiffThumbnail : public Thumbnail { public: //! Shortcut for a %TiffThumbnail auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Manipulators //@{ @@ -148,7 +156,11 @@ namespace { class JpegThumbnail : public Thumbnail { public: //! Shortcut for a %JpegThumbnail auto pointer. +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! @name Manipulators //@{ @@ -193,10 +205,15 @@ namespace Exiv2 { template Exiv2::Exifdatum& setValue(Exiv2::Exifdatum& exifDatum, const T& value) { +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr > v + = std::unique_ptr >(new Exiv2::ValueType); +#else std::auto_ptr > v = std::auto_ptr >(new Exiv2::ValueType); +#endif v->value_.push_back(value); - exifDatum.value_ = v; + exifDatum.value_ = EXV_NO_AUTO_PTR_MOVE(v); return exifDatum; } @@ -434,7 +451,11 @@ namespace Exiv2 { Value::AutoPtr Exifdatum::getValue() const { +#ifdef EXV_NO_AUTO_PTR + return value_.get() == 0 ? Value::AutoPtr(nullptr) : value_->clone(); +#else return value_.get() == 0 ? Value::AutoPtr(0) : value_->clone(); +#endif } long Exifdatum::sizeDataArea() const @@ -742,7 +763,11 @@ namespace Exiv2 { // Encode and check if the result fits into a JPEG Exif APP1 segment MemIo mio1; +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr header(new TiffHeader(byteOrder, 0x00000008, false)); +#else std::auto_ptr header(new TiffHeader(byteOrder, 0x00000008, false)); +#endif WriteMethod wm = TiffParserWorker::encode(mio1, pData, size, diff --git a/src/gifimage.cpp b/src/gifimage.cpp index 5f4932bedf..eeeb8f1489 100644 --- a/src/gifimage.cpp +++ b/src/gifimage.cpp @@ -37,7 +37,7 @@ namespace Exiv2 { GifImage::GifImage(BasicIo::AutoPtr io) - : Image(ImageType::gif, mdNone, io) + : Image(ImageType::gif, mdNone, EXV_NO_AUTO_PTR_MOVE(io)) { } // GifImage::GifImage @@ -100,7 +100,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newGifInstance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new GifImage(io)); + Image::AutoPtr image(new GifImage(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); diff --git a/src/image.cpp b/src/image.cpp index c478dcce34..7f48c2e0d4 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -167,7 +167,7 @@ namespace Exiv2 { Image::Image(int imageType, uint16_t supportedMetadata, BasicIo::AutoPtr io) - : io_(io), + : io_(EXV_NO_AUTO_PTR_MOVE(io)), pixelWidth_(0), pixelHeight_(0), imageType_(imageType), @@ -940,7 +940,7 @@ namespace Exiv2 { Image::AutoPtr ImageFactory::open(const byte* data, long size) { BasicIo::AutoPtr io(new MemIo(data, size)); - Image::AutoPtr image = open(io); // may throw + Image::AutoPtr image = open(EXV_NO_AUTO_PTR_MOVE(io)); // may throw if (image.get() == 0) throw Error(kerMemoryContainsUnknownImageType); return image; } @@ -952,7 +952,7 @@ namespace Exiv2 { } for (unsigned int i = 0; registry[i].imageType_ != ImageType::none; ++i) { if (registry[i].isThisType_(*io, false)) { - return registry[i].newInstance_(io, false); + return registry[i].newInstance_(EXV_NO_AUTO_PTR_MOVE(io), false); } } return Image::AutoPtr(); @@ -961,14 +961,18 @@ namespace Exiv2 { Image::AutoPtr ImageFactory::create(int type, const std::string& path) { +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr fileIo(new FileIo(path)); +#else std::auto_ptr fileIo(new FileIo(path)); +#endif // Create or overwrite the file, then close it if (fileIo->open("w+b") != 0) { throw Error(kerFileOpenFailed, path, "w+b", strError()); } fileIo->close(); - BasicIo::AutoPtr io(fileIo); - Image::AutoPtr image = create(type, io); + BasicIo::AutoPtr io(EXV_NO_AUTO_PTR_MOVE(fileIo)); + Image::AutoPtr image = create(type, EXV_NO_AUTO_PTR_MOVE(io)); if (image.get() == 0) throw Error(kerUnsupportedImageType, type); return image; } @@ -977,14 +981,18 @@ namespace Exiv2 { Image::AutoPtr ImageFactory::create(int type, const std::wstring& wpath) { +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr fileIo(new FileIo(wpath)); +#else std::auto_ptr fileIo(new FileIo(wpath)); +#endif // Create or overwrite the file, then close it if (fileIo->open("w+b") != 0) { throw WError(kerFileOpenFailed, wpath, "w+b", strError().c_str()); } fileIo->close(); - BasicIo::AutoPtr io(fileIo); - Image::AutoPtr image = create(type, io); + BasicIo::AutoPtr io(EXV_NO_AUTO_PTR_MOVE(fileIo)); + Image::AutoPtr image = create(type, EXV_NO_AUTO_PTR_MOVE(io)); if (image.get() == 0) throw Error(kerUnsupportedImageType, type); return image; } @@ -993,7 +1001,7 @@ namespace Exiv2 { Image::AutoPtr ImageFactory::create(int type) { BasicIo::AutoPtr io(new MemIo); - Image::AutoPtr image = create(type, io); + Image::AutoPtr image = create(type, EXV_NO_AUTO_PTR_MOVE(io)); if (image.get() == 0) throw Error(kerUnsupportedImageType, type); return image; } @@ -1004,7 +1012,7 @@ namespace Exiv2 { // BasicIo instance does not need to be open const Registry* r = find(registry, type); if (0 != r) { - return r->newInstance_(io, true); + return r->newInstance_(EXV_NO_AUTO_PTR_MOVE(io), true); } return Image::AutoPtr(); } // ImageFactory::create diff --git a/src/iptc.cpp b/src/iptc.cpp index 75024f3212..ad0d221ec1 100644 --- a/src/iptc.cpp +++ b/src/iptc.cpp @@ -201,7 +201,11 @@ namespace Exiv2 { Value::AutoPtr Iptcdatum::getValue() const { +#ifdef EXV_NO_AUTO_PTR + return value_.get() == 0 ? Value::AutoPtr(nullptr) : value_->clone(); +#else return value_.get() == 0 ? Value::AutoPtr(0) : value_->clone(); +#endif } const Value& Iptcdatum::value() const @@ -228,7 +232,7 @@ namespace Exiv2 { { UShortValue::AutoPtr v(new UShortValue); v->value_.push_back(value); - value_ = v; + value_ = EXV_NO_AUTO_PTR_MOVE(v); return *this; } diff --git a/src/jp2image.cpp b/src/jp2image.cpp index eb49d042bc..089fd4fed6 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -84,7 +84,7 @@ const unsigned char Jp2Blank[] = { // class member definitions namespace Exiv2 { - Jp2Image::Jp2Image(BasicIo::AutoPtr io, bool create) : Image(ImageType::jp2, mdExif | mdIptc | mdXmp, io) + Jp2Image::Jp2Image(BasicIo::AutoPtr io, bool create) : Image(ImageType::jp2, mdExif | mdIptc | mdXmp, EXV_NO_AUTO_PTR_MOVE(io)) { if (create) { if (io_->open() == 0) { @@ -952,7 +952,7 @@ namespace Exiv2 // free functions Image::AutoPtr newJp2Instance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new Jp2Image(io, create)); + Image::AutoPtr image(new Jp2Image(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp index c874e72a1b..2486e63ab9 100644 --- a/src/jpgimage.cpp +++ b/src/jpgimage.cpp @@ -318,7 +318,7 @@ namespace Exiv2 { JpegBase::JpegBase(int type, BasicIo::AutoPtr io, bool create, const byte initData[], long dataSize) - : Image(type, mdExif | mdIptc | mdXmp | mdComment, io) + : Image(type, mdExif | mdIptc | mdXmp | mdComment, EXV_NO_AUTO_PTR_MOVE(io)) { if (create) { initImage(initData, dataSize); @@ -1321,7 +1321,7 @@ namespace Exiv2 { 0x11,0x03,0x11,0x00,0x3F,0x00,0xA0,0x00,0x0F,0xFF,0xD9 }; JpegImage::JpegImage(BasicIo::AutoPtr io, bool create) - : JpegBase(ImageType::jpeg, io, create, blank_, sizeof(blank_)) + : JpegBase(ImageType::jpeg, EXV_NO_AUTO_PTR_MOVE(io), create, blank_, sizeof(blank_)) { } @@ -1348,7 +1348,7 @@ namespace Exiv2 { Image::AutoPtr newJpegInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new JpegImage(io, create)); + Image::AutoPtr image(new JpegImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } @@ -1373,7 +1373,7 @@ namespace Exiv2 { const byte ExvImage::blank_[] = { 0xff,0x01,'E','x','i','v','2',0xff,0xd9 }; ExvImage::ExvImage(BasicIo::AutoPtr io, bool create) - : JpegBase(ImageType::exv, io, create, blank_, sizeof(blank_)) + : JpegBase(ImageType::exv, EXV_NO_AUTO_PTR_MOVE(io), create, blank_, sizeof(blank_)) { } @@ -1402,7 +1402,7 @@ namespace Exiv2 { Image::AutoPtr newExvInstance(BasicIo::AutoPtr io, bool create) { Image::AutoPtr image; - image = Image::AutoPtr(new ExvImage(io, create)); + image = Image::AutoPtr(new ExvImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) image.reset(); return image; } diff --git a/src/matroskavideo.cpp b/src/matroskavideo.cpp index b97feb7fd1..72f87424cb 100644 --- a/src/matroskavideo.cpp +++ b/src/matroskavideo.cpp @@ -472,7 +472,7 @@ namespace Exiv2 { using namespace Exiv2::Internal; MatroskaVideo::MatroskaVideo(BasicIo::AutoPtr io) - : Image(ImageType::mkv, mdNone, io) + : Image(ImageType::mkv, mdNone, EXV_NO_AUTO_PTR_MOVE(io)) { } // MatroskaVideo::MatroskaVideo @@ -732,7 +732,7 @@ namespace Exiv2 { Image::AutoPtr newMkvInstance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new MatroskaVideo(io)); + Image::AutoPtr image(new MatroskaVideo(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); } diff --git a/src/mrwimage.cpp b/src/mrwimage.cpp index c837805365..8ba39b2732 100644 --- a/src/mrwimage.cpp +++ b/src/mrwimage.cpp @@ -40,7 +40,7 @@ namespace Exiv2 { MrwImage::MrwImage(BasicIo::AutoPtr io, bool /*create*/) - : Image(ImageType::mrw, mdExif | mdIptc | mdXmp, io) + : Image(ImageType::mrw, mdExif | mdIptc | mdXmp, EXV_NO_AUTO_PTR_MOVE(io)) { } // MrwImage::MrwImage @@ -155,7 +155,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newMrwInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new MrwImage(io, create)); + Image::AutoPtr image(new MrwImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/src/orfimage.cpp b/src/orfimage.cpp index 9835af2723..985f5b876b 100644 --- a/src/orfimage.cpp +++ b/src/orfimage.cpp @@ -44,7 +44,7 @@ namespace Exiv2 { using namespace Internal; OrfImage::OrfImage(BasicIo::AutoPtr io, bool create) - : TiffImage(/*ImageType::orf, mdExif | mdIptc | mdXmp,*/ io,create) + : TiffImage(/*ImageType::orf, mdExif | mdIptc | mdXmp,*/ EXV_NO_AUTO_PTR_MOVE(io),create) { setTypeSupported(ImageType::orf, mdExif | mdIptc | mdXmp); } // OrfImage::OrfImage @@ -189,7 +189,11 @@ namespace Exiv2 { ed.end()); } +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr header(new OrfHeader(byteOrder)); +#else std::auto_ptr header(new OrfHeader(byteOrder)); +#endif return TiffParserWorker::encode(io, pData, size, @@ -206,7 +210,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newOrfInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new OrfImage(io, create)); + Image::AutoPtr image(new OrfImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp index 4dfb948c76..d8ddd2e508 100644 --- a/src/pgfimage.cpp +++ b/src/pgfimage.cpp @@ -77,7 +77,7 @@ namespace Exiv2 { } PgfImage::PgfImage(BasicIo::AutoPtr io, bool create) - : Image(ImageType::pgf, mdExif | mdIptc| mdXmp | mdComment, io) + : Image(ImageType::pgf, mdExif | mdIptc| mdXmp | mdComment, EXV_NO_AUTO_PTR_MOVE(io)) , bSwap_(isBigEndianPlatform()) { if (create) @@ -316,7 +316,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newPgfInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new PgfImage(io, create)); + Image::AutoPtr image(new PgfImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); diff --git a/src/pngimage.cpp b/src/pngimage.cpp index 5363c5645e..dff80310a2 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -74,7 +74,7 @@ namespace Exiv2 { using namespace Internal; PngImage::PngImage(BasicIo::AutoPtr io, bool create) - : Image(ImageType::png, mdExif | mdIptc | mdXmp | mdComment, io) + : Image(ImageType::png, mdExif | mdIptc | mdXmp | mdComment, EXV_NO_AUTO_PTR_MOVE(io)) { if (create) { @@ -745,7 +745,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newPngInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new PngImage(io, create)); + Image::AutoPtr image(new PngImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); diff --git a/src/preview.cpp b/src/preview.cpp index ee9d430c91..1b1a7dcf7a 100644 --- a/src/preview.cpp +++ b/src/preview.cpp @@ -89,7 +89,11 @@ namespace { virtual ~Loader() {} //! Loader auto pointer +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! Create a Loader subclass for requested id static AutoPtr create(PreviewId id, const Image &image); diff --git a/src/psdimage.cpp b/src/psdimage.cpp index 2d1472fc15..67ca5de50f 100644 --- a/src/psdimage.cpp +++ b/src/psdimage.cpp @@ -118,7 +118,7 @@ enum { namespace Exiv2 { PsdImage::PsdImage(BasicIo::AutoPtr io) - : Image(ImageType::psd, mdExif | mdIptc | mdXmp, io) + : Image(ImageType::psd, mdExif | mdIptc | mdXmp, EXV_NO_AUTO_PTR_MOVE(io)) { } // PsdImage::PsdImage @@ -685,7 +685,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newPsdInstance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new PsdImage(io)); + Image::AutoPtr image(new PsdImage(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); diff --git a/src/quicktimevideo.cpp b/src/quicktimevideo.cpp index 335d8848e2..feb81369a3 100644 --- a/src/quicktimevideo.cpp +++ b/src/quicktimevideo.cpp @@ -602,7 +602,7 @@ namespace Exiv2 { using namespace Exiv2::Internal; QuickTimeVideo::QuickTimeVideo(BasicIo::AutoPtr io) - : Image(ImageType::qtime, mdNone, io) + : Image(ImageType::qtime, mdNone, EXV_NO_AUTO_PTR_MOVE(io)) , timeScale_(1) { } // QuickTimeVideo::QuickTimeVideo @@ -1625,7 +1625,7 @@ namespace Exiv2 { Image::AutoPtr newQTimeInstance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new QuickTimeVideo(io)); + Image::AutoPtr image(new QuickTimeVideo(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); } diff --git a/src/rafimage.cpp b/src/rafimage.cpp index 5cec4b9c87..03ca365889 100644 --- a/src/rafimage.cpp +++ b/src/rafimage.cpp @@ -42,7 +42,7 @@ namespace Exiv2 { RafImage::RafImage(BasicIo::AutoPtr io, bool /*create*/) - : Image(ImageType::raf, mdExif | mdIptc | mdXmp, io) + : Image(ImageType::raf, mdExif | mdIptc | mdXmp, EXV_NO_AUTO_PTR_MOVE(io)) { } // RafImage::RafImage @@ -398,7 +398,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newRafInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new RafImage(io, create)); + Image::AutoPtr image(new RafImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/src/riffvideo.cpp b/src/riffvideo.cpp index ad00cf93f8..3357b423e5 100644 --- a/src/riffvideo.cpp +++ b/src/riffvideo.cpp @@ -497,7 +497,7 @@ namespace Exiv2 { using namespace Exiv2::Internal; RiffVideo::RiffVideo(BasicIo::AutoPtr io) - : Image(ImageType::riff, mdNone, io) + : Image(ImageType::riff, mdNone, EXV_NO_AUTO_PTR_MOVE(io)) { } // RiffVideo::RiffVideo @@ -1300,7 +1300,7 @@ namespace Exiv2 { Image::AutoPtr newRiffInstance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new RiffVideo(io)); + Image::AutoPtr image(new RiffVideo(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); } diff --git a/src/rw2image.cpp b/src/rw2image.cpp index 1fdd72e7e5..a99d972227 100644 --- a/src/rw2image.cpp +++ b/src/rw2image.cpp @@ -42,7 +42,7 @@ namespace Exiv2 { using namespace Internal; Rw2Image::Rw2Image(BasicIo::AutoPtr io) - : Image(ImageType::rw2, mdExif | mdIptc | mdXmp, io) + : Image(ImageType::rw2, mdExif | mdIptc | mdXmp, EXV_NO_AUTO_PTR_MOVE(io)) { } // Rw2Image::Rw2Image @@ -240,7 +240,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newRw2Instance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new Rw2Image(io)); + Image::AutoPtr image(new Rw2Image(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); } diff --git a/src/tgaimage.cpp b/src/tgaimage.cpp index 3c012a41a6..3425b2050c 100644 --- a/src/tgaimage.cpp +++ b/src/tgaimage.cpp @@ -37,7 +37,7 @@ namespace Exiv2 { TgaImage::TgaImage(BasicIo::AutoPtr io) - : Image(ImageType::tga, mdNone, io) + : Image(ImageType::tga, mdNone, EXV_NO_AUTO_PTR_MOVE(io)) { } // TgaImage::TgaImage @@ -122,7 +122,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newTgaInstance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new TgaImage(io)); + Image::AutoPtr image(new TgaImage(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index 0d98f77528..2899b6eb7b 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -381,7 +381,7 @@ namespace Exiv2 { } size_ = value->copy(pData_, byteOrder); assert(size_ == newSize); - setValue(value); + setValue(EXV_NO_AUTO_PTR_MOVE(value)); } // TiffEntryBase::updateValue void TiffEntryBase::setValue(Value::AutoPtr value) @@ -620,7 +620,7 @@ namespace Exiv2 { tp->setData(const_cast(pData() + idx), sz); tp->setElDef(def); tp->setElByteOrder(cfg()->byteOrder_); - addChild(tc); + addChild(EXV_NO_AUTO_PTR_MOVE(tc)); return sz; } // TiffBinaryArray::addElement @@ -629,7 +629,7 @@ namespace Exiv2 { TiffComponent* const pRoot, TiffComponent::AutoPtr object) { - return doAddPath(tag, tiffPath, pRoot, object); + return doAddPath(tag, tiffPath, pRoot, EXV_NO_AUTO_PTR_MOVE(object)); } // TiffComponent::addPath TiffComponent* TiffComponent::doAddPath(uint16_t /*tag*/, @@ -671,7 +671,7 @@ namespace Exiv2 { if (tc == 0) { TiffComponent::AutoPtr atc; if (tiffPath.size() == 1 && object.get() != 0) { - atc = object; + atc = EXV_NO_AUTO_PTR_MOVE(object); } else { atc = TiffCreator::create(tpi.extendedTag(), tpi.group()); @@ -683,13 +683,13 @@ namespace Exiv2 { if (tiffPath.size() == 1 && dynamic_cast(atc.get()) != 0) return 0; if (tpi.extendedTag() == Tag::next) { - tc = this->addNext(atc); + tc = this->addNext(EXV_NO_AUTO_PTR_MOVE(atc)); } else { - tc = this->addChild(atc); + tc = this->addChild(EXV_NO_AUTO_PTR_MOVE(atc)); } } - return tc->addPath(tag, tiffPath, pRoot, object); + return tc->addPath(tag, tiffPath, pRoot, EXV_NO_AUTO_PTR_MOVE(object)); } // TiffDirectory::doAddPath TiffComponent* TiffSubIfd::doAddPath(uint16_t tag, @@ -716,15 +716,15 @@ namespace Exiv2 { } if (tc == 0) { if (tiffPath.size() == 1 && object.get() != 0) { - tc = addChild(object); + tc = addChild(EXV_NO_AUTO_PTR_MOVE(object)); } else { TiffComponent::AutoPtr atc(new TiffDirectory(tpi1.tag(), tpi2.group())); - tc = addChild(atc); + tc = addChild(EXV_NO_AUTO_PTR_MOVE(atc)); } setCount(static_cast(ifds_.size())); } - return tc->addPath(tag, tiffPath, pRoot, object); + return tc->addPath(tag, tiffPath, pRoot, EXV_NO_AUTO_PTR_MOVE(object)); } // TiffSubIfd::doAddPath TiffComponent* TiffMnEntry::doAddPath(uint16_t tag, @@ -746,7 +746,7 @@ namespace Exiv2 { mn_ = TiffMnCreator::create(tpi1.tag(), tpi1.group(), mnGroup_); assert(mn_); } - return mn_->addPath(tag, tiffPath, pRoot, object); + return mn_->addPath(tag, tiffPath, pRoot, EXV_NO_AUTO_PTR_MOVE(object)); } // TiffMnEntry::doAddPath TiffComponent* TiffIfdMakernote::doAddPath(uint16_t tag, @@ -754,7 +754,7 @@ namespace Exiv2 { TiffComponent* const pRoot, TiffComponent::AutoPtr object) { - return ifd_.addPath(tag, tiffPath, pRoot, object); + return ifd_.addPath(tag, tiffPath, pRoot, EXV_NO_AUTO_PTR_MOVE(object)); } TiffComponent* TiffBinaryArray::doAddPath(uint16_t tag, @@ -786,22 +786,22 @@ namespace Exiv2 { if (tc == 0) { TiffComponent::AutoPtr atc; if (tiffPath.size() == 1 && object.get() != 0) { - atc = object; + atc = EXV_NO_AUTO_PTR_MOVE(object); } else { atc = TiffCreator::create(tpi.extendedTag(), tpi.group()); } assert(atc.get() != 0); assert(tpi.extendedTag() != Tag::next); - tc = addChild(atc); + tc = addChild(EXV_NO_AUTO_PTR_MOVE(atc)); setCount(static_cast(elements_.size())); } - return tc->addPath(tag, tiffPath, pRoot, object); + return tc->addPath(tag, tiffPath, pRoot, EXV_NO_AUTO_PTR_MOVE(object)); } // TiffBinaryArray::doAddPath TiffComponent* TiffComponent::addChild(TiffComponent::AutoPtr tiffComponent) { - return doAddChild(tiffComponent); + return doAddChild(EXV_NO_AUTO_PTR_MOVE(tiffComponent)); } // TiffComponent::addChild TiffComponent* TiffComponent::doAddChild(AutoPtr /*tiffComponent*/) @@ -828,14 +828,14 @@ namespace Exiv2 { { TiffComponent* tc = 0; if (mn_) { - tc = mn_->addChild(tiffComponent); + tc = mn_->addChild(EXV_NO_AUTO_PTR_MOVE(tiffComponent)); } return tc; } // TiffMnEntry::doAddChild TiffComponent* TiffIfdMakernote::doAddChild(TiffComponent::AutoPtr tiffComponent) { - return ifd_.addChild(tiffComponent); + return ifd_.addChild(EXV_NO_AUTO_PTR_MOVE(tiffComponent)); } TiffComponent* TiffBinaryArray::doAddChild(TiffComponent::AutoPtr tiffComponent) @@ -848,7 +848,7 @@ namespace Exiv2 { TiffComponent* TiffComponent::addNext(TiffComponent::AutoPtr tiffComponent) { - return doAddNext(tiffComponent); + return doAddNext(EXV_NO_AUTO_PTR_MOVE(tiffComponent)); } // TiffComponent::addNext TiffComponent* TiffComponent::doAddNext(AutoPtr /*tiffComponent*/) @@ -870,14 +870,14 @@ namespace Exiv2 { { TiffComponent* tc = 0; if (mn_) { - tc = mn_->addNext(tiffComponent); + tc = mn_->addNext(EXV_NO_AUTO_PTR_MOVE(tiffComponent)); } return tc; } // TiffMnEntry::doAddNext TiffComponent* TiffIfdMakernote::doAddNext(TiffComponent::AutoPtr tiffComponent) { - return ifd_.addNext(tiffComponent); + return ifd_.addNext(EXV_NO_AUTO_PTR_MOVE(tiffComponent)); } void TiffComponent::accept(TiffVisitor& visitor) diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index f19026ee62..db13058f39 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -171,7 +171,11 @@ namespace Exiv2 { class TiffComponent { public: //! TiffComponent auto_ptr type +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr AutoPtr; +#else typedef std::auto_ptr AutoPtr; +#endif //! Container type to hold all metadata typedef std::vector Components; @@ -197,10 +201,17 @@ namespace Exiv2 { @return A pointer to the newly added TIFF entry. */ +#ifdef EXV_NO_AUTO_PTR + TiffComponent* addPath(uint16_t tag, + TiffPath& tiffPath, + TiffComponent* const pRoot, + AutoPtr object = nullptr); +#else TiffComponent* addPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot, AutoPtr object =AutoPtr(0)); +#endif /*! @brief Add a child to the component. Default is to do nothing. @param tiffComponent Auto pointer to the component to add. diff --git a/src/tifffwd_int.hpp b/src/tifffwd_int.hpp index 46a390a863..c3169f832d 100644 --- a/src/tifffwd_int.hpp +++ b/src/tifffwd_int.hpp @@ -98,7 +98,11 @@ namespace Exiv2 { Use TiffComponent::AutoPtr, it is not used in this declaration only to reduce dependencies. */ +#ifdef EXV_NO_AUTO_PTR + typedef std::unique_ptr (*NewTiffCompFct)(uint16_t tag, IfdId group); +#else typedef std::auto_ptr (*NewTiffCompFct)(uint16_t tag, IfdId group); +#endif //! Stack to hold a path from the TIFF root element to a TIFF entry typedef std::stack TiffPath; diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index aff87feb0d..f2fe4cd501 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -68,7 +68,7 @@ namespace Exiv2 { using namespace Internal; TiffImage::TiffImage(BasicIo::AutoPtr io, bool /*create*/) - : Image(ImageType::tiff, mdExif | mdIptc | mdXmp, io), + : Image(ImageType::tiff, mdExif | mdIptc | mdXmp, EXV_NO_AUTO_PTR_MOVE(io)), pixelWidth_(0), pixelHeight_(0) { } // TiffImage::TiffImage @@ -302,7 +302,11 @@ namespace Exiv2 { ed.end()); } +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr header(new TiffHeader(byteOrder)); +#else std::auto_ptr header(new TiffHeader(byteOrder)); +#endif return TiffParserWorker::encode(io, pData, size, @@ -319,7 +323,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newTiffInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new TiffImage(io, create)); + Image::AutoPtr image(new TiffImage(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/src/tiffimage_int.cpp b/src/tiffimage_int.cpp index e6f70208ae..a778bacdbb 100644 --- a/src/tiffimage_int.cpp +++ b/src/tiffimage_int.cpp @@ -1675,7 +1675,11 @@ namespace Exiv2 { TiffComponent::AutoPtr TiffCreator::create(uint32_t extendedTag, IfdId group) { +#ifdef EXV_NO_AUTO_PTR + TiffComponent::AutoPtr tc(nullptr); +#else TiffComponent::AutoPtr tc(0); +#endif uint16_t tag = static_cast(extendedTag & 0xffff); const TiffGroupStruct* ts = find(tiffGroupStruct_, TiffGroupStruct::Key(extendedTag, group)); @@ -1726,11 +1730,19 @@ namespace Exiv2 { ) { // Create standard TIFF header if necessary +#ifdef EXV_NO_AUTO_PTR + std::unique_ptr ph; + if (!pHeader) { + ph = std::unique_ptr(new TiffHeader); + pHeader = ph.get(); + } +#else std::auto_ptr ph; if (!pHeader) { ph = std::auto_ptr(new TiffHeader); pHeader = ph.get(); } +#endif TiffComponent::AutoPtr rootDir = parse(pData, size, root, pHeader); if (0 != rootDir.get()) { TiffDecoder decoder(exifData, @@ -1833,7 +1845,11 @@ namespace Exiv2 { TiffHeaderBase* pHeader ) { +#ifdef EXV_NO_AUTO_PTR + if (pData == 0 || size == 0) return TiffComponent::AutoPtr(nullptr); +#else if (pData == 0 || size == 0) return TiffComponent::AutoPtr(0); +#endif if (!pHeader->read(pData, size) || pHeader->offset() >= size) { throw Error(kerNotAnImage, "TIFF"); } diff --git a/src/tiffimage_int.hpp b/src/tiffimage_int.hpp index d564f3a021..1c7b54cf02 100644 --- a/src/tiffimage_int.hpp +++ b/src/tiffimage_int.hpp @@ -249,8 +249,13 @@ namespace Exiv2 { component creation function. If the pointer that is returned is 0, then the TIFF entry should be ignored. */ +#ifdef EXV_NO_AUTO_PTR + static std::unique_ptr create(uint32_t extendedTag, + IfdId group); +#else static std::auto_ptr create(uint32_t extendedTag, IfdId group); +#endif /*! @brief Get the path, i.e., a list of extended tag and group pairs, from the \em root TIFF element to the TIFF entry \em extendedTag and @@ -342,12 +347,21 @@ namespace Exiv2 { composite structure. If \em pData is 0 or \em size is 0, the return value is a 0 pointer. */ +#ifdef EXV_NO_AUTO_PTR + static std::unique_ptr parse( + const byte* pData, + uint32_t size, + uint32_t root, + TiffHeaderBase* pHeader + ); +#else static std::auto_ptr parse( const byte* pData, uint32_t size, uint32_t root, TiffHeaderBase* pHeader ); +#endif /*! @brief Find primary groups in the source tree provided and populate the list of primary groups. diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 16264e56c9..49f316f518 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -214,7 +214,7 @@ namespace Exiv2 { // Assumption is that the corresponding TIFF entry doesn't exist TiffPath tiffPath; TiffCreator::getPath(tiffPath, object->tag(), object->group(), root_); - pRoot_->addPath(object->tag(), tiffPath, pRoot_, clone); + pRoot_->addPath(object->tag(), tiffPath, pRoot_, EXV_NO_AUTO_PTR_MOVE(clone)); #ifdef EXIV2_DEBUG_MESSAGES ExifKey key(object->tag(), groupName(object->group())); std::cerr << "Copied " << key << "\n"; @@ -1371,7 +1371,7 @@ namespace Exiv2 { TiffComponent::AutoPtr tc = TiffCreator::create(tag, object->group()); if (tc.get()) { tc->setStart(p); - object->addChild(tc); + object->addChild(EXV_NO_AUTO_PTR_MOVE(tc)); } else { EXV_WARNING << "Unable to handle tag " << tag << ".\n"; } @@ -1386,7 +1386,11 @@ namespace Exiv2 { #endif return; } +#ifdef EXV_NO_AUTO_PTR + TiffComponent::AutoPtr tc(nullptr); +#else TiffComponent::AutoPtr tc(0); +#endif uint32_t next = getLong(p, byteOrder()); if (next) { tc = TiffCreator::create(Tag::next, object->group()); @@ -1406,7 +1410,7 @@ namespace Exiv2 { return; } tc->setStart(pData_ + baseOffset() + next); - object->addNext(tc); + object->addNext(EXV_NO_AUTO_PTR_MOVE(tc)); } } // object->hasNext() @@ -1448,7 +1452,7 @@ namespace Exiv2 { TiffComponent::AutoPtr td(new TiffDirectory(object->tag(), static_cast(object->newGroup_ + i))); td->setStart(pData_ + baseOffset() + offset); - object->addChild(td); + object->addChild(EXV_NO_AUTO_PTR_MOVE(td)); } } #ifndef SUPPRESS_WARNINGS @@ -1642,7 +1646,7 @@ namespace Exiv2 { enforce(v.get() != NULL, kerCorruptedMetadata); v->read(pData, size, byteOrder()); - object->setValue(v); + object->setValue(EXV_NO_AUTO_PTR_MOVE(v)); object->setData(pData, size); object->setOffset(offset); object->setIdx(nextIdx(object->group())); @@ -1740,7 +1744,7 @@ namespace Exiv2 { enforce(v.get() != NULL, kerCorruptedMetadata); v->read(pData, size, bo); - object->setValue(v); + object->setValue(EXV_NO_AUTO_PTR_MOVE(v)); object->setOffset(0); object->setIdx(nextIdx(object->group())); diff --git a/src/webpimage.cpp b/src/webpimage.cpp index 3eb9dfa78d..b86719a5a2 100644 --- a/src/webpimage.cpp +++ b/src/webpimage.cpp @@ -69,7 +69,7 @@ namespace Exiv2 { } WebPImage::WebPImage(BasicIo::AutoPtr io) - : Image(ImageType::webp, mdNone, io) + : Image(ImageType::webp, mdNone, EXV_NO_AUTO_PTR_MOVE(io)) { } // WebPImage::WebPImage @@ -733,7 +733,7 @@ namespace Exiv2 { Image::AutoPtr newWebPInstance(BasicIo::AutoPtr io, bool /*create*/) { - Image::AutoPtr image(new WebPImage(io)); + Image::AutoPtr image(new WebPImage(EXV_NO_AUTO_PTR_MOVE(io))); if (!image->good()) { image.reset(); } diff --git a/src/xmp.cpp b/src/xmp.cpp index 94a8ed44de..fd613460b9 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -421,7 +421,11 @@ namespace Exiv2 { Value::AutoPtr Xmpdatum::getValue() const { +#ifdef EXV_NO_AUTO_PTR + return p_->value_.get() == 0 ? Value::AutoPtr(nullptr) : p_->value_->clone(); +#else return p_->value_.get() == 0 ? Value::AutoPtr(0) : p_->value_->clone(); +#endif } const Value& Xmpdatum::value() const diff --git a/src/xmpsidecar.cpp b/src/xmpsidecar.cpp index d9d5e090f8..f18f5394a9 100644 --- a/src/xmpsidecar.cpp +++ b/src/xmpsidecar.cpp @@ -46,7 +46,7 @@ namespace Exiv2 { XmpSidecar::XmpSidecar(BasicIo::AutoPtr io, bool create) - : Image(ImageType::xmp, mdXmp, io) + : Image(ImageType::xmp, mdXmp, EXV_NO_AUTO_PTR_MOVE(io)) { if (create) { if (io_->open() == 0) { @@ -193,7 +193,7 @@ namespace Exiv2 { // free functions Image::AutoPtr newXmpInstance(BasicIo::AutoPtr io, bool create) { - Image::AutoPtr image(new XmpSidecar(io, create)); + Image::AutoPtr image(new XmpSidecar(EXV_NO_AUTO_PTR_MOVE(io), create)); if (!image->good()) { image.reset(); } diff --git a/xmpsdk/src/MD5.cpp b/xmpsdk/src/MD5.cpp index f162b728f5..d65e8669ee 100644 --- a/xmpsdk/src/MD5.cpp +++ b/xmpsdk/src/MD5.cpp @@ -153,7 +153,11 @@ MD5Final(md5byte digest[16], struct MD5_CTX *ctx) void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]) { +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) + UWORD32 a, b, c, d; +#else register UWORD32 a, b, c, d; +#endif a = buf[0]; b = buf[1];