From ebdf0514921019bbd261a85aecd6e684e8098c2a Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 26 Apr 2021 23:49:31 -0700 Subject: [PATCH] clang-tidy: use using Found with modernize-use-using Signed-off-by: Rosen Penev --- samples/easyaccess-test.cpp | 2 +- samples/exifdata.cpp | 12 +++++++++--- samples/exiv2json.cpp | 2 +- samples/geotag.cpp | 6 +++--- src/actions.hpp | 24 ++++++++++++------------ src/basicio.cpp | 8 ++++---- src/convert.cpp | 4 ++-- src/crwimage_int.hpp | 17 ++++++----------- src/exif.cpp | 6 +++--- src/exiv2.cpp | 2 +- src/exiv2app.hpp | 14 +++++++------- src/futils.cpp | 2 +- src/http.cpp | 2 +- src/makernote_int.hpp | 18 +++++++++--------- src/preview.cpp | 4 ++-- src/safe_op.hpp | 2 +- src/tiffcomposite_int.hpp | 14 +++++++------- src/tifffwd_int.hpp | 21 +++++++-------------- src/tiffimage_int.hpp | 2 +- src/tiffvisitor_int.hpp | 6 +++--- 20 files changed, 81 insertions(+), 87 deletions(-) diff --git a/samples/easyaccess-test.cpp b/samples/easyaccess-test.cpp index a27239f5dd..6ead23abae 100644 --- a/samples/easyaccess-test.cpp +++ b/samples/easyaccess-test.cpp @@ -25,7 +25,7 @@ #include #include -typedef Exiv2::ExifData::const_iterator (*EasyAccessFct)(const Exiv2::ExifData& ed); +using EasyAccessFct = Exiv2::ExifData::const_iterator (*)(const Exiv2::ExifData&); struct EasyAccess { const char* label_; diff --git a/samples/exifdata.cpp b/samples/exifdata.cpp index 423d5743b0..da235c673e 100644 --- a/samples/exifdata.cpp +++ b/samples/exifdata.cpp @@ -26,9 +26,15 @@ #include #include -typedef std::map format_t; -typedef format_t::const_iterator format_i; -typedef enum { wolf , csv , json , xml } format_e; +using format_t = std::map; +using format_i = format_t::const_iterator; +enum format_e +{ + wolf, + csv, + json, + xml +}; void syntax(const char* argv[],format_t& formats) { diff --git a/samples/exiv2json.cpp b/samples/exiv2json.cpp index 9db4f69222..6d6e885baa 100644 --- a/samples/exiv2json.cpp +++ b/samples/exiv2json.cpp @@ -60,7 +60,7 @@ struct Token { bool a; // name is an array eg History[] int i; // index (indexed from 1) eg History[1]/stEvt:action }; -typedef std::vector Tokens; +using Tokens = std::vector; // "XMP.xmp.MP.RegionInfo/MPRI:Regions[1]/MPReg:Rectangle" bool getToken(std::string& in,Token& token, std::set* pNS=NULL) diff --git a/samples/geotag.cpp b/samples/geotag.cpp index b5ba9bc52a..48a31da3e8 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -156,9 +156,9 @@ enum class Position; // globals -typedef std::map TimeDict_t; -typedef std::map::iterator TimeDict_i; -typedef std::vector strings_t; +using TimeDict_t = std::map; +using TimeDict_i = std::map::iterator; +using strings_t = std::vector; const char* gDeg = NULL ; // string "°" or "deg" TimeDict_t gTimeDict ; strings_t gFiles; diff --git a/src/actions.hpp b/src/actions.hpp index 2120e4de92..79c57b938c 100644 --- a/src/actions.hpp +++ b/src/actions.hpp @@ -65,7 +65,7 @@ namespace Action { class Task { public: //! Shortcut for an auto pointer. - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! Virtual destructor. virtual ~Task(); //! Virtual copy construction. @@ -150,7 +150,7 @@ namespace Action { //! Pointer to the one and only instance of this class. static TaskFactory* instance_; //! Type used to store Task prototype classes - typedef std::map Registry; + using Registry = std::map; //! List of task types and corresponding prototypes. Registry registry_; @@ -161,7 +161,7 @@ namespace Action { public: virtual ~Print(); virtual int run(const std::string& path); - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; UniquePtr clone() const; //! Print the Jpeg comment @@ -191,7 +191,7 @@ namespace Action { const std::string& key, const std::string& label ="") const; //! Type for an Exiv2 Easy access function - typedef Exiv2::ExifData::const_iterator (*EasyAccessFct)(const Exiv2::ExifData& ed); + using EasyAccessFct = Exiv2::ExifData::const_iterator (*)(const Exiv2::ExifData& ed); /*! @brief Print one summary line with a label (if provided) and requested data. A line break is printed only if a label is provided. @@ -217,7 +217,7 @@ namespace Action { public: virtual ~Rename(); virtual int run(const std::string& path); - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; UniquePtr clone() const; private: @@ -229,7 +229,7 @@ namespace Action { public: virtual ~Adjust(); virtual int run(const std::string& path); - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; UniquePtr clone() const; private: @@ -252,7 +252,7 @@ namespace Action { public: virtual ~Erase(); virtual int run(const std::string& path); - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; UniquePtr clone() const; /*! @@ -294,7 +294,7 @@ namespace Action { public: virtual ~Extract(); virtual int run(const std::string& path); - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; UniquePtr clone() const; /*! @@ -333,7 +333,7 @@ namespace Action { public: virtual ~Insert(); virtual int run(const std::string& path); - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; UniquePtr clone() const; /*! @@ -374,7 +374,7 @@ namespace Action { public: virtual ~Modify(); virtual int run(const std::string& path); - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; UniquePtr clone() const; Modify() {} //! Apply modification commands to the \em pImage, return 0 if successful. @@ -407,7 +407,7 @@ namespace Action { public: virtual ~FixIso(); virtual int run(const std::string& path); - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; UniquePtr clone() const; private: @@ -425,7 +425,7 @@ namespace Action { public: virtual ~FixCom(); virtual int run(const std::string& path); - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; UniquePtr clone() const; private: diff --git a/src/basicio.cpp b/src/basicio.cpp index 73ec03b1f8..bd09534ee8 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -69,7 +69,7 @@ #if defined(__MINGW__) || (defined(WIN32) && !defined(__CYGWIN__)) // Windows doesn't provide nlink_t -typedef short nlink_t; +using nlink_t = short; # include # include #endif @@ -321,7 +321,7 @@ namespace Exiv2 { HANDLE hFd = (HANDLE)_get_osfhandle(fileno(fp_)); if (hFd != INVALID_HANDLE_VALUE) { - typedef BOOL (WINAPI * GetFileInformationByHandle_t)(HANDLE, LPBY_HANDLE_FILE_INFORMATION); + using GetFileInformationByHandle_t = BOOL(WINAPI*)(HANDLE, LPBY_HANDLE_FILE_INFORMATION); HMODULE hKernel = ::GetModuleHandleA("kernel32.dll"); if (hKernel) { GetFileInformationByHandle_t pfcn_GetFileInformationByHandle = (GetFileInformationByHandle_t)GetProcAddress(hKernel, "GetFileInformationByHandle"); @@ -699,7 +699,7 @@ namespace Exiv2 { // that file has been opened with FILE_SHARE_DELETE by another process, // like a virus scanner or disk indexer // (see also http://stackoverflow.com/a/11023068) - typedef BOOL (WINAPI * ReplaceFileW_t)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID); + using ReplaceFileW_t = BOOL(WINAPI*)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID); HMODULE hKernel = ::GetModuleHandleA("kernel32.dll"); if (hKernel) { ReplaceFileW_t pfcn_ReplaceFileW = (ReplaceFileW_t)GetProcAddress(hKernel, "ReplaceFileW"); @@ -762,7 +762,7 @@ namespace Exiv2 { // that file has been opened with FILE_SHARE_DELETE by another process, // like a virus scanner or disk indexer // (see also http://stackoverflow.com/a/11023068) - typedef BOOL (WINAPI * ReplaceFileA_t)(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID); + using ReplaceFileA_t = BOOL(WINAPI*)(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID); HMODULE hKernel = ::GetModuleHandleA("kernel32.dll"); if (hKernel) { ReplaceFileA_t pfcn_ReplaceFileA = (ReplaceFileA_t)GetProcAddress(hKernel, "ReplaceFileA"); diff --git a/src/convert.cpp b/src/convert.cpp index 67b0e35530..3a382af69b 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -104,7 +104,7 @@ namespace Exiv2 { These functions have access to both the source and destination metadata containers and store the result directly in the destination container. */ - typedef void (Converter::*ConvertFct)(const char* from, const char* to); + using ConvertFct = void (Converter::*)(const char*, const char*); //! Structure to define conversions between two keys. struct Conversion { MetadataId metadataId_; //!< Type of metadata for the first key. @@ -1481,7 +1481,7 @@ namespace { return true; } - typedef bool (*ConvFct)(std::string& str); + using ConvFct = bool (*)(std::string& str); struct ConvFctList { bool operator==(const std::pair &fromTo) const diff --git a/src/crwimage_int.hpp b/src/crwimage_int.hpp index 54352ee807..b1bdacec10 100644 --- a/src/crwimage_int.hpp +++ b/src/crwimage_int.hpp @@ -52,18 +52,13 @@ namespace Exiv2 { // type definitions //! Function pointer for functions to decode Exif tags from a CRW entry - typedef void (*CrwDecodeFct)(const CiffComponent&, - const CrwMapping*, - Image&, - ByteOrder); + using CrwDecodeFct = void (*)(const CiffComponent&, const CrwMapping*, Image&, ByteOrder); //! Function pointer for functions to encode CRW entries from Exif tags - typedef void (*CrwEncodeFct)(const Image&, - const CrwMapping*, - CiffHeader*); + using CrwEncodeFct = void (*)(const Image&, const CrwMapping*, CiffHeader*); //! Stack to hold a path of CRW directories - typedef std::stack CrwDirs; + using CrwDirs = std::stack; //! Type to identify where the data is stored in a directory enum DataLocId { @@ -84,9 +79,9 @@ namespace Exiv2 { class CiffComponent { public: //! CiffComponent auto_ptr type - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! Container type to hold all metadata - typedef std::vector Components; + using Components = std::vector; //! @name Creators //@{ @@ -428,7 +423,7 @@ namespace Exiv2 { class CiffHeader { public: //! CiffHeader auto_ptr type - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! @name Creators //@{ diff --git a/src/exif.cpp b/src/exif.cpp index 3a7983ba56..e2cfd4f7dd 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -80,7 +80,7 @@ namespace { class Thumbnail { public: //! Shortcut for a %Thumbnail auto pointer. - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! @name Creators //@{ @@ -123,7 +123,7 @@ namespace { class TiffThumbnail : public Thumbnail { public: //! Shortcut for a %TiffThumbnail auto pointer. - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! @name Manipulators //@{ @@ -147,7 +147,7 @@ namespace { class JpegThumbnail : public Thumbnail { public: //! Shortcut for a %JpegThumbnail auto pointer. - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! @name Manipulators //@{ diff --git a/src/exiv2.cpp b/src/exiv2.cpp index 40d2c0bb55..2c3613190e 100644 --- a/src/exiv2.cpp +++ b/src/exiv2.cpp @@ -1035,7 +1035,7 @@ void Params::getStdin(Exiv2::DataBuf& buf) } // Params::getStdin() -typedef std::map long_t; +using long_t = std::map; int Params::getopt(int argc, char* const Argv[]) { diff --git a/src/exiv2app.hpp b/src/exiv2app.hpp index a19b8ca56c..4f2ce68fa4 100644 --- a/src/exiv2app.hpp +++ b/src/exiv2app.hpp @@ -93,7 +93,7 @@ struct ModifyCmd { std::string value_; //!< Data }; //! Container for modification commands -typedef std::vector ModifyCmds; +using ModifyCmds = std::vector; //! Structure to link command identifiers to strings struct CmdIdAndString { CmdId cmdId_; //!< Commands identifier @@ -141,17 +141,17 @@ class Params : public Util::Getopt { public: //! Container for command files - typedef std::vector CmdFiles; + using CmdFiles = std::vector; //! Container for commands from the command line - typedef std::vector CmdLines; + using CmdLines = std::vector; //! Container to store filenames. - typedef std::vector Files; + using Files = std::vector; //! Container for preview image numbers - typedef std::set PreviewNumbers; + using PreviewNumbers = std::set; //! Container for greps - typedef exv_grep_keys_t Greps; + using Greps = exv_grep_keys_t; //! Container for keys - typedef std::vector Keys; + using Keys = std::vector; /*! @brief Controls all access to the global Params instance. diff --git a/src/futils.cpp b/src/futils.cpp index 4d9b87eee9..1868b785a2 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -362,7 +362,7 @@ namespace Exiv2 { { Uri result; - typedef std::string::const_iterator iterator_t; + using iterator_t = std::string::const_iterator; if ( !uri.length() ) return result; diff --git a/src/http.cpp b/src/http.cpp index 8ecd00b19d..1d6e68131f 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -76,7 +76,7 @@ #define fopen_S(f,n,o) f=fopen(n,o) #define WINAPI -typedef unsigned long DWORD ; +using DWORD = unsigned long; #define SOCKET_ERROR -1 #define WSAEWOULDBLOCK EINPROGRESS diff --git a/src/makernote_int.hpp b/src/makernote_int.hpp index d4282b7640..cde8712ced 100644 --- a/src/makernote_int.hpp +++ b/src/makernote_int.hpp @@ -51,17 +51,17 @@ namespace Exiv2 { // class definitions //! Type for a pointer to a function creating a makernote (image) - typedef TiffComponent* (*NewMnFct)(uint16_t tag, - IfdId group, - IfdId mnGroup, - const byte* pData, - uint32_t size, - ByteOrder byteOrder); + using NewMnFct = TiffComponent* (*)(uint16_t tag, + IfdId group, + IfdId mnGroup, + const byte* pData, + uint32_t size, + ByteOrder byteOrder); //! Type for a pointer to a function creating a makernote (group) - typedef TiffComponent* (*NewMnFct2)(uint16_t tag, - IfdId group, - IfdId mnGroup); + using NewMnFct2 = TiffComponent* (*)(uint16_t tag, + IfdId group, + IfdId mnGroup); //! Makernote registry structure struct TiffMnRegistry { diff --git a/src/preview.cpp b/src/preview.cpp index 5629a8ba93..8ea0c33008 100644 --- a/src/preview.cpp +++ b/src/preview.cpp @@ -89,7 +89,7 @@ namespace { virtual ~Loader() {} //! Loader auto pointer - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! Create a Loader subclass for requested id static UniquePtr create(PreviewId id, const Image &image); @@ -114,7 +114,7 @@ namespace { Loader(PreviewId id, const Image &image); //! Functions that creates a loader from given parameters - typedef UniquePtr (*CreateFunc)(PreviewId id, const Image &image, int parIdx); + using CreateFunc = UniquePtr (*)(PreviewId, const Image &, int); //! Structure to list possible loaders struct LoaderList { diff --git a/src/safe_op.hpp b/src/safe_op.hpp index ddcc44b80e..8972e71852 100644 --- a/src/safe_op.hpp +++ b/src/safe_op.hpp @@ -90,7 +90,7 @@ namespace Safe template struct enable_if { - typedef T type; + using type = T; }; /*! diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 46a581b11e..155b1ed17b 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -45,7 +45,7 @@ namespace Exiv2 { // class definitions //! TIFF value type. - typedef uint16_t TiffType; + using TiffType = uint16_t; const TiffType ttUnsignedByte = 1; //!< Exif BYTE type const TiffType ttAsciiString = 2; //!< Exif ASCII type @@ -172,9 +172,9 @@ namespace Exiv2 { class TiffComponent { public: //! TiffComponent auto_ptr type - typedef std::unique_ptr UniquePtr; + using UniquePtr = std::unique_ptr; //! Container type to hold all metadata - typedef std::vector Components; + using Components = std::vector; //! @name Creators //@{ @@ -801,7 +801,7 @@ namespace Exiv2 { private: //! Pointers to the image data (strips) and their sizes. - typedef std::vector > Strips; + using Strips = std::vector>; // DATA Strips strips_; //!< Image strips data (never alloc'd) and sizes @@ -1054,7 +1054,7 @@ namespace Exiv2 { //@} //! A collection of TIFF directories (IFDs) - typedef std::vector Ifds; + using Ifds = std::vector; // DATA IfdId newGroup_; //!< Start of the range of group numbers for the sub-IFDs @@ -1305,10 +1305,10 @@ namespace Exiv2 { @brief Function pointer type for a function to determine which cfg + def of a corresponding array set to use. */ - typedef int (*CfgSelFct)(uint16_t, const byte*, uint32_t, TiffComponent* const); + using CfgSelFct = int (*)(uint16_t, const byte*, uint32_t, TiffComponent* const); //! Function pointer type for a crypt function used for binary arrays. - typedef DataBuf (*CryptFct)(uint16_t, const byte*, uint32_t, TiffComponent* const); + using CryptFct = DataBuf (*)(uint16_t, const byte*, uint32_t, TiffComponent* const); //! Defines one tag in a binary array struct ArrayDef { diff --git a/src/tifffwd_int.hpp b/src/tifffwd_int.hpp index 55ea91aa21..f62ced672d 100644 --- a/src/tifffwd_int.hpp +++ b/src/tifffwd_int.hpp @@ -73,39 +73,32 @@ namespace Exiv2 { @brief Function pointer type for a TiffDecoder member function to decode a TIFF component. */ - typedef void (TiffDecoder::*DecoderFct)(const TiffEntryBase*); + using DecoderFct = void (TiffDecoder::*)(const TiffEntryBase*); /*! @brief Function pointer type for a TiffDecoder member function to decode a TIFF component. */ - typedef void (TiffEncoder::*EncoderFct)(TiffEntryBase*, const Exifdatum*); + using EncoderFct = void (TiffEncoder::*)(TiffEntryBase*, const Exifdatum*); /*! @brief Type for a function pointer for a function to decode a TIFF component. */ - typedef DecoderFct (*FindDecoderFct)(const std::string& make, - uint32_t extendedTag, - IfdId group); + using FindDecoderFct = DecoderFct (*)(const std::string& make, uint32_t extendedTag, IfdId group); /*! @brief Type for a function pointer for a function to encode a TIFF component. */ - typedef EncoderFct (*FindEncoderFct)( - const std::string& make, - uint32_t extendedTag, - IfdId group - ); + using FindEncoderFct = EncoderFct (*)(const std::string& make, uint32_t extendedTag, IfdId group); /*! @brief Type for a function pointer for a function to create a TIFF component. Use TiffComponent::UniquePtr, it is not used in this declaration only to reduce dependencies. */ - typedef std::unique_ptr (*NewTiffCompFct)(uint16_t tag, IfdId group); + using NewTiffCompFct = std::unique_ptr (*)(uint16_t tag, IfdId group); //! Stack to hold a path from the TIFF root element to a TIFF entry - typedef std::stack TiffPath; + using TiffPath = std::stack; //! Type for a list of primary image groups - typedef std::vector PrimaryGroups; - + using PrimaryGroups = std::vector; }} // namespace Internal, Exiv2 #endif // #ifndef TIFFFWD_INT_HPP_ diff --git a/src/tiffimage_int.hpp b/src/tiffimage_int.hpp index 327e3acbbc..bb455de78c 100644 --- a/src/tiffimage_int.hpp +++ b/src/tiffimage_int.hpp @@ -457,7 +457,7 @@ namespace Exiv2 { ByteOrder byteOrder_; //!< Byte order to use to encode target address }; //! Type of the list containing an identifier and an address pair. - typedef std::map OffsetList; + using OffsetList = std::map; // DATA OffsetList offsetList_; //!< List of the offsets to replace diff --git a/src/tiffvisitor_int.hpp b/src/tiffvisitor_int.hpp index 4d320a6e25..08b4cb9081 100644 --- a/src/tiffvisitor_int.hpp +++ b/src/tiffvisitor_int.hpp @@ -706,9 +706,9 @@ namespace Exiv2 { //@} private: - typedef std::map DirList; - typedef std::map IdxSeq; - typedef std::vector PostList; + using DirList = std::map; + using IdxSeq = std::map; + using PostList = std::vector; // DATA const byte* pData_; //!< Pointer to the memory buffer