adapt c-api to get ImporterDesc for a given loader ( see https://github.com/assimp/assimp/issues/412 ).

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
pull/427/head
Kim Kulling 2014-12-01 20:34:15 +01:00
parent 1f13158b31
commit 7a31a68cfc
5 changed files with 30 additions and 3 deletions

View File

@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "GenericProperty.h"
#include "CInterfaceIOWrapper.h"
#include "../include/assimp/importerdesc.h"
#include "Importer.h"
// ------------------------------------------------------------------------------------------------
@ -84,7 +85,11 @@ namespace Assimp
/** Verbose logging active or not? */
static aiBool gVerboseLogging = false;
}
/** will return all registered importers. */
void GetImporterInstanceList(std::vector< BaseImporter* >& out);
} // namespace assimp
#ifndef ASSIMP_BUILD_SINGLETHREADED
@ -606,4 +611,22 @@ ASSIMP_API void aiIdentityMatrix4(
*mat = aiMatrix4x4();
}
// ------------------------------------------------------------------------------------------------
ASSIMP_API C_STRUCT const aiImporterDesc* aiGetImporterDesc( const char *extension ) {
if( NULL == extension ) {
return NULL;
}
const aiImporterDesc *desc( NULL );
std::vector< BaseImporter* > out;
GetImporterInstanceList( out );
for( size_t i = 0; i < out.size(); ++i ) {
if( 0 == strncmp( out[ i ]->GetInfo()->mFileExtensions, extension, strlen( extension ) ) ) {
desc = out[ i ]->GetInfo();
break;
}
}
return desc;
}
// ------------------------------------------------------------------------------------------------

View File

@ -91,6 +91,7 @@ struct ScopeGuard
private:
// no copying allowed.
ScopeGuard();
ScopeGuard( const ScopeGuard & );
ScopeGuard &operator = ( const ScopeGuard & );

View File

@ -247,7 +247,7 @@ ASSIMP_API C_STRUCT aiLogStream aiGetPredefinedLogStream(
* Attaching a log stream can slightly reduce Assimp's overall import
* performance. Multiple log-streams can be attached.
* @param stream Describes the new log stream.
* @note To ensure proepr destruction of the logging system, you need to manually
* @note To ensure proper destruction of the logging system, you need to manually
* call aiDetachLogStream() on every single log stream you attach.
* Alternatively (for the lazy folks) #aiDetachAllLogStreams is provided.
*/

View File

@ -133,4 +133,6 @@ struct aiImporterDesc
const char* mFileExtensions;
};
ASSIMP_API C_STRUCT const aiImporterDesc* aiGetImporterDesc( const char *extension );
#endif

View File

@ -16,6 +16,7 @@ SOURCE_GROUP( unit FILES
)
SET( TEST_SRCS
unit/AssimpAPITest.cpp
unit/utFastAtof.cpp
unit/utFindDegenerates.cpp
unit/utFindInvalidData.cpp