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();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
||||||
SetGenericProperty<int>(pp->ints,szName,value,NULL);
|
SetGenericProperty<int>(pp->ints,szName,value);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName,
|
||||||
{
|
{
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
||||||
SetGenericProperty<float>(pp->floats,szName,value,NULL);
|
SetGenericProperty<float>(pp->floats,szName,value);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ ASSIMP_API void aiSetImportPropertyString(aiPropertyStore* p, const char* szName
|
||||||
}
|
}
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
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);
|
ASSIMP_END_EXCEPTION_REGION(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +521,7 @@ ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore* p, const char* szName
|
||||||
}
|
}
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
||||||
SetGenericProperty<aiMatrix4x4>(pp->matrices,szName,*mat,NULL);
|
SetGenericProperty<aiMatrix4x4>(pp->matrices,szName,*mat);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -507,34 +507,30 @@ ExportProperties::ExportProperties(const ExportProperties &other)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void ExportProperties :: SetPropertyInteger(const char* szName, int iValue,
|
bool ExportProperties :: SetPropertyInteger(const char* szName, int iValue)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
SetGenericProperty<int>(mIntProperties, szName,iValue,bWasExisting);
|
return SetGenericProperty<int>(mIntProperties, szName,iValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void ExportProperties :: SetPropertyFloat(const char* szName, float iValue,
|
bool ExportProperties :: SetPropertyFloat(const char* szName, float iValue)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
SetGenericProperty<float>(mFloatProperties, szName,iValue,bWasExisting);
|
return SetGenericProperty<float>(mFloatProperties, szName,iValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void ExportProperties :: SetPropertyString(const char* szName, const std::string& value,
|
bool ExportProperties :: SetPropertyString(const char* szName, const std::string& value)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
SetGenericProperty<std::string>(mStringProperties, szName,value,bWasExisting);
|
return SetGenericProperty<std::string>(mStringProperties, szName,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value,
|
bool ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
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>
|
template <class T>
|
||||||
inline void SetGenericProperty(std::map< unsigned int, T >& list,
|
inline bool SetGenericProperty(std::map< unsigned int, T >& list,
|
||||||
const char* szName, const T& value, bool* bWasExisting = NULL)
|
const char* szName, const T& value)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != szName);
|
ai_assert(NULL != 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)
|
|
||||||
*bWasExisting = false;
|
|
||||||
list.insert(std::pair<unsigned int, T>( hash, value ));
|
list.insert(std::pair<unsigned int, T>( hash, value ));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
(*it).second = value;
|
(*it).second = value;
|
||||||
if (bWasExisting)
|
return true;
|
||||||
*bWasExisting = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -919,42 +919,46 @@ void Importer::GetExtensionList(aiString& szOut) const
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void Importer::SetPropertyInteger(const char* szName, int iValue,
|
bool Importer::SetPropertyInteger(const char* szName, int iValue)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
|
bool exising;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
SetGenericProperty<int>(pimpl->mIntProperties, szName,iValue,bWasExisting);
|
exising = SetGenericProperty<int>(pimpl->mIntProperties, szName,iValue);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||||
|
return exising;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void Importer::SetPropertyFloat(const char* szName, float iValue,
|
bool Importer::SetPropertyFloat(const char* szName, float iValue)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
|
bool exising;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
SetGenericProperty<float>(pimpl->mFloatProperties, szName,iValue,bWasExisting);
|
exising = SetGenericProperty<float>(pimpl->mFloatProperties, szName,iValue);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||||
|
return exising;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void Importer::SetPropertyString(const char* szName, const std::string& value,
|
bool Importer::SetPropertyString(const char* szName, const std::string& value)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
|
bool exising;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value,bWasExisting);
|
exising = SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||||
|
return exising;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value,
|
bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
|
bool exising;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value,bWasExisting);
|
exising = SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||||
|
return exising;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -556,7 +556,7 @@ bool MD3Importer::ReadMultipartFile()
|
||||||
|
|
||||||
// ensure we won't try to load ourselves recursively
|
// ensure we won't try to load ourselves recursively
|
||||||
BatchLoader::PropertyMap props;
|
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
|
// now read these three files
|
||||||
BatchLoader batch(mIOHandler);
|
BatchLoader batch(mIOHandler);
|
||||||
|
|
|
@ -348,16 +348,14 @@ public:
|
||||||
* are defined in the aiConfig.g header (all constants share the
|
* are defined in the aiConfig.g header (all constants share the
|
||||||
* prefix AI_CONFIG_XXX and are simple strings).
|
* prefix AI_CONFIG_XXX and are simple strings).
|
||||||
* @param iValue New value of the property
|
* @param iValue New value of the property
|
||||||
* @param bWasExisting Optional pointer to receive true if the
|
* @return true if the property was set before. The new value replaces
|
||||||
* property was set before. The new value replaces the previous value
|
* the previous value in this case.
|
||||||
* in this case.
|
|
||||||
* @note Property of different types (float, int, string ..) are kept
|
* @note Property of different types (float, int, string ..) are kept
|
||||||
* on different stacks, so calling SetPropertyInteger() for a
|
* on different stacks, so calling SetPropertyInteger() for a
|
||||||
* floating-point property has no effect - the loader will call
|
* floating-point property has no effect - the loader will call
|
||||||
* GetPropertyFloat() to read the property, but it won't be there.
|
* GetPropertyFloat() to read the property, but it won't be there.
|
||||||
*/
|
*/
|
||||||
void SetPropertyInteger(const char* szName, int iValue,
|
bool SetPropertyInteger(const char* szName, int iValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a boolean configuration property. Boolean properties
|
/** Set a boolean configuration property. Boolean properties
|
||||||
|
@ -366,30 +364,27 @@ public:
|
||||||
* #GetPropertyBool and vice versa.
|
* #GetPropertyBool and vice versa.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) {
|
bool SetPropertyBool(const char* szName, bool value) {
|
||||||
SetPropertyInteger(szName,value,bWasExisting);
|
return SetPropertyInteger(szName,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a floating-point configuration property.
|
/** Set a floating-point configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyFloat(const char* szName, float fValue,
|
bool SetPropertyFloat(const char* szName, float fValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a string configuration property.
|
/** Set a string configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyString(const char* szName, const std::string& sValue,
|
bool SetPropertyString(const char* szName, const std::string& sValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a matrix configuration property.
|
/** Set a matrix configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue,
|
bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Get a configuration property.
|
/** Get a configuration property.
|
||||||
|
|
|
@ -194,16 +194,14 @@ public:
|
||||||
* are defined in the aiConfig.g header (all constants share the
|
* are defined in the aiConfig.g header (all constants share the
|
||||||
* prefix AI_CONFIG_XXX and are simple strings).
|
* prefix AI_CONFIG_XXX and are simple strings).
|
||||||
* @param iValue New value of the property
|
* @param iValue New value of the property
|
||||||
* @param bWasExisting Optional pointer to receive true if the
|
* @return true if the property was set before. The new value replaces
|
||||||
* property was set before. The new value replaces the previous value
|
* the previous value in this case.
|
||||||
* in this case.
|
|
||||||
* @note Property of different types (float, int, string ..) are kept
|
* @note Property of different types (float, int, string ..) are kept
|
||||||
* on different stacks, so calling SetPropertyInteger() for a
|
* on different stacks, so calling SetPropertyInteger() for a
|
||||||
* floating-point property has no effect - the loader will call
|
* floating-point property has no effect - the loader will call
|
||||||
* GetPropertyFloat() to read the property, but it won't be there.
|
* GetPropertyFloat() to read the property, but it won't be there.
|
||||||
*/
|
*/
|
||||||
void SetPropertyInteger(const char* szName, int iValue,
|
bool SetPropertyInteger(const char* szName, int iValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a boolean configuration property. Boolean properties
|
/** Set a boolean configuration property. Boolean properties
|
||||||
|
@ -212,30 +210,27 @@ public:
|
||||||
* #GetPropertyBool and vice versa.
|
* #GetPropertyBool and vice versa.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) {
|
bool SetPropertyBool(const char* szName, bool value) {
|
||||||
SetPropertyInteger(szName,value,bWasExisting);
|
return SetPropertyInteger(szName,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a floating-point configuration property.
|
/** Set a floating-point configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyFloat(const char* szName, float fValue,
|
bool SetPropertyFloat(const char* szName, float fValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a string configuration property.
|
/** Set a string configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyString(const char* szName, const std::string& sValue,
|
bool SetPropertyString(const char* szName, const std::string& sValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a matrix configuration property.
|
/** Set a matrix configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue,
|
bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Get a configuration property.
|
/** Get a configuration property.
|
||||||
|
|
Loading…
Reference in New Issue