diff --git a/apps/esmtool/tes4.cpp b/apps/esmtool/tes4.cpp index 533600788e..3c7d03e67b 100644 --- a/apps/esmtool/tes4.cpp +++ b/apps/esmtool/tes4.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace EsmTool @@ -57,97 +58,6 @@ namespace EsmTool return "Unknown (" + std::to_string(type) + ")"; } - template > - struct HasFormId : std::false_type - { - }; - - template - struct HasFormId> : std::true_type - { - }; - - template - constexpr bool hasFormId = HasFormId::value; - - template > - struct HasId : std::false_type - { - }; - - template - struct HasId> : std::true_type - { - }; - - template - constexpr bool hasId = HasId::value; - - template > - struct HasFlags : std::false_type - { - }; - - template - struct HasFlags> : std::true_type - { - }; - - template - constexpr bool hasFlags = HasFlags::value; - - template > - struct HasEditorId : std::false_type - { - }; - - template - struct HasEditorId> : std::true_type - { - }; - - template - constexpr bool hasEditorId = HasEditorId::value; - - template > - struct HasModel : std::false_type - { - }; - - template - struct HasModel> : std::true_type - { - }; - - template - constexpr bool hasModel = HasModel::value; - - template > - struct HasNif : std::false_type - { - }; - - template - struct HasNif> : std::true_type - { - }; - - template - constexpr bool hasNif = HasNif::value; - - template > - struct HasKf : std::false_type - { - }; - - template - struct HasKf> : std::true_type - { - }; - - template - constexpr bool hasKf = HasKf::value; - template struct WriteArray { @@ -181,19 +91,19 @@ namespace EsmTool return; std::cout << "\n Record: " << ESM::NAME(reader.hdr().record.typeId).toStringView(); - if constexpr (hasFormId) + if constexpr (ESM4::hasFormId) std::cout << "\n FormId: " << value.mFormId; - if constexpr (hasId) + if constexpr (ESM4::hasId) std::cout << "\n Id: " << value.mId; - if constexpr (hasFlags) + if constexpr (ESM4::hasFlags) std::cout << "\n Record flags: " << recordFlags(value.mFlags); - if constexpr (hasEditorId) + if constexpr (ESM4::hasEditorId) std::cout << "\n EditorId: " << value.mEditorId; - if constexpr (hasModel) + if constexpr (ESM4::hasModel) std::cout << "\n Model: " << value.mModel; - if constexpr (hasNif) + if constexpr (ESM4::hasNif) std::cout << "\n Nif:" << WriteArray("\n - ", value.mNif); - if constexpr (hasKf) + if constexpr (ESM4::hasKf) std::cout << "\n Kf:" << WriteArray("\n - ", value.mKf); std::cout << '\n'; } diff --git a/components/esm4/typetraits.hpp b/components/esm4/typetraits.hpp new file mode 100644 index 0000000000..65e56e891d --- /dev/null +++ b/components/esm4/typetraits.hpp @@ -0,0 +1,100 @@ +#ifndef OPENMW_COMPONENTS_ESM4_TYPETRAITS +#define OPENMW_COMPONENTS_ESM4_TYPETRAITS + +#include + +namespace ESM4 +{ + template > + struct HasFormId : std::false_type + { + }; + + template + struct HasFormId> : std::true_type + { + }; + + template + inline constexpr bool hasFormId = HasFormId::value; + + template > + struct HasId : std::false_type + { + }; + + template + struct HasId> : std::true_type + { + }; + + template + inline constexpr bool hasId = HasId::value; + + template > + struct HasFlags : std::false_type + { + }; + + template + struct HasFlags> : std::true_type + { + }; + + template + inline constexpr bool hasFlags = HasFlags::value; + + template > + struct HasEditorId : std::false_type + { + }; + + template + struct HasEditorId> : std::true_type + { + }; + + template + inline constexpr bool hasEditorId = HasEditorId::value; + + template > + struct HasModel : std::false_type + { + }; + + template + struct HasModel> : std::true_type + { + }; + + template + inline constexpr bool hasModel = HasModel::value; + + template > + struct HasNif : std::false_type + { + }; + + template + struct HasNif> : std::true_type + { + }; + + template + inline constexpr bool hasNif = HasNif::value; + + template > + struct HasKf : std::false_type + { + }; + + template + struct HasKf> : std::true_type + { + }; + + template + inline constexpr bool hasKf = HasKf::value; +} + +#endif // OPENMW_COMPONENTS_ESM4_TYPETRAITS