• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Common/StdInStream.h
2 
3 #ifndef __COMMON_STD_IN_STREAM_H
4 #define __COMMON_STD_IN_STREAM_H
5 
6 #include <stdio.h>
7 
8 #include "MyString.h"
9 #include "MyTypes.h"
10 
11 class CStdInStream
12 {
13   FILE *_stream;
14   bool _streamIsOpen;
15 public:
16   int CodePage;
17 
18   CStdInStream(FILE *stream = NULL):
_stream(stream)19       _stream(stream),
20       _streamIsOpen(false),
21       CodePage(-1)
22       {};
23 
~CStdInStream()24   ~CStdInStream() { Close(); }
25 
26   bool Open(LPCTSTR fileName) throw();
27   bool Close() throw();
28 
29   // returns:
30   //   false, if ZERO character in stream
31   //   true, if EOF or '\n'
32   bool ScanAStringUntilNewLine(AString &s);
33   bool ScanUStringUntilNewLine(UString &s);
34   // bool ReadToString(AString &resultString);
35 
Eof()36   bool Eof() const throw() { return (feof(_stream) != 0); }
Error()37   bool Error() const throw() { return (ferror(_stream) != 0); }
38 
39   int GetChar();
40 };
41 
42 extern CStdInStream g_StdIn;
43 
44 #endif
45