Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-tidy: use using #1610

Merged
merged 1 commit into from
May 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/easyaccess-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <iomanip>
#include <cassert>

typedef Exiv2::ExifData::const_iterator (*EasyAccessFct)(const Exiv2::ExifData& ed);
using EasyAccessFct = Exiv2::ExifData::const_iterator (*)(const Exiv2::ExifData&);

struct EasyAccess {
const char* label_;
Expand Down
12 changes: 9 additions & 3 deletions samples/exifdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@
#include <cassert>
#include <string>

typedef std::map<std::string,int> format_t;
typedef format_t::const_iterator format_i;
typedef enum { wolf , csv , json , xml } format_e;
using format_t = std::map<std::string, int>;
using format_i = format_t::const_iterator;
enum format_e
{
wolf,
csv,
json,
xml
};

void syntax(const char* argv[],format_t& formats)
{
Expand Down
2 changes: 1 addition & 1 deletion samples/exiv2json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Token> Tokens;
using Tokens = std::vector<Token>;

// "XMP.xmp.MP.RegionInfo/MPRI:Regions[1]/MPReg:Rectangle"
bool getToken(std::string& in,Token& token, std::set<std::string>* pNS=NULL)
Expand Down
6 changes: 3 additions & 3 deletions samples/geotag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ enum
class Position;

// globals
typedef std::map<time_t,Position> TimeDict_t;
typedef std::map<time_t,Position>::iterator TimeDict_i;
typedef std::vector<std::string> strings_t;
using TimeDict_t = std::map<time_t, Position>;
using TimeDict_i = std::map<time_t, Position>::iterator;
using strings_t = std::vector<std::string>;
const char* gDeg = NULL ; // string "°" or "deg"
TimeDict_t gTimeDict ;
strings_t gFiles;
Expand Down
24 changes: 12 additions & 12 deletions src/actions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace Action {
class Task {
public:
//! Shortcut for an auto pointer.
typedef std::unique_ptr<Task> UniquePtr;
using UniquePtr = std::unique_ptr<Task>;
//! Virtual destructor.
virtual ~Task();
//! Virtual copy construction.
Expand Down Expand Up @@ -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<TaskType, Task*> Registry;
using Registry = std::map<TaskType, Task*>;
//! List of task types and corresponding prototypes.
Registry registry_;

Expand All @@ -161,7 +161,7 @@ namespace Action {
public:
virtual ~Print();
virtual int run(const std::string& path);
typedef std::unique_ptr<Print> UniquePtr;
using UniquePtr = std::unique_ptr<Print>;
UniquePtr clone() const;

//! Print the Jpeg comment
Expand Down Expand Up @@ -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.
Expand All @@ -217,7 +217,7 @@ namespace Action {
public:
virtual ~Rename();
virtual int run(const std::string& path);
typedef std::unique_ptr<Rename> UniquePtr;
using UniquePtr = std::unique_ptr<Rename>;
UniquePtr clone() const;

private:
Expand All @@ -229,7 +229,7 @@ namespace Action {
public:
virtual ~Adjust();
virtual int run(const std::string& path);
typedef std::unique_ptr<Adjust> UniquePtr;
using UniquePtr = std::unique_ptr<Adjust>;
UniquePtr clone() const;

private:
Expand All @@ -252,7 +252,7 @@ namespace Action {
public:
virtual ~Erase();
virtual int run(const std::string& path);
typedef std::unique_ptr<Erase> UniquePtr;
using UniquePtr = std::unique_ptr<Erase>;
UniquePtr clone() const;

/*!
Expand Down Expand Up @@ -294,7 +294,7 @@ namespace Action {
public:
virtual ~Extract();
virtual int run(const std::string& path);
typedef std::unique_ptr<Extract> UniquePtr;
using UniquePtr = std::unique_ptr<Extract>;
UniquePtr clone() const;

/*!
Expand Down Expand Up @@ -333,7 +333,7 @@ namespace Action {
public:
virtual ~Insert();
virtual int run(const std::string& path);
typedef std::unique_ptr<Insert> UniquePtr;
using UniquePtr = std::unique_ptr<Insert>;
UniquePtr clone() const;

/*!
Expand Down Expand Up @@ -374,7 +374,7 @@ namespace Action {
public:
virtual ~Modify();
virtual int run(const std::string& path);
typedef std::unique_ptr<Modify> UniquePtr;
using UniquePtr = std::unique_ptr<Modify>;
UniquePtr clone() const;
Modify() {}
//! Apply modification commands to the \em pImage, return 0 if successful.
Expand Down Expand Up @@ -407,7 +407,7 @@ namespace Action {
public:
virtual ~FixIso();
virtual int run(const std::string& path);
typedef std::unique_ptr<FixIso> UniquePtr;
using UniquePtr = std::unique_ptr<FixIso>;
UniquePtr clone() const;

private:
Expand All @@ -425,7 +425,7 @@ namespace Action {
public:
virtual ~FixCom();
virtual int run(const std::string& path);
typedef std::unique_ptr<FixCom> UniquePtr;
using UniquePtr = std::unique_ptr<FixCom>;
UniquePtr clone() const;

private:
Expand Down
8 changes: 4 additions & 4 deletions src/basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <windows.h>
# include <io.h>
#endif
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<const char*, const char*> &fromTo) const
Expand Down
17 changes: 6 additions & 11 deletions src/crwimage_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CrwSubDir> CrwDirs;
using CrwDirs = std::stack<CrwSubDir>;

//! Type to identify where the data is stored in a directory
enum DataLocId {
Expand All @@ -84,9 +79,9 @@ namespace Exiv2 {
class CiffComponent {
public:
//! CiffComponent auto_ptr type
typedef std::unique_ptr<CiffComponent> UniquePtr;
using UniquePtr = std::unique_ptr<CiffComponent>;
//! Container type to hold all metadata
typedef std::vector<CiffComponent*> Components;
using Components = std::vector<CiffComponent*>;

//! @name Creators
//@{
Expand Down Expand Up @@ -428,7 +423,7 @@ namespace Exiv2 {
class CiffHeader {
public:
//! CiffHeader auto_ptr type
typedef std::unique_ptr<CiffHeader> UniquePtr;
using UniquePtr = std::unique_ptr<CiffHeader>;

//! @name Creators
//@{
Expand Down
6 changes: 3 additions & 3 deletions src/exif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace {
class Thumbnail {
public:
//! Shortcut for a %Thumbnail auto pointer.
typedef std::unique_ptr<Thumbnail> UniquePtr;
using UniquePtr = std::unique_ptr<Thumbnail>;

//! @name Creators
//@{
Expand Down Expand Up @@ -123,7 +123,7 @@ namespace {
class TiffThumbnail : public Thumbnail {
public:
//! Shortcut for a %TiffThumbnail auto pointer.
typedef std::unique_ptr<TiffThumbnail> UniquePtr;
using UniquePtr = std::unique_ptr<TiffThumbnail>;

//! @name Manipulators
//@{
Expand All @@ -147,7 +147,7 @@ namespace {
class JpegThumbnail : public Thumbnail {
public:
//! Shortcut for a %JpegThumbnail auto pointer.
typedef std::unique_ptr<JpegThumbnail> UniquePtr;
using UniquePtr = std::unique_ptr<JpegThumbnail>;

//! @name Manipulators
//@{
Expand Down
2 changes: 1 addition & 1 deletion src/exiv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ void Params::getStdin(Exiv2::DataBuf& buf)

} // Params::getStdin()

typedef std::map<std::string,std::string> long_t;
using long_t = std::map<std::string, std::string>;

int Params::getopt(int argc, char* const Argv[])
{
Expand Down
14 changes: 7 additions & 7 deletions src/exiv2app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct ModifyCmd {
std::string value_; //!< Data
};
//! Container for modification commands
typedef std::vector<ModifyCmd> ModifyCmds;
using ModifyCmds = std::vector<ModifyCmd>;
//! Structure to link command identifiers to strings
struct CmdIdAndString {
CmdId cmdId_; //!< Commands identifier
Expand Down Expand Up @@ -141,17 +141,17 @@ class Params : public Util::Getopt {

public:
//! Container for command files
typedef std::vector<std::string> CmdFiles;
using CmdFiles = std::vector<std::string>;
//! Container for commands from the command line
typedef std::vector<std::string> CmdLines;
using CmdLines = std::vector<std::string>;
//! Container to store filenames.
typedef std::vector<std::string> Files;
using Files = std::vector<std::string>;
//! Container for preview image numbers
typedef std::set<int> PreviewNumbers;
using PreviewNumbers = std::set<int>;
//! Container for greps
typedef exv_grep_keys_t Greps;
using Greps = exv_grep_keys_t;
//! Container for keys
typedef std::vector<std::string> Keys;
using Keys = std::vector<std::string>;

/*!
@brief Controls all access to the global Params instance.
Expand Down
2 changes: 1 addition & 1 deletion src/futils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/makernote_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace {
virtual ~Loader() {}

//! Loader auto pointer
typedef std::unique_ptr<Loader> UniquePtr;
using UniquePtr = std::unique_ptr<Loader>;

//! Create a Loader subclass for requested id
static UniquePtr create(PreviewId id, const Image &image);
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/safe_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Safe
template <class T>
struct enable_if<true, T>
{
typedef T type;
using type = T;
};

/*!
Expand Down
Loading