]> git.tdb.fi Git - libs/datafile.git/commitdiff
Convert typedefs to using declarations
authorMikko Rasa <tdb@tdb.fi>
Sun, 10 Dec 2023 16:04:53 +0000 (18:04 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 10 Dec 2023 16:40:16 +0000 (18:40 +0200)
13 files changed:
source/binaryparser.h
source/binarywriter.h
source/binfloat.h
source/collection.h
source/collectionsource.h
source/directorysource.h
source/dynamicobjectloader.h
source/loaderaction.h
source/meta.h
source/objectloader.h
source/packsource.h
source/statement.h
source/type.h

index f6226a1d621df86719b45b653a41fc883ba8194f..4cb97ef68affa2f0b9b3b77c7d8890648151185f 100644 (file)
@@ -14,8 +14,8 @@ Parses data in binary format.
 class BinaryParser: public ParserMode
 {
 private:
-       typedef std::map<int, StatementInfo> Dictionary;
-       typedef std::map<unsigned, std::string> StringMap;
+       using Dictionary = std::map<int, StatementInfo>;
+       using StringMap = std::map<unsigned int, std::string>;
 
        Dictionary dict;
        StringMap strings;
index dafc7eb36755bb60cd720ef8b03cbd47ed74e516..12363cd9728ee90b129f5b8e6a9169f4cd7e0f16 100644 (file)
@@ -15,8 +15,8 @@ Writes data in binary format.
 class BinaryWriter: public WriterMode
 {
 private:
-       typedef std::map<StatementKey, int> Dictionary;
-       typedef std::map<std::string, unsigned> StringMap;
+       using Dictionary = std::map<StatementKey, int>;
+       using StringMap = std::map<std::string, unsigned>;
 
        Dictionary dict;
        unsigned next_kwd_id = 1;
index db3e92431823627249365d83f814b9f991a751c0..53ac53a6c09b7650f598a0b39f9223af9f574870 100644 (file)
@@ -46,10 +46,10 @@ struct BinFloat
 };
 
 template<>
-struct BinFloat::MatchingInt<float> { typedef std::uint32_t Type; };
+struct BinFloat::MatchingInt<float> { using Type = std::uint32_t; };
 
 template<>
-struct BinFloat::MatchingInt<double> { typedef std::uint64_t Type; };
+struct BinFloat::MatchingInt<double> { using Type = std::uint64_t; };
 
 template<typename T>
 inline BinFloat BinFloat::explode_iec559(T v)
index f866b7a6830c2902952fde9658fa5fde6757d934..3a4bf9dde6ac961fb5a4d3516854ba36eed1caae 100644 (file)
@@ -30,11 +30,11 @@ struct CollectionItemTypeChooser;
 
 template<typename T>
 struct CollectionItemTypeChooser<T, true>
-{ typedef LoadableCollectionItemType<T> Type; };
+{ using Type = LoadableCollectionItemType<T>; };
 
 template<typename T>
 struct CollectionItemTypeChooser<T, false>
-{ typedef CollectionItemType<T> Type; };
+{ using Type = CollectionItemType<T>; };
 
 /**
 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<std::string, Variant> ItemMap;
+       using ItemMap = std::map<std::string, Variant>;
 
        std::vector<CollectionItemTypeBase *> types;
        ItemMap items;
@@ -103,7 +103,7 @@ public:
                if(!item)
                        throw std::invalid_argument("Collection::add(item)");
 
-               typedef typename std::remove_cv<T>::type NCT;
+               using NCT = typename std::remove_cv<T>::type;
                RefPtr<NCT> ptr(item);
                try
                {
@@ -130,7 +130,7 @@ public:
        template<typename T>
        T &get(const std::string &name)
        {
-               typedef typename std::remove_cv<T>::type NCT;
+               using NCT = typename std::remove_cv<T>::type;
                return extract<NCT>(get_var(name, get_type<NCT>(name)));
        }
 
@@ -147,7 +147,7 @@ public:
        template<typename T>
        T *find(const std::string &name)
        {
-               typedef typename std::remove_cv<T>::type NCT;
+               using NCT = typename std::remove_cv<T>::type;
                const Variant *var = find_var(name, get_type<NCT>(name));
                return (var ? &extract<NCT>(*var) : 0);
        }
@@ -253,7 +253,7 @@ public:
        template<typename T>
        const std::string &get_name(T *d) const
        {
-               typedef RefPtr<typename std::remove_cv<T>::type> RPNCT;
+               using RPNCT = RefPtr<typename std::remove_cv<T>::type>;
 
                for(const auto &kvp: items)
                        if(kvp.second.has_type<RPNCT>())
index 3aa2190c736fa720766437586e0bbe649c1d7e08..e2757a073432e83407a87c3cd336df882172e638 100644 (file)
@@ -19,7 +19,7 @@ see DirectorySource and PackSource for concrete classes.
 class MSPDATAFILE_API CollectionSource
 {
 public:
-       typedef std::list<std::string> NameList;
+       using NameList = std::list<std::string>;
 
 protected:
        CollectionSource() = default;
index 07e1664ee585cd348f79e893cb685c792382dd0a..df1fc1f1b3279d3d54aba18317f607ac6ce96600 100644 (file)
@@ -14,7 +14,7 @@ A source that load items from files in a directory.
 class MSPDATAFILE_API DirectorySource: public CollectionSource
 {
 private:
-       typedef std::map<std::string, FS::Path> ObjectMap;
+       using ObjectMap = std::map<std::string, FS::Path>;
 
        ObjectMap objects;
 
index 687dacaf5363cf74b179a486c017731ae4976451..fd4e153edaae60dd00a467901c43faed28432ba0 100644 (file)
@@ -19,7 +19,7 @@ template<typename T, typename C = Collection>
 class DynamicObjectLoader: public Loader
 {
 public:
-       typedef C Collection;
+       using Collection = C;
 
 protected:
        template<typename U>
@@ -28,7 +28,7 @@ protected:
                void operator()(const std::string &, DynamicObjectLoader &) const;
        };
 
-       typedef Msp::TypeRegistry<CreateObject, DynamicObjectLoader &> TypeRegistry;
+       using TypeRegistry = Msp::TypeRegistry<CreateObject, DynamicObjectLoader &>;
 
        Collection *coll = nullptr;
        T *object = nullptr;
index 0c56eab0292e3201d36503e7b30cad332532c424..f1f1ee7ec23d007c715f878a7f62a29536687565 100644 (file)
@@ -53,7 +53,7 @@ template<typename L>
 class LoaderFunc0: public LoaderAction
 {
 private:
-       typedef void (L::*FuncType)();
+       using FuncType = void (L::*)();
 
        FuncType func;
 
@@ -82,7 +82,7 @@ template<typename L, typename A0>
 class LoaderFunc1: public LoaderAction
 {
 private:
-       typedef void (L::*FuncType)(A0);
+       using FuncType = void (L::*)(A0);
 
        FuncType func;
 
@@ -111,7 +111,7 @@ template<typename L, typename A0>
 class LoaderFunc1<L, const std::vector<A0> &>: public LoaderAction
 {
 private:
-       typedef void (L::*FuncType)(const std::vector<A0> &);
+       using FuncType = void (L::*)(const std::vector<A0> &);
 
        FuncType func;
 
@@ -154,7 +154,7 @@ template<typename L>
 class LoaderFunc1<L, const Statement &>: public LoaderAction
 {
 private:
-       typedef void (L::*FuncType)(const Statement &);
+       using FuncType = void (L::*)(const Statement &);
 
        FuncType func;
 
@@ -216,7 +216,7 @@ template<typename L, typename... Args>
 class LoaderFuncN: public LoaderAction
 {
 protected:
-       typedef void (L::*FuncType)(Args...);
+       using FuncType = void (L::*)(Args...);
 
        FuncType func;
 
@@ -242,8 +242,8 @@ template<typename L, typename B0, typename... Args>
 class LoaderFuncNBound1: public LoaderAction
 {
 protected:
-       typedef void (L::*FuncType)(B0, Args...);
-       typedef typename std::remove_reference<B0>::type Bound0Type;
+       using FuncType = void (L::*)(B0, Args...);
+       using Bound0Type = typename std::remove_reference<B0>::type;
 
        FuncType func;
        Bound0Type bound0;
@@ -271,7 +271,7 @@ template<typename L, typename T0>
 class LoadValue1: public LoaderAction
 {
 private:
-       typedef T0 L::*Pointer0Type;
+       using Pointer0Type = T0 L::*;
 
        Pointer0Type ptr0;
 
@@ -297,7 +297,7 @@ template<typename L, typename T0>
 class LoadValue1<L, T0 *>: public LoaderAction
 {
 private:
-       typedef T0 *L::*Pointer0Type;
+       using Pointer0Type = T0 *L::*;
 
        Pointer0Type ptr0;
 
@@ -325,8 +325,8 @@ template<typename L, typename T0, typename T1>
 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;
index 51bc924405d3bdc7861b054801f9f742ec90e226..98b9f1477f0bdba9e173c7b6092e2e0a049a4c94 100644 (file)
@@ -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
 {
index 978366f730e51cc197fe7dd20ab7f56f4b52e84e..9e5a1cc5199105c79d2c57a199e06d6cc25b669b 100644 (file)
@@ -17,7 +17,7 @@ template<typename O>
 class ObjectLoader: virtual public Loader
 {
 public:
-       typedef O Object;
+       using Object = O;
 
 protected:
        O &obj;
@@ -37,7 +37,7 @@ template<typename O, typename B>
 class DerivedObjectLoader: public B
 {
 public:
-       typedef O Object;
+       using Object = O;
 
 protected:
        O &obj;
@@ -58,7 +58,7 @@ template<typename O, typename C = Collection>
 class CollectionObjectLoader: public ObjectLoader<O>
 {
 public:
-       typedef C Collection;
+       using Collection = C;
 
 protected:
        C *coll = nullptr;
index e163736589f82327d61544fff080d3e2fa5dd543..c30e8f625cc53c18f3bfcea7126ed42a49f37892 100644 (file)
@@ -34,8 +34,8 @@ private:
        class File;
        class Object;
 
-       typedef std::map<std::string, const File *> FileMap;
-       typedef std::map<std::string, const Object *> ObjectMap;
+       using FileMap = std::map<std::string, const File *>;
+       using ObjectMap = std::map<std::string, const Object *>;
 
        class Pack
        {
index 6a9da0462d8fda6cecbe3d9a2c4bc775c481574f..d04ca510b8896216cee8842a52151d0bcca47c49 100644 (file)
@@ -12,7 +12,7 @@ struct Token;
 
 struct MSPDATAFILE_API Statement
 {
-       typedef std::vector<Value> Arguments;
+       using Arguments = std::vector<Value>;
 
        std::string keyword;
        Arguments args;
index 0e371e632a9bb4b66aee10520e5aab300726675e..4eb07bc2436835cfe0c60dfd628d1260c5ca4acb 100644 (file)
@@ -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<T &, false>: TypeInfo<T> { };
 
 template<typename T>
 struct TypeInfo<T, true>: TypeInfo<typename T::LoadType>
-{ typedef typename T::LoadType Load; };
+{ using Load = typename T::LoadType; };
 
 template<typename T>
 struct TypeInfo<T, false>: SymbolType
-{ typedef T Load; };
+{ using Load = T; };
 
 } // namespace DataFile
 } // namespace Msp