Skip to content

Commit 0bbaa6e

Browse files
committed
cpp: Replace auto_ptr by unique_ptr
1 parent 537cdad commit 0bbaa6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+646
-638
lines changed

cmake/compilerFlags.cmake

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# These flags applies to exiv2lib, the applications, and to the xmp code
22
include(CheckCXXCompilerFlag)
33

4+
set(CMAKE_CXX_STANDARD 11)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_CXX_EXTENSIONS OFF)
7+
48
if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN
59
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
610
set(COMPILER_IS_GCC ON)

cmake/compilerFlagsExiv2.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include(CheckCXXCompilerFlag)
44

55
if (COMPILER_IS_GCC OR COMPILER_IS_CLANG) # MINGW, Linux, APPLE, CYGWIN
66
if ( EXIV2_TEAM_WARNINGS_AS_ERRORS )
7-
add_compile_options(-Werror -Wno-error=deprecated-declarations)
7+
add_compile_options(-Werror)
88
check_cxx_compiler_flag(-Wno-error=deprecated-copy DEPRECATED_COPY)
99
if ( DEPRECATED_COPY)
1010
add_compile_options(-Wno-error=deprecated-copy)

cmake/printSummary.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ message( STATUS "RelWithDebInfo: ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}" )
3838
message( STATUS "MinSizeRel: ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}" )
3939
message( STATUS "" )
4040
message( STATUS "Compiler Options")
41-
OptionOutput( "Warnings as errors: " EXIV2_WARNINGS_AS_ERRORS )
42-
OptionOutput( "Use extra compiler warning flags: " EXIV2_EXTRA_WARNINGS )
41+
OptionOutput( "Warnings as errors: " EXIV2_TEAM_WARNINGS_AS_ERRORS )
42+
OptionOutput( "Use extra compiler warning flags: " EXIV2_TEAM_EXTRA_WARNINGS )
4343
message( STATUS "" )
4444

4545
message( STATUS "------------------------------------------------------------------" )

include/exiv2/asfvideo.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace Exiv2 {
6262
instance after it is passed to this method. Use the Image::io()
6363
method to get a temporary reference.
6464
*/
65-
AsfVideo(BasicIo::AutoPtr io);
65+
AsfVideo(BasicIo::UniquePtr io);
6666
//@}
6767

6868
//! @name Manipulators
@@ -169,7 +169,7 @@ namespace Exiv2 {
169169
Caller owns the returned object and the auto-pointer ensures that
170170
it will be deleted.
171171
*/
172-
EXIV2LIB_DEPRECATED_EXPORT Image::AutoPtr newAsfInstance(BasicIo::AutoPtr io, bool create);
172+
EXIV2LIB_DEPRECATED_EXPORT Image::UniquePtr newAsfInstance(BasicIo::UniquePtr io, bool create);
173173

174174
//! Check if the file iIo is a Windows Asf Video.
175175
EXIV2LIB_DEPRECATED_EXPORT bool isAsfType(BasicIo& iIo, bool advance);

include/exiv2/basicio.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "types.hpp"
3131

3232
// + standard includes
33-
#include <memory> // for std::auto_ptr
33+
#include <memory>
3434

3535
// The way to handle data from stdin or data uri path. If EXV_XPATH_MEMIO = 1,
3636
// it uses MemIo. Otherwises, it uses FileIo.
@@ -55,7 +55,7 @@ namespace Exiv2 {
5555
class EXIV2API BasicIo {
5656
public:
5757
//! BasicIo auto_ptr type
58-
typedef std::auto_ptr<BasicIo> AutoPtr;
58+
typedef std::unique_ptr<BasicIo> UniquePtr;
5959

6060
//! Seek starting positions
6161
enum Position { beg, cur, end };
@@ -521,7 +521,7 @@ namespace Exiv2 {
521521

522522
// Pimpl idiom
523523
class Impl;
524-
std::auto_ptr<Impl> p_;
524+
std::unique_ptr<Impl> p_;
525525

526526
}; // class FileIo
527527

@@ -721,7 +721,7 @@ namespace Exiv2 {
721721

722722
// Pimpl idiom
723723
class Impl;
724-
std::auto_ptr<Impl> p_;
724+
std::unique_ptr<Impl> p_;
725725

726726
}; // class MemIo
727727

include/exiv2/bmffimage.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace Exiv2
7676
@param create Specifies if an existing image should be read (false)
7777
or if a new file should be created (true).
7878
*/
79-
BmffImage(BasicIo::AutoPtr io, bool create);
79+
BmffImage(BasicIo::UniquePtr io, bool create);
8080
//@}
8181

8282
//@{
@@ -163,7 +163,7 @@ namespace Exiv2
163163
Caller owns the returned object and the auto-pointer ensures that
164164
it will be deleted.
165165
*/
166-
EXIV2API Image::AutoPtr newBmffInstance(BasicIo::AutoPtr io, bool create);
166+
EXIV2API Image::UniquePtr newBmffInstance(BasicIo::UniquePtr io, bool create);
167167

168168
//! Check if the file iIo is a BMFF image.
169169
EXIV2API bool isBmffType(BasicIo& iIo, bool advance);

include/exiv2/bmpimage.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace Exiv2 {
7373
instance after it is passed to this method. Use the Image::io()
7474
method to get a temporary reference.
7575
*/
76-
explicit BmpImage(BasicIo::AutoPtr io);
76+
explicit BmpImage(BasicIo::UniquePtr io);
7777
//@}
7878

7979
//! @name Manipulators
@@ -118,7 +118,7 @@ namespace Exiv2 {
118118
Caller owns the returned object and the auto-pointer ensures that
119119
it will be deleted.
120120
*/
121-
EXIV2API Image::AutoPtr newBmpInstance(BasicIo::AutoPtr io, bool create);
121+
EXIV2API Image::UniquePtr newBmpInstance(BasicIo::UniquePtr io, bool create);
122122

123123
//! Check if the file iIo is a Windows Bitmap image.
124124
EXIV2API bool isBmpType(BasicIo& iIo, bool advance);

include/exiv2/cr2image.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace Exiv2 {
6868
@param create Specifies if an existing image should be read (false)
6969
or if a new file should be created (true).
7070
*/
71-
Cr2Image(BasicIo::AutoPtr io, bool create);
71+
Cr2Image(BasicIo::UniquePtr io, bool create);
7272
//@}
7373

7474
//! @name Manipulators
@@ -152,7 +152,7 @@ namespace Exiv2 {
152152
Caller owns the returned object and the auto-pointer ensures that
153153
it will be deleted.
154154
*/
155-
EXIV2API Image::AutoPtr newCr2Instance(BasicIo::AutoPtr io, bool create);
155+
EXIV2API Image::UniquePtr newCr2Instance(BasicIo::UniquePtr io, bool create);
156156

157157
//! Check if the file iIo is a CR2 image.
158158
EXIV2API bool isCr2Type(BasicIo& iIo, bool advance);

include/exiv2/crwimage.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ namespace Exiv2 {
7575
@param create Specifies if an existing image should be read (false)
7676
or if a new file should be created (true).
7777
*/
78-
CrwImage(BasicIo::AutoPtr io, bool create);
78+
CrwImage(BasicIo::UniquePtr io, bool create);
7979
//@}
8080

8181
//! @name Manipulators
@@ -161,7 +161,7 @@ namespace Exiv2 {
161161
Caller owns the returned object and the auto-pointer ensures that
162162
it will be deleted.
163163
*/
164-
EXIV2API Image::AutoPtr newCrwInstance(BasicIo::AutoPtr io, bool create);
164+
EXIV2API Image::UniquePtr newCrwInstance(BasicIo::UniquePtr io, bool create);
165165

166166
//! Check if the file iIo is a CRW image.
167167
EXIV2API bool isCrwType(BasicIo& iIo, bool advance);

include/exiv2/datasets.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ namespace Exiv2 {
275275
class EXIV2API IptcKey : public Key {
276276
public:
277277
//! Shortcut for an %IptcKey auto pointer.
278-
typedef std::auto_ptr<IptcKey> AutoPtr;
278+
typedef std::unique_ptr<IptcKey> UniquePtr;
279279

280280
//! @name Creators
281281
//@{
@@ -320,7 +320,7 @@ namespace Exiv2 {
320320
virtual std::string tagName() const;
321321
virtual std::string tagLabel() const;
322322
virtual uint16_t tag() const;
323-
AutoPtr clone() const;
323+
UniquePtr clone() const;
324324
//! Return the name of the record
325325
std::string recordName() const;
326326
//! Return the record id

include/exiv2/exif.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ namespace Exiv2 {
192192
long toLong(long n =0) const;
193193
float toFloat(long n =0) const;
194194
Rational toRational(long n =0) const;
195-
Value::AutoPtr getValue() const;
195+
Value::UniquePtr getValue() const;
196196
const Value& value() const;
197197
//! Return the size of the data area.
198198
long sizeDataArea() const;
@@ -213,8 +213,8 @@ namespace Exiv2 {
213213

214214
private:
215215
// DATA
216-
ExifKey::AutoPtr key_; //!< Key
217-
Value::AutoPtr value_; //!< Value
216+
ExifKey::UniquePtr key_; //!< Key
217+
Value::UniquePtr value_; //!< Value
218218

219219
}; // class Exifdatum
220220

include/exiv2/gifimage.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace Exiv2 {
6666
instance after it is passed to this method. Use the Image::io()
6767
method to get a temporary reference.
6868
*/
69-
explicit GifImage(BasicIo::AutoPtr io);
69+
explicit GifImage(BasicIo::UniquePtr io);
7070
//@}
7171

7272
//! @name Manipulators
@@ -111,7 +111,7 @@ namespace Exiv2 {
111111
Caller owns the returned object and the auto-pointer ensures that
112112
it will be deleted.
113113
*/
114-
EXIV2API Image::AutoPtr newGifInstance(BasicIo::AutoPtr io, bool create);
114+
EXIV2API Image::UniquePtr newGifInstance(BasicIo::UniquePtr io, bool create);
115115

116116
//! Check if the file iIo is a GIF image.
117117
EXIV2API bool isGifType(BasicIo& iIo, bool advance);

include/exiv2/image.hpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace Exiv2 {
7878
class EXIV2API Image {
7979
public:
8080
//! Image auto_ptr type
81-
typedef std::auto_ptr<Image> AutoPtr;
81+
typedef std::unique_ptr<Image> UniquePtr;
8282

8383
//! @name Creators
8484
//@{
@@ -89,7 +89,7 @@ namespace Exiv2 {
8989
*/
9090
Image(int imageType,
9191
uint16_t supportedMetadata,
92-
BasicIo::AutoPtr io);
92+
BasicIo::UniquePtr io);
9393
//! Virtual Destructor
9494
virtual ~Image();
9595
//@}
@@ -481,7 +481,7 @@ namespace Exiv2 {
481481

482482
protected:
483483
// DATA
484-
BasicIo::AutoPtr io_; //!< Image data IO pointer
484+
BasicIo::UniquePtr io_; //!< Image data IO pointer
485485
ExifData exifData_; //!< Exif data container
486486
IptcData iptcData_; //!< IPTC data container
487487
XmpData xmpData_; //!< XMP data container
@@ -519,7 +519,7 @@ namespace Exiv2 {
519519
}; // class Image
520520

521521
//! Type for function pointer that creates new Image instances
522-
typedef Image::AutoPtr (*NewInstanceFct)(BasicIo::AutoPtr io, bool create);
522+
typedef Image::UniquePtr (*NewInstanceFct)(BasicIo::UniquePtr io, bool create);
523523
//! Type for function pointer that checks image types
524524
typedef bool (*IsThisTypeFct)(BasicIo& iIo, bool advance);
525525

@@ -545,13 +545,13 @@ namespace Exiv2 {
545545
@throw Error If the file is not found or it is unable to connect to the server to
546546
read the remote file.
547547
*/
548-
static BasicIo::AutoPtr createIo(const std::string& path, bool useCurl = true);
548+
static BasicIo::UniquePtr createIo(const std::string& path, bool useCurl = true);
549549
#ifdef EXV_UNICODE_PATH
550550
/*!
551551
@brief Like createIo() but accepts a unicode path in an std::wstring.
552552
@note This function is only available on Windows.
553553
*/
554-
static BasicIo::AutoPtr createIo(const std::wstring& wpath, bool useCurl = true);
554+
static BasicIo::UniquePtr createIo(const std::wstring& wpath, bool useCurl = true);
555555
#endif
556556
/*!
557557
@brief Create an Image subclass of the appropriate type by reading
@@ -566,13 +566,13 @@ namespace Exiv2 {
566566
@throw Error If opening the file fails or it contains data of an
567567
unknown image type.
568568
*/
569-
static Image::AutoPtr open(const std::string& path, bool useCurl = true);
569+
static Image::UniquePtr open(const std::string& path, bool useCurl = true);
570570
#ifdef EXV_UNICODE_PATH
571571
/*!
572572
@brief Like open() but accepts a unicode path in an std::wstring.
573573
@note This function is only available on Windows.
574574
*/
575-
static Image::AutoPtr open(const std::wstring& wpath, bool useCurl = true);
575+
static Image::UniquePtr open(const std::wstring& wpath, bool useCurl = true);
576576
#endif
577577
/*!
578578
@brief Create an Image subclass of the appropriate type by reading
@@ -585,7 +585,7 @@ namespace Exiv2 {
585585
matches that of the data buffer.
586586
@throw Error If the memory contains data of an unknown image type.
587587
*/
588-
static Image::AutoPtr open(const byte* data, long size);
588+
static Image::UniquePtr open(const byte* data, long size);
589589
/*!
590590
@brief Create an Image subclass of the appropriate type by reading
591591
the provided BasicIo instance. %Image type is derived from the
@@ -603,7 +603,7 @@ namespace Exiv2 {
603603
determined, the pointer is 0.
604604
@throw Error If opening the BasicIo fails
605605
*/
606-
static Image::AutoPtr open(BasicIo::AutoPtr io);
606+
static Image::UniquePtr open(BasicIo::UniquePtr io);
607607
/*!
608608
@brief Create an Image subclass of the requested type by creating a
609609
new image file. If the file already exists, it will be overwritten.
@@ -613,13 +613,13 @@ namespace Exiv2 {
613613
type.
614614
@throw Error If the image type is not supported.
615615
*/
616-
static Image::AutoPtr create(int type, const std::string& path);
616+
static Image::UniquePtr create(int type, const std::string& path);
617617
#ifdef EXV_UNICODE_PATH
618618
/*!
619619
@brief Like create() but accepts a unicode path in an std::wstring.
620620
@note This function is only available on Windows.
621621
*/
622-
static Image::AutoPtr create(int type, const std::wstring& wpath);
622+
static Image::UniquePtr create(int type, const std::wstring& wpath);
623623
#endif
624624
/*!
625625
@brief Create an Image subclass of the requested type by creating a
@@ -629,7 +629,7 @@ namespace Exiv2 {
629629
type.
630630
@throw Error If the image type is not supported
631631
*/
632-
static Image::AutoPtr create(int type);
632+
static Image::UniquePtr create(int type);
633633
/*!
634634
@brief Create an Image subclass of the requested type by writing a
635635
new image to a BasicIo instance. If the BasicIo instance already
@@ -644,7 +644,7 @@ namespace Exiv2 {
644644
@return An auto-pointer that owns an Image instance of the requested
645645
type. If the image type is not supported, the pointer is 0.
646646
*/
647-
static Image::AutoPtr create(int type, BasicIo::AutoPtr io);
647+
static Image::UniquePtr create(int type, BasicIo::UniquePtr io);
648648
/*!
649649
@brief Returns the image type of the provided file.
650650
@param path %Image file. The contents of the file are tested to

include/exiv2/iptc.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ namespace Exiv2 {
142142
long toLong(long n =0) const;
143143
float toFloat(long n =0) const;
144144
Rational toRational(long n =0) const;
145-
Value::AutoPtr getValue() const;
145+
Value::UniquePtr getValue() const;
146146
const Value& value() const;
147147
//@}
148148

149149
private:
150150
// DATA
151-
IptcKey::AutoPtr key_; //!< Key
152-
Value::AutoPtr value_; //!< Value
151+
IptcKey::UniquePtr key_; //!< Key
152+
Value::UniquePtr value_; //!< Value
153153

154154
}; // class Iptcdatum
155155

include/exiv2/jp2image.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace Exiv2
6666
@param create Specifies if an existing image should be read (false)
6767
or if a new file should be created (true).
6868
*/
69-
Jp2Image(BasicIo::AutoPtr io, bool create);
69+
Jp2Image(BasicIo::UniquePtr io, bool create);
7070
//@}
7171

7272
//! @name Manipulators
@@ -130,7 +130,7 @@ namespace Exiv2
130130
Caller owns the returned object and the auto-pointer ensures that
131131
it will be deleted.
132132
*/
133-
EXIV2API Image::AutoPtr newJp2Instance(BasicIo::AutoPtr io, bool create);
133+
EXIV2API Image::UniquePtr newJp2Instance(BasicIo::UniquePtr io, bool create);
134134

135135
//! Check if the file iIo is a JPEG-2000 image.
136136
EXIV2API bool isJp2Type(BasicIo& iIo, bool advance);

0 commit comments

Comments
 (0)