1 // Common/StdOutStream.h 2 3 #ifndef __COMMON_STD_OUT_STREAM_H 4 #define __COMMON_STD_OUT_STREAM_H 5 6 #include <stdio.h> 7 8 #include "MyString.h" 9 #include "MyTypes.h" 10 11 class CStdOutStream 12 { 13 FILE *_stream; 14 bool _streamIsOpen; 15 public: CStdOutStream()16 CStdOutStream(): _stream(0), _streamIsOpen(false) {}; CStdOutStream(FILE * stream)17 CStdOutStream(FILE *stream): _stream(stream), _streamIsOpen(false) {}; ~CStdOutStream()18 ~CStdOutStream() { Close(); } 19 20 // void AttachStdStream(FILE *stream) { _stream = stream; _streamIsOpen = false; } 21 // bool IsDefined() const { return _stream != NULL; } 22 23 operator FILE *() { return _stream; } 24 bool Open(const char *fileName) throw(); 25 bool Close() throw(); 26 bool Flush() throw(); 27 28 CStdOutStream & operator<<(CStdOutStream & (* func)(CStdOutStream &)) 29 { 30 (*func)(*this); 31 return *this; 32 } 33 34 CStdOutStream & operator<<(const char *s) throw() 35 { 36 fputs(s, _stream); 37 return *this; 38 } 39 40 CStdOutStream & operator<<(char c) throw() 41 { 42 fputc(c, _stream); 43 return *this; 44 } 45 46 CStdOutStream & operator<<(Int32 number) throw(); 47 CStdOutStream & operator<<(Int64 number) throw(); 48 CStdOutStream & operator<<(UInt32 number) throw(); 49 CStdOutStream & operator<<(UInt64 number) throw(); 50 51 CStdOutStream & operator<<(const wchar_t *s); 52 void PrintUString(const UString &s, AString &temp); 53 }; 54 55 CStdOutStream & endl(CStdOutStream & outStream) throw(); 56 57 extern CStdOutStream g_StdOut; 58 extern CStdOutStream g_StdErr; 59 60 void StdOut_Convert_UString_to_AString(const UString &s, AString &temp); 61 62 #endif 63