00001 #ifndef _CTBlineStream_HXX 00002 #define _CTBlineStream_HXX 1 00003 00008 /*----------------------------------------------------------------------------*/ 00009 /* C Tool Box: Designed and implemented by: */ 00010 /* Walter F.J. Mueller Gesellschaft fuer Schwerionenforschung (GSI) */ 00011 /* Planckstrasse 1, D-64291 Darmstadt, Germany */ 00012 /* Email: W.F.J.Mueller@gsi.de */ 00013 /* WWW: http://www-kp3.gsi.de/www/kp3/people/mueller.html */ 00014 /*------------------------------------------+---------------------------------*/ 00015 00016 #include "CTBstring.hxx" 00017 00018 class CTBlineStream { 00019 00020 public: 00021 CTBlineStream(); 00022 ~CTBlineStream(); 00023 00024 bool Open(const char* c_name); 00025 void Attach(istream* p_is); 00026 void Close(); 00027 00028 bool Get(CTBstring& line); 00029 bool Get(const char*& c_line); 00030 bool Unget(); 00031 00032 operator bool(); 00033 00034 CTBlineStream& operator>>(CTBstring& line); 00035 CTBlineStream& operator>>(const char*& c_line); 00036 00037 private: 00038 00039 bool Get(); // get next line 00040 00041 private: 00042 00043 istream* mp_is; // stream pointer 00044 bool mb_attached; // true if Attach() was called 00045 bool mb_valid_line; // true if m_line contents valid 00046 bool mb_reread_line; // true after a valid Unget() 00047 CTBstring m_line; // current line 00048 00049 }; 00050 00051 #if !(defined(CTB__OutLine) || defined(CTBlineStream__OutLine)) 00052 #include "CTBlineStream.icc" 00053 #endif 00054 00055 #endif