diff --git a/code/Assimp.cpp b/code/Assimp.cpp index 89b62d110..ef5b0d9bc 100644 --- a/code/Assimp.cpp +++ b/code/Assimp.cpp @@ -483,7 +483,7 @@ ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szNam { ASSIMP_BEGIN_EXCEPTION_REGION(); PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->ints,szName,value,NULL); + SetGenericProperty(pp->ints,szName,value); ASSIMP_END_EXCEPTION_REGION(void); } @@ -493,7 +493,7 @@ ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName, { ASSIMP_BEGIN_EXCEPTION_REGION(); PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->floats,szName,value,NULL); + SetGenericProperty(pp->floats,szName,value); ASSIMP_END_EXCEPTION_REGION(void); } @@ -507,7 +507,7 @@ ASSIMP_API void aiSetImportPropertyString(aiPropertyStore* p, const char* szName } ASSIMP_BEGIN_EXCEPTION_REGION(); PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->strings,szName,std::string(st->C_Str()),NULL); + SetGenericProperty(pp->strings,szName,std::string(st->C_Str())); ASSIMP_END_EXCEPTION_REGION(void); } @@ -521,7 +521,7 @@ ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore* p, const char* szName } ASSIMP_BEGIN_EXCEPTION_REGION(); PropertyMap* pp = reinterpret_cast(p); - SetGenericProperty(pp->matrices,szName,*mat,NULL); + SetGenericProperty(pp->matrices,szName,*mat); ASSIMP_END_EXCEPTION_REGION(void); } diff --git a/code/Exporter.cpp b/code/Exporter.cpp index c6fea8856..a0488e0f3 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -507,34 +507,30 @@ ExportProperties::ExportProperties(const ExportProperties &other) // ------------------------------------------------------------------------------------------------ // Set a configuration property -void ExportProperties :: SetPropertyInteger(const char* szName, int iValue, - bool* bWasExisting /*= NULL*/) +bool ExportProperties :: SetPropertyInteger(const char* szName, int iValue) { - SetGenericProperty(mIntProperties, szName,iValue,bWasExisting); + return SetGenericProperty(mIntProperties, szName,iValue); } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void ExportProperties :: SetPropertyFloat(const char* szName, float iValue, - bool* bWasExisting /*= NULL*/) +bool ExportProperties :: SetPropertyFloat(const char* szName, float iValue) { - SetGenericProperty(mFloatProperties, szName,iValue,bWasExisting); + return SetGenericProperty(mFloatProperties, szName,iValue); } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void ExportProperties :: SetPropertyString(const char* szName, const std::string& value, - bool* bWasExisting /*= NULL*/) +bool ExportProperties :: SetPropertyString(const char* szName, const std::string& value) { - SetGenericProperty(mStringProperties, szName,value,bWasExisting); + return SetGenericProperty(mStringProperties, szName,value); } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value, - bool* bWasExisting /*= NULL*/) +bool ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) { - SetGenericProperty(mMatrixProperties, szName,value,bWasExisting); + return SetGenericProperty(mMatrixProperties, szName,value); } // ------------------------------------------------------------------------------------------------ diff --git a/code/GenericProperty.h b/code/GenericProperty.h index 0e89015ab..06e6f7ca1 100644 --- a/code/GenericProperty.h +++ b/code/GenericProperty.h @@ -46,22 +46,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ------------------------------------------------------------------------------------------------ template -inline void SetGenericProperty(std::map< unsigned int, T >& list, - const char* szName, const T& value, bool* bWasExisting = NULL) +inline bool SetGenericProperty(std::map< unsigned int, T >& list, + const char* szName, const T& value) { ai_assert(NULL != szName); const uint32_t hash = SuperFastHash(szName); typename std::map::iterator it = list.find(hash); if (it == list.end()) { - if (bWasExisting) - *bWasExisting = false; list.insert(std::pair( hash, value )); - return; + return false; } (*it).second = value; - if (bWasExisting) - *bWasExisting = true; + return true; } // ------------------------------------------------------------------------------------------------ diff --git a/code/Importer.cpp b/code/Importer.cpp index a9173cddc..1c45ff978 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -919,42 +919,46 @@ void Importer::GetExtensionList(aiString& szOut) const // ------------------------------------------------------------------------------------------------ // Set a configuration property -void Importer::SetPropertyInteger(const char* szName, int iValue, - bool* bWasExisting /*= NULL*/) +bool Importer::SetPropertyInteger(const char* szName, int iValue) { + bool exising; ASSIMP_BEGIN_EXCEPTION_REGION(); - SetGenericProperty(pimpl->mIntProperties, szName,iValue,bWasExisting); - ASSIMP_END_EXCEPTION_REGION(void); + exising = SetGenericProperty(pimpl->mIntProperties, szName,iValue); + ASSIMP_END_EXCEPTION_REGION(bool); + return exising; } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void Importer::SetPropertyFloat(const char* szName, float iValue, - bool* bWasExisting /*= NULL*/) +bool Importer::SetPropertyFloat(const char* szName, float iValue) { + bool exising; ASSIMP_BEGIN_EXCEPTION_REGION(); - SetGenericProperty(pimpl->mFloatProperties, szName,iValue,bWasExisting); - ASSIMP_END_EXCEPTION_REGION(void); + exising = SetGenericProperty(pimpl->mFloatProperties, szName,iValue); + ASSIMP_END_EXCEPTION_REGION(bool); + return exising; } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void Importer::SetPropertyString(const char* szName, const std::string& value, - bool* bWasExisting /*= NULL*/) +bool Importer::SetPropertyString(const char* szName, const std::string& value) { + bool exising; ASSIMP_BEGIN_EXCEPTION_REGION(); - SetGenericProperty(pimpl->mStringProperties, szName,value,bWasExisting); - ASSIMP_END_EXCEPTION_REGION(void); + exising = SetGenericProperty(pimpl->mStringProperties, szName,value); + ASSIMP_END_EXCEPTION_REGION(bool); + return exising; } // ------------------------------------------------------------------------------------------------ // Set a configuration property -void Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value, - bool* bWasExisting /*= NULL*/) +bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) { + bool exising; ASSIMP_BEGIN_EXCEPTION_REGION(); - SetGenericProperty(pimpl->mMatrixProperties, szName,value,bWasExisting); - ASSIMP_END_EXCEPTION_REGION(void); + exising = SetGenericProperty(pimpl->mMatrixProperties, szName,value); + ASSIMP_END_EXCEPTION_REGION(bool); + return exising; } // ------------------------------------------------------------------------------------------------ diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index 49cecd1bf..701f8db81 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -556,7 +556,7 @@ bool MD3Importer::ReadMultipartFile() // ensure we won't try to load ourselves recursively BatchLoader::PropertyMap props; - SetGenericProperty( props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0, NULL); + SetGenericProperty( props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0); // now read these three files BatchLoader batch(mIOHandler); diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index 692830f02..fb890129e 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -348,16 +348,14 @@ public: * are defined in the aiConfig.g header (all constants share the * prefix AI_CONFIG_XXX and are simple strings). * @param iValue New value of the property - * @param bWasExisting Optional pointer to receive true if the - * property was set before. The new value replaces the previous value - * in this case. + * @return true if the property was set before. The new value replaces + * the previous value in this case. * @note Property of different types (float, int, string ..) are kept * on different stacks, so calling SetPropertyInteger() for a * floating-point property has no effect - the loader will call * GetPropertyFloat() to read the property, but it won't be there. */ - void SetPropertyInteger(const char* szName, int iValue, - bool* bWasExisting = NULL); + bool SetPropertyInteger(const char* szName, int iValue); // ------------------------------------------------------------------- /** Set a boolean configuration property. Boolean properties @@ -366,30 +364,27 @@ public: * #GetPropertyBool and vice versa. * @see SetPropertyInteger() */ - void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) { - SetPropertyInteger(szName,value,bWasExisting); + bool SetPropertyBool(const char* szName, bool value) { + return SetPropertyInteger(szName,value); } // ------------------------------------------------------------------- /** Set a floating-point configuration property. * @see SetPropertyInteger() */ - void SetPropertyFloat(const char* szName, float fValue, - bool* bWasExisting = NULL); + bool SetPropertyFloat(const char* szName, float fValue); // ------------------------------------------------------------------- /** Set a string configuration property. * @see SetPropertyInteger() */ - void SetPropertyString(const char* szName, const std::string& sValue, - bool* bWasExisting = NULL); + bool SetPropertyString(const char* szName, const std::string& sValue); // ------------------------------------------------------------------- /** Set a matrix configuration property. * @see SetPropertyInteger() */ - void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue, - bool* bWasExisting = NULL); + bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue); // ------------------------------------------------------------------- /** Get a configuration property. diff --git a/include/assimp/Importer.hpp b/include/assimp/Importer.hpp index 8aa9e5ae5..8d9141aeb 100644 --- a/include/assimp/Importer.hpp +++ b/include/assimp/Importer.hpp @@ -194,16 +194,14 @@ public: * are defined in the aiConfig.g header (all constants share the * prefix AI_CONFIG_XXX and are simple strings). * @param iValue New value of the property - * @param bWasExisting Optional pointer to receive true if the - * property was set before. The new value replaces the previous value - * in this case. + * @return true if the property was set before. The new value replaces + * the previous value in this case. * @note Property of different types (float, int, string ..) are kept * on different stacks, so calling SetPropertyInteger() for a * floating-point property has no effect - the loader will call * GetPropertyFloat() to read the property, but it won't be there. */ - void SetPropertyInteger(const char* szName, int iValue, - bool* bWasExisting = NULL); + bool SetPropertyInteger(const char* szName, int iValue); // ------------------------------------------------------------------- /** Set a boolean configuration property. Boolean properties @@ -212,30 +210,27 @@ public: * #GetPropertyBool and vice versa. * @see SetPropertyInteger() */ - void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) { - SetPropertyInteger(szName,value,bWasExisting); + bool SetPropertyBool(const char* szName, bool value) { + return SetPropertyInteger(szName,value); } // ------------------------------------------------------------------- /** Set a floating-point configuration property. * @see SetPropertyInteger() */ - void SetPropertyFloat(const char* szName, float fValue, - bool* bWasExisting = NULL); + bool SetPropertyFloat(const char* szName, float fValue); // ------------------------------------------------------------------- /** Set a string configuration property. * @see SetPropertyInteger() */ - void SetPropertyString(const char* szName, const std::string& sValue, - bool* bWasExisting = NULL); + bool SetPropertyString(const char* szName, const std::string& sValue); // ------------------------------------------------------------------- /** Set a matrix configuration property. * @see SetPropertyInteger() */ - void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue, - bool* bWasExisting = NULL); + bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue); // ------------------------------------------------------------------- /** Get a configuration property.