00001 /* 00008 * LEGAL: COPYRIGHT (C) 2004 JIM E. BROOKS 00009 * THIS SOURCE CODE IS RELEASED UNDER THE TERMS 00010 * OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2). 00011 *****************************************************************************/ 00012 00013 #ifndef BASE_STREAM_HH 00014 #define BASE_STREAM_HH 1 00015 00016 00017 00018 #include "base_common.hh" 00019 00020 namespace base { 00021 00022 bool 00023 StreamToNextLine( istream& strm ); 00024 00025 bool 00026 StreamPeek( istream& strm, const string& word ); 00027 00029 #define COUT (*base::global.mStreams.mOut) 00030 #define CERROR (*base::global.mStreams.mError) 00031 #define CDEBUG (*base::global.mStreams.mDebug) 00032 00043 class Streams : private Threadable 00044 { 00045 public: 00046 Streams( void ); 00047 ~Streams(); 00048 void Open( void ); 00049 void Close( void ); 00050 void SetErrorLogFname( const string& fname ) { mErrorLogFname = fname; } 00051 00052 public: 00053 SafePtr<ostream> mOut; // delete &cout; why my program crash? 00054 SafePtr<ostream> mError; 00055 SafePtr<ostream> mDebug; 00056 00057 private: 00058 string mErrorLogFname; 00059 FILE* mErrorLogFile; 00060 }; 00061 00077 class StreambufFile2 : public streambuf 00078 { 00079 00080 typedef streambuf Parent; 00081 public: 00082 StreambufFile2( SafePtr<FILE> file0, bool close0, 00083 SafePtr<FILE> file1 = NULL, bool close1 = false ); 00084 ~StreambufFile2(); 00085 00086 protected: 00087 virtual int_type overflow( int_type c ); 00088 std::streamsize xsputn( const char* buf, std::streamsize n ); 00089 00090 SafePtr<FILE> mFile0, mFile1; // stream outputs to both files 00091 bool mClose0, mClose1; // true if destructor should close the file 00092 }; 00093 00094 } // namespace base 00095 00096 #endif // BASE_STREAM_HH
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:07 2007