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