From e0619e871b3e7d0fc7fbd1d05b23d200369feb85 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 10 Dec 2023 18:04:53 +0200 Subject: [PATCH] Convert typedefs to using declarations --- source/binaryparser.h | 4 ++-- source/binarywriter.h | 4 ++-- source/binfloat.h | 4 ++-- source/collection.h | 14 +++++++------- source/collectionsource.h | 2 +- source/directorysource.h | 2 +- source/dynamicobjectloader.h | 4 ++-- source/loaderaction.h | 22 +++++++++++----------- source/meta.h | 2 +- source/objectloader.h | 6 +++--- source/packsource.h | 4 ++-- source/statement.h | 2 +- source/type.h | 22 +++++++++++----------- 13 files changed, 46 insertions(+), 46 deletions(-) diff --git a/source/binaryparser.h b/source/binaryparser.h index f6226a1..4cb97ef 100644 --- a/source/binaryparser.h +++ b/source/binaryparser.h @@ -14,8 +14,8 @@ Parses data in binary format. class BinaryParser: public ParserMode { private: - typedef std::map Dictionary; - typedef std::map StringMap; + using Dictionary = std::map; + using StringMap = std::map; Dictionary dict; StringMap strings; diff --git a/source/binarywriter.h b/source/binarywriter.h index dafc7eb..12363cd 100644 --- a/source/binarywriter.h +++ b/source/binarywriter.h @@ -15,8 +15,8 @@ Writes data in binary format. class BinaryWriter: public WriterMode { private: - typedef std::map Dictionary; - typedef std::map StringMap; + using Dictionary = std::map; + using StringMap = std::map; Dictionary dict; unsigned next_kwd_id = 1; diff --git a/source/binfloat.h b/source/binfloat.h index db3e924..53ac53a 100644 --- a/source/binfloat.h +++ b/source/binfloat.h @@ -46,10 +46,10 @@ struct BinFloat }; template<> -struct BinFloat::MatchingInt { typedef std::uint32_t Type; }; +struct BinFloat::MatchingInt { using Type = std::uint32_t; }; template<> -struct BinFloat::MatchingInt { typedef std::uint64_t Type; }; +struct BinFloat::MatchingInt { using Type = std::uint64_t; }; template inline BinFloat BinFloat::explode_iec559(T v) diff --git a/source/collection.h b/source/collection.h index f866b7a..3a4bf9d 100644 --- a/source/collection.h +++ b/source/collection.h @@ -30,11 +30,11 @@ struct CollectionItemTypeChooser; template struct CollectionItemTypeChooser -{ typedef LoadableCollectionItemType Type; }; +{ using Type = LoadableCollectionItemType; }; template struct CollectionItemTypeChooser -{ typedef CollectionItemType Type; }; +{ using Type = CollectionItemType; }; /** A collection of objects that can be loaded from a datafile. Each object is @@ -85,7 +85,7 @@ public: class ItemLoader; private: - typedef std::map ItemMap; + using ItemMap = std::map; std::vector types; ItemMap items; @@ -103,7 +103,7 @@ public: if(!item) throw std::invalid_argument("Collection::add(item)"); - typedef typename std::remove_cv::type NCT; + using NCT = typename std::remove_cv::type; RefPtr ptr(item); try { @@ -130,7 +130,7 @@ public: template T &get(const std::string &name) { - typedef typename std::remove_cv::type NCT; + using NCT = typename std::remove_cv::type; return extract(get_var(name, get_type(name))); } @@ -147,7 +147,7 @@ public: template T *find(const std::string &name) { - typedef typename std::remove_cv::type NCT; + using NCT = typename std::remove_cv::type; const Variant *var = find_var(name, get_type(name)); return (var ? &extract(*var) : 0); } @@ -253,7 +253,7 @@ public: template const std::string &get_name(T *d) const { - typedef RefPtr::type> RPNCT; + using RPNCT = RefPtr::type>; for(const auto &kvp: items) if(kvp.second.has_type()) diff --git a/source/collectionsource.h b/source/collectionsource.h index 3aa2190..e2757a0 100644 --- a/source/collectionsource.h +++ b/source/collectionsource.h @@ -19,7 +19,7 @@ see DirectorySource and PackSource for concrete classes. class MSPDATAFILE_API CollectionSource { public: - typedef std::list NameList; + using NameList = std::list; protected: CollectionSource() = default; diff --git a/source/directorysource.h b/source/directorysource.h index 07e1664..df1fc1f 100644 --- a/source/directorysource.h +++ b/source/directorysource.h @@ -14,7 +14,7 @@ A source that load items from files in a directory. class MSPDATAFILE_API DirectorySource: public CollectionSource { private: - typedef std::map ObjectMap; + using ObjectMap = std::map; ObjectMap objects; diff --git a/source/dynamicobjectloader.h b/source/dynamicobjectloader.h index 687daca..fd4e153 100644 --- a/source/dynamicobjectloader.h +++ b/source/dynamicobjectloader.h @@ -19,7 +19,7 @@ template class DynamicObjectLoader: public Loader { public: - typedef C Collection; + using Collection = C; protected: template @@ -28,7 +28,7 @@ protected: void operator()(const std::string &, DynamicObjectLoader &) const; }; - typedef Msp::TypeRegistry TypeRegistry; + using TypeRegistry = Msp::TypeRegistry; Collection *coll = nullptr; T *object = nullptr; diff --git a/source/loaderaction.h b/source/loaderaction.h index 0c56eab..f1f1ee7 100644 --- a/source/loaderaction.h +++ b/source/loaderaction.h @@ -53,7 +53,7 @@ template class LoaderFunc0: public LoaderAction { private: - typedef void (L::*FuncType)(); + using FuncType = void (L::*)(); FuncType func; @@ -82,7 +82,7 @@ template class LoaderFunc1: public LoaderAction { private: - typedef void (L::*FuncType)(A0); + using FuncType = void (L::*)(A0); FuncType func; @@ -111,7 +111,7 @@ template class LoaderFunc1 &>: public LoaderAction { private: - typedef void (L::*FuncType)(const std::vector &); + using FuncType = void (L::*)(const std::vector &); FuncType func; @@ -154,7 +154,7 @@ template class LoaderFunc1: public LoaderAction { private: - typedef void (L::*FuncType)(const Statement &); + using FuncType = void (L::*)(const Statement &); FuncType func; @@ -216,7 +216,7 @@ template class LoaderFuncN: public LoaderAction { protected: - typedef void (L::*FuncType)(Args...); + using FuncType = void (L::*)(Args...); FuncType func; @@ -242,8 +242,8 @@ template class LoaderFuncNBound1: public LoaderAction { protected: - typedef void (L::*FuncType)(B0, Args...); - typedef typename std::remove_reference::type Bound0Type; + using FuncType = void (L::*)(B0, Args...); + using Bound0Type = typename std::remove_reference::type; FuncType func; Bound0Type bound0; @@ -271,7 +271,7 @@ template class LoadValue1: public LoaderAction { private: - typedef T0 L::*Pointer0Type; + using Pointer0Type = T0 L::*; Pointer0Type ptr0; @@ -297,7 +297,7 @@ template class LoadValue1: public LoaderAction { private: - typedef T0 *L::*Pointer0Type; + using Pointer0Type = T0 *L::*; Pointer0Type ptr0; @@ -325,8 +325,8 @@ template class LoadValue2: public LoaderAction { private: - typedef T0 L::*Pointer0Type; - typedef T1 L::*Pointer1Type; + using Pointer0Type = T0 L::*; + using Pointer1Type = T1 L::*; Pointer0Type ptr0; Pointer1Type ptr1; diff --git a/source/meta.h b/source/meta.h index 51bc924..98b9f14 100644 --- a/source/meta.h +++ b/source/meta.h @@ -7,7 +7,7 @@ namespace Msp { namespace DataFile { /** -Helper struct to determine whether a Loader has a Collection typedef. +Helper struct to determine whether a Loader has a Collection type alias. */ struct CheckCollectionType: Sfinae { diff --git a/source/objectloader.h b/source/objectloader.h index 978366f..9e5a1cc 100644 --- a/source/objectloader.h +++ b/source/objectloader.h @@ -17,7 +17,7 @@ template class ObjectLoader: virtual public Loader { public: - typedef O Object; + using Object = O; protected: O &obj; @@ -37,7 +37,7 @@ template class DerivedObjectLoader: public B { public: - typedef O Object; + using Object = O; protected: O &obj; @@ -58,7 +58,7 @@ template class CollectionObjectLoader: public ObjectLoader { public: - typedef C Collection; + using Collection = C; protected: C *coll = nullptr; diff --git a/source/packsource.h b/source/packsource.h index e163736..c30e8f6 100644 --- a/source/packsource.h +++ b/source/packsource.h @@ -34,8 +34,8 @@ private: class File; class Object; - typedef std::map FileMap; - typedef std::map ObjectMap; + using FileMap = std::map; + using ObjectMap = std::map; class Pack { diff --git a/source/statement.h b/source/statement.h index 6a9da04..d04ca51 100644 --- a/source/statement.h +++ b/source/statement.h @@ -12,7 +12,7 @@ struct Token; struct MSPDATAFILE_API Statement { - typedef std::vector Arguments; + using Arguments = std::vector; std::string keyword; Arguments args; diff --git a/source/type.h b/source/type.h index 0e371e6..4eb07bc 100644 --- a/source/type.h +++ b/source/type.h @@ -23,36 +23,36 @@ struct Symbol struct IntType { static const char signature = 'i'; - typedef std::int64_t Store; - typedef Store Load; + using Store = std::int64_t; + using Load = Store; }; struct FloatType { static const char signature = 'f'; - typedef double Store; - typedef Store Load; + using Store = double; + using Load = Store; }; struct BoolType { static const char signature = 'b'; - typedef bool Store; - typedef Store Load; + using Store = bool; + using Load = Store; }; struct StringType { static const char signature = 's'; - typedef std::string Store; - typedef Store Load; + using Store = std::string; + using Load = Store; }; struct SymbolType { // For backward compatibility static const char signature = 'e'; - typedef Symbol Store; + using Store = Symbol; }; const char valid_signatures[] = @@ -128,11 +128,11 @@ struct TypeInfo: TypeInfo { }; template struct TypeInfo: TypeInfo -{ typedef typename T::LoadType Load; }; +{ using Load = typename T::LoadType; }; template struct TypeInfo: SymbolType -{ typedef T Load; }; +{ using Load = T; }; } // namespace DataFile } // namespace Msp -- 2.45.2