Improved prototype of Importer & Exporter SetProperty* functions for better integration with tools such as SWIG
parent
60d58901a5
commit
454b85a0ad
|
@ -483,7 +483,7 @@ ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szNam
|
|||
{
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
||||
SetGenericProperty<int>(pp->ints,szName,value,NULL);
|
||||
SetGenericProperty<int>(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<PropertyMap*>(p);
|
||||
SetGenericProperty<float>(pp->floats,szName,value,NULL);
|
||||
SetGenericProperty<float>(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<PropertyMap*>(p);
|
||||
SetGenericProperty<std::string>(pp->strings,szName,std::string(st->C_Str()),NULL);
|
||||
SetGenericProperty<std::string>(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<PropertyMap*>(p);
|
||||
SetGenericProperty<aiMatrix4x4>(pp->matrices,szName,*mat,NULL);
|
||||
SetGenericProperty<aiMatrix4x4>(pp->matrices,szName,*mat);
|
||||
ASSIMP_END_EXCEPTION_REGION(void);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<int>(mIntProperties, szName,iValue,bWasExisting);
|
||||
return SetGenericProperty<int>(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<float>(mFloatProperties, szName,iValue,bWasExisting);
|
||||
return SetGenericProperty<float>(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<std::string>(mStringProperties, szName,value,bWasExisting);
|
||||
return SetGenericProperty<std::string>(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<aiMatrix4x4>(mMatrixProperties, szName,value,bWasExisting);
|
||||
return SetGenericProperty<aiMatrix4x4>(mMatrixProperties, szName,value);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -46,22 +46,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
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<unsigned int, T>::iterator it = list.find(hash);
|
||||
if (it == list.end()) {
|
||||
if (bWasExisting)
|
||||
*bWasExisting = false;
|
||||
list.insert(std::pair<unsigned int, T>( hash, value ));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
(*it).second = value;
|
||||
if (bWasExisting)
|
||||
*bWasExisting = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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<int>(pimpl->mIntProperties, szName,iValue,bWasExisting);
|
||||
ASSIMP_END_EXCEPTION_REGION(void);
|
||||
exising = SetGenericProperty<int>(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<float>(pimpl->mFloatProperties, szName,iValue,bWasExisting);
|
||||
ASSIMP_END_EXCEPTION_REGION(void);
|
||||
exising = SetGenericProperty<float>(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<std::string>(pimpl->mStringProperties, szName,value,bWasExisting);
|
||||
ASSIMP_END_EXCEPTION_REGION(void);
|
||||
exising = SetGenericProperty<std::string>(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<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value,bWasExisting);
|
||||
ASSIMP_END_EXCEPTION_REGION(void);
|
||||
exising = SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value);
|
||||
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||
return exising;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue