![]() |
The Simons
|
00001 00002 // 00003 // SCL : Simons Component Library 00004 // 00006 // 00007 // Filename: Input.h 00008 // Contents: Input class 00009 // Author: Anthony J H Simons 00010 // Revised: 6 December 2005 00011 00012 // This software is distributed free in the hope that others will 00013 // find it useful. However, it comes WITHOUT ANY WARRANTY. No 00014 // liability can be accepted for software failure, merchantability 00015 // or fitness for a particular purpose. You can redistribute this 00016 // software in its original form, or in a modified form, provided 00017 // that this disclaimer is retained in the file banner. 00018 00019 #ifndef SCL_INPUT 00020 #define SCL_INPUT 00021 00022 #include "FileStream.h" // Include my superclass type 00023 #include "InputID.h" // Include my pointer type 00024 00025 #include "StringID.h" // Depend on the pointer type 00026 00027 #include <iosfwd> // In ANSI standard C++; cannot forward 00028 // declare 'class istream;' because it is a 00029 // 'typedef basic_istream<char> istream;' 00030 00042 00043 class Input : public FileStream { 00044 private: 00045 static std::istream closed; 00046 protected: 00047 std::istream* filesystem; 00048 Input(const Input&); 00049 public: 00050 Input(); 00051 virtual ~Input(); 00052 Input(StringID); 00053 virtual Void open(); 00054 virtual Void close(); 00055 virtual Boolean exists() const; 00056 virtual Boolean empty() const; 00057 virtual Boolean ready() const; 00058 virtual Boolean failed() const; 00059 virtual Boolean source() const; 00060 virtual InputID get(Boolean&); 00061 virtual InputID get(Character&); 00062 virtual InputID get(Natural&); 00063 virtual InputID get(Integer&); 00064 virtual InputID get(Decimal&); 00065 virtual InputID get(StringID&, Character = '\n'); 00066 virtual InputID get(Character[], Natural, Character = '\n'); 00067 virtual InputID skip(Character = '\n'); 00068 }; 00069 00071 00074 inline InputID::InputID() {} 00075 00077 inline InputID::~InputID() {} 00078 00082 inline InputID::InputID(const Null* null) : 00083 FileStreamID(null) {} 00084 00088 inline InputID::InputID(const Input* stream) : 00089 FileStreamID(stream) {} 00090 00094 inline InputID::InputID(const InputID& pointer) : 00095 FileStreamID(pointer) {} 00096 00100 inline InputID& InputID::operator=(const Input* stream) { 00101 assign(stream); 00102 return *this; 00103 } 00104 00109 inline InputID& InputID::operator=(const InputID& pointer) { 00110 assign(pointer); 00111 return *this; 00112 } 00113 00114 #endif 00115