Skip to content

Commit

Permalink
cpp: Replace auto_ptr by unique_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
piponazo committed Apr 15, 2021
1 parent 537cdad commit 0bbaa6e
Show file tree
Hide file tree
Showing 102 changed files with 646 additions and 638 deletions.
4 changes: 4 additions & 0 deletions cmake/compilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# These flags applies to exiv2lib, the applications, and to the xmp code
include(CheckCXXCompilerFlag)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN
if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(COMPILER_IS_GCC ON)
Expand Down
2 changes: 1 addition & 1 deletion cmake/compilerFlagsExiv2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(CheckCXXCompilerFlag)

if (COMPILER_IS_GCC OR COMPILER_IS_CLANG) # MINGW, Linux, APPLE, CYGWIN
if ( EXIV2_TEAM_WARNINGS_AS_ERRORS )
add_compile_options(-Werror -Wno-error=deprecated-declarations)
add_compile_options(-Werror)
check_cxx_compiler_flag(-Wno-error=deprecated-copy DEPRECATED_COPY)
if ( DEPRECATED_COPY)
add_compile_options(-Wno-error=deprecated-copy)
Expand Down
4 changes: 2 additions & 2 deletions cmake/printSummary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ message( STATUS "RelWithDebInfo: ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}" )
message( STATUS "MinSizeRel: ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}" )
message( STATUS "" )
message( STATUS "Compiler Options")
OptionOutput( "Warnings as errors: " EXIV2_WARNINGS_AS_ERRORS )
OptionOutput( "Use extra compiler warning flags: " EXIV2_EXTRA_WARNINGS )
OptionOutput( "Warnings as errors: " EXIV2_TEAM_WARNINGS_AS_ERRORS )
OptionOutput( "Use extra compiler warning flags: " EXIV2_TEAM_EXTRA_WARNINGS )
message( STATUS "" )

message( STATUS "------------------------------------------------------------------" )
Expand Down
4 changes: 2 additions & 2 deletions include/exiv2/asfvideo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace Exiv2 {
instance after it is passed to this method. Use the Image::io()
method to get a temporary reference.
*/
AsfVideo(BasicIo::AutoPtr io);
AsfVideo(BasicIo::UniquePtr io);
//@}

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

//! Check if the file iIo is a Windows Asf Video.
EXIV2LIB_DEPRECATED_EXPORT bool isAsfType(BasicIo& iIo, bool advance);
Expand Down
8 changes: 4 additions & 4 deletions include/exiv2/basicio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "types.hpp"

// + standard includes
#include <memory> // for std::auto_ptr
#include <memory>

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

//! Seek starting positions
enum Position { beg, cur, end };
Expand Down Expand Up @@ -521,7 +521,7 @@ namespace Exiv2 {

// Pimpl idiom
class Impl;
std::auto_ptr<Impl> p_;
std::unique_ptr<Impl> p_;

}; // class FileIo

Expand Down Expand Up @@ -721,7 +721,7 @@ namespace Exiv2 {

// Pimpl idiom
class Impl;
std::auto_ptr<Impl> p_;
std::unique_ptr<Impl> p_;

}; // class MemIo

Expand Down
4 changes: 2 additions & 2 deletions include/exiv2/bmffimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace Exiv2
@param create Specifies if an existing image should be read (false)
or if a new file should be created (true).
*/
BmffImage(BasicIo::AutoPtr io, bool create);
BmffImage(BasicIo::UniquePtr io, bool create);
//@}

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

//! Check if the file iIo is a BMFF image.
EXIV2API bool isBmffType(BasicIo& iIo, bool advance);
Expand Down
4 changes: 2 additions & 2 deletions include/exiv2/bmpimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Exiv2 {
instance after it is passed to this method. Use the Image::io()
method to get a temporary reference.
*/
explicit BmpImage(BasicIo::AutoPtr io);
explicit BmpImage(BasicIo::UniquePtr io);
//@}

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

//! Check if the file iIo is a Windows Bitmap image.
EXIV2API bool isBmpType(BasicIo& iIo, bool advance);
Expand Down
4 changes: 2 additions & 2 deletions include/exiv2/cr2image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace Exiv2 {
@param create Specifies if an existing image should be read (false)
or if a new file should be created (true).
*/
Cr2Image(BasicIo::AutoPtr io, bool create);
Cr2Image(BasicIo::UniquePtr io, bool create);
//@}

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

//! Check if the file iIo is a CR2 image.
EXIV2API bool isCr2Type(BasicIo& iIo, bool advance);
Expand Down
4 changes: 2 additions & 2 deletions include/exiv2/crwimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace Exiv2 {
@param create Specifies if an existing image should be read (false)
or if a new file should be created (true).
*/
CrwImage(BasicIo::AutoPtr io, bool create);
CrwImage(BasicIo::UniquePtr io, bool create);
//@}

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

//! Check if the file iIo is a CRW image.
EXIV2API bool isCrwType(BasicIo& iIo, bool advance);
Expand Down
4 changes: 2 additions & 2 deletions include/exiv2/datasets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ namespace Exiv2 {
class EXIV2API IptcKey : public Key {
public:
//! Shortcut for an %IptcKey auto pointer.
typedef std::auto_ptr<IptcKey> AutoPtr;
typedef std::unique_ptr<IptcKey> UniquePtr;

//! @name Creators
//@{
Expand Down Expand Up @@ -320,7 +320,7 @@ namespace Exiv2 {
virtual std::string tagName() const;
virtual std::string tagLabel() const;
virtual uint16_t tag() const;
AutoPtr clone() const;
UniquePtr clone() const;
//! Return the name of the record
std::string recordName() const;
//! Return the record id
Expand Down
6 changes: 3 additions & 3 deletions include/exiv2/exif.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ namespace Exiv2 {
long toLong(long n =0) const;
float toFloat(long n =0) const;
Rational toRational(long n =0) const;
Value::AutoPtr getValue() const;
Value::UniquePtr getValue() const;
const Value& value() const;
//! Return the size of the data area.
long sizeDataArea() const;
Expand All @@ -213,8 +213,8 @@ namespace Exiv2 {

private:
// DATA
ExifKey::AutoPtr key_; //!< Key
Value::AutoPtr value_; //!< Value
ExifKey::UniquePtr key_; //!< Key
Value::UniquePtr value_; //!< Value

}; // class Exifdatum

Expand Down
4 changes: 2 additions & 2 deletions include/exiv2/gifimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace Exiv2 {
instance after it is passed to this method. Use the Image::io()
method to get a temporary reference.
*/
explicit GifImage(BasicIo::AutoPtr io);
explicit GifImage(BasicIo::UniquePtr io);
//@}

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

//! Check if the file iIo is a GIF image.
EXIV2API bool isGifType(BasicIo& iIo, bool advance);
Expand Down
28 changes: 14 additions & 14 deletions include/exiv2/image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace Exiv2 {
class EXIV2API Image {
public:
//! Image auto_ptr type
typedef std::auto_ptr<Image> AutoPtr;
typedef std::unique_ptr<Image> UniquePtr;

//! @name Creators
//@{
Expand All @@ -89,7 +89,7 @@ namespace Exiv2 {
*/
Image(int imageType,
uint16_t supportedMetadata,
BasicIo::AutoPtr io);
BasicIo::UniquePtr io);
//! Virtual Destructor
virtual ~Image();
//@}
Expand Down Expand Up @@ -481,7 +481,7 @@ namespace Exiv2 {

protected:
// DATA
BasicIo::AutoPtr io_; //!< Image data IO pointer
BasicIo::UniquePtr io_; //!< Image data IO pointer
ExifData exifData_; //!< Exif data container
IptcData iptcData_; //!< IPTC data container
XmpData xmpData_; //!< XMP data container
Expand Down Expand Up @@ -519,7 +519,7 @@ namespace Exiv2 {
}; // class Image

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

Expand All @@ -545,13 +545,13 @@ namespace Exiv2 {
@throw Error If the file is not found or it is unable to connect to the server to
read the remote file.
*/
static BasicIo::AutoPtr createIo(const std::string& path, bool useCurl = true);
static BasicIo::UniquePtr createIo(const std::string& path, bool useCurl = true);
#ifdef EXV_UNICODE_PATH
/*!
@brief Like createIo() but accepts a unicode path in an std::wstring.
@note This function is only available on Windows.
*/
static BasicIo::AutoPtr createIo(const std::wstring& wpath, bool useCurl = true);
static BasicIo::UniquePtr createIo(const std::wstring& wpath, bool useCurl = true);
#endif
/*!
@brief Create an Image subclass of the appropriate type by reading
Expand All @@ -566,13 +566,13 @@ namespace Exiv2 {
@throw Error If opening the file fails or it contains data of an
unknown image type.
*/
static Image::AutoPtr open(const std::string& path, bool useCurl = true);
static Image::UniquePtr open(const std::string& path, bool useCurl = true);
#ifdef EXV_UNICODE_PATH
/*!
@brief Like open() but accepts a unicode path in an std::wstring.
@note This function is only available on Windows.
*/
static Image::AutoPtr open(const std::wstring& wpath, bool useCurl = true);
static Image::UniquePtr open(const std::wstring& wpath, bool useCurl = true);
#endif
/*!
@brief Create an Image subclass of the appropriate type by reading
Expand All @@ -585,7 +585,7 @@ namespace Exiv2 {
matches that of the data buffer.
@throw Error If the memory contains data of an unknown image type.
*/
static Image::AutoPtr open(const byte* data, long size);
static Image::UniquePtr open(const byte* data, long size);
/*!
@brief Create an Image subclass of the appropriate type by reading
the provided BasicIo instance. %Image type is derived from the
Expand All @@ -603,7 +603,7 @@ namespace Exiv2 {
determined, the pointer is 0.
@throw Error If opening the BasicIo fails
*/
static Image::AutoPtr open(BasicIo::AutoPtr io);
static Image::UniquePtr open(BasicIo::UniquePtr io);
/*!
@brief Create an Image subclass of the requested type by creating a
new image file. If the file already exists, it will be overwritten.
Expand All @@ -613,13 +613,13 @@ namespace Exiv2 {
type.
@throw Error If the image type is not supported.
*/
static Image::AutoPtr create(int type, const std::string& path);
static Image::UniquePtr create(int type, const std::string& path);
#ifdef EXV_UNICODE_PATH
/*!
@brief Like create() but accepts a unicode path in an std::wstring.
@note This function is only available on Windows.
*/
static Image::AutoPtr create(int type, const std::wstring& wpath);
static Image::UniquePtr create(int type, const std::wstring& wpath);
#endif
/*!
@brief Create an Image subclass of the requested type by creating a
Expand All @@ -629,7 +629,7 @@ namespace Exiv2 {
type.
@throw Error If the image type is not supported
*/
static Image::AutoPtr create(int type);
static Image::UniquePtr create(int type);
/*!
@brief Create an Image subclass of the requested type by writing a
new image to a BasicIo instance. If the BasicIo instance already
Expand All @@ -644,7 +644,7 @@ namespace Exiv2 {
@return An auto-pointer that owns an Image instance of the requested
type. If the image type is not supported, the pointer is 0.
*/
static Image::AutoPtr create(int type, BasicIo::AutoPtr io);
static Image::UniquePtr create(int type, BasicIo::UniquePtr io);
/*!
@brief Returns the image type of the provided file.
@param path %Image file. The contents of the file are tested to
Expand Down
6 changes: 3 additions & 3 deletions include/exiv2/iptc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ namespace Exiv2 {
long toLong(long n =0) const;
float toFloat(long n =0) const;
Rational toRational(long n =0) const;
Value::AutoPtr getValue() const;
Value::UniquePtr getValue() const;
const Value& value() const;
//@}

private:
// DATA
IptcKey::AutoPtr key_; //!< Key
Value::AutoPtr value_; //!< Value
IptcKey::UniquePtr key_; //!< Key
Value::UniquePtr value_; //!< Value

}; // class Iptcdatum

Expand Down
4 changes: 2 additions & 2 deletions include/exiv2/jp2image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace Exiv2
@param create Specifies if an existing image should be read (false)
or if a new file should be created (true).
*/
Jp2Image(BasicIo::AutoPtr io, bool create);
Jp2Image(BasicIo::UniquePtr io, bool create);
//@}

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

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

0 comments on commit 0bbaa6e

Please sign in to comment.