MCPcopy Create free account
hub / github.com/assimp/assimp / GetImporterIndex

Method GetImporterIndex

code/Common/Importer.cpp:1006–1033  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Find a loader plugin for a given file extension

Source from the content-addressed store, hash-verified

1004// ------------------------------------------------------------------------------------------------
1005// Find a loader plugin for a given file extension
1006size_t Importer::GetImporterIndex (const char* szExtension) const {
1007 ai_assert(nullptr != pimpl);
1008 ai_assert(nullptr != szExtension);
1009
1010 ASSIMP_BEGIN_EXCEPTION_REGION();
1011
1012 // skip over wild-card and dot characters at string head --
1013 for ( ; *szExtension == '*' || *szExtension == '.'; ++szExtension );
1014
1015 std::string ext(szExtension);
1016 if (ext.empty()) {
1017 return static_cast<size_t>(-1);
1018 }
1019 ext = ai_tolower(ext);
1020 std::set<std::string> str;
1021 for (std::vector<BaseImporter*>::const_iterator i = pimpl->mImporter.begin();i != pimpl->mImporter.end();++i) {
1022 str.clear();
1023
1024 (*i)->GetExtensionList(str);
1025 for (std::set<std::string>::const_iterator it = str.begin(); it != str.end(); ++it) {
1026 if (ext == *it) {
1027 return std::distance(static_cast< std::vector<BaseImporter*>::const_iterator >(pimpl->mImporter.begin()), i);
1028 }
1029 }
1030 }
1031 ASSIMP_END_EXCEPTION_REGION(size_t);
1032 return static_cast<size_t>(-1);
1033}
1034
1035// ------------------------------------------------------------------------------------------------
1036// Helper function to build a list of all file extensions supported by ASSIMP

Callers

nothing calls this directly

Calls 7

ai_tolowerFunction · 0.85
distanceFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
GetExtensionListMethod · 0.45

Tested by

no test coverage detected