# HG changeset patch # User Sebastien Jodogne # Date 1583159565 -3600 # Node ID 2a170a8f1faf08e9f5310f2f3791705ca7deeef0 # Parent 1f4910999fe799f7a908823647c7a5c4f7b332ff replacing std::auto_ptr by std::unique_ptr diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Cache/MemoryCache.cpp --- a/Core/Cache/MemoryCache.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/Cache/MemoryCache.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -62,7 +62,7 @@ } // Create a new cache page - std::auto_ptr result(new Page); + std::unique_ptr result(new Page); result->id_ = id; result->content_.reset(provider_.Provide(id)); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Cache/MemoryCache.h --- a/Core/Cache/MemoryCache.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/Cache/MemoryCache.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,9 +33,11 @@ #pragma once -#include +#include "../Compatibility.h" +#include "ICachePageProvider.h" #include "LeastRecentlyUsedIndex.h" -#include "ICachePageProvider.h" + +#include namespace Orthanc { @@ -50,7 +52,7 @@ struct Page { std::string id_; - std::auto_ptr content_; + std::unique_ptr content_; }; ICachePageProvider& provider_; diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Cache/MemoryObjectCache.cpp --- a/Core/Cache/MemoryObjectCache.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/Cache/MemoryObjectCache.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,8 @@ #include "../PrecompiledHeaders.h" #include "MemoryObjectCache.h" +#include "../Compatibility.h" + namespace Orthanc { class MemoryObjectCache::Item : public boost::noncopyable @@ -142,7 +144,7 @@ void MemoryObjectCache::Acquire(const std::string& key, ICacheable* value) { - std::auto_ptr item(new Item(value)); + std::unique_ptr item(new Item(value)); if (value == NULL) { diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Compatibility.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Core/Compatibility.h Mon Mar 02 15:32:45 2020 +0100 @@ -0,0 +1,66 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2020 Osimis S.A., Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + **/ + + +#pragma once + +#if __cplusplus < 201103L +/** + * "std::unique_ptr" was introduced in C++11, and "std::auto_ptr" was + * removed in C++17. We emulate "std::auto_ptr" using boost: "The + * smart pointer unique_ptr [is] a drop-in replacement for + * std::unique_ptr, usable also from C++03 compilers." This is only + * available if Boost >= 1.57.0 (from November 2014). + * https://www.boost.org/doc/libs/1_57_0/doc/html/move/reference.html#header.boost.move.unique_ptr_hpp + **/ + +#include + +namespace std +{ + template + class unique_ptr : public boost::movelib::unique_ptr + { + public: + unique_ptr() : + boost::movelib::unique_ptr() + { + } + + unique_ptr(T* p) : + boost::movelib::unique_ptr(p) + { + } + }; +} + +#endif diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomFormat/DicomImageInformation.cpp --- a/Core/DicomFormat/DicomImageInformation.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomFormat/DicomImageInformation.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -39,6 +39,7 @@ #include "DicomImageInformation.h" +#include "../Compatibility.h" #include "../OrthancException.h" #include "../Toolbox.h" #include @@ -223,7 +224,7 @@ DicomImageInformation* DicomImageInformation::Clone() const { - std::auto_ptr target(new DicomImageInformation); + std::unique_ptr target(new DicomImageInformation); target->width_ = width_; target->height_ = height_; target->samplesPerPixel_ = samplesPerPixel_; diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomFormat/DicomMap.cpp --- a/Core/DicomFormat/DicomMap.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomFormat/DicomMap.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -37,6 +37,7 @@ #include #include +#include "../Compatibility.h" #include "../Endianness.h" #include "../Logging.h" #include "../OrthancException.h" @@ -300,7 +301,7 @@ DicomMap* DicomMap::Clone() const { - std::auto_ptr result(new DicomMap); + std::unique_ptr result(new DicomMap); for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it) { @@ -1165,7 +1166,7 @@ throw OrthancException(ErrorCode_BadFileFormat); } - std::auto_ptr value(new DicomValue); + std::unique_ptr value(new DicomValue); value->Unserialize(source[tags[i]]); content_[tag] = value.release(); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomNetworking/DicomFindAnswers.cpp --- a/Core/DicomNetworking/DicomFindAnswers.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomNetworking/DicomFindAnswers.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -46,7 +46,7 @@ { void DicomFindAnswers::AddAnswerInternal(ParsedDicomFile* answer) { - std::auto_ptr protection(answer); + std::unique_ptr protection(answer); if (isWorklist_) { @@ -166,7 +166,7 @@ DcmDataset& source = *GetAnswer(index).GetDcmtkObject().getDataset(); - std::auto_ptr target(new DcmDataset); + std::unique_ptr target(new DcmDataset); for (unsigned long i = 0; i < source.card(); i++) { diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomNetworking/DicomServer.cpp --- a/Core/DicomNetworking/DicomServer.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomNetworking/DicomServer.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -53,7 +53,7 @@ { boost::thread thread_; T_ASC_Network *network_; - std::auto_ptr workers_; + std::unique_ptr workers_; }; @@ -65,7 +65,7 @@ { /* receive an association and acknowledge or reject it. If the association was */ /* acknowledged, offer corresponding services and invoke one or more if required. */ - std::auto_ptr dispatcher(Internals::AcceptAssociation(*server, server->pimpl_->network_)); + std::unique_ptr dispatcher(Internals::AcceptAssociation(*server, server->pimpl_->network_)); try { diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomNetworking/DicomUserConnection.cpp --- a/Core/DicomNetworking/DicomUserConnection.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomNetworking/DicomUserConnection.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -584,7 +584,7 @@ case ModalityManufacturer_GenericNoWildcardInDates: case ModalityManufacturer_GenericNoUniversalWildcard: { - std::auto_ptr fix(fields.Clone()); + std::unique_ptr fix(fields.Clone()); std::set tags; fix->GetTags(tags); @@ -699,7 +699,7 @@ { CheckIsOpen(); - std::auto_ptr query; + std::unique_ptr query; if (normalize) { @@ -812,7 +812,7 @@ { CheckIsOpen(); - std::auto_ptr query(ConvertQueryFields(fields, manufacturer_)); + std::unique_ptr query(ConvertQueryFields(fields, manufacturer_)); DcmDataset* dataset = query->GetDcmtkObject().getDataset(); const char* sopClass = UID_MOVEStudyRootQueryRetrieveInformationModel; diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomNetworking/Internals/CommandDispatcher.cpp --- a/Core/DicomNetworking/Internals/CommandDispatcher.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomNetworking/Internals/CommandDispatcher.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -90,6 +90,7 @@ #include "FindScp.h" #include "StoreScp.h" #include "MoveScp.h" +#include "../../Compatibility.h" #include "../../Toolbox.h" #include "../../Logging.h" @@ -738,7 +739,7 @@ case DicomRequestType_Store: if (server_.HasStoreRequestHandlerFactory()) // Should always be true { - std::auto_ptr handler + std::unique_ptr handler (server_.GetStoreRequestHandlerFactory().ConstructStoreRequestHandler()); if (handler.get() != NULL) @@ -751,7 +752,7 @@ case DicomRequestType_Move: if (server_.HasMoveRequestHandlerFactory()) // Should always be true { - std::auto_ptr handler + std::unique_ptr handler (server_.GetMoveRequestHandlerFactory().ConstructMoveRequestHandler()); if (handler.get() != NULL) @@ -765,13 +766,13 @@ if (server_.HasFindRequestHandlerFactory() || // Should always be true server_.HasWorklistRequestHandlerFactory()) { - std::auto_ptr findHandler; + std::unique_ptr findHandler; if (server_.HasFindRequestHandlerFactory()) { findHandler.reset(server_.GetFindRequestHandlerFactory().ConstructFindRequestHandler()); } - std::auto_ptr worklistHandler; + std::unique_ptr worklistHandler; if (server_.HasWorklistRequestHandlerFactory()) { worklistHandler.reset(server_.GetWorklistRequestHandlerFactory().ConstructWorklistRequestHandler()); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomNetworking/Internals/MoveScp.cpp --- a/Core/DicomNetworking/Internals/MoveScp.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomNetworking/Internals/MoveScp.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -114,7 +114,7 @@ unsigned int subOperationCount_; unsigned int failureCount_; unsigned int warningCount_; - std::auto_ptr iterator_; + std::unique_ptr iterator_; const std::string* remoteIp_; const std::string* remoteAet_; const std::string* calledAet_; diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomNetworking/TimeoutDicomConnectionManager.h --- a/Core/DicomNetworking/TimeoutDicomConnectionManager.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomNetworking/TimeoutDicomConnectionManager.h Mon Mar 02 15:32:45 2020 +0100 @@ -63,6 +63,8 @@ #else +#include "../Compatibility.h" + #include namespace Orthanc @@ -72,9 +74,9 @@ private: class Resource; - std::auto_ptr connection_; - boost::posix_time::ptime lastUse_; - boost::posix_time::time_duration timeout_; + std::unique_ptr connection_; + boost::posix_time::ptime lastUse_; + boost::posix_time::time_duration timeout_; void Touch(); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomParsing/DicomDirWriter.cpp --- a/Core/DicomParsing/DicomDirWriter.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomParsing/DicomDirWriter.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -104,6 +104,7 @@ #include "FromDcmtkBridge.h" #include "ToDcmtkBridge.h" +#include "../Compatibility.h" #include "../Logging.h" #include "../OrthancException.h" #include "../TemporaryFile.h" @@ -132,7 +133,7 @@ std::string fileSetId_; bool extendedSopClass_; TemporaryFile file_; - std::auto_ptr dir_; + std::unique_ptr dir_; typedef std::pair IndexKey; typedef std::map Index; @@ -466,7 +467,7 @@ return false; // Already existing } - std::auto_ptr record(new DcmDirectoryRecord(type, NULL, filename)); + std::unique_ptr record(new DcmDirectoryRecord(type, NULL, filename)); switch (level) { diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomParsing/DicomModification.cpp --- a/Core/DicomParsing/DicomModification.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomParsing/DicomModification.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,13 +34,14 @@ #include "../PrecompiledHeaders.h" #include "DicomModification.h" +#include "../Compatibility.h" #include "../Logging.h" #include "../OrthancException.h" #include "../SerializationToolbox.h" #include "FromDcmtkBridge.h" #include "ITagVisitor.h" -#include // For std::auto_ptr +#include // For std::unique_ptr static const std::string ORTHANC_DEIDENTIFICATION_METHOD_2008 = @@ -317,7 +318,7 @@ void DicomModification::MapDicomTags(ParsedDicomFile& dicom, ResourceType level) { - std::auto_ptr tag; + std::unique_ptr tag; switch (level) { diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomParsing/FromDcmtkBridge.cpp --- a/Core/DicomParsing/FromDcmtkBridge.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomParsing/FromDcmtkBridge.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -47,6 +47,7 @@ #include "FromDcmtkBridge.h" #include "ToDcmtkBridge.h" +#include "../Compatibility.h" #include "../Logging.h" #include "../Toolbox.h" #include "../OrthancException.h" @@ -351,7 +352,7 @@ << name << " (multiplicity: " << minMultiplicity << "-" << (arbitrary ? "n" : boost::lexical_cast(maxMultiplicity)) << ")"; - std::auto_ptr entry; + std::unique_ptr entry; if (privateCreator.empty()) { if (tag.GetGroup() % 2 == 1) @@ -885,7 +886,7 @@ if (element.isLeaf()) { // The "0" below lets "LeafValueToJson()" take care of "TooLong" values - std::auto_ptr v(FromDcmtkBridge::ConvertLeafElement + std::unique_ptr v(FromDcmtkBridge::ConvertLeafElement (element, flags, 0, encoding, hasCodeExtensions, ignoreTagLength)); if (ignoreTagLength.find(GetTag(element)) == ignoreTagLength.end()) @@ -1632,7 +1633,7 @@ Encoding dicomEncoding, const std::string& privateCreator) { - std::auto_ptr element; + std::unique_ptr element; switch (value.type()) { @@ -1659,7 +1660,7 @@ for (Json::Value::ArrayIndex i = 0; i < value.size(); i++) { - std::auto_ptr item(new DcmItem); + std::unique_ptr item(new DcmItem); switch (value[i].type()) { @@ -1780,7 +1781,7 @@ Encoding defaultEncoding, const std::string& privateCreator) { - std::auto_ptr result(new DcmDataset); + std::unique_ptr result(new DcmDataset); Encoding encoding = ExtractEncoding(json, defaultEncoding); SetString(*result, DCM_SpecificCharacterSet, GetDicomSpecificCharacterSet(encoding)); @@ -1816,7 +1817,7 @@ if (tag != DICOM_TAG_SPECIFIC_CHARACTER_SET) { - std::auto_ptr element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding, privateCreator)); + std::unique_ptr element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding, privateCreator)); const DcmTagKey& tag = element->getTag(); result->findAndDeleteElement(tag); @@ -1868,7 +1869,7 @@ } is.setEos(); - std::auto_ptr result(new DcmFileFormat); + std::unique_ptr result(new DcmFileFormat); result->transferInit(); if (!result->read(is).good()) diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomParsing/Internals/DicomFrameIndex.h --- a/Core/DicomParsing/Internals/DicomFrameIndex.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomParsing/Internals/DicomFrameIndex.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #pragma once +#include "../../Compatibility.h" #include "../../Enumerations.h" #include @@ -62,8 +63,8 @@ class UncompressedIndex; class PsmctRle1Index; - std::auto_ptr index_; - unsigned int countFrames_; + std::unique_ptr index_; + unsigned int countFrames_; public: DicomFrameIndex(DcmFileFormat& dicom); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomParsing/Internals/DicomImageDecoder.cpp --- a/Core/DicomParsing/Internals/DicomImageDecoder.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomParsing/Internals/DicomImageDecoder.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -249,7 +249,7 @@ { private: std::string psmct_; - std::auto_ptr slowAccessor_; + std::unique_ptr slowAccessor_; public: void Setup(DcmDataset& dataset, @@ -388,7 +388,7 @@ } - static ImageAccessor* DecodeLookupTable(std::auto_ptr& target, + static ImageAccessor* DecodeLookupTable(std::unique_ptr& target, const DicomImageInformation& info, DcmDataset& dataset, const uint8_t* pixelData, @@ -508,7 +508,7 @@ * Create the target image. **/ - std::auto_ptr target(CreateImage(dataset, false)); + std::unique_ptr target(CreateImage(dataset, false)); ImageSource source; source.Setup(dataset, frame); @@ -616,7 +616,7 @@ FromDcmtkBridge::ExtractDicomSummary(m, dataset); DicomImageInformation info(m); - std::auto_ptr target(CreateImage(dataset, true)); + std::unique_ptr target(CreateImage(dataset, true)); Uint32 startFragment = 0; // Default OFString decompressedColorModel; // Out @@ -692,7 +692,7 @@ DJLSRepresentationParameter representationParameter(2, OFTrue); DJLSCodecParameter parameters; - std::auto_ptr decoder; + std::unique_ptr decoder; switch (syntax) { @@ -734,7 +734,7 @@ EUC_default, // Mode for UID creation, unused for decompression EPC_default); // Automatically determine whether color-by-plane is required from the SOP Class UID and decompressed photometric interpretation DJ_RPLossy representationParameter; - std::auto_ptr decoder; + std::unique_ptr decoder; switch (syntax) { @@ -799,7 +799,7 @@ { LOG(INFO) << "Decoding a compressed image by converting its transfer syntax to Little Endian"; - std::auto_ptr converted(dynamic_cast(dataset.clone())); + std::unique_ptr converted(dynamic_cast(dataset.clone())); converted->chooseRepresentation(EXS_LittleEndianExplicit, NULL); if (converted->canWriteXfer(EXS_LittleEndianExplicit)) @@ -820,7 +820,7 @@ } - bool DicomImageDecoder::TruncateDecodedImage(std::auto_ptr& image, + bool DicomImageDecoder::TruncateDecodedImage(std::unique_ptr& image, PixelFormat format, bool allowColorConversion) { @@ -840,17 +840,22 @@ if (image->GetFormat() != format) { // A conversion is required - std::auto_ptr target + std::unique_ptr target (new Image(format, image->GetWidth(), image->GetHeight(), false)); ImageProcessing::Convert(*target, *image); - image = target; + +#if __cplusplus < 201103L + image.reset(target.release()); +#else + image = std::move(target); +#endif } return true; } - bool DicomImageDecoder::PreviewDecodedImage(std::auto_ptr& image) + bool DicomImageDecoder::PreviewDecodedImage(std::unique_ptr& image) { switch (image->GetFormat()) { @@ -862,10 +867,16 @@ case PixelFormat_RGB48: { - std::auto_ptr target + std::unique_ptr target (new Image(PixelFormat_RGB24, image->GetWidth(), image->GetHeight(), false)); ImageProcessing::Convert(*target, *image); - image = target; + +#if __cplusplus < 201103L + image.reset(target.release()); +#else + image = std::move(target); +#endif + return true; } @@ -891,10 +902,15 @@ // If the source image is not grayscale 8bpp, convert it if (image->GetFormat() != PixelFormat_Grayscale8) { - std::auto_ptr target + std::unique_ptr target (new Image(PixelFormat_Grayscale8, image->GetWidth(), image->GetHeight(), false)); ImageProcessing::Convert(*target, *image); - image = target; + +#if __cplusplus < 201103L + image.reset(target.release()); +#else + image = std::move(target); +#endif } return true; @@ -906,7 +922,7 @@ } - void DicomImageDecoder::ApplyExtractionMode(std::auto_ptr& image, + void DicomImageDecoder::ApplyExtractionMode(std::unique_ptr& image, ImageExtractionMode mode, bool invert) { @@ -956,7 +972,7 @@ void DicomImageDecoder::ExtractPamImage(std::string& result, - std::auto_ptr& image, + std::unique_ptr& image, ImageExtractionMode mode, bool invert) { @@ -968,7 +984,7 @@ #if ORTHANC_ENABLE_PNG == 1 void DicomImageDecoder::ExtractPngImage(std::string& result, - std::auto_ptr& image, + std::unique_ptr& image, ImageExtractionMode mode, bool invert) { @@ -982,7 +998,7 @@ #if ORTHANC_ENABLE_JPEG == 1 void DicomImageDecoder::ExtractJpegImage(std::string& result, - std::auto_ptr& image, + std::unique_ptr& image, ImageExtractionMode mode, bool invert, uint8_t quality) diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomParsing/Internals/DicomImageDecoder.h --- a/Core/DicomParsing/Internals/DicomImageDecoder.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomParsing/Internals/DicomImageDecoder.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #pragma once +#include "../../Compatibility.h" #include "../ParsedDicomFile.h" #include @@ -82,13 +83,13 @@ DcmDataset& dataset, unsigned int frame); - static bool TruncateDecodedImage(std::auto_ptr& image, + static bool TruncateDecodedImage(std::unique_ptr& image, PixelFormat format, bool allowColorConversion); - static bool PreviewDecodedImage(std::auto_ptr& image); + static bool PreviewDecodedImage(std::unique_ptr& image); - static void ApplyExtractionMode(std::auto_ptr& image, + static void ApplyExtractionMode(std::unique_ptr& image, ImageExtractionMode mode, bool invert); @@ -102,20 +103,20 @@ unsigned int frame); static void ExtractPamImage(std::string& result, - std::auto_ptr& image, + std::unique_ptr& image, ImageExtractionMode mode, bool invert); #if ORTHANC_ENABLE_PNG == 1 static void ExtractPngImage(std::string& result, - std::auto_ptr& image, + std::unique_ptr& image, ImageExtractionMode mode, bool invert); #endif #if ORTHANC_ENABLE_JPEG == 1 static void ExtractJpegImage(std::string& result, - std::auto_ptr& image, + std::unique_ptr& image, ImageExtractionMode mode, bool invert, uint8_t quality); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomParsing/ParsedDicomDir.cpp --- a/Core/DicomParsing/ParsedDicomDir.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomParsing/ParsedDicomDir.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #include "../PrecompiledHeaders.h" #include "ParsedDicomDir.h" +#include "../Compatibility.h" #include "../OrthancException.h" #include "ParsedDicomFile.h" #include "FromDcmtkBridge.h" @@ -119,7 +120,7 @@ nextOffsets_[i] = next; lowerOffsets_[i] = lower; - std::auto_ptr entry(new DicomMap); + std::unique_ptr entry(new DicomMap); FromDcmtkBridge::ExtractDicomSummary(*entry, *item); if (next != 0) diff -r 1f4910999fe7 -r 2a170a8f1faf Core/DicomParsing/ParsedDicomFile.cpp --- a/Core/DicomParsing/ParsedDicomFile.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/DicomParsing/ParsedDicomFile.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -156,8 +156,8 @@ { struct ParsedDicomFile::PImpl { - std::auto_ptr file_; - std::auto_ptr frameIndex_; + std::unique_ptr file_; + std::unique_ptr frameIndex_; }; @@ -649,7 +649,7 @@ bool hasCodeExtensions; Encoding encoding = DetectEncoding(hasCodeExtensions); - std::auto_ptr element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding, privateCreator)); + std::unique_ptr element(FromDcmtkBridge::FromJson(tag, value, decodeDataUriScheme, encoding, privateCreator)); InsertInternal(*pimpl_->file_->getDataset(), element.release()); } @@ -798,7 +798,7 @@ } } - std::auto_ptr element(FromDcmtkBridge::CreateElementForTag(tag, privateCreator)); + std::unique_ptr element(FromDcmtkBridge::CreateElementForTag(tag, privateCreator)); if (!utf8Value.empty()) { @@ -921,9 +921,9 @@ Encoding encoding = DetectEncoding(hasCodeExtensions); std::set tmp; - std::auto_ptr v(FromDcmtkBridge::ConvertLeafElement - (*element, DicomToJsonFlags_Default, - 0, encoding, hasCodeExtensions, tmp)); + std::unique_ptr v(FromDcmtkBridge::ConvertLeafElement + (*element, DicomToJsonFlags_Default, + 0, encoding, hasCodeExtensions, tmp)); if (v.get() == NULL || v->IsNull()) @@ -1309,7 +1309,7 @@ DcmTag key(DICOM_TAG_PIXEL_DATA.GetGroup(), DICOM_TAG_PIXEL_DATA.GetElement()); - std::auto_ptr pixels(new DcmPixelData(key)); + std::unique_ptr pixels(new DcmPixelData(key)); unsigned int pitch = accessor.GetWidth() * bytesPerPixel; Uint8* target = NULL; @@ -1444,7 +1444,7 @@ ReplacePlainString(FromDcmtkBridge::Convert(DCM_MIMETypeOfEncapsulatedDocument), MIME_PDF); //ReplacePlainString(FromDcmtkBridge::Convert(DCM_SeriesNumber), "1"); - std::auto_ptr element(new DcmPolymorphOBOW(DCM_EncapsulatedDocument)); + std::unique_ptr element(new DcmPolymorphOBOW(DCM_EncapsulatedDocument)); size_t s = pdf.size(); if (s & 1) @@ -1519,7 +1519,7 @@ const bool generateIdentifiers = (flags & DicomFromJsonFlags_GenerateIdentifiers) ? true : false; const bool decodeDataUriScheme = (flags & DicomFromJsonFlags_DecodeDataUriScheme) ? true : false; - std::auto_ptr result(new ParsedDicomFile(generateIdentifiers)); + std::unique_ptr result(new ParsedDicomFile(generateIdentifiers)); result->SetEncoding(FromDcmtkBridge::ExtractEncoding(json, GetDefaultDicomEncoding())); const Json::Value::Members tags = json.getMemberNames(); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/FileStorage/StorageAccessor.cpp --- a/Core/FileStorage/StorageAccessor.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/FileStorage/StorageAccessor.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #include "../PrecompiledHeaders.h" #include "StorageAccessor.h" +#include "../Compatibility.h" #include "../Compression/ZlibCompressor.h" #include "../MetricsRegistry.h" #include "../OrthancException.h" @@ -54,7 +55,7 @@ class StorageAccessor::MetricsTimer : public boost::noncopyable { private: - std::auto_ptr timer_; + std::unique_ptr timer_; public: MetricsTimer(StorageAccessor& that, diff -r 1f4910999fe7 -r 2a170a8f1faf Core/HttpServer/EmbeddedResourceHttpHandler.h --- a/Core/HttpServer/EmbeddedResourceHttpHandler.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/HttpServer/EmbeddedResourceHttpHandler.h Mon Mar 02 15:32:45 2020 +0100 @@ -51,7 +51,7 @@ const std::string& baseUri, EmbeddedResources::DirectoryResourceId resourceId); - virtual bool CreateChunkedRequestReader(std::auto_ptr& target, + virtual bool CreateChunkedRequestReader(std::unique_ptr& target, RequestOrigin origin, const char* remoteIp, const char* username, diff -r 1f4910999fe7 -r 2a170a8f1faf Core/HttpServer/FilesystemHttpHandler.h --- a/Core/HttpServer/FilesystemHttpHandler.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/HttpServer/FilesystemHttpHandler.h Mon Mar 02 15:32:45 2020 +0100 @@ -53,7 +53,7 @@ FilesystemHttpHandler(const std::string& baseUri, const std::string& root); - virtual bool CreateChunkedRequestReader(std::auto_ptr& target, + virtual bool CreateChunkedRequestReader(std::unique_ptr& target, RequestOrigin origin, const char* remoteIp, const char* username, diff -r 1f4910999fe7 -r 2a170a8f1faf Core/HttpServer/HttpContentNegociation.cpp --- a/Core/HttpServer/HttpContentNegociation.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/HttpServer/HttpContentNegociation.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -170,18 +170,22 @@ } - void HttpContentNegociation::SelectBestMatch(std::auto_ptr& best, + void HttpContentNegociation::SelectBestMatch(std::unique_ptr& best, const Handler& handler, const std::string& type, const std::string& subtype, float quality) { - std::auto_ptr match(new Reference(handler, type, subtype, quality)); + std::unique_ptr match(new Reference(handler, type, subtype, quality)); if (best.get() == NULL || *best < *match) { - best = match; +#if __cplusplus < 201103L + best.reset(match.release()); +#else + best = std::move(match); +#endif } } @@ -227,7 +231,7 @@ Tokens mediaRanges; Toolbox::TokenizeString(mediaRanges, accept, ','); - std::auto_ptr bestMatch; + std::unique_ptr bestMatch; for (Tokens::const_iterator it = mediaRanges.begin(); it != mediaRanges.end(); ++it) diff -r 1f4910999fe7 -r 2a170a8f1faf Core/HttpServer/HttpContentNegociation.h --- a/Core/HttpServer/HttpContentNegociation.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/HttpServer/HttpContentNegociation.h Mon Mar 02 15:32:45 2020 +0100 @@ -32,6 +32,8 @@ #pragma once +#include "../Compatibility.h" + #include #include #include @@ -95,7 +97,7 @@ static float GetQuality(const Tokens& parameters); - static void SelectBestMatch(std::auto_ptr& best, + static void SelectBestMatch(std::unique_ptr& best, const Handler& handler, const std::string& type, const std::string& subtype, diff -r 1f4910999fe7 -r 2a170a8f1faf Core/HttpServer/HttpServer.cpp --- a/Core/HttpServer/HttpServer.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/HttpServer/HttpServer.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -853,7 +853,7 @@ if (!isMultipartForm) { - std::auto_ptr stream; + std::unique_ptr stream; if (server.HasHandler()) { diff -r 1f4910999fe7 -r 2a170a8f1faf Core/HttpServer/HttpStreamTranscoder.h --- a/Core/HttpServer/HttpStreamTranscoder.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/HttpServer/HttpStreamTranscoder.h Mon Mar 02 15:32:45 2020 +0100 @@ -35,7 +35,9 @@ #include "BufferHttpSender.h" -#include // For std::auto_ptr +#include "../Compatibility.h" + +#include // For std::unique_ptr namespace Orthanc { @@ -49,7 +51,7 @@ uint64_t currentChunkOffset_; bool ready_; - std::auto_ptr uncompressed_; + std::unique_ptr uncompressed_; void ReadSource(std::string& buffer); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/HttpServer/IHttpHandler.h --- a/Core/HttpServer/IHttpHandler.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/HttpServer/IHttpHandler.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #pragma once +#include "../Compatibility.h" #include "../Toolbox.h" #include "HttpOutput.h" @@ -73,7 +74,7 @@ * This function allows to deal with chunked transfers (new in * Orthanc 1.5.7). It is only called if "method" is POST or PUT. **/ - virtual bool CreateChunkedRequestReader(std::auto_ptr& target, + virtual bool CreateChunkedRequestReader(std::unique_ptr& target, RequestOrigin origin, const char* remoteIp, const char* username, diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Images/Font.cpp --- a/Core/Images/Font.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/Images/Font.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -103,7 +103,7 @@ throw OrthancException(ErrorCode_BadFont); } - std::auto_ptr c(new Character); + std::unique_ptr c(new Character); c->advance_ = info["Advance"].asUInt(); c->height_ = info["Height"].asUInt(); @@ -407,7 +407,7 @@ unsigned int width, height; ComputeTextExtent(width, height, utf8); - std::auto_ptr target(new Image(format, width, height, false)); + std::unique_ptr target(new Image(format, width, height, false)); ImageProcessing::Set(*target, 0, 0, 0, 255); Draw(*target, utf8, 0, 0, r, g, b); @@ -420,7 +420,7 @@ unsigned int width, height; ComputeTextExtent(width, height, utf8); - std::auto_ptr target(new Image(PixelFormat_Grayscale8, width, height, false)); + std::unique_ptr target(new Image(PixelFormat_Grayscale8, width, height, false)); ImageProcessing::Set(*target, 0); Draw(*target, utf8, 0, 0, 255); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Images/FontRegistry.cpp --- a/Core/Images/FontRegistry.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/Images/FontRegistry.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -51,7 +51,7 @@ void FontRegistry::AddFromMemory(const std::string& font) { - std::auto_ptr f(new Font); + std::unique_ptr f(new Font); f->LoadFromMemory(font); fonts_.push_back(f.release()); } @@ -60,7 +60,7 @@ #if ORTHANC_SANDBOXED == 0 void FontRegistry::AddFromFile(const std::string& path) { - std::auto_ptr f(new Font); + std::unique_ptr f(new Font); f->LoadFromFile(path); fonts_.push_back(f.release()); } diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Images/Image.cpp --- a/Core/Images/Image.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/Images/Image.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #include "Image.h" +#include "../Compatibility.h" #include "ImageProcessing.h" #include @@ -54,7 +55,7 @@ Image* Image::Clone(const ImageAccessor& source) { - std::auto_ptr target(new Image(source.GetFormat(), source.GetWidth(), source.GetHeight(), false)); + std::unique_ptr target(new Image(source.GetFormat(), source.GetWidth(), source.GetHeight(), false)); ImageProcessing::Copy(*target, source); return target.release(); } diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Images/ImageProcessing.cpp --- a/Core/Images/ImageProcessing.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/Images/ImageProcessing.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -2058,8 +2058,8 @@ ImageAccessor* ImageProcessing::Halve(const ImageAccessor& source, bool forceMinimalPitch) { - std::auto_ptr target(new Image(source.GetFormat(), source.GetWidth() / 2, - source.GetHeight() / 2, forceMinimalPitch)); + std::unique_ptr target(new Image(source.GetFormat(), source.GetWidth() / 2, + source.GetHeight() / 2, forceMinimalPitch)); Resize(*target, source); return target.release(); } @@ -2459,7 +2459,7 @@ unsigned int width, unsigned int height) { - std::auto_ptr target(new Image(source.GetFormat(), width, height, false)); + std::unique_ptr target(new Image(source.GetFormat(), width, height, false)); FitSize(*target, source); return target.release(); } diff -r 1f4910999fe7 -r 2a170a8f1faf Core/JobsEngine/JobsEngine.h --- a/Core/JobsEngine/JobsEngine.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/JobsEngine/JobsEngine.h Mon Mar 02 15:32:45 2020 +0100 @@ -35,6 +35,8 @@ #include "JobsRegistry.h" +#include "../Compatibility.h" + #include namespace Orthanc @@ -52,7 +54,7 @@ boost::mutex stateMutex_; State state_; - std::auto_ptr registry_; + std::unique_ptr registry_; boost::thread retryHandler_; unsigned int threadSleep_; std::vector workers_; diff -r 1f4910999fe7 -r 2a170a8f1faf Core/JobsEngine/JobsRegistry.cpp --- a/Core/JobsEngine/JobsRegistry.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/JobsEngine/JobsRegistry.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -58,7 +58,7 @@ std::string id_; JobState state_; std::string jobType_; - std::auto_ptr job_; + std::unique_ptr job_; int priority_; // "+inf()" means highest priority boost::posix_time::ptime creationTime_; boost::posix_time::ptime lastStateChangeTime_; @@ -669,7 +669,7 @@ throw OrthancException(ErrorCode_NullPointer); } - std::auto_ptr protection(handler); + std::unique_ptr protection(handler); { boost::mutex::scoped_lock lock(mutex_); @@ -1396,7 +1396,7 @@ for (Json::Value::Members::const_iterator it = members.begin(); it != members.end(); ++it) { - std::auto_ptr job; + std::unique_ptr job; try { diff -r 1f4910999fe7 -r 2a170a8f1faf Core/JobsEngine/Operations/JobOperationValues.cpp --- a/Core/JobsEngine/Operations/JobOperationValues.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/JobsEngine/Operations/JobOperationValues.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -129,7 +129,7 @@ throw OrthancException(ErrorCode_BadFileFormat); } - std::auto_ptr result(new JobOperationValues); + std::unique_ptr result(new JobOperationValues); result->Reserve(source.size()); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp --- a/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -56,12 +56,12 @@ class SequenceOfOperationsJob::Operation : public boost::noncopyable { private: - size_t index_; - std::auto_ptr operation_; - std::auto_ptr originalInputs_; - std::auto_ptr workInputs_; - std::list nextOperations_; - size_t currentInput_; + size_t index_; + std::unique_ptr operation_; + std::unique_ptr originalInputs_; + std::unique_ptr workInputs_; + std::list nextOperations_; + size_t currentInput_; public: Operation(size_t index, diff -r 1f4910999fe7 -r 2a170a8f1faf Core/JobsEngine/SetOfCommandsJob.cpp --- a/Core/JobsEngine/SetOfCommandsJob.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/JobsEngine/SetOfCommandsJob.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -250,7 +250,7 @@ const Json::Value& source) : started_(false) { - std::auto_ptr raii(unserializer); + std::unique_ptr raii(unserializer); permissive_ = SerializationToolbox::ReadBoolean(source, KEY_PERMISSIVE); position_ = SerializationToolbox::ReadUnsignedInteger(source, KEY_POSITION); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Logging.cpp --- a/Core/Logging.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/Logging.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -315,6 +315,7 @@ * behavior from Google Log. *********************************************************/ +#include "Compatibility.h" #include "OrthancException.h" #include "Enumerations.h" #include "Toolbox.h" @@ -344,7 +345,7 @@ std::ostream* warning_; std::ostream* info_; - std::auto_ptr file_; + std::unique_ptr file_; LoggingContext() : infoEnabled_(false), @@ -372,7 +373,7 @@ -static std::auto_ptr loggingContext_; +static std::unique_ptr loggingContext_; static boost::mutex loggingMutex_; @@ -424,7 +425,7 @@ } - static void PrepareLogFolder(std::auto_ptr& file, + static void PrepareLogFolder(std::unique_ptr& file, const std::string& suffix, const std::string& directory) { @@ -455,7 +456,7 @@ void Reset() { // Recover the old logging context - std::auto_ptr old; + std::unique_ptr old; { boost::mutex::scoped_lock lock(loggingMutex_); @@ -465,7 +466,11 @@ } else { - old = loggingContext_; +#if __cplusplus < 201103L + old.reset(loggingContext_.release()); +#else + old = std::move(loggingContext_); +#endif // Create a new logging context, loggingContext_.reset(new LoggingContext); @@ -512,7 +517,7 @@ if (!memento->valid_) throw std::runtime_error("Memento already used"); memento->valid_ = false; - std::auto_ptr deleter(memento); + std::unique_ptr deleter(memento); { boost::mutex::scoped_lock lock(loggingMutex_); loggingContext_.reset(new LoggingContext); @@ -584,7 +589,7 @@ } - static void CheckFile(std::auto_ptr& f) + static void CheckFile(std::unique_ptr& f) { if (loggingContext_->file_.get() == NULL || !loggingContext_->file_->is_open()) @@ -783,7 +788,14 @@ std::ostream* infoStream) { boost::mutex::scoped_lock lock(loggingMutex_); - std::auto_ptr old = loggingContext_; + std::unique_ptr old; + +#if __cplusplus < 201103L + old.reset(loggingContext_.release()); +#else + old = std::move(loggingContext_); +#endif + loggingContext_.reset(new LoggingContext); loggingContext_->error_ = errorStream; loggingContext_->warning_ = warningStream; @@ -797,15 +809,15 @@ FuncStreamBuf globalEmscriptenErrorStreamBuf(emscripten_console_error); - std::auto_ptr globalEmscriptenErrorStream; + std::unique_ptr globalEmscriptenErrorStream; FuncStreamBuf globalEmscriptenWarningStreamBuf(emscripten_console_warn); - std::auto_ptr globalEmscriptenWarningStream; + std::unique_ptr globalEmscriptenWarningStream; FuncStreamBuf globalEmscriptenInfoStreamBuf(emscripten_console_log); - std::auto_ptr globalEmscriptenInfoStream; + std::unique_ptr globalEmscriptenInfoStream; void EnableEmscriptenLogging() { diff -r 1f4910999fe7 -r 2a170a8f1faf Core/MetricsRegistry.cpp --- a/Core/MetricsRegistry.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/MetricsRegistry.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,8 +34,9 @@ #include "PrecompiledHeaders.h" #include "MetricsRegistry.h" +#include "ChunkedBuffer.h" +#include "Compatibility.h" #include "OrthancException.h" -#include "ChunkedBuffer.h" namespace Orthanc { @@ -228,7 +229,7 @@ if (found == content_.end()) { - std::auto_ptr item(new Item(type)); + std::unique_ptr item(new Item(type)); item->Update(value); content_[name] = item.release(); } diff -r 1f4910999fe7 -r 2a170a8f1faf Core/MultiThreading/RunnableWorkersPool.cpp --- a/Core/MultiThreading/RunnableWorkersPool.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/MultiThreading/RunnableWorkersPool.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -35,6 +35,7 @@ #include "RunnableWorkersPool.h" #include "SharedMessageQueue.h" +#include "../Compatibility.h" #include "../OrthancException.h" #include "../Logging.h" @@ -55,7 +56,7 @@ { try { - std::auto_ptr obj(that->queue_.Dequeue(100)); + std::unique_ptr obj(that->queue_.Dequeue(100)); if (obj.get() != NULL) { IRunnableBySteps& runnable = *dynamic_cast(obj.get()); diff -r 1f4910999fe7 -r 2a170a8f1faf Core/MultiThreading/SharedMessageQueue.cpp --- a/Core/MultiThreading/SharedMessageQueue.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/MultiThreading/SharedMessageQueue.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -35,6 +35,8 @@ #include "SharedMessageQueue.h" +#include "../Compatibility.h" + /** * FIFO (queue): @@ -137,7 +139,7 @@ } } - std::auto_ptr message(queue_.front()); + std::unique_ptr message(queue_.front()); queue_.pop_front(); if (queue_.empty()) @@ -199,7 +201,7 @@ { while (!queue_.empty()) { - std::auto_ptr message(queue_.front()); + std::unique_ptr message(queue_.front()); queue_.pop_front(); } diff -r 1f4910999fe7 -r 2a170a8f1faf Core/OrthancException.h --- a/Core/OrthancException.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/OrthancException.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #pragma once +#include "Compatibility.h" #include "Enumerations.h" #include "Logging.h" @@ -53,7 +54,7 @@ HttpStatus httpStatus_; // New in Orthanc 1.5.0 - std::auto_ptr details_; + std::unique_ptr details_; public: OrthancException(const OrthancException& other) : diff -r 1f4910999fe7 -r 2a170a8f1faf Core/PrecompiledHeaders.h --- a/Core/PrecompiledHeaders.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/PrecompiledHeaders.h Mon Mar 02 15:32:45 2020 +0100 @@ -39,11 +39,11 @@ #if ORTHANC_USE_PRECOMPILED_HEADERS == 1 -#include -#include +//#include +//#include #include -#include -#include +//#include +//#include #include #include @@ -53,6 +53,7 @@ # include #endif +#include "../Core/Compatibility.h" #include "Enumerations.h" #include "Logging.h" #include "OrthancException.h" diff -r 1f4910999fe7 -r 2a170a8f1faf Core/RestApi/RestApi.h --- a/Core/RestApi/RestApi.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/RestApi/RestApi.h Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #pragma once #include "RestApiHierarchy.h" +#include "../Compatibility.h" #include @@ -47,7 +48,7 @@ public: static void AutoListChildren(RestApiGetCall& call); - virtual bool CreateChunkedRequestReader(std::auto_ptr& target, + virtual bool CreateChunkedRequestReader(std::unique_ptr& target, RequestOrigin origin, const char* remoteIp, const char* username, diff -r 1f4910999fe7 -r 2a170a8f1faf Core/Toolbox.cpp --- a/Core/Toolbox.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Core/Toolbox.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #include "PrecompiledHeaders.h" #include "Toolbox.h" +#include "Compatibility.h" #include "OrthancException.h" #include "Logging.h" @@ -1434,7 +1435,7 @@ #if ORTHANC_ENABLE_LOCALE == 1 - static std::auto_ptr globalLocale_; + static std::unique_ptr globalLocale_; static bool SetGlobalLocale(const char* locale) { diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/Database/Compatibility/SetOfResources.cpp --- a/OrthancServer/Database/Compatibility/SetOfResources.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/Database/Compatibility/SetOfResources.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -55,7 +55,7 @@ } else { - std::auto_ptr filtered(new Resources); + std::unique_ptr filtered(new Resources); for (std::list::const_iterator it = resources.begin(); it != resources.end(); ++it) @@ -66,7 +66,11 @@ } } - resources_ = filtered; +#if __cplusplus < 201103L + resources_.reset(filtered.release()); +#else + resources_ = std::move(filtered); +#endif } } @@ -80,7 +84,7 @@ if (resources_.get() != NULL) { - std::auto_ptr children(new Resources); + std::unique_ptr children(new Resources); for (Resources::const_iterator it = resources_->begin(); it != resources_->end(); ++it) @@ -95,7 +99,11 @@ } } - resources_ = children; +#if __cplusplus < 201103L + resources_.reset(children.release()); +#else + resources_ = std::move(children); +#endif } switch (level_) diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/Database/Compatibility/SetOfResources.h --- a/OrthancServer/Database/Compatibility/SetOfResources.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/Database/Compatibility/SetOfResources.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #pragma once +#include "../../../Core/Compatibility.h" #include "../IDatabaseWrapper.h" #include "ILookupResources.h" @@ -48,9 +49,9 @@ private: typedef std::set Resources; - IDatabaseWrapper& database_; - ResourceType level_; - std::auto_ptr resources_; + IDatabaseWrapper& database_; + ResourceType level_; + std::unique_ptr resources_; public: SetOfResources(IDatabaseWrapper& database, diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/Database/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/Database/SQLiteDatabaseWrapper.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/Database/SQLiteDatabaseWrapper.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -583,9 +583,9 @@ class SQLiteDatabaseWrapper::Transaction : public IDatabaseWrapper::ITransaction { private: - SQLiteDatabaseWrapper& that_; - std::auto_ptr transaction_; - int64_t initialDiskSize_; + SQLiteDatabaseWrapper& that_; + std::unique_ptr transaction_; + int64_t initialDiskSize_; public: Transaction(SQLiteDatabaseWrapper& that) : @@ -1181,7 +1181,7 @@ resourcesId.clear(); instancesId.clear(); - std::auto_ptr statement; + std::unique_ptr statement; switch (level) { diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/DicomInstanceToStore.cpp --- a/OrthancServer/DicomInstanceToStore.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/DicomInstanceToStore.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -157,7 +157,7 @@ MetadataMap metadata_; private: - std::auto_ptr hasher_; + std::unique_ptr hasher_; void ComputeMissingInformation() { diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/LuaScripting.cpp --- a/OrthancServer/LuaScripting.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/LuaScripting.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -610,7 +610,7 @@ if (operation == "modify") { - std::auto_ptr modification(new DicomModification); + std::unique_ptr modification(new DicomModification); modification->ParseModifyRequest(parameters); return lock.AddModifyInstanceOperation(context_, modification.release()); @@ -749,7 +749,7 @@ { for (;;) { - std::auto_ptr event(that->pendingEvents_.Dequeue(100)); + std::unique_ptr event(that->pendingEvents_.Dequeue(100)); if (event.get() == NULL) { diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/OrthancFindRequestHandler.cpp --- a/OrthancServer/OrthancFindRequestHandler.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/OrthancFindRequestHandler.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -273,7 +273,7 @@ throw OrthancException(ErrorCode_UnknownResource); // The resource was deleted in between } - std::auto_ptr result(new DicomMap); + std::unique_ptr result(new DicomMap); switch (level) { @@ -537,7 +537,7 @@ const DicomMap& mainDicomTags, const Json::Value* dicomAsJson) { - std::auto_ptr counters(ComputeCounters(context_, instanceId, level_, query_)); + std::unique_ptr counters(ComputeCounters(context_, instanceId, level_, query_)); AddAnswer(answers_, mainDicomTags, dicomAsJson, queryAsArray_, sequencesToReturn_, counters.get()); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/OrthancHttpHandler.cpp --- a/OrthancServer/OrthancHttpHandler.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/OrthancHttpHandler.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -40,7 +40,7 @@ namespace Orthanc { bool OrthancHttpHandler::CreateChunkedRequestReader( - std::auto_ptr& target, + std::unique_ptr& target, RequestOrigin origin, const char* remoteIp, const char* username, diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/OrthancHttpHandler.h --- a/OrthancServer/OrthancHttpHandler.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/OrthancHttpHandler.h Mon Mar 02 15:32:45 2020 +0100 @@ -50,7 +50,7 @@ { } - virtual bool CreateChunkedRequestReader(std::auto_ptr& target, + virtual bool CreateChunkedRequestReader(std::unique_ptr& target, RequestOrigin origin, const char* remoteIp, const char* username, diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/OrthancMoveRequestHandler.cpp --- a/OrthancServer/OrthancMoveRequestHandler.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/OrthancMoveRequestHandler.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -59,7 +59,7 @@ RemoteModalityParameters remote_; std::string originatorAet_; uint16_t originatorId_; - std::auto_ptr connection_; + std::unique_ptr connection_; public: SynchronousMove(ServerContext& context, @@ -126,10 +126,10 @@ class AsynchronousMove : public IMoveRequestIterator { private: - ServerContext& context_; - std::auto_ptr job_; - size_t position_; - size_t countInstances_; + ServerContext& context_; + std::unique_ptr job_; + size_t position_; + size_t countInstances_; public: AsynchronousMove(ServerContext& context, diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -116,7 +116,7 @@ { std::string id = call.GetUriComponent("id", ""); - std::auto_ptr modified; + std::unique_ptr modified; { ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id); @@ -169,7 +169,7 @@ } - static void SubmitModificationJob(std::auto_ptr& modification, + static void SubmitModificationJob(std::unique_ptr& modification, bool isAnonymization, RestApiPostCall& call, const Json::Value& body, @@ -177,7 +177,7 @@ { ServerContext& context = OrthancRestApi::GetContext(call); - std::auto_ptr job(new ResourceModificationJob(context)); + std::unique_ptr job(new ResourceModificationJob(context)); job->SetModification(modification.release(), level, isAnonymization); job->SetOrigin(call); @@ -192,7 +192,7 @@ template static void ModifyResource(RestApiPostCall& call) { - std::auto_ptr modification(new DicomModification); + std::unique_ptr modification(new DicomModification); Json::Value body; ParseModifyRequest(body, *modification, call); @@ -207,7 +207,7 @@ template static void AnonymizeResource(RestApiPostCall& call) { - std::auto_ptr modification(new DicomModification); + std::unique_ptr modification(new DicomModification); Json::Value body; ParseAnonymizationRequest(body, *modification, call); @@ -343,7 +343,7 @@ { for (Json::ArrayIndex i = 0; i < content.size(); i++) { - std::auto_ptr dicom(base.Clone(false)); + std::unique_ptr dicom(base.Clone(false)); const Json::Value* payload = NULL; if (content[i].type() == Json::stringValue) @@ -668,7 +668,7 @@ const std::string study = call.GetUriComponent("id", ""); - std::auto_ptr job(new SplitStudyJob(context, study)); + std::unique_ptr job(new SplitStudyJob(context, study)); job->SetOrigin(call); std::vector series; @@ -751,7 +751,7 @@ const std::string study = call.GetUriComponent("id", ""); - std::auto_ptr job(new MergeStudyJob(context, study)); + std::unique_ptr job(new MergeStudyJob(context, study)); job->SetOrigin(call); std::vector resources; diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -254,7 +254,7 @@ bool synchronous, int priority) { - std::auto_ptr raii(job); + std::unique_ptr raii(job); if (job == NULL) { @@ -290,7 +290,7 @@ bool isDefaultSynchronous, const Json::Value& body) const { - std::auto_ptr raii(job); + std::unique_ptr raii(job); if (body.type() != Json::objectValue) { @@ -309,7 +309,7 @@ bool isDefaultSynchronous, const Json::Value& body) const { - std::auto_ptr raii(job); + std::unique_ptr raii(job); if (body.type() != Json::objectValue) { diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/OrthancRestApi/OrthancRestArchive.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -123,7 +123,7 @@ static void SubmitJob(RestApiOutput& output, ServerContext& context, - std::auto_ptr& job, + std::unique_ptr& job, int priority, bool synchronous, const std::string& filename) @@ -179,7 +179,7 @@ int priority; GetJobParameters(synchronous, extended, priority, body, DEFAULT_IS_EXTENDED); - std::auto_ptr job(new ArchiveJob(context, IS_MEDIA, extended)); + std::unique_ptr job(new ArchiveJob(context, IS_MEDIA, extended)); AddResourcesOfInterest(*job, body); SubmitJob(call.GetOutput(), context, job, priority, synchronous, "Archive.zip"); } @@ -209,7 +209,7 @@ extended = false; } - std::auto_ptr job(new ArchiveJob(context, IS_MEDIA, extended)); + std::unique_ptr job(new ArchiveJob(context, IS_MEDIA, extended)); job->AddResource(id); SubmitJob(call.GetOutput(), context, job, 0 /* priority */, @@ -232,7 +232,7 @@ int priority; GetJobParameters(synchronous, extended, priority, body, DEFAULT_IS_EXTENDED); - std::auto_ptr job(new ArchiveJob(context, IS_MEDIA, extended)); + std::unique_ptr job(new ArchiveJob(context, IS_MEDIA, extended)); job->AddResource(id); SubmitJob(call.GetOutput(), context, job, priority, synchronous, id + ".zip"); } diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -416,7 +416,7 @@ ***************************************************************************/ static void AnswerQueryHandler(RestApiPostCall& call, - std::auto_ptr& handler) + std::unique_ptr& handler) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -466,7 +466,7 @@ } else { - std::auto_ptr handler(new QueryRetrieveHandler(context)); + std::unique_ptr handler(new QueryRetrieveHandler(context)); handler->SetModality(call.GetUriComponent("id", "")); handler->SetLevel(StringToResourceType(request[KEY_LEVEL].asCString())); @@ -618,7 +618,7 @@ call.BodyToString(targetAet); } - std::auto_ptr job(new DicomMoveScuJob(context)); + std::unique_ptr job(new DicomMoveScuJob(context)); { QueryAccessor query(call); @@ -744,7 +744,7 @@ ServerContext& context = OrthancRestApi::GetContext(call); - std::auto_ptr handler(new QueryRetrieveHandler(context)); + std::unique_ptr handler(new QueryRetrieveHandler(context)); { const QueryAccessor parent(call); @@ -944,7 +944,7 @@ std::string remote = call.GetUriComponent("id", ""); Json::Value request; - std::auto_ptr job(new DicomModalityStoreJob(context)); + std::unique_ptr job(new DicomModalityStoreJob(context)); GetInstancesToExport(request, *job, remote, call); @@ -1084,7 +1084,7 @@ std::string remote = call.GetUriComponent("id", ""); Json::Value request; - std::auto_ptr job(new OrthancPeerStoreJob(context)); + std::unique_ptr job(new OrthancPeerStoreJob(context)); GetInstancesToExport(request, *job, remote, call); @@ -1276,7 +1276,7 @@ RemoteModalityParameters remote = MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); - std::auto_ptr query + std::unique_ptr query (ParsedDicomFile::CreateFromJson(json, static_cast(0), "" /* no private creator */)); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -388,14 +388,14 @@ class ImageToEncode { private: - std::auto_ptr& image_; + std::unique_ptr& image_; ImageExtractionMode mode_; bool invert_; MimeType format_; std::string answer_; public: - ImageToEncode(std::auto_ptr& image, + ImageToEncode(std::unique_ptr& image, ImageExtractionMode mode, bool invert) : image_(image), @@ -518,7 +518,7 @@ } virtual void Handle(RestApiGetCall& call, - std::auto_ptr& decoded, + std::unique_ptr& decoded, const DicomMap& dicom) = 0; virtual bool RequiresDicomTags() const = 0; @@ -541,7 +541,7 @@ } DicomMap dicom; - std::auto_ptr decoded; + std::unique_ptr decoded; try { @@ -613,7 +613,7 @@ static void DefaultHandler(RestApiGetCall& call, - std::auto_ptr& decoded, + std::unique_ptr& decoded, ImageExtractionMode mode, bool invert) { @@ -649,7 +649,7 @@ } virtual void Handle(RestApiGetCall& call, - std::auto_ptr& decoded, + std::unique_ptr& decoded, const DicomMap& dicom) ORTHANC_OVERRIDE { bool invert = false; @@ -817,7 +817,7 @@ public: virtual void Handle(RestApiGetCall& call, - std::auto_ptr& decoded, + std::unique_ptr& decoded, const DicomMap& dicom) ORTHANC_OVERRIDE { bool invert; @@ -865,7 +865,7 @@ } else { - std::auto_ptr resized( + std::unique_ptr resized( new Image(decoded->GetFormat(), targetWidth, targetHeight, false)); if (smooth && @@ -901,7 +901,7 @@ const float scaling = 255.0f * rescaleSlope / windowWidth; const float offset = (rescaleIntercept - windowCenter + windowWidth / 2.0f) / rescaleSlope; - std::auto_ptr rescaled(new Image(PixelFormat_Grayscale8, decoded->GetWidth(), decoded->GetHeight(), false)); + std::unique_ptr rescaled(new Image(PixelFormat_Grayscale8, decoded->GetWidth(), decoded->GetHeight(), false)); ImageProcessing::ShiftScale(*rescaled, converted, offset, scaling, false); if (targetWidth == decoded->GetWidth() && @@ -911,7 +911,7 @@ } else { - std::auto_ptr resized( + std::unique_ptr resized( new Image(PixelFormat_Grayscale8, targetWidth, targetHeight, false)); if (smooth && @@ -976,7 +976,7 @@ DefaultDicomImageDecoder decoder; // This is Orthanc's built-in decoder #endif - std::auto_ptr decoded(decoder.Decode(dicomContent.c_str(), dicomContent.size(), frame)); + std::unique_ptr decoded(decoder.Decode(dicomContent.c_str(), dicomContent.size(), frame)); std::string result; decoded->ToMatlabString(result); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/Search/DatabaseLookup.cpp --- a/OrthancServer/Search/DatabaseLookup.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/Search/DatabaseLookup.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -117,9 +117,9 @@ } std::set ignoreTagLength; - std::auto_ptr value(FromDcmtkBridge::ConvertLeafElement - (*element, DicomToJsonFlags_None, - 0, encoding, hasCodeExtensions, ignoreTagLength)); + std::unique_ptr value(FromDcmtkBridge::ConvertLeafElement + (*element, DicomToJsonFlags_None, + 0, encoding, hasCodeExtensions, ignoreTagLength)); // WARNING: Also modify "HierarchicalMatcher::Setup()" if modifying this code if (value.get() == NULL || @@ -185,7 +185,7 @@ fixedTag = DICOM_TAG_MODALITY; } - std::auto_ptr constraint + std::unique_ptr constraint (new DicomTagConstraint(fixedTag, ConstraintType_List, caseSensitive, mandatoryTag)); std::vector items; diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/Search/HierarchicalMatcher.cpp --- a/OrthancServer/Search/HierarchicalMatcher.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/Search/HierarchicalMatcher.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -123,9 +123,9 @@ flatTags_.insert(tag); std::set ignoreTagLength; - std::auto_ptr value(FromDcmtkBridge::ConvertLeafElement - (*element, DicomToJsonFlags_None, - 0, encoding, hasCodeExtensions, ignoreTagLength)); + std::unique_ptr value(FromDcmtkBridge::ConvertLeafElement + (*element, DicomToJsonFlags_None, + 0, encoding, hasCodeExtensions, ignoreTagLength)); // WARNING: Also modify "DatabaseLookup::IsMatch()" if modifying this code if (value.get() == NULL || @@ -257,7 +257,7 @@ Encoding encoding, bool hasCodeExtensions) const { - std::auto_ptr target(new DcmDataset); + std::unique_ptr target(new DcmDataset); for (std::set::const_iterator it = flatTags_.begin(); it != flatTags_.end(); ++it) @@ -274,7 +274,7 @@ "Not applicable to private tags: " + it->Format()); } - std::auto_ptr cloned(FromDcmtkBridge::CreateElementForTag(*it, "" /* no private creator */)); + std::unique_ptr cloned(FromDcmtkBridge::CreateElementForTag(*it, "" /* no private creator */)); cloned->copyFrom(*element); target->insert(cloned.release()); } @@ -289,7 +289,7 @@ if (source.findAndGetSequence(tag, sequence).good() && sequence != NULL) { - std::auto_ptr cloned(new DcmSequenceOfItems(tag)); + std::unique_ptr cloned(new DcmSequenceOfItems(tag)); for (unsigned long i = 0; i < sequence->card(); i++) { @@ -303,7 +303,7 @@ // "DcmItem" object before it can be included in a // sequence. Otherwise, "dciodvfy" reports an error "Bad // tag in sequence - Expecting Item or Sequence Delimiter." - std::auto_ptr child(it->second->ExtractInternal(*sequence->getItem(i), encoding, hasCodeExtensions)); + std::unique_ptr child(it->second->ExtractInternal(*sequence->getItem(i), encoding, hasCodeExtensions)); cloned->append(new DcmItem(*child)); } } @@ -321,10 +321,10 @@ bool hasCodeExtensions; Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); - std::auto_ptr dataset(ExtractInternal(*dicom.GetDcmtkObject().getDataset(), - encoding, hasCodeExtensions)); + std::unique_ptr dataset(ExtractInternal(*dicom.GetDcmtkObject().getDataset(), + encoding, hasCodeExtensions)); - std::auto_ptr result(new ParsedDicomFile(*dataset)); + std::unique_ptr result(new ParsedDicomFile(*dataset)); result->SetEncoding(encoding); return result.release(); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerContext.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -75,7 +75,7 @@ { while (!that->done_) { - std::auto_ptr obj(that->pendingChanges_.Dequeue(sleepDelay)); + std::unique_ptr obj(that->pendingChanges_.Dequeue(sleepDelay)); if (obj.get() != NULL) { @@ -664,7 +664,7 @@ lock_(that_.dicomCacheMutex_) { #if ENABLE_DICOM_CACHE == 0 - static std::auto_ptr p; + static std::unique_ptr p; p.reset(provider_.Provide(instancePublicId)); dicom_ = dynamic_cast(p.get()); #else @@ -833,7 +833,7 @@ // Optimization in Orthanc 1.5.1 - Don't read the full JSON from // the disk if only "main DICOM tags" are to be returned - std::auto_ptr dicomAsJson; + std::unique_ptr dicomAsJson; bool hasOnlyMainDicomTags; DicomMap dicom; diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerContext.h --- a/OrthancServer/ServerContext.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerContext.h Mon Mar 02 15:32:45 2020 +0100 @@ -183,7 +183,7 @@ LuaScripting mainLua_; LuaScripting filterLua_; LuaServerListener luaListener_; - std::auto_ptr mediaArchive_; + std::unique_ptr mediaArchive_; // The "JobsEngine" must be *after* "LuaScripting", as // "LuaScripting" embeds "LuaJobManager" that registers as an @@ -206,7 +206,7 @@ boost::thread changeThread_; boost::thread saveJobsThread_; - std::auto_ptr queryRetrieveArchive_; + std::unique_ptr queryRetrieveArchive_; std::string defaultLocalAet_; OrthancHttpHandler httpHandler_; bool saveJobs_; @@ -214,7 +214,7 @@ unsigned int limitFindInstances_; unsigned int limitFindResults_; - std::auto_ptr metricsRegistry_; + std::unique_ptr metricsRegistry_; bool isHttpServerSecure_; bool isExecuteLuaEnabled_; diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerIndex.cpp --- a/OrthancServer/ServerIndex.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerIndex.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -241,7 +241,7 @@ { private: ServerIndex& index_; - std::auto_ptr transaction_; + std::unique_ptr transaction_; bool isCommitted_; public: diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerIndex.h --- a/OrthancServer/ServerIndex.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerIndex.h Mon Mar 02 15:32:45 2020 +0100 @@ -65,14 +65,14 @@ boost::thread flushThread_; boost::thread unstableResourcesMonitorThread_; - std::auto_ptr listener_; + std::unique_ptr listener_; IDatabaseWrapper& db_; LeastRecentlyUsedIndex unstableResources_; uint64_t maximumStorageSize_; unsigned int maximumPatients_; bool overwrite_; - std::auto_ptr mainDicomTagsRegistry_; + std::unique_ptr mainDicomTagsRegistry_; static void FlushThread(ServerIndex* that, unsigned int threadSleep); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/ArchiveJob.cpp --- a/OrthancServer/ServerJobs/ArchiveJob.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/ArchiveJob.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -276,7 +276,7 @@ else if (previous == resources_.end()) { // This is the first time we meet this resource - std::auto_ptr child(new ArchiveIndex(GetChildResourceType(level_))); + std::unique_ptr child(new ArchiveIndex(GetChildResourceType(level_))); child->Add(index, resource); resources_[id] = child.release(); } @@ -308,7 +308,7 @@ std::list children; index.GetChildren(children, it->first); - std::auto_ptr child(new ArchiveIndex(GetChildResourceType(level_))); + std::unique_ptr child(new ArchiveIndex(GetChildResourceType(level_))); for (std::list::const_iterator it2 = children.begin(); it2 != children.end(); ++it2) @@ -695,12 +695,12 @@ class ArchiveJob::ZipWriterIterator : public boost::noncopyable { private: - TemporaryFile& target_; - ServerContext& context_; - ZipCommands commands_; - std::auto_ptr zip_; - std::auto_ptr dicomDir_; - bool isMedia_; + TemporaryFile& target_; + ServerContext& context_; + ZipCommands commands_; + std::unique_ptr zip_; + std::unique_ptr dicomDir_; + bool isMedia_; public: ZipWriterIterator(TemporaryFile& target, @@ -902,7 +902,7 @@ class DynamicTemporaryFile : public IDynamicObject { private: - std::auto_ptr file_; + std::unique_ptr file_; public: DynamicTemporaryFile(TemporaryFile* f) : file_(f) diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/ArchiveJob.h --- a/OrthancServer/ServerJobs/ArchiveJob.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/ArchiveJob.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #pragma once +#include "../../Core/Compatibility.h" #include "../../Core/JobsEngine/IJob.h" #include "../../Core/TemporaryFile.h" @@ -55,7 +56,7 @@ class ZipWriterIterator; boost::shared_ptr synchronousTarget_; - std::auto_ptr asynchronousTarget_; + std::unique_ptr asynchronousTarget_; ServerContext& context_; boost::shared_ptr archive_; bool isMedia_; diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/DicomModalityStoreJob.cpp --- a/OrthancServer/ServerJobs/DicomModalityStoreJob.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/DicomModalityStoreJob.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #include "../PrecompiledHeadersServer.h" #include "DicomModalityStoreJob.h" +#include "../../Core/Compatibility.h" #include "../../Core/Logging.h" #include "../../Core/SerializationToolbox.h" #include "../ServerContext.h" diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/DicomModalityStoreJob.h --- a/OrthancServer/ServerJobs/DicomModalityStoreJob.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/DicomModalityStoreJob.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #pragma once +#include "../../Core/Compatibility.h" #include "../../Core/JobsEngine/SetOfInstancesJob.h" #include "../../Core/DicomNetworking/DicomUserConnection.h" @@ -43,12 +44,12 @@ class DicomModalityStoreJob : public SetOfInstancesJob { private: - ServerContext& context_; - std::string localAet_; - RemoteModalityParameters remote_; - std::string moveOriginatorAet_; - uint16_t moveOriginatorId_; - std::auto_ptr connection_; + ServerContext& context_; + std::string localAet_; + RemoteModalityParameters remote_; + std::string moveOriginatorAet_; + uint16_t moveOriginatorId_; + std::unique_ptr connection_; void OpenConnection(); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/DicomMoveScuJob.cpp --- a/OrthancServer/ServerJobs/DicomMoveScuJob.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/DicomMoveScuJob.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -46,8 +46,8 @@ class DicomMoveScuJob::Command : public SetOfCommandsJob::ICommand { private: - DicomMoveScuJob& that_; - std::auto_ptr findAnswer_; + DicomMoveScuJob& that_; + std::unique_ptr findAnswer_; public: Command(DicomMoveScuJob& that, diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/DicomMoveScuJob.h --- a/OrthancServer/ServerJobs/DicomMoveScuJob.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/DicomMoveScuJob.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #pragma once +#include "../../Core/Compatibility.h" #include "../../Core/JobsEngine/SetOfCommandsJob.h" #include "../../Core/DicomNetworking/DicomUserConnection.h" @@ -48,12 +49,12 @@ class Command; class Unserializer; - ServerContext& context_; - std::string localAet_; - std::string targetAet_; - RemoteModalityParameters remote_; - std::auto_ptr connection_; - Json::Value query_; + ServerContext& context_; + std::string localAet_; + std::string targetAet_; + RemoteModalityParameters remote_; + std::unique_ptr connection_; + Json::Value query_; void Retrieve(const DicomMap& findAnswer); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/LuaJobManager.h --- a/OrthancServer/ServerJobs/LuaJobManager.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/LuaJobManager.h Mon Mar 02 15:32:45 2020 +0100 @@ -69,11 +69,11 @@ class Lock : public boost::noncopyable { private: - LuaJobManager& that_; - boost::mutex::scoped_lock lock_; - JobsEngine& engine_; - std::auto_ptr jobLock_; - bool isNewJob_; + LuaJobManager& that_; + boost::mutex::scoped_lock lock_; + JobsEngine& engine_; + std::unique_ptr jobLock_; + bool isNewJob_; public: Lock(LuaJobManager& that, diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/MergeStudyJob.cpp --- a/OrthancServer/ServerJobs/MergeStudyJob.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/MergeStudyJob.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -85,7 +85,7 @@ * Retrieve the DICOM instance to be modified **/ - std::auto_ptr modified; + std::unique_ptr modified; try { diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.cpp --- a/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -94,7 +94,7 @@ LOG(INFO) << "Lua: Modifying instance " << instance.GetId(); - std::auto_ptr modified; + std::unique_ptr modified; { ServerContext::DicomCacheLocker lock(context_, instance.GetId()); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.h --- a/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,8 +33,9 @@ #pragma once +#include "../../../Core/Compatibility.h" +#include "../../../Core/DicomParsing/DicomModification.h" #include "../../../Core/JobsEngine/Operations/IJobOperation.h" -#include "../../../Core/DicomParsing/DicomModification.h" namespace Orthanc { @@ -43,9 +44,9 @@ class ModifyInstanceOperation : public IJobOperation { private: - ServerContext& context_; - RequestOrigin origin_; - std::auto_ptr modification_; + ServerContext& context_; + RequestOrigin origin_; + std::unique_ptr modification_; public: ModifyInstanceOperation(ServerContext& context, diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/Operations/StoreScuOperation.cpp --- a/OrthancServer/ServerJobs/Operations/StoreScuOperation.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/Operations/StoreScuOperation.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -46,7 +46,7 @@ const JobOperationValue& input, IDicomConnectionManager& connectionManager) { - std::auto_ptr resource + std::unique_ptr resource (connectionManager.AcquireConnection(localAet_, modality_)); if (resource.get() == NULL) diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/Operations/SystemCallOperation.cpp --- a/OrthancServer/ServerJobs/Operations/SystemCallOperation.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/Operations/SystemCallOperation.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -81,7 +81,7 @@ arguments.reserve(arguments.size() + postArguments_.size() + 1); - std::auto_ptr tmp; + std::unique_ptr tmp; switch (input.GetType()) { diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/OrthancJobUnserializer.cpp --- a/OrthancServer/ServerJobs/OrthancJobUnserializer.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/OrthancJobUnserializer.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -64,7 +64,7 @@ #if ORTHANC_ENABLE_PLUGINS == 1 if (context_.HasPlugins()) { - std::auto_ptr job(context_.GetPlugins().UnserializeJob(type, source)); + std::unique_ptr job(context_.GetPlugins().UnserializeJob(type, source)); if (job.get() != NULL) { return job.release(); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/OrthancPeerStoreJob.h --- a/OrthancServer/ServerJobs/OrthancPeerStoreJob.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/OrthancPeerStoreJob.h Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,7 @@ #pragma once +#include "../../Core/Compatibility.h" #include "../../Core/JobsEngine/SetOfInstancesJob.h" #include "../../Core/HttpClient.h" @@ -44,9 +45,9 @@ class OrthancPeerStoreJob : public SetOfInstancesJob { private: - ServerContext& context_; - WebServiceParameters peer_; - std::auto_ptr client_; + ServerContext& context_; + WebServiceParameters peer_; + std::unique_ptr client_; protected: virtual bool HandleInstance(const std::string& instance); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/ResourceModificationJob.cpp --- a/OrthancServer/ServerJobs/ResourceModificationJob.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/ResourceModificationJob.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -147,8 +147,8 @@ * Retrieve the original instance from the DICOM cache. **/ - std::auto_ptr originalHasher; - std::auto_ptr modified; + std::unique_ptr originalHasher; + std::unique_ptr modified; try { diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/ResourceModificationJob.h --- a/OrthancServer/ServerJobs/ResourceModificationJob.h Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/ResourceModificationJob.h Mon Mar 02 15:32:45 2020 +0100 @@ -46,11 +46,11 @@ private: class Output; - ServerContext& context_; - std::auto_ptr modification_; - boost::shared_ptr output_; - bool isAnonymization_; - DicomInstanceOrigin origin_; + ServerContext& context_; + std::unique_ptr modification_; + boost::shared_ptr output_; + bool isAnonymization_; + DicomInstanceOrigin origin_; protected: virtual bool HandleInstance(const std::string& instance); diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/ServerJobs/SplitStudyJob.cpp --- a/OrthancServer/ServerJobs/SplitStudyJob.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/ServerJobs/SplitStudyJob.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -71,7 +71,7 @@ * Retrieve the DICOM instance to be modified **/ - std::auto_ptr modified; + std::unique_ptr modified; try { diff -r 1f4910999fe7 -r 2a170a8f1faf OrthancServer/main.cpp --- a/OrthancServer/main.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/OrthancServer/main.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -130,7 +130,7 @@ virtual IFindRequestHandler* ConstructFindRequestHandler() { - std::auto_ptr result(new OrthancFindRequestHandler(context_)); + std::unique_ptr result(new OrthancFindRequestHandler(context_)); { OrthancConfiguration::ReaderLock lock; @@ -1294,8 +1294,8 @@ bool upgradeDatabase, bool loadJobsFromDatabase) { - std::auto_ptr databasePtr; - std::auto_ptr storage; + std::unique_ptr databasePtr; + std::unique_ptr storage; #if ORTHANC_ENABLE_PLUGINS == 1 OrthancPlugins plugins; diff -r 1f4910999fe7 -r 2a170a8f1faf Plugins/Engine/OrthancPlugins.cpp --- a/Plugins/Engine/OrthancPlugins.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Plugins/Engine/OrthancPlugins.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -367,7 +367,7 @@ public: DicomWebBinaryFormatter(const _OrthancPluginEncodeDicomWeb& parameters) : - callback_(parameters.callback) + callback_(parameters.callback) { } @@ -435,7 +435,7 @@ }; HttpOutput& output_; - std::auto_ptr errorDetails_; + std::unique_ptr errorDetails_; bool logDetails_; MultipartState multipartState_; std::string multipartSubType_; @@ -665,8 +665,8 @@ public: ChunkedRestCallback(_OrthancPluginChunkedRestCallback parameters) : - parameters_(parameters), - regex_(parameters.pathRegularExpression) + parameters_(parameters), + regex_(parameters.pathRegularExpression) { } @@ -690,8 +690,8 @@ public: ServerContextLock(PImpl& that) : - lock_(that.contextMutex_), - context_(that.context_) + lock_(that.contextMutex_), + context_(that.context_) { if (context_ == NULL) { @@ -740,7 +740,7 @@ IncomingHttpRequestFilters incomingHttpRequestFilters_; IncomingHttpRequestFilters2 incomingHttpRequestFilters2_; RefreshMetricsCallbacks refreshMetricsCallbacks_; - std::auto_ptr storageArea_; + std::unique_ptr storageArea_; boost::recursive_mutex restCallbackMutex_; boost::recursive_mutex storedCallbackMutex_; @@ -755,7 +755,7 @@ Properties properties_; int argc_; char** argv_; - std::auto_ptr database_; + std::unique_ptr database_; PluginsErrorDictionary dictionary_; PImpl() : @@ -775,8 +775,8 @@ { private: OrthancPlugins& that_; - std::auto_ptr matcher_; - std::auto_ptr filtered_; + std::unique_ptr matcher_; + std::unique_ptr filtered_; ParsedDicomFile* currentQuery_; void Reset() @@ -889,7 +889,7 @@ } ParsedDicomFile f(dicom, size); - std::auto_ptr summary(matcher_->Extract(f)); + std::unique_ptr summary(matcher_->Extract(f)); reinterpret_cast(answers)->Add(*summary); } }; @@ -899,7 +899,7 @@ { private: OrthancPlugins& that_; - std::auto_ptr currentQuery_; + std::unique_ptr currentQuery_; void Reset() { @@ -1351,7 +1351,7 @@ public: RestCallbackMatcher(const UriComponents& uri) : - flatUri_(Toolbox::FlattenUri(uri)) + flatUri_(Toolbox::FlattenUri(uri)) { } @@ -2356,7 +2356,7 @@ std::string result; { - std::auto_ptr compressor; + std::unique_ptr compressor; switch (p.compression) { @@ -2406,14 +2406,14 @@ } - static OrthancPluginImage* ReturnImage(std::auto_ptr& image) + static OrthancPluginImage* ReturnImage(std::unique_ptr& image) { // Images returned to plugins are assumed to be writeable. If the // input image is read-only, we return a copy so that it can be modified. if (image->IsReadOnly()) { - std::auto_ptr copy(new Image(image->GetFormat(), image->GetWidth(), image->GetHeight(), false)); + std::unique_ptr copy(new Image(image->GetFormat(), image->GetWidth(), image->GetHeight(), false)); ImageProcessing::Copy(*copy, *image); image.reset(NULL); return reinterpret_cast(copy.release()); @@ -2429,7 +2429,7 @@ { const _OrthancPluginUncompressImage& p = *reinterpret_cast(parameters); - std::auto_ptr image; + std::unique_ptr image; switch (p.format) { @@ -2813,7 +2813,7 @@ const _OrthancPluginConvertPixelFormat& p = *reinterpret_cast(parameters); const ImageAccessor& source = *reinterpret_cast(p.source); - std::auto_ptr target(new Image(Plugins::Convert(p.targetFormat), source.GetWidth(), source.GetHeight(), false)); + std::unique_ptr target(new Image(Plugins::Convert(p.targetFormat), source.GetWidth(), source.GetHeight(), false)); ImageProcessing::Convert(*target, source); *(p.target) = ReturnImage(target); @@ -2866,7 +2866,7 @@ const _OrthancPluginDicomToJson& p = *reinterpret_cast(parameters); - std::auto_ptr dicom; + std::unique_ptr dicom; if (service == _OrthancPluginService_DicomBufferToJson) { @@ -2931,7 +2931,7 @@ privateCreator = lock.GetConfiguration().GetDefaultPrivateCreator(); } - std::auto_ptr file + std::unique_ptr file (ParsedDicomFile::CreateFromJson(json, static_cast(p.flags), privateCreator)); @@ -2995,7 +2995,7 @@ const _OrthancPluginCreateImage& p = *reinterpret_cast(parameters); - std::auto_ptr result; + std::unique_ptr result; switch (service) { @@ -4481,7 +4481,7 @@ }; - bool OrthancPlugins::CreateChunkedRequestReader(std::auto_ptr& target, + bool OrthancPlugins::CreateChunkedRequestReader(std::unique_ptr& target, RequestOrigin origin, const char* remoteIp, const char* username, diff -r 1f4910999fe7 -r 2a170a8f1faf Plugins/Engine/OrthancPlugins.h --- a/Plugins/Engine/OrthancPlugins.h Fri Feb 28 13:23:11 2020 +0100 +++ b/Plugins/Engine/OrthancPlugins.h Mon Mar 02 15:32:45 2020 +0100 @@ -334,7 +334,7 @@ void RefreshMetrics(); // New in Orthanc 1.5.7 - virtual bool CreateChunkedRequestReader(std::auto_ptr& target, + virtual bool CreateChunkedRequestReader(std::unique_ptr& target, RequestOrigin origin, const char* remoteIp, const char* username, diff -r 1f4910999fe7 -r 2a170a8f1faf Plugins/Engine/PluginsErrorDictionary.cpp --- a/Plugins/Engine/PluginsErrorDictionary.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Plugins/Engine/PluginsErrorDictionary.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -69,7 +69,7 @@ uint16_t httpStatus, const char* message) { - std::auto_ptr error(new Error); + std::unique_ptr error(new Error); error->pluginName_ = PluginsManager::GetPluginName(library); error->pluginCode_ = pluginCode; diff -r 1f4910999fe7 -r 2a170a8f1faf Plugins/Engine/PluginsManager.cpp --- a/Plugins/Engine/PluginsManager.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/Plugins/Engine/PluginsManager.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -249,7 +249,7 @@ return; } - std::auto_ptr plugin(new Plugin(*this, path)); + std::unique_ptr plugin(new Plugin(*this, path)); if (!IsOrthancPlugin(plugin->GetSharedLibrary())) { diff -r 1f4910999fe7 -r 2a170a8f1faf UnitTestsSources/DicomMapTests.cpp --- a/UnitTestsSources/DicomMapTests.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/UnitTestsSources/DicomMapTests.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #include "PrecompiledHeadersUnitTests.h" #include "gtest/gtest.h" +#include "../Core/Compatibility.h" #include "../Core/OrthancException.h" #include "../Core/DicomFormat/DicomMap.h" #include "../Core/DicomParsing/FromDcmtkBridge.h" @@ -121,7 +122,7 @@ ASSERT_EQ(1u, s.size()); ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin()); - std::auto_ptr mm(m.Clone()); + std::unique_ptr mm(m.Clone()); ASSERT_EQ("PatientName", mm->GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); m.SetValue(DICOM_TAG_PATIENT_ID, "Hello", false); @@ -450,10 +451,10 @@ dataset.insertEmptyElement(DCM_StudyID, OFFalse); { - std::auto_ptr sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence)); + std::unique_ptr sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence)); { - std::auto_ptr item(new DcmItem); + std::unique_ptr item(new DcmItem); item->putAndInsertString(DCM_ReferencedSOPInstanceUID, "nope", OFFalse); ASSERT_TRUE(sequence->insert(item.release(), false, false).good()); } @@ -695,7 +696,7 @@ // "dicom.GetDcmtkObject().getDataset()->putAndInsertTagKey(tag, // value)" that was not available in DCMTK 3.6.0 - std::auto_ptr element(new DcmAttributeTag(ToDcmtkBridge::Convert(tag))); + std::unique_ptr element(new DcmAttributeTag(ToDcmtkBridge::Convert(tag))); DcmTagKey v = ToDcmtkBridge::Convert(value); if (!element->putTagVal(v).good()) @@ -938,11 +939,11 @@ ParsedDicomFile dicom(false); { - std::auto_ptr sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence)); + std::unique_ptr sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence)); for (unsigned int i = 0; i < 3; i++) { - std::auto_ptr item(new DcmItem); + std::unique_ptr item(new DcmItem); std::string s = "item" + boost::lexical_cast(i); item->putAndInsertString(DCM_ReferencedSOPInstanceUID, s.c_str(), OFFalse); ASSERT_TRUE(sequence->insert(item.release(), false, false).good()); diff -r 1f4910999fe7 -r 2a170a8f1faf UnitTestsSources/FromDcmtkTests.cpp --- a/UnitTestsSources/FromDcmtkTests.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/UnitTestsSources/FromDcmtkTests.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #include "PrecompiledHeadersUnitTests.h" #include "gtest/gtest.h" +#include "../Core/Compatibility.h" #include "../Core/DicomNetworking/DicomFindAnswers.h" #include "../Core/DicomParsing/DicomModification.h" #include "../Core/DicomParsing/DicomWebJsonVisitor.h" @@ -95,7 +96,7 @@ { char b[1024]; sprintf(b, "UnitTestsResults/anon%06d.dcm", i); - std::auto_ptr f(o.Clone(false)); + std::unique_ptr f(o.Clone(false)); if (i > 4) o.ReplacePlainString(DICOM_TAG_SERIES_INSTANCE_UID, "coucou"); m.Apply(*f); @@ -402,7 +403,7 @@ // https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#private-class-members TEST(FromDcmtkBridge, FromJson) { - std::auto_ptr element; + std::unique_ptr element; { Json::Value a; @@ -817,7 +818,7 @@ { - std::auto_ptr dicom + std::unique_ptr dicom (ParsedDicomFile::CreateFromJson(v, static_cast(DicomFromJsonFlags_GenerateIdentifiers), "")); Json::Value vv; @@ -833,7 +834,7 @@ { - std::auto_ptr dicom + std::unique_ptr dicom (ParsedDicomFile::CreateFromJson(v, static_cast(DicomFromJsonFlags_GenerateIdentifiers), "")); Json::Value vv; @@ -847,7 +848,7 @@ { - std::auto_ptr dicom + std::unique_ptr dicom (ParsedDicomFile::CreateFromJson(v, static_cast(DicomFromJsonFlags_DecodeDataUriScheme), "")); Json::Value vv; @@ -916,7 +917,7 @@ Orthanc::SystemToolbox::ReadFile(s, PATH); Orthanc::ParsedDicomFile f(s); - std::auto_ptr decoded(Orthanc::DicomImageDecoder::Decode(f, 0)); + std::unique_ptr decoded(Orthanc::DicomImageDecoder::Decode(f, 0)); ASSERT_EQ(256u, decoded->GetWidth()); ASSERT_EQ(256u, decoded->GetHeight()); ASSERT_EQ(Orthanc::PixelFormat_Grayscale8, decoded->GetFormat()); @@ -978,7 +979,7 @@ Orthanc::SystemToolbox::ReadFile(s, PATH); Orthanc::ParsedDicomFile f(s); - std::auto_ptr decoded(Orthanc::DicomImageDecoder::Decode(f, 0)); + std::unique_ptr decoded(Orthanc::DicomImageDecoder::Decode(f, 0)); ASSERT_EQ(384u, decoded->GetWidth()); ASSERT_EQ(256u, decoded->GetHeight()); ASSERT_EQ(Orthanc::PixelFormat_RGB24, decoded->GetFormat()); @@ -1035,7 +1036,7 @@ Orthanc::SystemToolbox::ReadFile(s, PATH); Orthanc::ParsedDicomFile f(s); - std::auto_ptr decoded(Orthanc::DicomImageDecoder::Decode(f, 0)); + std::unique_ptr decoded(Orthanc::DicomImageDecoder::Decode(f, 0)); ASSERT_EQ(256u, decoded->GetWidth()); ASSERT_EQ(256u, decoded->GetHeight()); ASSERT_EQ(Orthanc::PixelFormat_Grayscale16, decoded->GetFormat()); @@ -1091,7 +1092,7 @@ Orthanc::SystemToolbox::ReadFile(s, PATH); Orthanc::ParsedDicomFile f(s); - std::auto_ptr decoded(Orthanc::DicomImageDecoder::Decode(f, 0)); + std::unique_ptr decoded(Orthanc::DicomImageDecoder::Decode(f, 0)); ASSERT_EQ(256u, decoded->GetWidth()); ASSERT_EQ(256u, decoded->GetHeight()); ASSERT_EQ(Orthanc::PixelFormat_SignedGrayscale16, decoded->GetFormat()); diff -r 1f4910999fe7 -r 2a170a8f1faf UnitTestsSources/ImageProcessingTests.cpp --- a/UnitTestsSources/ImageProcessingTests.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/UnitTestsSources/ImageProcessingTests.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #include "PrecompiledHeadersUnitTests.h" #include "gtest/gtest.h" +#include "../Core/Compatibility.h" #include "../Core/DicomFormat/DicomImageInformation.h" #include "../Core/Images/Image.h" #include "../Core/Images/ImageProcessing.h" @@ -92,7 +93,7 @@ class TestImageTraits : public ::testing::Test { private: - std::auto_ptr image_; + std::unique_ptr image_; protected: virtual void SetUp() ORTHANC_OVERRIDE @@ -547,7 +548,7 @@ SetGrayscale8Pixel(dirac, 4, 0, 100); { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0); ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0)); @@ -561,7 +562,7 @@ } { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2); ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0)); @@ -575,7 +576,7 @@ } { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0); ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); ASSERT_TRUE(TestGrayscale8Pixel(*image, 1, 0, 0)); @@ -595,7 +596,7 @@ SetGrayscale8Pixel(dirac, 0, 4, 100); { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2); ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0)); @@ -609,7 +610,7 @@ } { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0); ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0)); @@ -623,7 +624,7 @@ } { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0); ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 0, 0)); ASSERT_TRUE(TestGrayscale8Pixel(*image, 0, 1, 0)); @@ -643,7 +644,7 @@ SetRGB24Pixel(dirac, 4, 0, 100, 120, 140); { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0); ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); ASSERT_TRUE(TestRGB24Pixel(*image, 1, 0, 0, 0, 0)); @@ -657,7 +658,7 @@ } { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2); ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); ASSERT_TRUE(TestRGB24Pixel(*image, 1, 0, 0, 0, 0)); @@ -671,7 +672,7 @@ } { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0); ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); ASSERT_TRUE(TestRGB24Pixel(*image, 1, 0, 0, 0, 0)); @@ -691,7 +692,7 @@ SetRGB24Pixel(dirac, 0, 4, 100, 120, 140); { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k2, 0, k1, 2); ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); ASSERT_TRUE(TestRGB24Pixel(*image, 0, 1, 0, 0, 0)); @@ -705,7 +706,7 @@ } { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k1, 2, k2, 0); ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); ASSERT_TRUE(TestRGB24Pixel(*image, 0, 1, 0, 0, 0)); @@ -719,7 +720,7 @@ } { - std::auto_ptr image(Image::Clone(dirac)); + std::unique_ptr image(Image::Clone(dirac)); ImageProcessing::SeparableConvolution(*image, k2, 0, k2, 0); ASSERT_TRUE(TestRGB24Pixel(*image, 0, 0, 0, 0, 0)); ASSERT_TRUE(TestRGB24Pixel(*image, 0, 1, 0, 0, 0)); diff -r 1f4910999fe7 -r 2a170a8f1faf UnitTestsSources/MultiThreadingTests.cpp --- a/UnitTestsSources/MultiThreadingTests.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/UnitTestsSources/MultiThreadingTests.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #include "PrecompiledHeadersUnitTests.h" #include "gtest/gtest.h" +#include "../Core/Compatibility.h" #include "../Core/FileStorage/MemoryStorageArea.h" #include "../Core/JobsEngine/JobsEngine.h" #include "../Core/Logging.h" @@ -272,7 +273,7 @@ q.Enqueue(new DynamicInteger(30, s)); q.Enqueue(new DynamicInteger(40, s)); - std::auto_ptr i; + std::unique_ptr i; i.reset(dynamic_cast(q.Dequeue(1))); ASSERT_EQ(10, i->GetValue()); i.reset(dynamic_cast(q.Dequeue(1))); ASSERT_EQ(20, i->GetValue()); i.reset(dynamic_cast(q.Dequeue(1))); ASSERT_EQ(30, i->GetValue()); @@ -747,7 +748,7 @@ SequenceOfOperationsJob* job = NULL; { - std::auto_ptr a(new SequenceOfOperationsJob); + std::unique_ptr a(new SequenceOfOperationsJob); job = a.get(); engine.GetRegistry().Submit(id, a.release(), 0); } @@ -837,7 +838,7 @@ } else { - std::auto_ptr unserialized(unserializer.UnserializeJob(a)); + std::unique_ptr unserialized(unserializer.UnserializeJob(a)); Json::Value b = 43; if (unserialized->Serialize(b)) @@ -863,7 +864,7 @@ } else { - std::auto_ptr unserialized + std::unique_ptr unserialized (dynamic_cast(unserializer.UnserializeJob(a))); Json::Value b = 43; @@ -889,7 +890,7 @@ Json::Value a = 42; operation.Serialize(a); - std::auto_ptr unserialized(unserializer.UnserializeOperation(a)); + std::unique_ptr unserialized(unserializer.UnserializeOperation(a)); Json::Value b = 43; unserialized->Serialize(b); @@ -904,7 +905,7 @@ Json::Value a = 42; value.Serialize(a); - std::auto_ptr unserialized(unserializer.UnserializeValue(a)); + std::unique_ptr unserialized(unserializer.UnserializeValue(a)); Json::Value b = 43; unserialized->Serialize(b); @@ -957,7 +958,7 @@ { GenericJobUnserializer unserializer; - std::auto_ptr values(JobOperationValues::Unserialize(unserializer, s)); + std::unique_ptr values(JobOperationValues::Unserialize(unserializer, s)); ASSERT_EQ(3u, values->GetSize()); ASSERT_EQ(JobOperationValue::Type_Null, values->GetValue(0).GetType()); ASSERT_EQ(JobOperationValue::Type_String, values->GetValue(1).GetType()); @@ -984,7 +985,7 @@ ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); - std::auto_ptr value; + std::unique_ptr value; value.reset(unserializer.UnserializeValue(s)); ASSERT_EQ(JobOperationValue::Type_Null, value->GetType()); @@ -1021,7 +1022,7 @@ ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); { - std::auto_ptr operation; + std::unique_ptr operation; operation.reset(unserializer.UnserializeOperation(s)); // Make sure that we have indeed unserialized a log operation @@ -1065,7 +1066,7 @@ ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); - std::auto_ptr job; + std::unique_ptr job; job.reset(unserializer.UnserializeJob(s)); const DummyInstancesJob& tmp = dynamic_cast(*job); @@ -1116,7 +1117,7 @@ ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); - std::auto_ptr job; + std::unique_ptr job; job.reset(unserializer.UnserializeJob(s)); std::string tmp; @@ -1147,7 +1148,7 @@ source.Insert(DICOM_TAG_SERIES_DESCRIPTION, "Test 2", false, ""); source.Insert(DICOM_TAG_PATIENT_NAME, "Test 3", false, ""); - std::auto_ptr modified(source.Clone(true)); + std::unique_ptr modified(source.Clone(true)); { DicomModification modification; @@ -1166,7 +1167,7 @@ DicomModification modification(s); ASSERT_EQ(ResourceType_Series, modification.GetLevel()); - std::auto_ptr second(source.Clone(true)); + std::unique_ptr second(source.Clone(true)); modification.Apply(*second); std::string s; @@ -1282,7 +1283,7 @@ private: MemoryStorageArea storage_; SQLiteDatabaseWrapper db_; // The SQLite DB is in memory - std::auto_ptr context_; + std::unique_ptr context_; TimeoutDicomConnectionManager manager_; public: @@ -1336,7 +1337,7 @@ instance.Serialize(s); } - std::auto_ptr value; + std::unique_ptr value; value.reset(unserializer.UnserializeValue(s)); ASSERT_EQ(JobOperationValue::Type_DicomInstance, value->GetType()); ASSERT_EQ(id, dynamic_cast(*value).GetId()); @@ -1369,7 +1370,7 @@ operation.Serialize(s); } - std::auto_ptr operation; + std::unique_ptr operation; { operation.reset(unserializer.UnserializeOperation(s)); @@ -1456,7 +1457,7 @@ // ModifyInstanceOperation { - std::auto_ptr modification(new DicomModification); + std::unique_ptr modification(new DicomModification); modification->SetupAnonymization(DicomVersion_2008); ModifyInstanceOperation operation(GetContext(), RequestOrigin_Lua, modification.release()); @@ -1507,7 +1508,7 @@ } { - std::auto_ptr job; + std::unique_ptr job; job.reset(unserializer.UnserializeJob(s)); DicomModalityStoreJob& tmp = dynamic_cast(*job); @@ -1537,7 +1538,7 @@ } { - std::auto_ptr job; + std::unique_ptr job; job.reset(unserializer.UnserializeJob(s)); OrthancPeerStoreJob& tmp = dynamic_cast(*job); @@ -1550,7 +1551,7 @@ // ResourceModificationJob { - std::auto_ptr modification(new DicomModification); + std::unique_ptr modification(new DicomModification); modification->SetupAnonymization(DicomVersion_2008); ResourceModificationJob job(GetContext()); @@ -1562,7 +1563,7 @@ } { - std::auto_ptr job; + std::unique_ptr job; job.reset(unserializer.UnserializeJob(s)); ResourceModificationJob& tmp = dynamic_cast(*job); @@ -1629,7 +1630,7 @@ } { - std::auto_ptr job; + std::unique_ptr job; job.reset(unserializer.UnserializeJob(s)); SplitStudyJob& tmp = dynamic_cast(*job); @@ -1693,7 +1694,7 @@ } { - std::auto_ptr job; + std::unique_ptr job; job.reset(unserializer.UnserializeJob(s)); MergeStudyJob& tmp = dynamic_cast(*job); diff -r 1f4910999fe7 -r 2a170a8f1faf UnitTestsSources/ServerIndexTests.cpp --- a/UnitTestsSources/ServerIndexTests.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/UnitTestsSources/ServerIndexTests.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -34,6 +34,7 @@ #include "PrecompiledHeadersUnitTests.h" #include "gtest/gtest.h" +#include "../Core/Compatibility.h" #include "../Core/FileStorage/FilesystemStorage.h" #include "../Core/FileStorage/MemoryStorageArea.h" #include "../Core/Logging.h" @@ -95,8 +96,8 @@ class DatabaseWrapperTest : public ::testing::Test { protected: - std::auto_ptr listener_; - std::auto_ptr index_; + std::unique_ptr listener_; + std::unique_ptr index_; public: DatabaseWrapperTest() diff -r 1f4910999fe7 -r 2a170a8f1faf UnitTestsSources/ToolboxTests.cpp --- a/UnitTestsSources/ToolboxTests.cpp Fri Feb 28 13:23:11 2020 +0100 +++ b/UnitTestsSources/ToolboxTests.cpp Mon Mar 02 15:32:45 2020 +0100 @@ -33,6 +33,8 @@ #include "PrecompiledHeadersUnitTests.h" #include "gtest/gtest.h" +#include "../Core/Compatibility.h" +#include "../Core/IDynamicObject.h" #include "../Core/OrthancException.h" #include "../Core/Toolbox.h" @@ -134,3 +136,13 @@ printf("decoding took %zu ms\n", (std::chrono::duration_cast(afterDecoding - afterEncoding))); } #endif + + +TEST(Toolbox, UniquePtr) +{ + std::unique_ptr i(new int(42)); + ASSERT_EQ(42, *i); + + std::unique_ptr > j(new SingleValueObject(42)); + ASSERT_EQ(42, j->GetValue()); +}