From 03fcec7fe374fcefd816b96fa073fbfb496cfb33 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Fri, 23 Jan 2009 21:06:43 +0000 Subject: [PATCH] Removed direct STL dependency from the Assimp interface, should hopefully 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 --- code/Assimp.cpp | 30 ++-- code/DefaultIOSystem.cpp | 33 ++-- code/DefaultIOSystem.h | 11 +- code/DefaultLogger.cpp | 115 ++++++++----- code/FileLogStream.h | 23 +-- code/Importer.cpp | 55 +++++-- code/ObjFileParser.cpp | 8 +- code/StdOStreamLogStream.h | 6 +- code/ValidateDataStructure.cpp | 4 +- code/Win32DebugLogStream.h | 6 +- .../cppunit-1.12.1/src/cppunit/cppunit.vcproj | 8 +- include/DefaultLogger.h | 61 +++---- include/IOStream.h | 2 +- include/IOSystem.h | 154 +++++++++++++----- include/LogStream.h | 16 +- include/Logger.h | 44 ++++- include/NullLogger.h | 38 +++-- include/aiTypes.h | 15 +- include/assimp.hpp | 97 +++++++---- tools/assimp_view/LogWindow.cpp | 6 +- tools/assimp_view/LogWindow.h | 4 +- workspaces/vc8/UnitTest.vcproj | 32 ++-- workspaces/vc8/assimp.vcproj | 31 ++-- workspaces/vc8/assimp_view.vcproj | 20 ++- workspaces/vc8/shared/FastSTL.vsprops | 11 ++ workspaces/vc9/assimp_view.vcproj | 1 - 26 files changed, 542 insertions(+), 289 deletions(-) create mode 100644 workspaces/vc8/shared/FastSTL.vsprops diff --git a/code/Assimp.cpp b/code/Assimp.cpp index 556028445..eb8104dcb 100644 --- a/code/Assimp.cpp +++ b/code/Assimp.cpp @@ -149,7 +149,7 @@ public: {} // ------------------------------------------------------------------- - bool Exists( const std::string& pFile) const + bool Exists( const char* pFile) const { CIOSystemWrapper* pip = const_cast(this); IOStream* p = pip->Open(pFile); @@ -161,17 +161,16 @@ public: } // ------------------------------------------------------------------- - 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); } @@ -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) @@ -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) @@ -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) diff --git a/code/DefaultIOSystem.cpp b/code/DefaultIOSystem.cpp index a1f1959d3..785ad0abc 100644 --- a/code/DefaultIOSystem.cpp +++ b/code/DefaultIOSystem.cpp @@ -53,7 +53,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; - // ------------------------------------------------------------------------------------------------ // Constructor. DefaultIOSystem::DefaultIOSystem() @@ -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; @@ -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); } // ------------------------------------------------------------------------------------------------ @@ -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); } @@ -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 diff --git a/code/DefaultIOSystem.h b/code/DefaultIOSystem.h index 6e9fdfb1f..1952be88e 100644 --- a/code/DefaultIOSystem.h +++ b/code/DefaultIOSystem.h @@ -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 */ @@ -60,15 +59,15 @@ public: // ------------------------------------------------------------------- /** 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. */ @@ -76,7 +75,7 @@ public: // ------------------------------------------------------------------- /** Compare two paths */ - bool ComparePaths (const std::string& one, const std::string& second); + bool ComparePaths (const char* one, const char* second) const; }; } //!ns Assimp diff --git a/code/DefaultLogger.cpp b/code/DefaultLogger.cpp index ebd22ecfc..76875f99b 100644 --- a/code/DefaultLogger.cpp +++ b/code/DefaultLogger.cpp @@ -39,6 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------- */ +/** @file DefaultLogger.cpp + * @brief Implementation of DefaultLogger (and Logger) + */ + #include "AssimpPCH.h" #include "DefaultIOSystem.h" @@ -54,7 +58,7 @@ NullLogger DefaultLogger::s_pNullLogger; Logger *DefaultLogger::m_pLogger = &DefaultLogger::s_pNullLogger; // ---------------------------------------------------------------------------------- -// +// Represents a logstream + its error severity struct LogStreamInfo { unsigned int m_uiErrorSeverity; @@ -78,7 +82,7 @@ struct LogStreamInfo // ---------------------------------------------------------------------------------- // Construct a default log stream LogStream* LogStream::createDefaultStream(DefaultLogStreams streams, - const std::string& name /*= "AssimpLog.txt"*/, + const char* name /*= "AssimpLog.txt"*/, IOSystem* io /*= NULL*/) { switch (streams) @@ -97,7 +101,7 @@ LogStream* LogStream::createDefaultStream(DefaultLogStreams streams, case DLS_COUT: return new StdOStreamLogStream(std::cout); case DLS_FILE: - return (name.size() ? new FileLogStream(name,io) : NULL); + return (name && *name ? new FileLogStream(name,io) : NULL); default: // We don't know this default log stream, so raise an assertion ai_assert(false); @@ -110,10 +114,10 @@ LogStream* LogStream::createDefaultStream(DefaultLogStreams streams, // ---------------------------------------------------------------------------------- // Creates the only singleton instance -Logger *DefaultLogger::create(const std::string &name /*= "AssimpLog.txt"*/, - LogSeverity severity /*= NORMAL*/, - unsigned int defStreams /*= DLS_DEBUGGER | DLS_FILE*/, - IOSystem* io /*= NULL*/) +Logger *DefaultLogger::create(const char* name /*= "AssimpLog.txt"*/, + LogSeverity severity /*= NORMAL*/, + unsigned int defStreams /*= DLS_DEBUGGER | DLS_FILE*/, + IOSystem* io /*= NULL*/) { if (m_pLogger && !isNullLogger() ) delete m_pLogger; @@ -134,12 +138,36 @@ Logger *DefaultLogger::create(const std::string &name /*= "AssimpLog.txt"*/, m_pLogger->attachStream( LogStream::createDefaultStream(DLS_CERR)); // Stream the log to a file - if (defStreams & DLS_FILE && !name.empty()) + if (defStreams & DLS_FILE && name && *name) m_pLogger->attachStream( LogStream::createDefaultStream(DLS_FILE,name,io)); return m_pLogger; } +// ---------------------------------------------------------------------------------- +void Logger::debug(const std::string &message) { + ai_assert(message.length()<=Logger::MAX_LOG_MESSAGE_LENGTH); + return OnDebug(message.c_str()); +} + +// ---------------------------------------------------------------------------------- +void Logger::info(const std::string &message) { + ai_assert(message.length()<=Logger::MAX_LOG_MESSAGE_LENGTH); + return OnInfo(message.c_str()); +} + +// ---------------------------------------------------------------------------------- +void Logger::warn(const std::string &message) { + ai_assert(message.length()<=Logger::MAX_LOG_MESSAGE_LENGTH); + return OnWarn(message.c_str()); +} + +// ---------------------------------------------------------------------------------- +void Logger::error(const std::string &message) { + ai_assert(message.length()<=Logger::MAX_LOG_MESSAGE_LENGTH); + return OnError(message.c_str()); +} + // ---------------------------------------------------------------------------------- void DefaultLogger::set( Logger *logger ) { @@ -174,37 +202,45 @@ void DefaultLogger::kill() // ---------------------------------------------------------------------------------- // Debug message -void DefaultLogger::debug( const std::string &message ) +void DefaultLogger::OnDebug( const char* message ) { if ( m_Severity == Logger::NORMAL ) return; - const std::string msg( "Debug, T" + getThreadID() + ": " + message ); - writeToStreams( msg, Logger::DEBUGGING ); + char msg[MAX_LOG_MESSAGE_LENGTH*2]; + ::sprintf(msg,"Debug, T%i: %s", GetThreadID(), message ); + + WriteToStreams( msg, Logger::DEBUGGING ); } // ---------------------------------------------------------------------------------- // Logs an info -void DefaultLogger::info( const std::string &message ) +void DefaultLogger::OnInfo( const char* message ) { - const std::string msg( "Info, T" + getThreadID() + ": " + message ); - writeToStreams( msg , Logger::INFO ); + char msg[MAX_LOG_MESSAGE_LENGTH*2]; + ::sprintf(msg,"Info, T%i: %s", GetThreadID(), message ); + + WriteToStreams( msg , Logger::INFO ); } // ---------------------------------------------------------------------------------- // Logs a warning -void DefaultLogger::warn( const std::string &message ) +void DefaultLogger::OnWarn( const char* message ) { - const std::string msg( "Warn, T" + getThreadID() + ": "+ message ); - writeToStreams( msg, Logger::WARN ); + char msg[MAX_LOG_MESSAGE_LENGTH*2]; + ::sprintf(msg,"Warn, T%i: %s", GetThreadID(), message ); + + WriteToStreams( msg, Logger::WARN ); } // ---------------------------------------------------------------------------------- // Logs an error -void DefaultLogger::error( const std::string &message ) +void DefaultLogger::OnError( const char* message ) { - const std::string msg( "Error, T"+ getThreadID() + ": " + message ); - writeToStreams( msg, Logger::ERR ); + char msg[MAX_LOG_MESSAGE_LENGTH*2]; + ::sprintf(msg,"Error, T%i: %s", GetThreadID(), message ); + + WriteToStreams( msg, Logger::ERR ); } // ---------------------------------------------------------------------------------- @@ -289,57 +325,50 @@ DefaultLogger::~DefaultLogger() // ---------------------------------------------------------------------------------- // Writes message to stream -void DefaultLogger::writeToStreams(const std::string &message, +void DefaultLogger::WriteToStreams(const char *message, ErrorSeverity ErrorSev ) { - if ( message.empty() ) - return; - - std::string s; + ai_assert(NULL != message); // Check whether this is a repeated message - if (message == lastMsg) + if (! ::strncmp( message,lastMsg, lastLen-1)) { if (!noRepeatMsg) { noRepeatMsg = true; - s = "Skipping one or more lines with the same contents\n"; + message = "Skipping one or more lines with the same contents\n"; } else return; } else { - lastMsg = s = message; - noRepeatMsg = false; + // append a new-line character to the message to be printed + lastLen = ::strlen(message); + ::memcpy(lastMsg,message,lastLen+1); + ::strcat(lastMsg+lastLen,"\n"); - s.append("\n"); + message = lastMsg; + noRepeatMsg = false; + ++lastLen; } for ( ConstStreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it) { if ( ErrorSev & (*it)->m_uiErrorSeverity ) - (*it)->m_pStream->write( s); + (*it)->m_pStream->write( message); } } // ---------------------------------------------------------------------------------- // Returns thread id, if not supported only a zero will be returned. -std::string DefaultLogger::getThreadID() +unsigned int DefaultLogger::GetThreadID() { - std::string thread_id( "0" ); + // fixme: we can get this value via boost::threads #ifdef WIN32 - HANDLE hThread = ::GetCurrentThread(); - if ( hThread ) - { - std::stringstream thread_msg; - thread_msg << ::GetCurrentThreadId() /*<< " "*/; - return thread_msg.str(); - } - else - return thread_id; + return (unsigned int)::GetCurrentThreadId(); #else - return thread_id; + return 0; // not supported #endif } diff --git a/code/FileLogStream.h b/code/FileLogStream.h index b76b083c2..2ab624ce1 100644 --- a/code/FileLogStream.h +++ b/code/FileLogStream.h @@ -6,7 +6,6 @@ namespace Assimp { - // ---------------------------------------------------------------------------------- /** @class FileLogStream * @brief Logstream to write into a file. @@ -15,32 +14,29 @@ class FileLogStream : public LogStream { public: - FileLogStream( const std::string &strFileName, IOSystem* io = NULL ); + FileLogStream( const char* file, IOSystem* io = NULL ); ~FileLogStream(); - void write( const std::string &message ); + void write( const char* message ); private: IOStream *m_pStream; }; - // ---------------------------------------------------------------------------------- // Constructor -inline FileLogStream::FileLogStream( const std::string &strFileName, IOSystem* io ) : +inline FileLogStream::FileLogStream( const char* file, IOSystem* io ) : m_pStream(NULL) { - if ( strFileName.empty() ) + if ( !file || 0 == *file ) return; - const static std::string mode = "wt"; - // If no IOSystem is specified: take a default one if (!io) { DefaultIOSystem FileSystem; - m_pStream = FileSystem.Open( strFileName, mode ); + m_pStream = FileSystem.Open( file, "wt"); } - else m_pStream = io->Open( strFileName, mode ); + else m_pStream = io->Open( file, "wt" ); } // ---------------------------------------------------------------------------------- @@ -51,21 +47,18 @@ inline FileLogStream::~FileLogStream() delete m_pStream; } - // ---------------------------------------------------------------------------------- // Write method -inline void FileLogStream::write( const std::string &message ) +inline void FileLogStream::write( const char* message ) { if (m_pStream != NULL) { - m_pStream->Write(message.c_str(), sizeof(char), message.size()); + m_pStream->Write(message, sizeof(char), ::strlen(message)); m_pStream->Flush(); } } - // ---------------------------------------------------------------------------------- - } // !Namespace Assimp #endif // !! ASSIMP_FILELOGSTREAM_H_INC diff --git a/code/Importer.cpp b/code/Importer.cpp index c6e3d085a..05d307d8b 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -569,13 +569,45 @@ void Importer::FreeScene( ) mScene = NULL; } +// ------------------------------------------------------------------------------------------------ +// Get the current error string, if any +const std::string& Importer::GetErrorString() const +{ + return mErrorString; +} + +// ------------------------------------------------------------------------------------------------ +// Enable extra-verbose mode +void Importer::SetExtraVerbose(bool bDo) +{ + bExtraVerbose = bDo; +} + +// ------------------------------------------------------------------------------------------------ +// Get the current scene +const aiScene* Importer::GetScene() const +{ + return mScene; +} + +// ------------------------------------------------------------------------------------------------ +// Orphan the current scene +aiScene* Importer::GetOrphanedScene() +{ + aiScene* s = mScene; + mScene = NULL; + return s; +} + // ------------------------------------------------------------------------------------------------ // Reads the given file and returns its contents if successful. -const aiScene* Importer::ReadFile( const std::string& pFile, unsigned int pFlags) +const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) { // Validate the flags ai_assert(ValidateFlags(pFlags)); + const std::string pFile(_pFile); + // ====================================================================== // Put a large try block around everything to catch all std::exception's // that might be thrown by STL containers or by new(). @@ -701,17 +733,18 @@ const aiScene* Importer::ReadFile( const std::string& pFile, unsigned int pFlags // ------------------------------------------------------------------------------------------------ // Helper function to check whether an extension is supported by ASSIMP -bool Importer::IsExtensionSupported(const std::string& szExtension) +bool Importer::IsExtensionSupported(const char* szExtension) { return NULL != FindLoader(szExtension); } // ------------------------------------------------------------------------------------------------ -BaseImporter* Importer::FindLoader (const std::string& szExtension) +BaseImporter* Importer::FindLoader (const char* _szExtension) { + const std::string szExtension(_szExtension); for (std::vector::const_iterator - i = this->mImporter.begin(); - i != this->mImporter.end();++i) + i = mImporter.begin(); + i != mImporter.end();++i) { // pass the file extension to the CanRead(..,NULL)-method if ((*i)->CanRead(szExtension,NULL))return *i; @@ -721,19 +754,21 @@ BaseImporter* Importer::FindLoader (const std::string& szExtension) // ------------------------------------------------------------------------------------------------ // Helper function to build a list of all file extensions supported by ASSIMP -void Importer::GetExtensionList(std::string& szOut) +void Importer::GetExtensionList(aiString& szOut) { unsigned int iNum = 0; + std::string tmp; // todo: Rewrite baseImporter::GetExtensionList to use aiString, too for (std::vector::const_iterator - i = this->mImporter.begin(); - i != this->mImporter.end();++i,++iNum) + i = mImporter.begin(); + i != mImporter.end();++i,++iNum) { // insert a comma as delimiter character if (0 != iNum) - szOut.append(";"); + tmp.append(";"); - (*i)->GetExtensionList(szOut); + (*i)->GetExtensionList(tmp); } + szOut.Set(tmp); return; } diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 901dea937..89e9ce989 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -437,11 +437,15 @@ void ObjFileParser::getMaterialLib() while (!isNewLine(*m_DataIt)) m_DataIt++; + // TODO: fix path construction + // CLEANUP ... who is resposible for *two* identical DefaultIOSystems + // where the IOSystem passed to ReadFile() should be used??? + // Check for existence DefaultIOSystem IOSystem; std::string strMatName(pStart, &(*m_DataIt)); std::string absName = m_strAbsPath + IOSystem.getOsSeparator() + strMatName; - if ( !IOSystem.Exists(absName) ) + if ( !IOSystem.Exists( absName.c_str()) ) { m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); return; @@ -454,7 +458,7 @@ void ObjFileParser::getMaterialLib() // Load the material library DefaultIOSystem FileSystem; - IOStream *pFile = FileSystem.Open(absName); + IOStream *pFile = FileSystem.Open(absName.c_str()); if (0L != pFile) { // Import material library data from file diff --git a/code/StdOStreamLogStream.h b/code/StdOStreamLogStream.h index 8909c8c45..241510bf1 100644 --- a/code/StdOStreamLogStream.h +++ b/code/StdOStreamLogStream.h @@ -22,7 +22,7 @@ public: ~StdOStreamLogStream(); /** @brief Writer */ - void write(const std::string &messgae); + void write(const char* message); private: std::ostream& ostream; }; @@ -40,9 +40,9 @@ inline StdOStreamLogStream::~StdOStreamLogStream() // --------------------------------------------------------------------------- // Write method -inline void StdOStreamLogStream::write(const std::string &message) +inline void StdOStreamLogStream::write(const char* message) { - ostream << message.c_str(); + ostream << message; ostream.flush(); } diff --git a/code/ValidateDataStructure.cpp b/code/ValidateDataStructure.cpp index eca2e51a5..885588bcf 100644 --- a/code/ValidateDataStructure.cpp +++ b/code/ValidateDataStructure.cpp @@ -308,7 +308,7 @@ void ValidateDSProcess::Execute( aiScene* pScene) void ValidateDSProcess::Validate( const aiLight* pLight) { if (pLight->mType == aiLightSource_UNDEFINED) - ReportError("aiLight::mType is aiLightSource_UNDEFINED"); + ReportWarning("aiLight::mType is aiLightSource_UNDEFINED"); if (!pLight->mAttenuationConstant && !pLight->mAttenuationLinear && @@ -334,7 +334,7 @@ void ValidateDSProcess::Validate( const aiCamera* pCamera) ReportError("aiCamera::mClipPlaneFar must be >= aiCamera::mClipPlaneNear"); if (!pCamera->mHorizontalFOV || pCamera->mHorizontalFOV >= (float)AI_MATH_PI) - ReportError("%f is not a valid value for aiCamera::mHorizontalFOV",pCamera->mHorizontalFOV); + ReportWarning("%f is not a valid value for aiCamera::mHorizontalFOV",pCamera->mHorizontalFOV); } // ------------------------------------------------------------------------------------------------ diff --git a/code/Win32DebugLogStream.h b/code/Win32DebugLogStream.h index 7b25736cf..36cae6706 100644 --- a/code/Win32DebugLogStream.h +++ b/code/Win32DebugLogStream.h @@ -23,7 +23,7 @@ public: ~Win32DebugLogStream(); /** @brief Writer */ - void write(const std::string &messgae); + void write(const char* messgae); }; // --------------------------------------------------------------------------- @@ -38,9 +38,9 @@ inline Win32DebugLogStream::~Win32DebugLogStream() // --------------------------------------------------------------------------- // Write method -inline void Win32DebugLogStream::write(const std::string &message) +inline void Win32DebugLogStream::write(const char* message) { - OutputDebugString( message.c_str() ); + OutputDebugString( message); } // --------------------------------------------------------------------------- diff --git a/contrib/cppunit-1.12.1/src/cppunit/cppunit.vcproj b/contrib/cppunit-1.12.1/src/cppunit/cppunit.vcproj index e8247acbb..a2286c299 100644 --- a/contrib/cppunit-1.12.1/src/cppunit/cppunit.vcproj +++ b/contrib/cppunit-1.12.1/src/cppunit/cppunit.vcproj @@ -653,11 +653,11 @@ @@ -2694,11 +2694,11 @@ > diff --git a/include/DefaultLogger.h b/include/DefaultLogger.h index 89b0751d9..ede298623 100644 --- a/include/DefaultLogger.h +++ b/include/DefaultLogger.h @@ -54,11 +54,14 @@ namespace Assimp { class IOStream; struct LogStreamInfo; +//! Default log file +#define ASSIMP_DEFAULT_LOG_NAME "AssimpLog.txt" + // ------------------------------------------------------------------------------------ -/** @class DefaultLogger - * @brief Default logging implementation. The logger writes into a file. - * The name can be set by creating the logger. If no filename was specified - * the logger will use the standard out and error streams. +/** @class DefaultLogger + * @brief Default logging implementation. + * + * todo .... move static stuff to Logger where it belongs to. */ class ASSIMP_API DefaultLogger : public Logger @@ -66,9 +69,9 @@ class ASSIMP_API DefaultLogger : public: /** @brief Creates a default logging instance (DefaultLogger) - * @param name Name for log file. Only valid in combination + * @param name Name for log file. Only valid in combination * with the DLS_FILE flag. - * @param severity Log severity, VERBOSE will activate debug messages + * @param severity Log severity, VERBOSE will activate debug messages * @param defStreams Default log streams to be attached. Bitwise * combination of the DefaultLogStreams enumerated * values. If DLS_FILE is specified, but an empty @@ -78,7 +81,7 @@ public: * * This replaces the default NullLogger with a DefaultLogger instance. */ - static Logger *create(const std::string &name = "AssimpLog.txt", + static Logger *create(const char* name = ASSIMP_DEFAULT_LOG_NAME, LogSeverity severity = NORMAL, unsigned int defStreams = DLS_DEBUGGER | DLS_FILE, IOSystem* io = NULL); @@ -110,31 +113,32 @@ public: static void kill(); - - - /** @brief Logs debug infos, only been written when severity level VERBOSE is set */ - void debug(const std::string &message); - - /** @brief Logs an info message */ - void info(const std::string &message); - - /** @brief Logs a warning message */ - void warn(const std::string &message); - - /** @brief Logs an error message */ - void error(const std::string &message); - /** @brief Severity setter */ - void setLogSeverity(LogSeverity log_severity); + /* override */ void setLogSeverity(LogSeverity log_severity); /** @brief Attach a stream to the logger. */ - void attachStream(LogStream *pStream, unsigned int severity); + /* override */ void attachStream(LogStream *pStream, + unsigned int severity); /** @brief Detach a still attached stream from logger */ - void detatchStream(LogStream *pStream, unsigned int severity); + /* override */ void detatchStream(LogStream *pStream, + unsigned int severity); private: + /** @brief Logs debug infos, only been written when severity level VERBOSE is set */ + /* override */ void OnDebug(const char* message); + + /** @brief Logs an info message */ + /* override */ void OnInfo(const char* message); + + /** @brief Logs a warning message */ + /* override */ void OnWarn(const char* message); + + /** @brief Logs an error message */ + /* override */ void OnError(const char* message); + + /** @brief Private construction for internal use by create(). * @param severity Logging granularity */ @@ -144,12 +148,12 @@ private: ~DefaultLogger(); /** @brief Writes a message to all streams */ - void writeToStreams(const std::string &message, ErrorSeverity ErrorSev ); + void WriteToStreams(const char* message, ErrorSeverity ErrorSev ); /** @brief Returns the thread id. - * @remark This is an OS specific feature, if not supported, a zero will be returned. + * @remark This is an OS specific feature, if not supported, a zero will be returned. */ - std::string getThreadID(); + unsigned int GetThreadID(); private: // Aliases for stream container @@ -167,7 +171,8 @@ private: StreamArray m_StreamArray; bool noRepeatMsg; - std::string lastMsg; + char lastMsg[MAX_LOG_MESSAGE_LENGTH*2]; + size_t lastLen; }; // ------------------------------------------------------------------------------------ diff --git a/include/IOStream.h b/include/IOStream.h index c6844fa25..60651cf94 100644 --- a/include/IOStream.h +++ b/include/IOStream.h @@ -62,7 +62,7 @@ namespace Assimp { * to the Importer. If you implement this interface, be sure to also provide an * implementation for IOSystem that creates instances of your custom IO class. */ -class ASSIMP_API IOStream +class ASSIMP_API IOStream : public Intern::AllocateFromAssimpHeap { protected: /** Constructor protected, use IOSystem::Open() to create an instance. */ diff --git a/include/IOSystem.h b/include/IOSystem.h index c13679330..a85cd1808 100644 --- a/include/IOSystem.h +++ b/include/IOSystem.h @@ -52,70 +52,101 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. corresponding C interface. #endif - #include "aiTypes.h" namespace Assimp { - class IOStream; // --------------------------------------------------------------------------- /** @class IOSystem -* @brief Interface to the file system. -* -* Derive an own implementation from this interface to supply custom file handling -* to the importer library. If you implement this interface, you also want to -* supply a custom implementation for IOStream. -*/ -class ASSIMP_API IOSystem + * @brief Interface to the file system. + * + * Derive an own implementation from this interface to supply custom file handling + * to the importer library. If you implement this interface, you also want to + * supply a custom implementation for IOStream. + * + * @see Importer::SetIOHandler() + */ +class ASSIMP_API IOSystem : public Intern::AllocateFromAssimpHeap { public: - /** @brief Constructor. Create an instance of your derived class and - * assign it to an #Assimp::Importer instance by calling Importer::SetIOHandler(). + + // ------------------------------------------------------------------- + /** @brief Default constructor. + * + * Create an instance of your derived class and assign it to an + * #Assimp::Importer instance by calling Importer::SetIOHandler(). */ IOSystem(); - /** Destructor. */ + // ------------------------------------------------------------------- + /** @brief Virtual destructor. + * + * It is safe to be called from within DLL Assimp, we're constructed + * on Assimp's heap. + */ virtual ~IOSystem(); + +public: + + // ------------------------------------------------------------------- + /** @brief For backward compatibility + * @see Exists(const char*) + */ + AI_FORCE_INLINE bool Exists( const std::string& pFile) const; + // ------------------------------------------------------------------- /** @brief Tests for the existence of a file at the given path. - * - * @param pFile Path to the file - * @return true if there is a file with this path, else false. - */ - virtual bool Exists( const std::string& pFile) const = 0; + * + * @param pFile Path to the file + * @return true if there is a file with this path, else false. + */ + + virtual bool Exists( const char* pFile) const = 0; + + // ------------------------------------------------------------------- /** @brief Returns the system specific directory separator - * @return System specific directory separator - */ - virtual std::string getOsSeparator() const = 0; + * @return System specific directory separator + */ + virtual char getOsSeparator() const = 0; + // ------------------------------------------------------------------- /** @brief Open a new file with a given path. - * - * When the access to the file is finished, call Close() to release - * all associated resources. - * - * @param pFile Path to the file - * @param pMode Desired file I/O mode. Required are: "wb", "w", "wt", - * "rb", "r", "rt". - * - * @return New IOStream interface allowing the lib to access - * the underlying file. - * @note When implementing this class to provide custom IO handling, - * you probably have to supply an own implementation of IOStream as well. - */ - virtual IOStream* Open(const std::string& pFile, - const std::string& pMode = std::string("rb")) = 0; + * + * When the access to the file is finished, call Close() to release + * all associated resources (or the virtual dtor of the IOStream). + * + * @param pFile Path to the file + * @param pMode Desired file I/O mode. Required are: "wb", "w", "wt", + * "rb", "r", "rt". + * + * @return New IOStream interface allowing the lib to access + * the underlying file. + * @note When implementing this class to provide custom IO handling, + * you probably have to supply an own implementation of IOStream as well. + */ + virtual IOStream* Open(const char* pFile, + const char* pMode = "rb") = 0; // ------------------------------------------------------------------- - /** @brief Closes the given file and releases all resources associated with it. + /** @brief For backward compatibility + * @see Open(const char*, const char*) + */ + inline IOStream* Open(const std::string& pFile, + const std::string& pMode = std::string("rb")); + + + + // ------------------------------------------------------------------- + /** @brief Closes the given file and releases all resources + * associated with it. * @param pFile The file instance previously created by Open(). */ virtual void Close( IOStream* pFile) = 0; - // ------------------------------------------------------------------- /** @brief Compares two paths and check whether the point to * identical files. @@ -129,24 +160,65 @@ public: * @return true if the paths point to the same file. The file needn't * be existing, however. */ - virtual bool ComparePaths (const std::string& one, - const std::string& second); + virtual bool ComparePaths (const char* one, + const char* second) const; + + // ------------------------------------------------------------------- + /** @brief For backward compatibility + * @see ComparePaths(const char*, const char*) + */ + inline bool ComparePaths (const std::string& one, + const std::string& second) const; }; // ---------------------------------------------------------------------------- -inline IOSystem::IOSystem() +AI_FORCE_INLINE IOSystem::IOSystem() { // empty } // ---------------------------------------------------------------------------- -inline IOSystem::~IOSystem() +AI_FORCE_INLINE IOSystem::~IOSystem() { // empty } + +// ---------------------------------------------------------------------------- +// For compatibility, the interface of some functions taking a std::string was +// changed to const char* to avoid crashes between binary incompatible STL +// versions. This code her is inlined, so it shouldn't cause any problems. // ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +AI_FORCE_INLINE IOStream* IOSystem::Open(const std::string& pFile, + const std::string& pMode) +{ + // NOTE: + // For compatibility, interface was changed to const char* to + // avoid crashes between binary incompatible STL versions + return Open(pFile.c_str(),pMode.c_str()); +} +// ---------------------------------------------------------------------------- +AI_FORCE_INLINE bool IOSystem::Exists( const std::string& pFile) const +{ + // NOTE: + // For compatibility, interface was changed to const char* to + // avoid crashes between binary incompatible STL versions + return Exists(pFile.c_str()); +} + +// ---------------------------------------------------------------------------- +inline bool IOSystem::ComparePaths (const std::string& one, + const std::string& second) const +{ + // NOTE: + // For compatibility, interface was changed to const char* to + // avoid crashes between binary incompatible STL versions + return ComparePaths(one.c_str(),second.c_str()); +} + +// ---------------------------------------------------------------------------- } //!ns Assimp #endif //AI_IOSYSTEM_H_INC diff --git a/include/LogStream.h b/include/LogStream.h index 0247004b8..f2b4d6114 100644 --- a/include/LogStream.h +++ b/include/LogStream.h @@ -69,7 +69,7 @@ enum DefaultLogStreams // MSVC only: Stream the log the the debugger DLS_DEBUGGER = 0x8 -}; +}; // !enum DefaultLogStreams // ------------------------------------------------------------------------------------ /** @class LogStream @@ -88,11 +88,19 @@ public: /** @brief Virtual destructor */ virtual ~LogStream(); + // ------------------------------------------------------------------- /** @brief Overwrite this for your own output methods + * + * Log messages *may* consist of multiple lines and you shouldn't + * expect a consistent formatting. If you want custom formatting + * (e.g. generate HTML), supply a custom instance of Logger to + * DefaultLogger:set(). Usually you can *expect* that a log message + * is exactly one line long, terminated with a single \n sequence. * @param message Message to be written */ - virtual void write(const std::string &message) = 0; + virtual void write(const char* message) = 0; + // ------------------------------------------------------------------- /** @brief Creates a default log stream * @param streams Type of the default stream * @param name For DLS_FILE: name of the output file @@ -101,9 +109,9 @@ public: * @return New LogStream instance - you're responsible for it's destruction! */ static LogStream* createDefaultStream(DefaultLogStreams streams, - const std::string& name = "AssimpLog.txt", + const char* name = "AssimpLog.txt", IOSystem* io = NULL); -}; +}; // !class LogStream // ------------------------------------------------------------------------------------ // Default constructor diff --git a/include/Logger.h b/include/Logger.h index a1af1bc83..48ac91da0 100644 --- a/include/Logger.h +++ b/include/Logger.h @@ -85,6 +85,10 @@ public: ERR = 8 //!< Error log message }; + /** @brief Maximum length for log messages + */ + static const size_t MAX_LOG_MESSAGE_LENGTH = 1024; + public: /** @brief Virtual destructor */ virtual ~Logger(); @@ -92,22 +96,22 @@ public: /** @brief Writes a debug message * @param message Debug message */ - virtual void debug(const std::string &message)= 0; + void debug(const std::string &message); /** @brief Writes a info message * @param message Info message */ - virtual void info(const std::string &message) = 0; + void info(const std::string &message); /** @brief Writes a warning message * @param message Warn message */ - virtual void warn(const std::string &message) = 0; + void warn(const std::string &message); /** @brief Writes an error message * @param message Error message */ - virtual void error(const std::string &message) = 0; + void error(const std::string &message); /** @brief Set a new log severity. * @param log_severity New severity for logging @@ -142,6 +146,38 @@ public: protected: /** @brief Default constructor */ Logger(); + + /** @brief Called as a request to write a specific debug message + * @param message Debug message. Never longer than + * MAX_LOG_MESSAGE_LENGTH characters (exluding the '0'). + * @note The message string is only valid until the scope of + * the function is left. + */ + virtual void OnDebug(const char* message)= 0; + + /** @brief Called as a request to write a specific info message + * @param message Info message. Never longer than + * MAX_LOG_MESSAGE_LENGTH characters (exluding the '0'). + * @note The message string is only valid until the scope of + * the function is left. + */ + virtual void OnInfo(const char* message) = 0; + + /** @brief Called as a request to write a specific warn message + * @param message Warn message. Never longer than + * MAX_LOG_MESSAGE_LENGTH characters (exluding the '0'). + * @note The message string is only valid until the scope of + * the function is left. + */ + virtual void OnWarn(const char* essage) = 0; + + /** @brief Called as a request to write a specific error message + * @param message Error message. Never longer than + * MAX_LOG_MESSAGE_LENGTH characters (exluding the '0'). + * @note The message string is only valid until the scope of + * the function is left. + */ + virtual void OnError(const char* message) = 0; }; // ---------------------------------------------------------------------------------- diff --git a/include/NullLogger.h b/include/NullLogger.h index bf942c599..ddeca4fc2 100644 --- a/include/NullLogger.h +++ b/include/NullLogger.h @@ -38,16 +38,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ -/** @file NullLogger.h +/** @file NullLogger.h + * @brief Dummy logger */ -#if (!defined AI_NULLLOGGER_H_INCLUDED) -#define AI_NULLLOGGER_H_INCLUDED +#ifndef INCLUDED_AI_NULLLOGGER_H +#define INCLUDED_AI_NULLLOGGER_H #include "../include/Logger.h" -namespace Assimp -{ +namespace Assimp { // --------------------------------------------------------------------------- /** @class NullLogger @@ -59,25 +59,39 @@ class ASSIMP_API NullLogger : public Logger { public: /** @brief Logs a debug message */ - void debug(const std::string &message) { (void)message;} //this avoids compiler warnings + void OnDebug(const char* message) { + (void)message; //this avoids compiler warnings + } /** @brief Logs an info message */ - void info(const std::string &message) {(void)message;} //this avoids compiler warnings + void OnInfo(const char* message) { + (void)message; //this avoids compiler warnings + } /** @brief Logs a warning message */ - void warn(const std::string &message) {(void)message;} //this avoids compiler warnings + void OnWarn(const char* message) { + (void)message; //this avoids compiler warnings + } /** @brief Logs an error message */ - void error(const std::string &message) {(void)message;} //this avoids compiler warnings + void OnError(const char* message) { + (void)message; //this avoids compiler warnings + } /** @brief Log severity setter */ - void setLogSeverity(LogSeverity log_severity) {(void)log_severity;} //this avoids compiler warnings + void setLogSeverity(LogSeverity log_severity) { + (void)log_severity; //this avoids compiler warnings + } /** @brief Detach a still attached stream from logger */ - void attachStream(LogStream *pStream, unsigned int severity) {(void)pStream; (void)severity;} //this avoids compiler warnings + void attachStream(LogStream *pStream, unsigned int severity) { + (void)pStream; (void)severity; //this avoids compiler warnings + } /** @brief Detach a still attached stream from logger */ - void detatchStream(LogStream *pStream, unsigned int severity) {(void)pStream; (void)severity;} //this avoids compiler warnings + void detatchStream(LogStream *pStream, unsigned int severity) { + (void)pStream; (void)severity; //this avoids compiler warnings + } }; } diff --git a/include/aiTypes.h b/include/aiTypes.h index 0387e1e5a..f06cfa41b 100644 --- a/include/aiTypes.h +++ b/include/aiTypes.h @@ -67,10 +67,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { namespace Intern { - // Internal helper class to utilize our internal new/delete routines - // for allocating object of this class. By doing this you can safely - // share class objects between Assimp and the application - it works - // even over DLL boundaries. + /** @brief Internal helper class to utilize our internal new/delete + * routines for allocating object of this and derived classes. + * + * By doing this you can safely share class objects between Assimp + * and the application - it works even over DLL boundaries. A good + * example is the IOSystem where the application allocates its custom + * IOSystem, then calls Importer::SetIOSystem(). When the Importer + * destructs, Assimp calls operator delete on the stored IOSystem. + * If it lies on a different heap than Assimp is working with, + * the application is determined to crash. + */ struct ASSIMP_API AllocateFromAssimpHeap { // new/delete overload diff --git a/include/assimp.hpp b/include/assimp.hpp index ef664cfc8..816be4be2 100644 --- a/include/assimp.hpp +++ b/include/assimp.hpp @@ -302,21 +302,30 @@ public: // ------------------------------------------------------------------- /** Reads the given file and returns its contents if successful. - * - * If the call succeeds, the contents of the file are returned as a - * pointer to an aiScene object. The returned data is intended to be - * read-only, the importer object keeps ownership of the data and will - * destroy it upon destruction. If the import fails, NULL is returned. - * A human-readable error description can be retrieved by calling - * GetErrorString(). The previous scene will be deleted during this call. - * @param pFile Path and filename to the file to be imported. - * @param pFlags Optional post processing steps to be executed after - * a successful import. Provide a bitwise combination of the - * #aiPostProcessSteps flags. - * @return A pointer to the imported data, NULL if the import failed. - * The pointer to the scene remains in possession of the Importer - * instance. Use GetOrphanedScene() to take ownership of it. - */ + * + * If the call succeeds, the contents of the file are returned as a + * pointer to an aiScene object. The returned data is intended to be + * read-only, the importer object keeps ownership of the data and will + * destroy it upon destruction. If the import fails, NULL is returned. + * A human-readable error description can be retrieved by calling + * GetErrorString(). The previous scene will be deleted during this call. + * @param pFile Path and filename to the file to be imported. + * @param pFlags Optional post processing steps to be executed after + * a successful import. Provide a bitwise combination of the + * #aiPostProcessSteps flags. + * @return A pointer to the imported data, NULL if the import failed. + * The pointer to the scene remains in possession of the Importer + * instance. Use GetOrphanedScene() to take ownership of it. + */ + const aiScene* ReadFile( const char* pFile, unsigned int pFlags); + + // ------------------------------------------------------------------- + /** @brief Reads the given file and returns its contents if successful. + * + * This function is provided for backward compatibility. + * See the const char* version for detailled docs. + * @see ReadFile(const char*, pFlags) + */ const aiScene* ReadFile( const std::string& pFile, unsigned int pFlags); @@ -348,6 +357,15 @@ public: * Cases-insensitive. * @return true if the extension is supported, false otherwise */ + bool IsExtensionSupported(const char* szExtension); + + // ------------------------------------------------------------------- + /** @brief Returns whether a given file extension is supported by ASSIMP. + * + * This function is provided for backward compatibility. + * See the const char* version for detailled docs. + * @see IsExtensionSupported(const char*) + */ bool IsExtensionSupported(const std::string& szExtension); @@ -360,7 +378,16 @@ public: * is a loader which handles such files. * Format of the list: "*.3ds;*.obj;*.dae". */ - void GetExtensionList(std::string& szOut); + void GetExtensionList(aiString& szOut); + + // ------------------------------------------------------------------- + /** @brief Get a full list of all file extensions supported by ASSIMP. + * + * This function is provided for backward compatibility. + * See the aiString version for detailled docs. + * @see GetExtensionList(aiString&) + */ + inline void GetExtensionList(std::string& szOut); // ------------------------------------------------------------------- @@ -372,7 +399,7 @@ public: * must include a trailing dot. * @return NULL if there is no loader for the extension. */ - BaseImporter* FindLoader (const std::string& szExtension); + BaseImporter* FindLoader (const char* szExtension); // ------------------------------------------------------------------- @@ -449,27 +476,31 @@ protected: SharedPostProcessInfo* mPPShared; }; //! class Importer -// ---------------------------------------------------------------------------------- -inline const std::string& Importer::GetErrorString() const -{ - return mErrorString; -} -// ---------------------------------------------------------------------------------- -inline void Importer::SetExtraVerbose(bool bDo) + +// ---------------------------------------------------------------------------- +// For compatibility, the interface of some functions taking a std::string was +// changed to const char* to avoid crashes between binary incompatible STL +// versions. This code her is inlined, so it shouldn't cause any problems. +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +AI_FORCE_INLINE const aiScene* Importer::ReadFile( const std::string& pFile, + unsigned int pFlags) { - bExtraVerbose = bDo; + return ReadFile(pFile.c_str(),pFlags); } -// ---------------------------------------------------------------------------------- -inline const aiScene* Importer::GetScene() const +// ---------------------------------------------------------------------------- +AI_FORCE_INLINE void Importer::GetExtensionList(std::string& szOut) { - return mScene; + aiString s; + GetExtensionList(s); + szOut = s.data; } -// ---------------------------------------------------------------------------------- -inline aiScene* Importer::GetOrphanedScene() +// ---------------------------------------------------------------------------- +AI_FORCE_INLINE bool Importer::IsExtensionSupported( + const std::string& szExtension) { - aiScene* s = mScene; - mScene = NULL; - return s; + return IsExtensionSupported(szExtension.c_str()); } } // !namespace Assimp diff --git a/tools/assimp_view/LogWindow.cpp b/tools/assimp_view/LogWindow.cpp index cbf3c2c25..551453ecc 100644 --- a/tools/assimp_view/LogWindow.cpp +++ b/tools/assimp_view/LogWindow.cpp @@ -127,7 +127,7 @@ void CLogWindow::Show() } } //------------------------------------------------------------------------------- -void CMyLogStream::write(const std::string &message) +void CMyLogStream::write(const char* message) { CLogWindow::Instance().WriteLine(message); } @@ -193,7 +193,7 @@ void CLogWindow::Save() D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0)); } //------------------------------------------------------------------------------- -void CLogWindow::WriteLine(const std::string& message) +void CLogWindow::WriteLine(const char* message) { this->szPlainText.append(message); this->szPlainText.append("\r\n"); @@ -203,7 +203,7 @@ void CLogWindow::WriteLine(const std::string& message) this->szText.resize(this->szText.length()-1); } - switch (message.c_str()[0]) + switch (message[0]) { case 'e': case 'E': diff --git a/tools/assimp_view/LogWindow.h b/tools/assimp_view/LogWindow.h index c9c365285..78773ba03 100644 --- a/tools/assimp_view/LogWindow.h +++ b/tools/assimp_view/LogWindow.h @@ -52,7 +52,7 @@ class CMyLogStream : Assimp::LogStream { public: /** @brief Implementation of the abstract method */ - void write(const std::string &message); + void write(const char* message); }; @@ -93,7 +93,7 @@ public: void Save(); // write a line to the log window - void WriteLine(const std::string& message); + void WriteLine(const char* message); // Set the bUpdate member inline void SetAutoUpdate(bool b) diff --git a/workspaces/vc8/UnitTest.vcproj b/workspaces/vc8/UnitTest.vcproj index f5361bb60..5b2dde2e3 100644 --- a/workspaces/vc8/UnitTest.vcproj +++ b/workspaces/vc8/UnitTest.vcproj @@ -23,7 +23,7 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\UnitTest.vsprops" + InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\FastSTL.vsprops" CharacterSet="1" > @@ -268,7 +268,7 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\UnitTest.vsprops" + InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\FastSTL.vsprops" CharacterSet="1" WholeProgramOptimization="1" > @@ -349,7 +349,7 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\UnitTest.vsprops" + InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\FastSTL.vsprops" CharacterSet="1" WholeProgramOptimization="1" > @@ -429,7 +429,7 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\UnitTest.vsprops" + InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\FastSTL.vsprops" CharacterSet="1" WholeProgramOptimization="1" > @@ -510,7 +510,7 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\UnitTest.vsprops" + InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\FastSTL.vsprops" CharacterSet="1" > @@ -755,7 +755,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\NoBoostShared.vsprops" + InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\NoBoostShared.vsprops;.\shared\FastSTL.vsprops" CharacterSet="1" WholeProgramOptimization="1" > @@ -836,7 +836,7 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\NoBoostShared.vsprops" + InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\NoBoostShared.vsprops;.\shared\FastSTL.vsprops" CharacterSet="1" > @@ -1246,7 +1246,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\SingleThreadedShared.vsprops" + InheritedPropertySheets=".\shared\UnitTest.vsprops;.\shared\SingleThreadedShared.vsprops;.\shared\FastSTL.vsprops" CharacterSet="1" WholeProgramOptimization="1" > diff --git a/workspaces/vc8/assimp.vcproj b/workspaces/vc8/assimp.vcproj index 0d03a0fb3..543e8b96b 100644 --- a/workspaces/vc8/assimp.vcproj +++ b/workspaces/vc8/assimp.vcproj @@ -20,7 +20,7 @@ @@ -267,6 +270,7 @@ OutputDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="$(SolutionDir)..\..\tools\build\$(ConfigurationName)_$(PlatformName)\obj" ConfigurationType="1" + InheritedPropertySheets=".\shared\FastSTL.vsprops" CharacterSet="2" WholeProgramOptimization="1" > @@ -349,6 +353,7 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" + InheritedPropertySheets=".\shared\FastSTL.vsprops" CharacterSet="2" WholeProgramOptimization="1" > @@ -430,6 +435,7 @@ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" + InheritedPropertySheets=".\shared\FastSTL.vsprops" CharacterSet="2" WholeProgramOptimization="1" > @@ -512,6 +518,7 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" + InheritedPropertySheets=".\shared\FastSTL.vsprops" CharacterSet="2" > @@ -757,7 +765,7 @@ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\NoBoostShared.vsprops" + InheritedPropertySheets=".\shared\NoBoostShared.vsprops;.\shared\FastSTL.vsprops" CharacterSet="2" WholeProgramOptimization="1" > @@ -840,7 +848,7 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\NoBoostShared.vsprops" + InheritedPropertySheets=".\shared\NoBoostShared.vsprops;.\shared\FastSTL.vsprops" CharacterSet="2" > @@ -1249,6 +1260,7 @@ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" + InheritedPropertySheets=".\shared\FastSTL.vsprops" CharacterSet="2" WholeProgramOptimization="1" > diff --git a/workspaces/vc8/shared/FastSTL.vsprops b/workspaces/vc8/shared/FastSTL.vsprops new file mode 100644 index 000000000..dd1a5f575 --- /dev/null +++ b/workspaces/vc8/shared/FastSTL.vsprops @@ -0,0 +1,11 @@ + + + + diff --git a/workspaces/vc9/assimp_view.vcproj b/workspaces/vc9/assimp_view.vcproj index dbb89db10..9309bba5d 100644 --- a/workspaces/vc9/assimp_view.vcproj +++ b/workspaces/vc9/assimp_view.vcproj @@ -186,7 +186,6 @@ OutputDirectory="./../../bin/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" IntermediateDirectory="./../../obj/$(ProjectName)_$(ConfigurationName)_$(PlatformName)" ConfigurationType="1" - InheritedPropertySheets=".\shared\FastSTL.vsprops" CharacterSet="2" WholeProgramOptimization="1" >