• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
16   bool IsTerminalMode;
17 
CStdOutStream()18   CStdOutStream(): _stream(0), _streamIsOpen(false), IsTerminalMode(false) {};
CStdOutStream(FILE * stream)19   CStdOutStream(FILE *stream): _stream(stream), _streamIsOpen(false) {};
~CStdOutStream()20   ~CStdOutStream() { Close(); }
21 
22   // void AttachStdStream(FILE *stream) { _stream  = stream; _streamIsOpen = false; }
23   // bool IsDefined() const { return _stream  != NULL; }
24 
25   operator FILE *() { return _stream; }
26   bool Open(const char *fileName) throw();
27   bool Close() throw();
28   bool Flush() throw();
29 
30   CStdOutStream & operator<<(CStdOutStream & (* func)(CStdOutStream  &))
31   {
32     (*func)(*this);
33     return *this;
34   }
35 
36   CStdOutStream & operator<<(const char *s) throw()
37   {
38     fputs(s, _stream);
39     return *this;
40   }
41 
42   CStdOutStream & operator<<(char c) throw()
43   {
44     fputc((unsigned char)c, _stream);
45     return *this;
46   }
47 
48   CStdOutStream & operator<<(Int32 number) throw();
49   CStdOutStream & operator<<(Int64 number) throw();
50   CStdOutStream & operator<<(UInt32 number) throw();
51   CStdOutStream & operator<<(UInt64 number) throw();
52 
53   CStdOutStream & operator<<(const wchar_t *s);
54   void PrintUString(const UString &s, AString &temp);
55 
56   void Normalize_UString__LF_Allowed(UString &s);
57   void Normalize_UString(UString &s);
58 
59   void NormalizePrint_UString(const UString &s, UString &tempU, AString &tempA);
60   void NormalizePrint_UString(const UString &s);
61   void NormalizePrint_wstr(const wchar_t *s);
62 };
63 
64 CStdOutStream & endl(CStdOutStream & outStream) throw();
65 
66 extern CStdOutStream g_StdOut;
67 extern CStdOutStream g_StdErr;
68 
69 void StdOut_Convert_UString_to_AString(const UString &s, AString &temp);
70 
71 #endif
72