Diana
0.8.3
|
00001 /* ----------------------------------------------------------------------------- 00002 * Diana process modelling, simulation and analysis software 00003 * Copyright (c) 2005, Michael Krasnyk 00004 * All rights reserved. 00005 * 00006 * This file is a part of Diana process modelling, simulation and analysis software 00007 * 00008 * Diana is free software; you can redistribute it and/or modify it 00009 * under the terms of the GNU General Public License as published 00010 * by the Free Software Foundation (see accompanying file LICENSE) 00011 * ----------------------------------------------------------------------------- 00012 * $Id$ 00013 * ----------------------------------------------------------------------------- 00014 * Description: 00015 */ 00016 00017 00018 #ifndef __FILE_H 00019 #define __FILE_H 00020 00021 00027 #define MAX_STRING_LENGTH 4096 00028 #define MAX_FILE_NAME 1024 00029 00030 #include <iostream> 00031 #include <fstream> 00032 #include <CapeOpen.hpp> 00033 00034 using namespace std; 00035 class CFile 00036 { 00037 private: 00038 fstream* m_pFile; 00039 protected: 00040 void SkipSpaces(); 00041 CapeBoolean SkipComments(); 00042 public: 00043 CFile( const CapeString& _szFileName ) 00044 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument); 00045 ~CFile(); 00046 00047 template <typename T> void Write( T Value ) 00048 { 00049 if ( *m_pFile == 0 ) return; 00050 *m_pFile << Value; 00051 }; 00052 template <typename T> CapeBoolean Read( T* Value ) 00053 { 00054 if ( !SkipComments() ) return false; 00055 *m_pFile >> *Value; return true; 00056 }; 00057 00058 00059 CapeBoolean ReadWord( CapeString* _szWord ); 00060 CapeBoolean ReadWord( CapeString* _szWord, char _cDelimiter ); 00061 CapeBoolean SkipWord(); 00062 void WriteString( const char * _szString); 00063 void WriteString( const CapeString& _String ); 00064 }; 00065 #endif 00066