Skip to content

Commit

Permalink
Removed direct STL dependency from the Assimp interface, should hopef…
Browse files Browse the repository at this point in the history
…ully avoid problems with binary incompatible STLs. Some API changes, e.g. in the logger.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@321 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
  • Loading branch information
aramis_acg committed Jan 23, 2009
1 parent b5ab829 commit 03fcec7
Show file tree
Hide file tree
Showing 26 changed files with 539 additions and 286 deletions.
30 changes: 14 additions & 16 deletions code/Assimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class CIOSystemWrapper : public IOSystem
{}

// -------------------------------------------------------------------
bool Exists( const std::string& pFile) const
bool Exists( const char* pFile) const
{
CIOSystemWrapper* pip = const_cast<CIOSystemWrapper*>(this);
IOStream* p = pip->Open(pFile);
Expand All @@ -161,17 +161,16 @@ class CIOSystemWrapper : public IOSystem
}

// -------------------------------------------------------------------
std::string getOsSeparator() const
char getOsSeparator() const
{
// FIXME
return "/";
return '/';
}

// -------------------------------------------------------------------
IOStream* Open(const std::string& pFile,
const std::string& pMode = std::string("rb"))
IOStream* Open(const char* pFile,const char* pMode = "rb")
{
aiFile* p = mFileSystem->OpenProc(mFileSystem,pFile.c_str(),pMode.c_str());
aiFile* p = mFileSystem->OpenProc(mFileSystem,pFile,pMode);
if (!p)return NULL;
return new CIOStreamWrapper(p);
}
Expand Down Expand Up @@ -278,6 +277,7 @@ const char* aiGetErrorString()
{
return gLastErrorString.c_str();
}

// ------------------------------------------------------------------------------------------------
// Returns the error text of the last failed import process.
int aiIsExtensionSupported(const char* szExtension)
Expand All @@ -289,18 +289,18 @@ int aiIsExtensionSupported(const char* szExtension)
boost::mutex::scoped_lock lock(gMutex);
#endif

if (!gActiveImports.empty())
{
return (int)((*(gActiveImports.begin())).second->IsExtensionSupported(
std::string ( szExtension )));
if (!gActiveImports.empty()) {
return (int)((*(gActiveImports.begin())).second->IsExtensionSupported( szExtension ));
}

// need to create a temporary Importer instance.
// TODO: Find a better solution ...
Assimp::Importer* pcTemp = new Assimp::Importer();
int i = (int)pcTemp->IsExtensionSupported(std::string ( szExtension ));
int i = (int)pcTemp->IsExtensionSupported(std::string(szExtension));
delete pcTemp;
return i;
}

// ------------------------------------------------------------------------------------------------
// Get a list of all file extensions supported by ASSIMP
void aiGetExtensionList(aiString* szOut)
Expand All @@ -312,20 +312,18 @@ void aiGetExtensionList(aiString* szOut)
boost::mutex::scoped_lock lock(gMutex);
#endif

std::string szTemp;
if (!gActiveImports.empty())
{
(*(gActiveImports.begin())).second->GetExtensionList(szTemp);
szOut->Set ( szTemp );
(*(gActiveImports.begin())).second->GetExtensionList(*szOut);
return;
}
// need to create a temporary Importer instance.
// TODO: Find a better solution ...
Assimp::Importer* pcTemp = new Assimp::Importer();
pcTemp->GetExtensionList(szTemp);
szOut->Set ( szTemp );
pcTemp->GetExtensionList(*szOut);
delete pcTemp;
}

// ------------------------------------------------------------------------------------------------
void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn,
C_STRUCT aiMemoryInfo* in)
Expand Down
33 changes: 16 additions & 17 deletions code/DefaultIOSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

using namespace Assimp;


// ------------------------------------------------------------------------------------------------
// Constructor.
DefaultIOSystem::DefaultIOSystem()
Expand All @@ -70,9 +69,9 @@ DefaultIOSystem::~DefaultIOSystem()

// ------------------------------------------------------------------------------------------------
// Tests for the existence of a file at the given path.
bool DefaultIOSystem::Exists( const std::string& pFile) const
bool DefaultIOSystem::Exists( const char* pFile) const
{
FILE* file = ::fopen( pFile.c_str(), "rb");
FILE* file = ::fopen( pFile, "rb");
if( !file)
return false;

Expand All @@ -82,13 +81,16 @@ bool DefaultIOSystem::Exists( const std::string& pFile) const

// ------------------------------------------------------------------------------------------------
// Open a new file with a given path.
IOStream* DefaultIOSystem::Open( const std::string& strFile, const std::string& strMode)
IOStream* DefaultIOSystem::Open( const char* strFile, const char* strMode)
{
FILE* file = ::fopen( strFile.c_str(), strMode.c_str());
ai_assert(NULL != strFile);
ai_assert(NULL != strMode);

FILE* file = ::fopen( strFile, strMode);
if( NULL == file)
return NULL;

return new DefaultIOStream( file, strFile);
return new DefaultIOStream(file, (std::string) strFile);
}

// ------------------------------------------------------------------------------------------------
Expand All @@ -100,20 +102,18 @@ void DefaultIOSystem::Close( IOStream* pFile)

// ------------------------------------------------------------------------------------------------
// Returns the operation specific directory separator
std::string DefaultIOSystem::getOsSeparator() const
char DefaultIOSystem::getOsSeparator() const
{
#ifndef _WIN32
std::string sep = "/";
return '/';
#else
std::string sep = "\\";
return '\\';
#endif
return sep;
}

// ------------------------------------------------------------------------------------------------
// IOSystem default implementation (ComparePaths isn't a pure virtual function)
bool IOSystem::ComparePaths (const std::string& one,
const std::string& second)
bool IOSystem::ComparePaths (const char* one, const char* second) const
{
return !ASSIMP_stricmp(one,second);
}
Expand All @@ -123,20 +123,19 @@ bool IOSystem::ComparePaths (const std::string& one,

// ------------------------------------------------------------------------------------------------
// Convert a relative path into an absolute path
inline void MakeAbsolutePath (const std::string& in, char* _out)
inline void MakeAbsolutePath (const char* in, char* _out)
{
#ifdef _WIN32
::_fullpath(_out, in.c_str(),PATHLIMIT);
::_fullpath(_out, in,PATHLIMIT);
#else
// use realpath
realpath(in.c_str(), _out);
realpath(in, _out);
#endif
}

// ------------------------------------------------------------------------------------------------
// DefaultIOSystem's more specialized implementation
bool DefaultIOSystem::ComparePaths (const std::string& one,
const std::string& second)
bool DefaultIOSystem::ComparePaths (const char* one, const char* second) const
{
// chances are quite good both paths are formatted identically,
// so we can hopefully return here already
Expand Down
11 changes: 5 additions & 6 deletions code/DefaultIOSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "../include/IOSystem.h"

namespace Assimp
{
namespace Assimp {

// ---------------------------------------------------------------------------
/** Default implementation of IOSystem using the standard C file functions */
Expand All @@ -60,23 +59,23 @@ class DefaultIOSystem : public IOSystem

// -------------------------------------------------------------------
/** Tests for the existence of a file at the given path. */
bool Exists( const std::string& pFile) const;
bool Exists( const char* pFile) const;

// -------------------------------------------------------------------
/** Returns the directory separator. */
std::string getOsSeparator() const;
char getOsSeparator() const;

// -------------------------------------------------------------------
/** Open a new file with a given path. */
IOStream* Open( const std::string& pFile, const std::string& pMode = std::string("rb"));
IOStream* Open( const char* pFile, const char* pMode = "rb");

// -------------------------------------------------------------------
/** Closes the given file and releases all resources associated with it. */
void Close( IOStream* pFile);

// -------------------------------------------------------------------
/** Compare two paths */
bool ComparePaths (const std::string& one, const std::string& second);
bool ComparePaths (const char* one, const char* second) const;
};

} //!ns Assimp
Expand Down
Loading

0 comments on commit 03fcec7

Please sign in to comment.