2008-05-08 20:02:51 +00:00
|
|
|
#ifndef ASSIMP_FILELOGSTREAM_H_INC
|
|
|
|
#define ASSIMP_FILELOGSTREAM_H_INC
|
|
|
|
|
2008-05-21 15:35:28 +00:00
|
|
|
#include "../include/LogStream.h"
|
|
|
|
#include "../include/IOStream.h"
|
2008-05-08 20:02:51 +00:00
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
namespace Assimp {
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------------
|
2008-05-08 20:02:51 +00:00
|
|
|
/** @class FileLogStream
|
|
|
|
* @brief Logstream to write into a file.
|
|
|
|
*/
|
|
|
|
class FileLogStream :
|
|
|
|
public LogStream
|
|
|
|
{
|
|
|
|
public:
|
2009-01-23 21:06:43 +00:00
|
|
|
FileLogStream( const char* file, IOSystem* io = NULL );
|
2008-05-08 20:02:51 +00:00
|
|
|
~FileLogStream();
|
2009-01-23 21:06:43 +00:00
|
|
|
void write( const char* message );
|
2008-05-08 20:02:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
IOStream *m_pStream;
|
|
|
|
};
|
2009-01-12 22:06:54 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------------
|
2008-05-08 20:02:51 +00:00
|
|
|
// Constructor
|
2009-01-23 21:06:43 +00:00
|
|
|
inline FileLogStream::FileLogStream( const char* file, IOSystem* io ) :
|
2008-05-08 20:02:51 +00:00
|
|
|
m_pStream(NULL)
|
|
|
|
{
|
2009-01-23 21:06:43 +00:00
|
|
|
if ( !file || 0 == *file )
|
2008-05-08 20:02:51 +00:00
|
|
|
return;
|
2009-01-12 22:06:54 +00:00
|
|
|
|
|
|
|
// If no IOSystem is specified: take a default one
|
|
|
|
if (!io)
|
|
|
|
{
|
|
|
|
DefaultIOSystem FileSystem;
|
2009-01-23 21:06:43 +00:00
|
|
|
m_pStream = FileSystem.Open( file, "wt");
|
2009-01-12 22:06:54 +00:00
|
|
|
}
|
2009-01-23 21:06:43 +00:00
|
|
|
else m_pStream = io->Open( file, "wt" );
|
2008-05-08 20:02:51 +00:00
|
|
|
}
|
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
// ----------------------------------------------------------------------------------
|
2008-05-08 20:02:51 +00:00
|
|
|
// Destructor
|
|
|
|
inline FileLogStream::~FileLogStream()
|
|
|
|
{
|
2009-01-12 22:06:54 +00:00
|
|
|
// The virtual d'tor should destroy the underlying file
|
|
|
|
delete m_pStream;
|
2008-05-08 20:02:51 +00:00
|
|
|
}
|
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
// ----------------------------------------------------------------------------------
|
2008-05-08 20:02:51 +00:00
|
|
|
// Write method
|
2009-01-23 21:06:43 +00:00
|
|
|
inline void FileLogStream::write( const char* message )
|
2008-05-08 20:02:51 +00:00
|
|
|
{
|
|
|
|
if (m_pStream != NULL)
|
|
|
|
{
|
2009-01-23 21:06:43 +00:00
|
|
|
m_pStream->Write(message, sizeof(char), ::strlen(message));
|
2009-01-12 22:06:54 +00:00
|
|
|
m_pStream->Flush();
|
2008-05-08 20:02:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
// ----------------------------------------------------------------------------------
|
|
|
|
} // !Namespace Assimp
|
2008-05-08 20:02:51 +00:00
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
#endif // !! ASSIMP_FILELOGSTREAM_H_INC
|