From f47479aba4797fc9c9b119cd21ab427748a9f839 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 8 Sep 2021 23:18:13 +0200 Subject: [PATCH] Rework format + introdule missing C++11 features --- code/Common/Bitmap.cpp | 57 ++++++++++++------------ include/assimp/Bitmap.h | 14 ++++-- include/assimp/BlobIOSystem.h | 75 +++++++++++++++++--------------- include/assimp/ByteSwapper.h | 4 +- include/assimp/ColladaMetaData.h | 1 - include/assimp/CreateAnimMesh.h | 1 - include/assimp/DefaultIOStream.h | 37 +++++++--------- include/assimp/DefaultIOSystem.h | 11 +++-- include/assimp/DefaultLogger.hpp | 34 ++++++++------- include/assimp/Exceptional.h | 30 +++++++++++-- include/assimp/IOSystem.hpp | 54 ++++++++++------------- include/assimp/Importer.hpp | 2 +- include/assimp/LineSplitter.h | 56 +++++++++--------------- include/assimp/LogStream.hpp | 9 ++-- include/assimp/Logger.hpp | 27 ++++-------- include/assimp/NullLogger.hpp | 5 +++ include/assimp/aabb.h | 24 +++++----- include/assimp/ai_assert.h | 26 +++++++---- include/assimp/camera.h | 34 +++++++-------- include/assimp/cfileio.h | 5 +-- include/assimp/color4.inl | 2 - include/assimp/commonMetaData.h | 2 - 22 files changed, 258 insertions(+), 252 deletions(-) diff --git a/code/Common/Bitmap.cpp b/code/Common/Bitmap.cpp index 23b96d42d..51f31625e 100644 --- a/code/Common/Bitmap.cpp +++ b/code/Common/Bitmap.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -54,33 +52,36 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { -void Bitmap::Save(aiTexture *texture, IOStream *file) { - if (file != nullptr) { - Header header; - DIB dib; - - dib.size = DIB::dib_size; - dib.width = texture->mWidth; - dib.height = texture->mHeight; - dib.planes = 1; - dib.bits_per_pixel = 8 * mBytesPerPixel; - dib.compression = 0; - dib.image_size = (((dib.width * mBytesPerPixel) + 3) & 0x0000FFFC) * dib.height; - dib.x_resolution = 0; - dib.y_resolution = 0; - dib.nb_colors = 0; - dib.nb_important_colors = 0; - - header.type = 0x4D42; // 'BM' - header.offset = Header::header_size + DIB::dib_size; - header.size = header.offset + dib.image_size; - header.reserved1 = 0; - header.reserved2 = 0; - - WriteHeader(header, file); - WriteDIB(dib, file); - WriteData(texture, file); +bool Bitmap::Save(aiTexture *texture, IOStream *file) { + if (file == nullptr) { + return false; } + + Header header; + DIB dib; + dib.size = DIB::dib_size; + dib.width = texture->mWidth; + dib.height = texture->mHeight; + dib.planes = 1; + dib.bits_per_pixel = 8 * mBytesPerPixel; + dib.compression = 0; + dib.image_size = (((dib.width * mBytesPerPixel) + 3) & 0x0000FFFC) * dib.height; + dib.x_resolution = 0; + dib.y_resolution = 0; + dib.nb_colors = 0; + dib.nb_important_colors = 0; + + header.type = 0x4D42; // 'BM' + header.offset = Header::header_size + DIB::dib_size; + header.size = header.offset + dib.image_size; + header.reserved1 = 0; + header.reserved2 = 0; + + WriteHeader(header, file); + WriteDIB(dib, file); + WriteData(texture, file); + + return true; } template diff --git a/include/assimp/Bitmap.h b/include/assimp/Bitmap.h index e4ce194d9..228f6e9ba 100644 --- a/include/assimp/Bitmap.h +++ b/include/assimp/Bitmap.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -55,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #include "defs.h" -#include +#include #include struct aiTexture; @@ -64,6 +62,10 @@ namespace Assimp { class IOStream; +// --------------------------------------------------------------------------- +/** + * This class is used to store and write bitmap information. + */ class ASSIMP_API Bitmap { protected: @@ -114,7 +116,11 @@ protected: static constexpr std::size_t mBytesPerPixel = 4; public: - static void Save(aiTexture* texture, IOStream* file); + /// @brief Will save an aiTexture instance as a bitmap. + /// @param texture The pointer to the texture instance + /// @param file The filename to save into. + /// @return true if successfully saved, false if not. + static bool Save(aiTexture* texture, IOStream* file); protected: static void WriteHeader(Header& header, IOStream* file); diff --git a/include/assimp/BlobIOSystem.h b/include/assimp/BlobIOSystem.h index 0abf166bc..90e806431 100644 --- a/include/assimp/BlobIOSystem.h +++ b/include/assimp/BlobIOSystem.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -44,14 +42,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Provides cheat implementations for IOSystem and IOStream to * redirect exporter output to a blob chain.*/ +#pragma once #ifndef AI_BLOBIOSYSTEM_H_INCLUDED #define AI_BLOBIOSYSTEM_H_INCLUDED #include -#include #include #include #include +#include #include #include @@ -63,6 +62,10 @@ class BlobIOSystem; // -------------------------------------------------------------------------------------------- class BlobIOStream : public IOStream { public: + /// @brief The class constructor with all needed parameters + /// @param creator Pointer to the creator instance + /// @param file The filename + /// @param initial The initial size BlobIOStream(BlobIOSystem *creator, const std::string &file, size_t initial = 4096) : buffer(), cur_size(), @@ -74,7 +77,8 @@ public: // empty } - virtual ~BlobIOStream(); + /// @brief The class destructor. + ~BlobIOStream() override; public: // ------------------------------------------------------------------- @@ -89,16 +93,12 @@ public: } // ------------------------------------------------------------------- - virtual size_t Read(void *, - size_t, - size_t) { + size_t Read(void *, size_t, size_t) override { return 0; } // ------------------------------------------------------------------- - virtual size_t Write(const void *pvBuffer, - size_t pSize, - size_t pCount) { + size_t Write(const void *pvBuffer, size_t pSize, size_t pCount) override { pSize *= pCount; if (cursor + pSize > cur_size) { Grow(cursor + pSize); @@ -112,23 +112,22 @@ public: } // ------------------------------------------------------------------- - virtual aiReturn Seek(size_t pOffset, - aiOrigin pOrigin) { + aiReturn Seek(size_t pOffset, aiOrigin pOrigin) override { switch (pOrigin) { - case aiOrigin_CUR: - cursor += pOffset; - break; + case aiOrigin_CUR: + cursor += pOffset; + break; - case aiOrigin_END: - cursor = file_size - pOffset; - break; + case aiOrigin_END: + cursor = file_size - pOffset; + break; - case aiOrigin_SET: - cursor = pOffset; - break; + case aiOrigin_SET: + cursor = pOffset; + break; - default: - return AI_FAILURE; + default: + return AI_FAILURE; } if (cursor > file_size) { @@ -136,21 +135,22 @@ public: } file_size = std::max(cursor, file_size); + return AI_SUCCESS; } // ------------------------------------------------------------------- - virtual size_t Tell() const { + size_t Tell() const override { return cursor; } // ------------------------------------------------------------------- - virtual size_t FileSize() const { + size_t FileSize() const override { return file_size; } // ------------------------------------------------------------------- - virtual void Flush() { + void Flush() override { // ignore } @@ -196,15 +196,19 @@ class BlobIOSystem : public IOSystem { public: + /// @brief The default class constructor. BlobIOSystem() : baseName{AI_BLOBIO_MAGIC} { } + /// @brief The class constructor with the base name. + /// @param baseName The base name. BlobIOSystem(const std::string &baseName) : baseName(baseName) { + // empty } - virtual ~BlobIOSystem() { + ~BlobIOSystem() override { for (BlobEntry &blobby : blobs) { delete blobby.second; } @@ -263,18 +267,17 @@ public: public: // ------------------------------------------------------------------- - virtual bool Exists(const char *pFile) const { + bool Exists(const char *pFile) const override { return created.find(std::string(pFile)) != created.end(); } // ------------------------------------------------------------------- - virtual char getOsSeparator() const { + char getOsSeparator() const override { return '/'; } // ------------------------------------------------------------------- - virtual IOStream *Open(const char *pFile, - const char *pMode) { + IOStream *Open(const char *pFile, const char *pMode) override { if (pMode[0] != 'w') { return nullptr; } @@ -284,7 +287,7 @@ public: } // ------------------------------------------------------------------- - virtual void Close(IOStream *pFile) { + void Close(IOStream *pFile) override { delete pFile; } @@ -294,7 +297,7 @@ private: // we don't know in which the files are closed, so we // can't reliably say that the first must be the master // file ... - blobs.push_back(BlobEntry(filename, child->GetBlob())); + blobs.emplace_back(filename, child->GetBlob()); } private: @@ -304,8 +307,10 @@ private: }; // -------------------------------------------------------------------------------------------- -BlobIOStream ::~BlobIOStream() { - creator->OnDestruct(file, this); +BlobIOStream::~BlobIOStream() { + if (nullptr != creator) { + creator->OnDestruct(file, this); + } delete[] buffer; } diff --git a/include/assimp/ByteSwapper.h b/include/assimp/ByteSwapper.h index 98fdafc98..9e1eea10f 100644 --- a/include/assimp/ByteSwapper.h +++ b/include/assimp/ByteSwapper.h @@ -52,10 +52,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include #if _MSC_VER >= 1400 -#include +#include #endif namespace Assimp { diff --git a/include/assimp/ColladaMetaData.h b/include/assimp/ColladaMetaData.h index 602f342f9..f8fd5e6b4 100644 --- a/include/assimp/ColladaMetaData.h +++ b/include/assimp/ColladaMetaData.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/include/assimp/CreateAnimMesh.h b/include/assimp/CreateAnimMesh.h index dda4dc63a..868a1f399 100644 --- a/include/assimp/CreateAnimMesh.h +++ b/include/assimp/CreateAnimMesh.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/include/assimp/DefaultIOStream.h b/include/assimp/DefaultIOStream.h index 6d0e13149..aae80a2a4 100644 --- a/include/assimp/DefaultIOStream.h +++ b/include/assimp/DefaultIOStream.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -82,32 +81,27 @@ public: // ------------------------------------------------------------------- /// Read from stream - size_t Read(void* pvBuffer, - size_t pSize, - size_t pCount); + size_t Read(void* pvBuffer, size_t pSize, size_t pCount) override; // ------------------------------------------------------------------- /// Write to stream - size_t Write(const void* pvBuffer, - size_t pSize, - size_t pCount); + size_t Write(const void* pvBuffer, size_t pSize, size_t pCount) override; // ------------------------------------------------------------------- /// Seek specific position - aiReturn Seek(size_t pOffset, - aiOrigin pOrigin); + aiReturn Seek(size_t pOffset, aiOrigin pOrigin) override; // ------------------------------------------------------------------- /// Get current seek position - size_t Tell() const; + size_t Tell() const override; // ------------------------------------------------------------------- /// Get size of file - size_t FileSize() const; + size_t FileSize() const override; // ------------------------------------------------------------------- /// Flush file contents - void Flush(); + void Flush() override; private: FILE* mFile; @@ -116,22 +110,21 @@ private: }; // ---------------------------------------------------------------------------------- -AI_FORCE_INLINE -DefaultIOStream::DefaultIOStream() AI_NO_EXCEPT -: mFile(nullptr) -, mFilename() -, mCachedSize(SIZE_MAX) { +AI_FORCE_INLINE DefaultIOStream::DefaultIOStream() AI_NO_EXCEPT : + mFile(nullptr), + mFilename(), + mCachedSize(SIZE_MAX) { // empty } // ---------------------------------------------------------------------------------- -AI_FORCE_INLINE -DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename) -: mFile(pFile) -, mFilename(strFilename) -, mCachedSize(SIZE_MAX) { +AI_FORCE_INLINE DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename) : + mFile(pFile), + mFilename(strFilename), + mCachedSize(SIZE_MAX) { // empty } + // ---------------------------------------------------------------------------------- } // ns assimp diff --git a/include/assimp/DefaultIOSystem.h b/include/assimp/DefaultIOSystem.h index 3f7235f5b..c2f1aac61 100644 --- a/include/assimp/DefaultIOSystem.h +++ b/include/assimp/DefaultIOSystem.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -59,23 +58,23 @@ class ASSIMP_API DefaultIOSystem : public IOSystem { public: // ------------------------------------------------------------------- /** Tests for the existence of a file at the given path. */ - bool Exists( const char* pFile) const; + bool Exists( const char* pFile) const override; // ------------------------------------------------------------------- /** Returns the directory separator. */ - char getOsSeparator() const; + char getOsSeparator() const override; // ------------------------------------------------------------------- /** Open a new file with a given path. */ - IOStream* Open( const char* pFile, const char* pMode = "rb"); + IOStream* Open( const char* pFile, const char* pMode = "rb") override; // ------------------------------------------------------------------- /** Closes the given file and releases all resources associated with it. */ - void Close( IOStream* pFile); + void Close( IOStream* pFile) override; // ------------------------------------------------------------------- /** Compare two paths */ - bool ComparePaths (const char* one, const char* second) const; + bool ComparePaths (const char* one, const char* second) const override; /** @brief get the file name of a full filepath * example: /tmp/archive.tar.gz -> archive.tar.gz diff --git a/include/assimp/DefaultLogger.hpp b/include/assimp/DefaultLogger.hpp index f71bb07aa..e06c94f31 100644 --- a/include/assimp/DefaultLogger.hpp +++ b/include/assimp/DefaultLogger.hpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -42,9 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file DefaultLogger.hpp */ +#pragma once #ifndef INCLUDED_AI_DEFAULTLOGGER #define INCLUDED_AI_DEFAULTLOGGER +#ifdef __GNUC__ +#pragma GCC system_header +#endif + #include "LogStream.hpp" #include "Logger.hpp" #include "NullLogger.hpp" @@ -55,7 +59,7 @@ namespace Assimp { class IOStream; struct LogStreamInfo; -/** default name of logfile */ +/** default name of log-file */ #define ASSIMP_DEFAULT_LOG_NAME "AssimpLog.txt" // ------------------------------------------------------------------------------------ @@ -72,7 +76,6 @@ struct LogStreamInfo; * implementation of #Logger to #set(). * @note The whole logging stuff causes a small extra overhead for all imports. */ class ASSIMP_API DefaultLogger : public Logger { - public: // ---------------------------------------------------------------------- /** @brief Creates a logging instance. @@ -121,13 +124,11 @@ public: // ---------------------------------------------------------------------- /** @copydoc Logger::attachStream */ - bool attachStream(LogStream *pStream, - unsigned int severity); + bool attachStream(LogStream *pStream, unsigned int severity) override; // ---------------------------------------------------------------------- /** @copydoc Logger::detachStream */ - bool detachStream(LogStream *pStream, - unsigned int severity); + bool detachStream(LogStream *pStream, unsigned int severity) override; private: // ---------------------------------------------------------------------- @@ -137,22 +138,22 @@ private: // ---------------------------------------------------------------------- /** @briefDestructor */ - ~DefaultLogger(); + ~DefaultLogger() override; /** @brief Logs debug infos, only been written when severity level DEBUG or higher is set */ - void OnDebug(const char *message); + void OnDebug(const char *message) override; /** @brief Logs debug infos, only been written when severity level VERBOSE is set */ - void OnVerboseDebug(const char *message); + void OnVerboseDebug(const char *message) override; /** @brief Logs an info message */ - void OnInfo(const char *message); + void OnInfo(const char *message) override; /** @brief Logs a warning message */ - void OnWarn(const char *message); + void OnWarn(const char *message) override; /** @brief Logs an error message */ - void OnError(const char *message); + void OnError(const char *message) override; // ---------------------------------------------------------------------- /** @brief Writes a message to all streams */ @@ -167,9 +168,9 @@ private: private: // Aliases for stream container - typedef std::vector StreamArray; - typedef std::vector::iterator StreamIt; - typedef std::vector::const_iterator ConstStreamIt; + using StreamArray = std::vector; + using StreamIt = std::vector::iterator; + using ConstStreamIt = std::vector::const_iterator; //! only logging instance static Logger *m_pLogger; @@ -182,6 +183,7 @@ private: char lastMsg[MAX_LOG_MESSAGE_LENGTH * 2]; size_t lastLen; }; + // ------------------------------------------------------------------------------------ } // Namespace Assimp diff --git a/include/assimp/Exceptional.h b/include/assimp/Exceptional.h index 1bf399cbc..3078de9f4 100644 --- a/include/assimp/Exceptional.h +++ b/include/assimp/Exceptional.h @@ -56,10 +56,22 @@ using std::runtime_error; #pragma warning(disable : 4275) #endif +// --------------------------------------------------------------------------- +/** + * The base-class for all other exceptions + */ class ASSIMP_API DeadlyErrorBase : public runtime_error { protected: + /// @brief The class constructor with the formatter. + /// @param f The formatter. DeadlyErrorBase(Assimp::Formatter::format f); + /// @brief The class constructor with the parameter ellipse. + /// @tparam ...T The type for the ellipse + /// @tparam U The other type + /// @param f The formatter + /// @param u One parameter + /// @param ...args The rest template DeadlyErrorBase(Assimp::Formatter::format f, U&& u, T&&... args) : DeadlyErrorBase(std::move(f << std::forward(u)), std::forward(args)...) {} @@ -71,19 +83,31 @@ protected: * nullptr instead of a valid aiScene then. */ class ASSIMP_API DeadlyImportError : public DeadlyErrorBase { public: + /// @brief The class constructor with the message. + /// @param message The message DeadlyImportError(const char *message) : - DeadlyErrorBase(Assimp::Formatter::format(), std::forward(message)) {} + DeadlyErrorBase(Assimp::Formatter::format(), std::forward(message)) { + // empty + } - /** Constructor with arguments */ + /// @brief The class constructor with the parameter ellipse. + /// @tparam ...T The type for the ellipse + /// @param ...args The args template explicit DeadlyImportError(T&&... args) : - DeadlyErrorBase(Assimp::Formatter::format(), std::forward(args)...) {} + DeadlyErrorBase(Assimp::Formatter::format(), std::forward(args)...) { + // empty + } #if defined(_MSC_VER) && defined(__clang__) DeadlyImportError(DeadlyImportError& other) = delete; #endif }; +// --------------------------------------------------------------------------- +/** FOR EXPORTER PLUGINS ONLY: Simple exception class to be thrown if an + * unrecoverable error occurs while exporting. Exporting APIs return + * nullptr instead of a valid aiScene then. */ class ASSIMP_API DeadlyExportError : public DeadlyErrorBase { public: /** Constructor with arguments */ diff --git a/include/assimp/IOSystem.hpp b/include/assimp/IOSystem.hpp index 7be373cf1..dda0718e6 100644 --- a/include/assimp/IOSystem.hpp +++ b/include/assimp/IOSystem.hpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -63,8 +61,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef _WIN32 # include -# include -# include +# include +# include #else # include # include @@ -75,7 +73,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { - class IOStream; +class IOStream; // --------------------------------------------------------------------------- /** @brief CPP-API: Interface to the file system. @@ -226,22 +224,26 @@ public: */ virtual bool ChangeDirectory( const std::string &path ); - virtual bool DeleteFile( const std::string &file ); + // ------------------------------------------------------------------- + /** + * @brief Will delete the given file. + * @param file [in] The filename + * @return true, if the file wase deleted, false if not. + */ + virtual bool DeleteFile(const std::string &file); private: std::vector m_pathStack; }; // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -IOSystem::IOSystem() AI_NO_EXCEPT -: m_pathStack() { +AI_FORCE_INLINE IOSystem::IOSystem() AI_NO_EXCEPT : + m_pathStack() { // empty } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -IOSystem::~IOSystem() { +AI_FORCE_INLINE IOSystem::~IOSystem() { // empty } @@ -252,8 +254,7 @@ IOSystem::~IOSystem() { // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -IOStream* IOSystem::Open(const std::string& pFile, const std::string& pMode) { +AI_FORCE_INLINE IOStream* IOSystem::Open(const std::string& pFile, const std::string& pMode) { // NOTE: // For compatibility, interface was changed to const char* to // avoid crashes between binary incompatible STL versions @@ -261,8 +262,7 @@ IOStream* IOSystem::Open(const std::string& pFile, const std::string& pMode) { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::Exists( const std::string& pFile) const { +AI_FORCE_INLINE bool IOSystem::Exists( const std::string& pFile) const { // NOTE: // For compatibility, interface was changed to const char* to // avoid crashes between binary incompatible STL versions @@ -270,8 +270,7 @@ bool IOSystem::Exists( const std::string& pFile) const { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::ComparePaths (const std::string& one, const std::string& second) const { +AI_FORCE_INLINE bool IOSystem::ComparePaths(const std::string& one, const std::string& second) const { // NOTE: // For compatibility, interface was changed to const char* to // avoid crashes between binary incompatible STL versions @@ -279,8 +278,7 @@ bool IOSystem::ComparePaths (const std::string& one, const std::string& second) } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::PushDirectory( const std::string &path ) { +AI_FORCE_INLINE bool IOSystem::PushDirectory( const std::string &path ) { if ( path.empty() ) { return false; } @@ -291,8 +289,7 @@ bool IOSystem::PushDirectory( const std::string &path ) { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -const std::string &IOSystem::CurrentDirectory() const { +AI_FORCE_INLINE const std::string &IOSystem::CurrentDirectory() const { if ( m_pathStack.empty() ) { static const std::string Dummy; return Dummy; @@ -301,14 +298,12 @@ const std::string &IOSystem::CurrentDirectory() const { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -size_t IOSystem::StackSize() const { +AI_FORCE_INLINE size_t IOSystem::StackSize() const { return m_pathStack.size(); } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::PopDirectory() { +AI_FORCE_INLINE bool IOSystem::PopDirectory() { if ( m_pathStack.empty() ) { return false; } @@ -319,8 +314,7 @@ bool IOSystem::PopDirectory() { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::CreateDirectory( const std::string &path ) { +AI_FORCE_INLINE bool IOSystem::CreateDirectory( const std::string &path ) { if ( path.empty() ) { return false; } @@ -333,8 +327,7 @@ bool IOSystem::CreateDirectory( const std::string &path ) { } // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::ChangeDirectory( const std::string &path ) { +AI_FORCE_INLINE bool IOSystem::ChangeDirectory( const std::string &path ) { if ( path.empty() ) { return false; } @@ -348,8 +341,7 @@ bool IOSystem::ChangeDirectory( const std::string &path ) { // ---------------------------------------------------------------------------- -AI_FORCE_INLINE -bool IOSystem::DeleteFile( const std::string &file ) { +AI_FORCE_INLINE bool IOSystem::DeleteFile( const std::string &file ) { if ( file.empty() ) { return false; } diff --git a/include/assimp/Importer.hpp b/include/assimp/Importer.hpp index 09b5b6883..97f34090e 100644 --- a/include/assimp/Importer.hpp +++ b/include/assimp/Importer.hpp @@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Public ASSIMP data structures #include -#include +//#include namespace Assimp { // ======================================================================= diff --git a/include/assimp/LineSplitter.h b/include/assimp/LineSplitter.h index 44e6f0f1e..0a9d24437 100644 --- a/include/assimp/LineSplitter.h +++ b/include/assimp/LineSplitter.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -144,26 +143,23 @@ private: bool mSwallow, mSkip_empty_lines, mTrim; }; -AI_FORCE_INLINE -LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_empty_lines, bool trim ) -: mIdx(0) -, mCur() -, mStream(stream) -, mSwallow() -, mSkip_empty_lines(skip_empty_lines) -, mTrim(trim) { +AI_FORCE_INLINE LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_empty_lines, bool trim ) : + mIdx(0), + mCur(), + mStream(stream), + mSwallow(), + mSkip_empty_lines(skip_empty_lines), + mTrim(trim) { mCur.reserve(1024); operator++(); mIdx = 0; } -AI_FORCE_INLINE -LineSplitter::~LineSplitter() { +AI_FORCE_INLINE LineSplitter::~LineSplitter() { // empty } -AI_FORCE_INLINE -LineSplitter& LineSplitter::operator++() { +AI_FORCE_INLINE LineSplitter& LineSplitter::operator++() { if (mSwallow) { mSwallow = false; return *this; @@ -203,18 +199,15 @@ LineSplitter& LineSplitter::operator++() { return *this; } -AI_FORCE_INLINE -LineSplitter &LineSplitter::operator++(int) { +AI_FORCE_INLINE LineSplitter &LineSplitter::operator++(int) { return ++(*this); } -AI_FORCE_INLINE -const char *LineSplitter::operator[] (size_t idx) const { +AI_FORCE_INLINE const char *LineSplitter::operator[] (size_t idx) const { const char* s = operator->()->c_str(); SkipSpaces(&s); for (size_t i = 0; i < idx; ++i) { - for (; !IsSpace(*s); ++s) { if (IsLineEnd(*s)) { throw std::range_error("Token index out of range, EOL reached"); @@ -226,8 +219,7 @@ const char *LineSplitter::operator[] (size_t idx) const { } template -AI_FORCE_INLINE -void LineSplitter::get_tokens(const char* (&tokens)[N]) const { +AI_FORCE_INLINE void LineSplitter::get_tokens(const char* (&tokens)[N]) const { const char* s = operator->()->c_str(); SkipSpaces(&s); @@ -242,45 +234,37 @@ void LineSplitter::get_tokens(const char* (&tokens)[N]) const { } } -AI_FORCE_INLINE -const std::string* LineSplitter::operator -> () const { +AI_FORCE_INLINE const std::string* LineSplitter::operator -> () const { return &mCur; } -AI_FORCE_INLINE -std::string LineSplitter::operator* () const { +AI_FORCE_INLINE std::string LineSplitter::operator* () const { return mCur; } -AI_FORCE_INLINE -LineSplitter::operator bool() const { +AI_FORCE_INLINE LineSplitter::operator bool() const { return mStream.GetRemainingSize() > 0; } -AI_FORCE_INLINE -LineSplitter::operator line_idx() const { +AI_FORCE_INLINE LineSplitter::operator line_idx() const { return mIdx; } -AI_FORCE_INLINE -LineSplitter::line_idx LineSplitter::get_index() const { +AI_FORCE_INLINE LineSplitter::line_idx LineSplitter::get_index() const { return mIdx; } -AI_FORCE_INLINE -StreamReaderLE &LineSplitter::get_stream() { +AI_FORCE_INLINE StreamReaderLE &LineSplitter::get_stream() { return mStream; } -AI_FORCE_INLINE -bool LineSplitter::match_start(const char* check) { +AI_FORCE_INLINE bool LineSplitter::match_start(const char* check) { const size_t len = ::strlen(check); return len <= mCur.length() && std::equal(check, check + len, mCur.begin()); } -AI_FORCE_INLINE -void LineSplitter::swallow_next_increment() { +AI_FORCE_INLINE void LineSplitter::swallow_next_increment() { mSwallow = true; } diff --git a/include/assimp/LogStream.hpp b/include/assimp/LogStream.hpp index 3c2a587a2..64a7955fd 100644 --- a/include/assimp/LogStream.hpp +++ b/include/assimp/LogStream.hpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -43,9 +42,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file LogStream.hpp * @brief Abstract base class 'LogStream', representing an output log stream. */ +#pragma once #ifndef INCLUDED_AI_LOGSTREAM_H #define INCLUDED_AI_LOGSTREAM_H +#ifdef __GNUC__ +#pragma GCC system_header +#endif + #include "types.h" namespace Assimp { @@ -103,7 +107,6 @@ inline LogStream::~LogStream() { // empty } -// ------------------------------------------------------------------------------------ } // Namespace Assimp -#endif +#endif // INCLUDED_AI_LOGSTREAM_H diff --git a/include/assimp/Logger.hpp b/include/assimp/Logger.hpp index aa7ffba7c..549b0fbc2 100644 --- a/include/assimp/Logger.hpp +++ b/include/assimp/Logger.hpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -43,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Logger.hpp * @brief Abstract base class 'Logger', base of the logging system. */ +#pragma once #ifndef INCLUDED_AI_LOGGER_H #define INCLUDED_AI_LOGGER_H @@ -93,8 +93,6 @@ public: Err = 8 //!< Error log message }; -public: - /** @brief Virtual destructor */ virtual ~Logger(); @@ -259,39 +257,30 @@ protected: }; // ---------------------------------------------------------------------------------- -// Default constructor -inline -Logger::Logger() AI_NO_EXCEPT -: m_Severity(NORMAL) { +inline Logger::Logger() AI_NO_EXCEPT : + m_Severity(NORMAL) { // empty } // ---------------------------------------------------------------------------------- -// Virtual destructor -inline -Logger::~Logger() { +inline Logger::~Logger() { // empty } // ---------------------------------------------------------------------------------- -// Construction with given logging severity -inline -Logger::Logger(LogSeverity severity) -: m_Severity(severity) { +inline Logger::Logger(LogSeverity severity) : + m_Severity(severity) { // empty } // ---------------------------------------------------------------------------------- -// Log severity setter -inline -void Logger::setLogSeverity(LogSeverity log_severity){ +inline void Logger::setLogSeverity(LogSeverity log_severity){ m_Severity = log_severity; } // ---------------------------------------------------------------------------------- // Log severity getter -inline -Logger::LogSeverity Logger::getLogSeverity() const { +inline Logger::LogSeverity Logger::getLogSeverity() const { return m_Severity; } diff --git a/include/assimp/NullLogger.hpp b/include/assimp/NullLogger.hpp index 8281da4f7..8277b014a 100644 --- a/include/assimp/NullLogger.hpp +++ b/include/assimp/NullLogger.hpp @@ -44,9 +44,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Dummy logger */ +#pragma once #ifndef INCLUDED_AI_NULLLOGGER_H #define INCLUDED_AI_NULLLOGGER_H +#ifdef __GNUC__ +#pragma GCC system_header +#endif + #include "Logger.hpp" namespace Assimp { diff --git a/include/assimp/aabb.h b/include/assimp/aabb.h index cbf6193cb..a6ccdd452 100644 --- a/include/assimp/aabb.h +++ b/include/assimp/aabb.h @@ -44,36 +44,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_AABB_H_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif #include +// --------------------------------------------------------------------------- +/** + * An axis-aligned bounding box. + */ struct aiAABB { C_STRUCT aiVector3D mMin; C_STRUCT aiVector3D mMax; #ifdef __cplusplus - - aiAABB() - : mMin() - , mMax() { + /// @brief The default class constructor. + aiAABB() : + mMin(), mMax() { // empty } - aiAABB(const aiVector3D &min, const aiVector3D &max ) - : mMin(min) - , mMax(max) { + /// @brief The class constructor with the minimum and maximum. + /// @param min The minimum dimension. + /// @param max The maximum dimension. + aiAABB(const aiVector3D &min, const aiVector3D &max) : + mMin(min), mMax(max) { // empty } + /// @brief The class destructor. ~aiAABB() { // empty } #endif // __cplusplus - }; - #endif // AI_AABB_H_INC diff --git a/include/assimp/ai_assert.h b/include/assimp/ai_assert.h index b377b6e8b..b4f1ef8b2 100644 --- a/include/assimp/ai_assert.h +++ b/include/assimp/ai_assert.h @@ -38,6 +38,11 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------- */ + +/** @file ai_assert.h + * @brief Declares the assimp-specific assertion handler. + */ + #pragma once #ifndef AI_ASSERT_H_INC #define AI_ASSERT_H_INC @@ -46,19 +51,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined(ASSIMP_BUILD_DEBUG) -namespace Assimp -{ - // Assert violation behavior can be customized: see AssertHandler.h. - ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line); +namespace Assimp { + +/// @brief Assert violation behavior can be customized: see AssertHandler.h. +/// @param failedExpression The expression to validate. +/// @param file The file location +/// @param line The line number +ASSIMP_API void aiAssertViolation(const char* failedExpression, const char* file, int line); + } +#endif -# define ai_assert(expression) (void)((!!(expression)) || (Assimp::aiAssertViolation(#expression, __FILE__, __LINE__), 0)) -# define ai_assert_entry() ai_assert(false) - +// Define assertion resolinig +#if defined(ASSIMP_BUILD_DEBUG) +# define ai_assert(expression) (void)((!!(expression)) || (Assimp::aiAssertViolation(#expression, __FILE__, __LINE__), 0)) +# define ai_assert_entry() ai_assert(false) #else # define ai_assert(expression) # define ai_assert_entry() #endif // ASSIMP_BUILD_DEBUG #endif // AI_ASSERT_H_INC - diff --git a/include/assimp/camera.h b/include/assimp/camera.h index 6a7acadbb..56c4dbe3f 100644 --- a/include/assimp/camera.h +++ b/include/assimp/camera.h @@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CAMERA_H_INC #ifdef __GNUC__ -# pragma GCC system_header +#pragma GCC system_header #endif #include "types.h" @@ -100,8 +100,7 @@ extern "C" { * camera already look in the right direction. * */ -struct aiCamera -{ +struct aiCamera { /** The name of the camera. * * There must be a node in the scenegraph with the same name. @@ -127,7 +126,6 @@ struct aiCamera */ C_STRUCT aiVector3D mUp; - /** 'LookAt' - vector of the camera coordinate system relative to * the coordinate space defined by the corresponding node. * @@ -184,26 +182,27 @@ struct aiCamera #ifdef __cplusplus aiCamera() AI_NO_EXCEPT - : mUp (0.f,1.f,0.f) - , mLookAt (0.f,0.f,1.f) - , mHorizontalFOV (0.25f * (float)AI_MATH_PI) - , mClipPlaneNear (0.1f) - , mClipPlaneFar (1000.f) - , mAspect (0.f) - , mOrthographicWidth (0.f) - {} + : mUp(0.f, 1.f, 0.f), + mLookAt(0.f, 0.f, 1.f), + mHorizontalFOV(0.25f * (float)AI_MATH_PI), + mClipPlaneNear(0.1f), + mClipPlaneFar(1000.f), + mAspect(0.f), + mOrthographicWidth(0.f) {} /** @brief Get a *right-handed* camera matrix from me * @param out Camera matrix to be filled */ - void GetCameraMatrix (aiMatrix4x4& out) const - { + void GetCameraMatrix(aiMatrix4x4 &out) const { /** todo: test ... should work, but i'm not absolutely sure */ /** We don't know whether these vectors are already normalized ...*/ - aiVector3D zaxis = mLookAt; zaxis.Normalize(); - aiVector3D yaxis = mUp; yaxis.Normalize(); - aiVector3D xaxis = mUp^mLookAt; xaxis.Normalize(); + aiVector3D zaxis = mLookAt; + zaxis.Normalize(); + aiVector3D yaxis = mUp; + yaxis.Normalize(); + aiVector3D xaxis = mUp ^ mLookAt; + xaxis.Normalize(); out.a4 = -(xaxis * mPosition); out.b4 = -(yaxis * mPosition); @@ -228,7 +227,6 @@ struct aiCamera #endif }; - #ifdef __cplusplus } #endif diff --git a/include/assimp/cfileio.h b/include/assimp/cfileio.h index c1f8625b9..48a728a2a 100644 --- a/include/assimp/cfileio.h +++ b/include/assimp/cfileio.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -106,8 +104,7 @@ struct aiFileIO * the CRT. However, you can supply a custom implementation to Assimp by * delivering a custom aiFileIO. Use this to enable reading from other sources, * such as ZIP archives or memory locations. */ -struct aiFile -{ +struct aiFile { /** Callback to read from a file */ aiFileReadProc ReadProc; diff --git a/include/assimp/color4.inl b/include/assimp/color4.inl index fb31afa27..e5bfdf356 100644 --- a/include/assimp/color4.inl +++ b/include/assimp/color4.inl @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, diff --git a/include/assimp/commonMetaData.h b/include/assimp/commonMetaData.h index 128281bfb..34a375bf3 100644 --- a/include/assimp/commonMetaData.h +++ b/include/assimp/commonMetaData.h @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2021, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms,