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