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: CStdInStream()16 CStdInStream(): _stream(0), _streamIsOpen(false) {}; CStdInStream(FILE * stream)17 CStdInStream(FILE *stream): _stream(stream), _streamIsOpen(false) {}; ~CStdInStream()18 ~CStdInStream() { Close(); } 19 20 bool Open(LPCTSTR fileName) throw(); 21 bool Close() throw(); 22 23 // returns: 24 // false, if ZERO character in stream 25 // true, if EOF or '\n' 26 bool ScanAStringUntilNewLine(AString &s); 27 bool ScanUStringUntilNewLine(UString &s); 28 // bool ReadToString(AString &resultString); 29 Eof()30 bool Eof() const throw() { return (feof(_stream) != 0); } Error()31 bool Error() const throw() { return (ferror(_stream) != 0); } 32 33 int GetChar(); 34 }; 35 36 extern CStdInStream g_StdIn; 37 38 #endif 39