vrshoot
view libs/assimp/FileLogStream.h @ 1:e7ca128b8713
looks nice :)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 02 Feb 2014 00:35:22 +0200 |
parents | |
children |
line source
1 #ifndef ASSIMP_FILELOGSTREAM_H_INC
2 #define ASSIMP_FILELOGSTREAM_H_INC
4 #include "assimp/LogStream.hpp"
5 #include "assimp/IOStream.hpp"
7 namespace Assimp {
9 // ----------------------------------------------------------------------------------
10 /** @class FileLogStream
11 * @brief Logstream to write into a file.
12 */
13 class FileLogStream :
14 public LogStream
15 {
16 public:
17 FileLogStream( const char* file, IOSystem* io = NULL );
18 ~FileLogStream();
19 void write( const char* message );
21 private:
22 IOStream *m_pStream;
23 };
25 // ----------------------------------------------------------------------------------
26 // Constructor
27 inline FileLogStream::FileLogStream( const char* file, IOSystem* io ) :
28 m_pStream(NULL)
29 {
30 if ( !file || 0 == *file )
31 return;
33 // If no IOSystem is specified: take a default one
34 if (!io)
35 {
36 DefaultIOSystem FileSystem;
37 m_pStream = FileSystem.Open( file, "wt");
38 }
39 else m_pStream = io->Open( file, "wt" );
40 }
42 // ----------------------------------------------------------------------------------
43 // Destructor
44 inline FileLogStream::~FileLogStream()
45 {
46 // The virtual d'tor should destroy the underlying file
47 delete m_pStream;
48 }
50 // ----------------------------------------------------------------------------------
51 // Write method
52 inline void FileLogStream::write( const char* message )
53 {
54 if (m_pStream != NULL)
55 {
56 m_pStream->Write(message, sizeof(char), ::strlen(message));
57 m_pStream->Flush();
58 }
59 }
61 // ----------------------------------------------------------------------------------
62 } // !Namespace Assimp
64 #endif // !! ASSIMP_FILELOGSTREAM_H_INC