aboutsummaryrefslogtreecommitdiff
path: root/CPP/Common/StdOutStream.h
blob: bd15d7cb2084768e0a338f8ab675759fc9f18abc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Common/StdOutStream.h

#ifndef ZIP7_INC_COMMON_STD_OUT_STREAM_H
#define ZIP7_INC_COMMON_STD_OUT_STREAM_H

#include <stdio.h>

#include "MyString.h"
#include "MyTypes.h"

class CStdOutStream
{
  FILE *_stream;
  // bool _streamIsOpen;
public:
  bool IsTerminalMode;
  int CodePage;

  CStdOutStream(FILE *stream = NULL):
      _stream(stream),
      // _streamIsOpen(false),
      IsTerminalMode(false),
      CodePage(-1)
      {}

  // ~CStdOutStream() { Close(); }

  // void AttachStdStream(FILE *stream) { _stream  = stream; _streamIsOpen = false; }
  // bool IsDefined() const { return _stream  != NULL; }

  operator FILE *() { return _stream; }
  /*
  bool Open(const char *fileName) throw();
  bool Close() throw();
  */
  bool Flush() throw();
  
  CStdOutStream & operator<<(CStdOutStream & (* func)(CStdOutStream  &))
  {
    (*func)(*this);
    return *this;
  }

  CStdOutStream & operator<<(const char *s) throw()
  {
    fputs(s, _stream);
    return *this;
  }

  CStdOutStream & operator<<(char c) throw()
  {
    fputc((unsigned char)c, _stream);
    return *this;
  }

  CStdOutStream & operator<<(Int32 number) throw();
  CStdOutStream & operator<<(Int64 number) throw();
  CStdOutStream & operator<<(UInt32 number) throw();
  CStdOutStream & operator<<(UInt64 number) throw();

  CStdOutStream & operator<<(const wchar_t *s);
  void PrintUString(const UString &s, AString &temp);
  void Convert_UString_to_AString(const UString &src, AString &dest);

  void Normalize_UString_LF_Allowed(UString &s);
  void Normalize_UString(UString &s);

  void NormalizePrint_UString(const UString &s, UString &tempU, AString &tempA);
  void NormalizePrint_UString(const UString &s);
  void NormalizePrint_wstr(const wchar_t *s);
};

CStdOutStream & endl(CStdOutStream & outStream) throw();

extern CStdOutStream g_StdOut;
extern CStdOutStream g_StdErr;

#endif