|
@@ -46,15 +46,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
#include <assimp/Importer.hpp>
|
|
#include <assimp/Importer.hpp>
|
|
#include <assimp/ai_assert.h>
|
|
#include <assimp/ai_assert.h>
|
|
#include "Hash.h"
|
|
#include "Hash.h"
|
|
-#include <map>
|
|
|
|
|
|
|
|
|
|
+#include <map>
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
template <class T>
|
|
template <class T>
|
|
-inline bool SetGenericProperty(std::map< unsigned int, T >& list,
|
|
|
|
- const char* szName, const T& value)
|
|
|
|
-{
|
|
|
|
- ai_assert(NULL != szName);
|
|
|
|
|
|
+inline
|
|
|
|
+bool SetGenericProperty(std::map< unsigned int, T >& list,
|
|
|
|
+ const char* szName, const T& value) {
|
|
|
|
+ ai_assert(nullptr != szName);
|
|
const uint32_t hash = SuperFastHash(szName);
|
|
const uint32_t hash = SuperFastHash(szName);
|
|
|
|
|
|
typename std::map<unsigned int, T>::iterator it = list.find(hash);
|
|
typename std::map<unsigned int, T>::iterator it = list.find(hash);
|
|
@@ -63,20 +63,22 @@ inline bool SetGenericProperty(std::map< unsigned int, T >& list,
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
(*it).second = value;
|
|
(*it).second = value;
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
template <class T>
|
|
template <class T>
|
|
-inline const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
|
|
|
- const char* szName, const T& errorReturn)
|
|
|
|
-{
|
|
|
|
- ai_assert(NULL != szName);
|
|
|
|
|
|
+inline
|
|
|
|
+const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
|
|
|
+ const char* szName, const T& errorReturn) {
|
|
|
|
+ ai_assert(nullptr != szName);
|
|
const uint32_t hash = SuperFastHash(szName);
|
|
const uint32_t hash = SuperFastHash(szName);
|
|
|
|
|
|
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
|
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
|
- if (it == list.end())
|
|
|
|
|
|
+ if (it == list.end()) {
|
|
return errorReturn;
|
|
return errorReturn;
|
|
|
|
+ }
|
|
|
|
|
|
return (*it).second;
|
|
return (*it).second;
|
|
}
|
|
}
|
|
@@ -85,16 +87,17 @@ inline const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
|
// Special version for pointer types - they will be deleted when replaced with another value
|
|
// Special version for pointer types - they will be deleted when replaced with another value
|
|
// passing NULL removes the whole property
|
|
// passing NULL removes the whole property
|
|
template <class T>
|
|
template <class T>
|
|
-inline void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
|
|
|
- const char* szName, T* value, bool* bWasExisting = NULL)
|
|
|
|
-{
|
|
|
|
- ai_assert(NULL != szName);
|
|
|
|
|
|
+inline
|
|
|
|
+void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
|
|
|
+ const char* szName, T* value, bool* bWasExisting = nullptr ) {
|
|
|
|
+ ai_assert(nullptr != szName);
|
|
const uint32_t hash = SuperFastHash(szName);
|
|
const uint32_t hash = SuperFastHash(szName);
|
|
|
|
|
|
typename std::map<unsigned int, T*>::iterator it = list.find(hash);
|
|
typename std::map<unsigned int, T*>::iterator it = list.find(hash);
|
|
if (it == list.end()) {
|
|
if (it == list.end()) {
|
|
- if (bWasExisting)
|
|
|
|
|
|
+ if (bWasExisting) {
|
|
*bWasExisting = false;
|
|
*bWasExisting = false;
|
|
|
|
+ }
|
|
|
|
|
|
list.insert(std::pair<unsigned int,T*>( hash, value ));
|
|
list.insert(std::pair<unsigned int,T*>( hash, value ));
|
|
return;
|
|
return;
|
|
@@ -106,20 +109,23 @@ inline void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
|
if (!value) {
|
|
if (!value) {
|
|
list.erase(it);
|
|
list.erase(it);
|
|
}
|
|
}
|
|
- if (bWasExisting)
|
|
|
|
|
|
+ if (bWasExisting) {
|
|
*bWasExisting = true;
|
|
*bWasExisting = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
template <class T>
|
|
template <class T>
|
|
-inline bool HasGenericProperty(const std::map< unsigned int, T >& list,
|
|
|
|
- const char* szName)
|
|
|
|
-{
|
|
|
|
- ai_assert(NULL != szName);
|
|
|
|
|
|
+inline
|
|
|
|
+bool HasGenericProperty(const std::map< unsigned int, T >& list,
|
|
|
|
+ const char* szName) {
|
|
|
|
+ ai_assert(nullptr != szName);
|
|
const uint32_t hash = SuperFastHash(szName);
|
|
const uint32_t hash = SuperFastHash(szName);
|
|
|
|
|
|
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
|
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
|
- if (it == list.end()) return false;
|
|
|
|
|
|
+ if (it == list.end()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|