xref: /aosp_15_r20/external/lzma/CPP/Common/StdOutStream.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
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   CBoolPair ListPathSeparatorSlash;
18   int CodePage;
19 
20   CStdOutStream(FILE *stream = NULL):
_stream(stream)21       _stream(stream),
22       // _streamIsOpen(false),
23       IsTerminalMode(false),
24       CodePage(-1)
25   {
26     ListPathSeparatorSlash.Val =
27 #ifdef _WIN32
28         false;
29 #else
30         true;
31 #endif
32   }
33 
34   // ~CStdOutStream() { Close(); }
35 
36   // void AttachStdStream(FILE *stream) { _stream  = stream; _streamIsOpen = false; }
37   // bool IsDefined() const { return _stream  != NULL; }
38 
39   operator FILE *() { return _stream; }
40   /*
41   bool Open(const char *fileName) throw();
42   bool Close() throw();
43   */
44   bool Flush() throw();
45 
46   CStdOutStream & operator<<(CStdOutStream & (* func)(CStdOutStream  &))
47   {
48     (*func)(*this);
49     return *this;
50   }
51 
52   CStdOutStream & operator<<(const char *s) throw()
53   {
54     fputs(s, _stream);
55     return *this;
56   }
57 
58   CStdOutStream & operator<<(char c) throw()
59   {
60     fputc((unsigned char)c, _stream);
61     return *this;
62   }
63 
64   CStdOutStream & operator<<(Int32 number) throw();
65   CStdOutStream & operator<<(Int64 number) throw();
66   CStdOutStream & operator<<(UInt32 number) throw();
67   CStdOutStream & operator<<(UInt64 number) throw();
68 
69   CStdOutStream & operator<<(const wchar_t *s);
70   void PrintUString(const UString &s, AString &temp);
71   void Convert_UString_to_AString(const UString &src, AString &dest);
72 
73   void Normalize_UString(UString &s);
74   void Normalize_UString_Path(UString &s);
75 
76   void NormalizePrint_UString_Path(const UString &s, UString &tempU, AString &tempA);
77   void NormalizePrint_UString_Path(const UString &s);
78   void NormalizePrint_UString(const UString &s);
79   void NormalizePrint_wstr_Path(const wchar_t *s);
80 };
81 
82 CStdOutStream & endl(CStdOutStream & outStream) throw();
83 
84 extern CStdOutStream g_StdOut;
85 extern CStdOutStream g_StdErr;
86 
87 #endif
88