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