From 0f3e6e2941f754014d5f9f12656a9e326fca61ed Mon Sep 17 00:00:00 2001 From: Krishty Date: Wed, 5 May 2021 00:08:54 +0200 Subject: [PATCH] replaced std::size() with AI_COUNT_OF for pre-C++20 compilers --- code/AssetLib/3DS/3DSLoader.cpp | 2 +- code/AssetLib/AC/ACLoader.cpp | 2 +- code/AssetLib/AMF/AMFImporter.cpp | 2 +- code/AssetLib/ASE/ASELoader.cpp | 2 +- code/AssetLib/BVH/BVHLoader.cpp | 2 +- code/AssetLib/Blender/BlenderLoader.cpp | 2 +- code/AssetLib/COB/COBLoader.cpp | 2 +- code/AssetLib/CSM/CSMLoader.cpp | 2 +- code/AssetLib/Collada/ColladaLoader.cpp | 2 +- code/AssetLib/DXF/DXFLoader.cpp | 2 +- code/AssetLib/FBX/FBXImporter.cpp | 2 +- code/AssetLib/HMP/HMPLoader.cpp | 2 +- code/AssetLib/IFC/IFCLoader.cpp | 2 +- code/AssetLib/Irr/IRRLoader.cpp | 2 +- code/AssetLib/Irr/IRRMeshLoader.cpp | 2 +- code/AssetLib/LWO/LWOLoader.cpp | 2 +- code/AssetLib/LWS/LWSLoader.cpp | 2 +- code/AssetLib/MD2/MD2Loader.cpp | 2 +- code/AssetLib/MD3/MD3Loader.cpp | 2 +- code/AssetLib/MD5/MD5Loader.cpp | 2 +- code/AssetLib/MDC/MDCLoader.cpp | 2 +- code/AssetLib/MDL/MDLLoader.cpp | 2 +- code/AssetLib/MMD/MMDImporter.cpp | 2 +- code/AssetLib/MS3D/MS3DLoader.cpp | 2 +- code/AssetLib/NDO/NDOLoader.cpp | 2 +- code/AssetLib/OFF/OFFLoader.cpp | 2 +- code/AssetLib/Ogre/OgreImporter.cpp | 2 +- code/AssetLib/OpenGEX/OpenGEXImporter.cpp | 2 +- code/AssetLib/Ply/PlyLoader.cpp | 2 +- code/AssetLib/Q3D/Q3DLoader.cpp | 2 +- code/AssetLib/STL/STLLoader.cpp | 2 +- code/AssetLib/Terragen/TerragenLoader.cpp | 2 +- code/AssetLib/X/XFileImporter.cpp | 2 +- code/AssetLib/XGL/XGLLoader.cpp | 2 +- include/assimp/defs.h | 2 ++ 35 files changed, 36 insertions(+), 34 deletions(-) diff --git a/code/AssetLib/3DS/3DSLoader.cpp b/code/AssetLib/3DS/3DSLoader.cpp index b690f557d..89a4fbc7e 100644 --- a/code/AssetLib/3DS/3DSLoader.cpp +++ b/code/AssetLib/3DS/3DSLoader.cpp @@ -113,7 +113,7 @@ Discreet3DSImporter::~Discreet3DSImporter() { // Returns whether the class can handle the format of the given file. bool Discreet3DSImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { static const uint16_t token[] = { 0x4d4d, 0x3dc2 /*, 0x3daa */ }; - return CheckMagicToken(pIOHandler, pFile, token, std::size(token), 0, sizeof token[0]); + return CheckMagicToken(pIOHandler, pFile, token, AI_COUNT_OF(token), 0, sizeof token[0]); } // ------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/AC/ACLoader.cpp b/code/AssetLib/AC/ACLoader.cpp index c259b2eb0..ea097ae0d 100644 --- a/code/AssetLib/AC/ACLoader.cpp +++ b/code/AssetLib/AC/ACLoader.cpp @@ -154,7 +154,7 @@ AC3DImporter::~AC3DImporter() { // Returns whether the class can handle the format of the given file. bool AC3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { static const uint32_t tokens[] = { AI_MAKE_MAGIC("AC3D") }; - return CheckMagicToken(pIOHandler, pFile, tokens, std::size(tokens)); + return CheckMagicToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens)); } // ------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/AMF/AMFImporter.cpp b/code/AssetLib/AMF/AMFImporter.cpp index 0cc02a2c7..9e846d473 100644 --- a/code/AssetLib/AMF/AMFImporter.cpp +++ b/code/AssetLib/AMF/AMFImporter.cpp @@ -504,7 +504,7 @@ void AMFImporter::ParseNode_Metadata(XmlNode &node) { bool AMFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*pCheckSig*/) const { static const char *tokens[] = { "" }; - return SearchFileHeaderForToken(pIOHandler, pFile, tokens, std::size(tokens)); + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens)); } else { /// @todo Read and validate first header chunk? return false; diff --git a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp index 4ee9031d7..429a03ad8 100644 --- a/code/AssetLib/OpenGEX/OpenGEXImporter.cpp +++ b/code/AssetLib/OpenGEX/OpenGEXImporter.cpp @@ -283,7 +283,7 @@ OpenGEXImporter::~OpenGEXImporter() { //------------------------------------------------------------------------------------------------ bool OpenGEXImporter::CanRead(const std::string &file, IOSystem *pIOHandler, bool /*checkSig*/) const { static const char *tokens[] = { "Metric", "GeometryNode", "VertexArray (attrib", "IndexArray" }; - return SearchFileHeaderForToken(pIOHandler, file, tokens, std::size(tokens)); + return SearchFileHeaderForToken(pIOHandler, file, tokens, AI_COUNT_OF(tokens)); } //------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/Ply/PlyLoader.cpp b/code/AssetLib/Ply/PlyLoader.cpp index d92ffacd1..86cf33703 100644 --- a/code/AssetLib/Ply/PlyLoader.cpp +++ b/code/AssetLib/Ply/PlyLoader.cpp @@ -102,7 +102,7 @@ PLYImporter::~PLYImporter() { // Returns whether the class can handle the format of the given file. bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { static const char *tokens[] = { "ply" }; - return SearchFileHeaderForToken(pIOHandler, pFile, tokens, std::size(tokens)); + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens)); } // ------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp index 74ff01ca0..9f41f190f 100644 --- a/code/AssetLib/Q3D/Q3DLoader.cpp +++ b/code/AssetLib/Q3D/Q3DLoader.cpp @@ -85,7 +85,7 @@ Q3DImporter::~Q3DImporter() { // Returns whether the class can handle the format of the given file. bool Q3DImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { static const char *tokens[] = { "quick3Do", "quick3Ds" }; - return SearchFileHeaderForToken(pIOHandler, pFile, tokens, std::size(tokens)); + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens)); } // ------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/STL/STLLoader.cpp b/code/AssetLib/STL/STLLoader.cpp index 65cfc7830..68a2244f4 100644 --- a/code/AssetLib/STL/STLLoader.cpp +++ b/code/AssetLib/STL/STLLoader.cpp @@ -143,7 +143,7 @@ STLImporter::~STLImporter() { // Returns whether the class can handle the format of the given file. bool STLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { static const char *tokens[] = { "STL", "solid" }; - return SearchFileHeaderForToken(pIOHandler, pFile, tokens, std::size(tokens)); + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens)); } // ------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/Terragen/TerragenLoader.cpp b/code/AssetLib/Terragen/TerragenLoader.cpp index 16e5ac470..6308727f8 100644 --- a/code/AssetLib/Terragen/TerragenLoader.cpp +++ b/code/AssetLib/Terragen/TerragenLoader.cpp @@ -79,7 +79,7 @@ TerragenImporter::~TerragenImporter() {} // Returns whether the class can handle the format of the given file. bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { static const char *tokens[] = { "terragen" }; - return SearchFileHeaderForToken(pIOHandler, pFile, tokens, std::size(tokens)); + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens)); } // ------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/X/XFileImporter.cpp b/code/AssetLib/X/XFileImporter.cpp index 73cb1acda..a2a26824a 100644 --- a/code/AssetLib/X/XFileImporter.cpp +++ b/code/AssetLib/X/XFileImporter.cpp @@ -91,7 +91,7 @@ XFileImporter::~XFileImporter() { // Returns whether the class can handle the format of the given file. bool XFileImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/) const { static const uint32_t token[] = { AI_MAKE_MAGIC("xof ") }; - return CheckMagicToken(pIOHandler,pFile,token,std::size(token)); + return CheckMagicToken(pIOHandler,pFile,token,AI_COUNT_OF(token)); } // ------------------------------------------------------------------------------------------------ diff --git a/code/AssetLib/XGL/XGLLoader.cpp b/code/AssetLib/XGL/XGLLoader.cpp index 7e134a054..943791ef0 100644 --- a/code/AssetLib/XGL/XGLLoader.cpp +++ b/code/AssetLib/XGL/XGLLoader.cpp @@ -107,7 +107,7 @@ XGLImporter::~XGLImporter() { // Returns whether the class can handle the format of the given file. bool XGLImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { static const char *tokens[] = { "", "", "" }; - return SearchFileHeaderForToken(pIOHandler, pFile, tokens, std::size(tokens)); + return SearchFileHeaderForToken(pIOHandler, pFile, tokens, AI_COUNT_OF(tokens)); } // ------------------------------------------------------------------------------------------------ diff --git a/include/assimp/defs.h b/include/assimp/defs.h index d61fd7901..dbaff24c1 100644 --- a/include/assimp/defs.h +++ b/include/assimp/defs.h @@ -322,4 +322,6 @@ static const ai_real ai_epsilon = (ai_real)0.00001; #define AI_DEBUG_INVALIDATE_PTR(x) #endif +#define AI_COUNT_OF(X) (sizeof(X) / sizeof((X)[0])) + #endif // !! AI_DEFINES_H_INC