CTextStream.hpp

Go to the documentation of this file.
00001 #ifndef __CTextStream__
00002 #define __CTextStream__
00003 
00004 //  ===========================================================================
00005 
00006 #include "../Basics/CString.hpp"
00007 #include "../Basics/CSystemString.hpp"
00008 #include "../Basics/CCountedObject.hpp"
00009 #include <fstream>
00010 
00011 //  ===========================================================================
00012 
00013 using Exponent::Basics::CString;
00014 using Exponent::Basics::CSystemString;
00015 using std::ifstream;
00016 using std::ofstream;
00017 
00018 //  ===========================================================================
00019 
00020 namespace Exponent
00021 {
00022     namespace IO
00023     {
00047         class CTextStream : public CCountedObject
00048         {
00050             EXPONENT_CLASS_DECLARATION;
00053 //  ===========================================================================
00054 
00055         public:
00056 
00057 //  ===========================================================================
00058 
00063             enum EStreamMode
00064             {
00065                 e_input = 0,        
00066                 e_output,           
00067             };
00068 
00069 //  ===========================================================================
00070 
00071             const static long CTEXTSTREAM_MAX_CHARACTERS = 1024; 
00073 //  ===========================================================================
00074 
00080             CTextStream(const CSystemString &path, const EStreamMode mode);
00081 
00085             CTextStream();
00086 
00090             virtual ~CTextStream();
00091 
00092 //  ===========================================================================
00093 
00099             bool openStream(const CSystemString &path, const EStreamMode mode);
00100 
00104             void closeStream();
00105 
00110             bool isStreamOpen() const { return m_streamIsOpen; }
00111 
00112 //  ===========================================================================
00113 
00119             CTextStream &operator << (const char *string);
00120 
00126             CTextStream &operator << (const CString &string);
00127 
00133             CTextStream &operator << (const CSystemString &string);
00134 
00140             CTextStream &operator << (const CCountedObject &object);
00141 
00147             CTextStream &operator << (const long value);
00148 
00154             CTextStream &operator << (const int value);
00155 
00161             CTextStream &operator << (const double value);
00162 
00168             CTextStream &operator << (const float value);
00169 
00175             CTextStream &operator << (const bool value);
00176 
00182             CTextStream &operator >> (char *string);
00183 
00189             CTextStream &operator >> (CString &string);
00190 
00196             CTextStream &operator >> (CSystemString &string);
00197 
00203             CTextStream &operator >> (long &value);
00204 
00210             CTextStream &operator >> (int &value);
00211 
00217             CTextStream &operator >> (double &value);
00218 
00224             CTextStream &operator >> (float &value);
00225 
00231             CTextStream &operator >> (bool &value);
00232 
00233 //  ===========================================================================
00234 
00239             bool validForOutput();
00240 
00245             bool validForInput();
00246 
00251             bool hasReachedEOF();
00252 
00256             void flushToDisk();
00257 
00258 //  ===========================================================================
00259 
00260         protected:
00261 
00262 //  ===========================================================================
00263 
00264             bool m_streamIsOpen;                                
00265             EStreamMode m_mode;                                 
00266             CSystemString m_filePath;                           
00267             ofstream m_outFile;                                 
00268             ifstream m_inputFile;                               
00269             char m_buffer[CTEXTSTREAM_MAX_CHARACTERS];          
00270         };
00271     }
00272 }
00273 #endif  // End of CTextStream.hpp

Infinity API - CTextStream.hpp Source File generated on 7 Mar 2007