nuclear@0: #ifndef ASSIMP_FILELOGSTREAM_H_INC nuclear@0: #define ASSIMP_FILELOGSTREAM_H_INC nuclear@0: nuclear@0: #include "assimp/LogStream.hpp" nuclear@0: #include "assimp/IOStream.hpp" nuclear@0: nuclear@0: namespace Assimp { nuclear@0: nuclear@0: // ---------------------------------------------------------------------------------- nuclear@0: /** @class FileLogStream nuclear@0: * @brief Logstream to write into a file. nuclear@0: */ nuclear@0: class FileLogStream : nuclear@0: public LogStream nuclear@0: { nuclear@0: public: nuclear@0: FileLogStream( const char* file, IOSystem* io = NULL ); nuclear@0: ~FileLogStream(); nuclear@0: void write( const char* message ); nuclear@0: nuclear@0: private: nuclear@0: IOStream *m_pStream; nuclear@0: }; nuclear@0: nuclear@0: // ---------------------------------------------------------------------------------- nuclear@0: // Constructor nuclear@0: inline FileLogStream::FileLogStream( const char* file, IOSystem* io ) : nuclear@0: m_pStream(NULL) nuclear@0: { nuclear@0: if ( !file || 0 == *file ) nuclear@0: return; nuclear@0: nuclear@0: // If no IOSystem is specified: take a default one nuclear@0: if (!io) nuclear@0: { nuclear@0: DefaultIOSystem FileSystem; nuclear@0: m_pStream = FileSystem.Open( file, "wt"); nuclear@0: } nuclear@0: else m_pStream = io->Open( file, "wt" ); nuclear@0: } nuclear@0: nuclear@0: // ---------------------------------------------------------------------------------- nuclear@0: // Destructor nuclear@0: inline FileLogStream::~FileLogStream() nuclear@0: { nuclear@0: // The virtual d'tor should destroy the underlying file nuclear@0: delete m_pStream; nuclear@0: } nuclear@0: nuclear@0: // ---------------------------------------------------------------------------------- nuclear@0: // Write method nuclear@0: inline void FileLogStream::write( const char* message ) nuclear@0: { nuclear@0: if (m_pStream != NULL) nuclear@0: { nuclear@0: m_pStream->Write(message, sizeof(char), ::strlen(message)); nuclear@0: m_pStream->Flush(); nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: // ---------------------------------------------------------------------------------- nuclear@0: } // !Namespace Assimp nuclear@0: nuclear@0: #endif // !! ASSIMP_FILELOGSTREAM_H_INC