vrshoot

annotate 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
rev   line source
nuclear@0 1 #ifndef ASSIMP_FILELOGSTREAM_H_INC
nuclear@0 2 #define ASSIMP_FILELOGSTREAM_H_INC
nuclear@0 3
nuclear@0 4 #include "assimp/LogStream.hpp"
nuclear@0 5 #include "assimp/IOStream.hpp"
nuclear@0 6
nuclear@0 7 namespace Assimp {
nuclear@0 8
nuclear@0 9 // ----------------------------------------------------------------------------------
nuclear@0 10 /** @class FileLogStream
nuclear@0 11 * @brief Logstream to write into a file.
nuclear@0 12 */
nuclear@0 13 class FileLogStream :
nuclear@0 14 public LogStream
nuclear@0 15 {
nuclear@0 16 public:
nuclear@0 17 FileLogStream( const char* file, IOSystem* io = NULL );
nuclear@0 18 ~FileLogStream();
nuclear@0 19 void write( const char* message );
nuclear@0 20
nuclear@0 21 private:
nuclear@0 22 IOStream *m_pStream;
nuclear@0 23 };
nuclear@0 24
nuclear@0 25 // ----------------------------------------------------------------------------------
nuclear@0 26 // Constructor
nuclear@0 27 inline FileLogStream::FileLogStream( const char* file, IOSystem* io ) :
nuclear@0 28 m_pStream(NULL)
nuclear@0 29 {
nuclear@0 30 if ( !file || 0 == *file )
nuclear@0 31 return;
nuclear@0 32
nuclear@0 33 // If no IOSystem is specified: take a default one
nuclear@0 34 if (!io)
nuclear@0 35 {
nuclear@0 36 DefaultIOSystem FileSystem;
nuclear@0 37 m_pStream = FileSystem.Open( file, "wt");
nuclear@0 38 }
nuclear@0 39 else m_pStream = io->Open( file, "wt" );
nuclear@0 40 }
nuclear@0 41
nuclear@0 42 // ----------------------------------------------------------------------------------
nuclear@0 43 // Destructor
nuclear@0 44 inline FileLogStream::~FileLogStream()
nuclear@0 45 {
nuclear@0 46 // The virtual d'tor should destroy the underlying file
nuclear@0 47 delete m_pStream;
nuclear@0 48 }
nuclear@0 49
nuclear@0 50 // ----------------------------------------------------------------------------------
nuclear@0 51 // Write method
nuclear@0 52 inline void FileLogStream::write( const char* message )
nuclear@0 53 {
nuclear@0 54 if (m_pStream != NULL)
nuclear@0 55 {
nuclear@0 56 m_pStream->Write(message, sizeof(char), ::strlen(message));
nuclear@0 57 m_pStream->Flush();
nuclear@0 58 }
nuclear@0 59 }
nuclear@0 60
nuclear@0 61 // ----------------------------------------------------------------------------------
nuclear@0 62 } // !Namespace Assimp
nuclear@0 63
nuclear@0 64 #endif // !! ASSIMP_FILELOGSTREAM_H_INC