vrshoot
diff libs/assimp/FileLogStream.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/assimp/FileLogStream.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,64 @@ 1.4 +#ifndef ASSIMP_FILELOGSTREAM_H_INC 1.5 +#define ASSIMP_FILELOGSTREAM_H_INC 1.6 + 1.7 +#include "assimp/LogStream.hpp" 1.8 +#include "assimp/IOStream.hpp" 1.9 + 1.10 +namespace Assimp { 1.11 + 1.12 +// ---------------------------------------------------------------------------------- 1.13 +/** @class FileLogStream 1.14 + * @brief Logstream to write into a file. 1.15 + */ 1.16 +class FileLogStream : 1.17 + public LogStream 1.18 +{ 1.19 +public: 1.20 + FileLogStream( const char* file, IOSystem* io = NULL ); 1.21 + ~FileLogStream(); 1.22 + void write( const char* message ); 1.23 + 1.24 +private: 1.25 + IOStream *m_pStream; 1.26 +}; 1.27 + 1.28 +// ---------------------------------------------------------------------------------- 1.29 +// Constructor 1.30 +inline FileLogStream::FileLogStream( const char* file, IOSystem* io ) : 1.31 + m_pStream(NULL) 1.32 +{ 1.33 + if ( !file || 0 == *file ) 1.34 + return; 1.35 + 1.36 + // If no IOSystem is specified: take a default one 1.37 + if (!io) 1.38 + { 1.39 + DefaultIOSystem FileSystem; 1.40 + m_pStream = FileSystem.Open( file, "wt"); 1.41 + } 1.42 + else m_pStream = io->Open( file, "wt" ); 1.43 +} 1.44 + 1.45 +// ---------------------------------------------------------------------------------- 1.46 +// Destructor 1.47 +inline FileLogStream::~FileLogStream() 1.48 +{ 1.49 + // The virtual d'tor should destroy the underlying file 1.50 + delete m_pStream; 1.51 +} 1.52 + 1.53 +// ---------------------------------------------------------------------------------- 1.54 +// Write method 1.55 +inline void FileLogStream::write( const char* message ) 1.56 +{ 1.57 + if (m_pStream != NULL) 1.58 + { 1.59 + m_pStream->Write(message, sizeof(char), ::strlen(message)); 1.60 + m_pStream->Flush(); 1.61 + } 1.62 +} 1.63 + 1.64 +// ---------------------------------------------------------------------------------- 1.65 +} // !Namespace Assimp 1.66 + 1.67 +#endif // !! ASSIMP_FILELOGSTREAM_H_INC