You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 line
1.6 KiB

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