#include <FileReader.h>
Inherited by Interpolator::GenericFileReader1D, Interpolator::GenericFileReader2D, Interpolator::LowEnergyThetaBraggCorrectionReader, and Interpolator::SambaFileReader.
Inheritance diagram for Interpolator::FileReader:

Public Member Functions | |
| FileReader () | |
| Default constructor. | |
| FileReader (const std::string &sFileName) | |
This constructor requires 1 parameter :
| |
| FileReader (const std::string &sFileName, long lNbVariables, long lNbDatas) | |
This constructor requires 3 parameters :
| |
| virtual | ~FileReader () |
| Destructor. | |
| bool | isReadable () |
| This method test if the file can be open and read. | |
| double | extractDouble () |
| Extract a double from the buffer. | |
| std::string | extractString () |
| Extract a std::string from the buffer. | |
| int | extractInt () |
| Extract a int from the buffer. | |
| std::string | extractLine () |
| Return a complete line of the buffer. | |
| long | extractFileSize () |
| Return the size of the file. | |
| long | extractNbFileLines () |
| Return the number of lines of the file. | |
| long | extractBufferSize () |
| Compute the size of the buffer. | |
| long | getFileSize () const |
| Return the file size. | |
| long | getNbFileLines () const |
| Return the number of lines of the file. | |
| long | getBufferSize () const |
| Return the size of the buffer containing the file. | |
| long | getNbVariables () const |
| Return the number of variables (the number of columns) of the file. | |
| long | getNbData () const |
| Return the number of Data (number of lines of Data) of the file. | |
| void | setFileSize (long lFileSize) |
| Set the file size. | |
| void | setNbFileLines (long lNbFileLines) |
| Set the number of lines in the file. | |
| void | setBufferSize (long lBufferSize) |
| Set the size of the buffer containing the file. | |
| void | setNbVariables (long lNbVariables) |
| Set the number of variables (the number of columns). | |
| void | setNbData (long lNbData) |
| Set the number of Data (number of lines of Data). | |
| void | copyFileToBuffer () |
| This method is used to copy the file in the buffer After the copy is done the file is closed. | |
| virtual void | Parse ()=0 |
| void | extractHeader () |
Private Attributes | |
| std::string | _sFileName |
| long | _lNbVariables |
| long | _lNbData |
| std::stringstream | _mFileBuffer |
| long | _lBufferSize |
| long | _lFileSize |
| long | _lNbFileLines |
Definition at line 30 of file FileReader.h.
|
|
Default constructor.
Definition at line 23 of file FileReader.cpp.
|
|
|
This constructor requires 1 parameter :
Definition at line 40 of file FileReader.cpp. References Interpolator::Interpolator::_verb, copyFileToBuffer(), extractBufferSize(), extractFileSize(), extractHeader(), extractNbFileLines(), isReadable(), setBufferSize(), setFileSize(), and setNbFileLines(). 00040 : _sFileName(sFileName)// throw (FileNotFoundException) 00041 { 00042 if(isReadable()) 00043 { 00044 copyFileToBuffer(); 00045 setBufferSize(extractBufferSize()); 00046 setFileSize(extractFileSize()); 00047 setNbFileLines(extractNbFileLines()); 00048 extractHeader(); 00049 if(Interpolator::_verb == true) cout << "Open file : " << sFileName << " --> OK" << endl; 00050 } 00051 else throw FileNotFoundException(sFileName,"FileReader::FileReader(const std::string& sFileName)",__FILE__,__LINE__); 00052 }
Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
This constructor requires 3 parameters :
Definition at line 62 of file FileReader.cpp. References Interpolator::Interpolator::_verb, copyFileToBuffer(), extractBufferSize(), extractFileSize(), extractNbFileLines(), isReadable(), setBufferSize(), setFileSize(), and setNbFileLines(). 00062 : _sFileName(sFileName),_lNbVariables(lNbVariables),_lNbData(lNbData) // throw (FileNotFoundException) 00063 { 00064 if(isReadable()) 00065 { 00066 copyFileToBuffer(); 00067 setBufferSize(extractBufferSize()); 00068 setFileSize(extractFileSize()); 00069 setNbFileLines(extractNbFileLines()); 00070 if(Interpolator::_verb == true) cout << "Open file : " << sFileName << " --> OK" << endl; 00071 } 00072 else throw FileNotFoundException(sFileName,"FileReader::FileReader(const std::string& sFileName,long lNbVariables,long lNbData)",__FILE__,__LINE__); 00073 }
Here is the call graph for this function: ![]() |
|
|
Destructor.
Definition at line 29 of file FileReader.cpp.
|
|
|
This method is used to copy the file in the buffer
Definition at line 194 of file FileReader.cpp. References _mFileBuffer, _sFileName, extractBufferSize(), and setBufferSize(). Referenced by FileReader(). 00195 { 00196 ifstream mFile(_sFileName.c_str()); 00197 00198 if ( mFile ) 00199 { 00200 _mFileBuffer << mFile.rdbuf(); 00201 mFile.close(); 00202 setBufferSize(extractBufferSize()); 00203 } 00204 else throw FileNotFoundException(_sFileName,"FileReader::copyFileToBuffer()",__FILE__,__LINE__); 00205 }
Here is the call graph for this function: ![]() |
|
|
Compute the size of the buffer.
Definition at line 186 of file FileReader.cpp. References _mFileBuffer. Referenced by copyFileToBuffer(), and FileReader(). 00187 { 00188 return (long)_mFileBuffer.str().size(); 00189 }
|
|
|
Extract a double from the buffer.
Definition at line 161 of file FileReader.cpp. References extractString(). Referenced by Interpolator::SambaFileReader::Parse(), Interpolator::LowEnergyThetaBraggCorrectionReader::Parse(), Interpolator::GenericFileReader2D::Parse(), and Interpolator::GenericFileReader1D::Parse(). 00162 { 00163 00164 std::string sTemp; 00165 sTemp = extractString(); 00166 return atof(sTemp.c_str()); 00167 }
Here is the call graph for this function: ![]() |
|
|
Return the size of the file.
Definition at line 90 of file FileReader.cpp. References _sFileName. Referenced by FileReader(). 00091 { 00092 ifstream mFile(_sFileName.c_str()); 00093 long pos,size; 00094 if (mFile) 00095 { 00096 pos = mFile.tellg(); 00097 mFile.seekg( 0 , ios_base::end ); 00098 size = mFile.tellg() ; 00099 mFile.seekg( pos, ios_base::beg ); 00100 } 00101 else throw FileNotFoundException(_sFileName,"FileReader::extractNbFileLines()",__FILE__,__LINE__); 00102 return size; 00103 }
|
|
|
Definition at line 124 of file FileReader.cpp. References _lNbData, _lNbVariables, _sFileName, and extractInt(). Referenced by FileReader(). 00125 { 00126 ifstream mFile(_sFileName.c_str()); 00127 if (mFile) 00128 { 00129 _lNbVariables = extractInt(); 00130 _lNbData = extractInt(); 00131 } 00132 }
Here is the call graph for this function: ![]() |
|
|
Extract a int from the buffer.
Definition at line 170 of file FileReader.cpp. References extractString(). Referenced by extractHeader(). 00171 { 00172 std::string sTemp; 00173 sTemp = extractString(); 00174 return atoi(sTemp.c_str()); 00175 }
Here is the call graph for this function: ![]() |
|
|
Return a complete line of the buffer.
Definition at line 153 of file FileReader.cpp. References _mFileBuffer. 00154 { 00155 std::string sLine; 00156 getline(_mFileBuffer, sLine ); 00157 return sLine; 00158 }
|
|
|
Return the number of lines of the file.
Definition at line 137 of file FileReader.cpp. References _sFileName. Referenced by FileReader(). 00138 { 00139 ifstream mFile(_sFileName.c_str()); 00140 int iLines = 0; 00141 if ( mFile ) 00142 { 00143 iLines = count( istreambuf_iterator<char>( mFile ), 00144 istreambuf_iterator<char>(), 00145 '\n' ); 00146 } 00147 else throw FileNotFoundException(_sFileName,"FileReader::extractNbFileLines()",__FILE__,__LINE__); 00148 return iLines+1; 00149 }
|
|
|
Extract a std::string from the buffer.
Definition at line 178 of file FileReader.cpp. References _mFileBuffer. Referenced by extractDouble(), extractInt(), Interpolator::SambaFileReader::Parse(), Interpolator::LowEnergyThetaBraggCorrectionReader::Parse(), Interpolator::GenericFileReader2D::Parse(), and Interpolator::GenericFileReader1D::Parse(). 00179 { 00180 std::string sTemp; 00181 _mFileBuffer >> sTemp; 00182 return sTemp; 00183 }
|
|
|
Return the size of the buffer containing the file.
Definition at line 232 of file FileReader.cpp. References _lBufferSize. 00233 { 00234 return _lBufferSize; 00235 }
|
|
|
Return the file size.
Definition at line 208 of file FileReader.cpp. References _lFileSize. 00209 { 00210 return _lFileSize; 00211 }
|
|
|
Return the number of Data (number of lines of Data) of the file.
Definition at line 220 of file FileReader.cpp. References _lNbData. Referenced by Interpolator::GenericFileReader1D::displayAll(), Interpolator::FileWriter::FileWriter(), Interpolator::GenericFileReader1D::getColumn(), Interpolator::GenericFileReader1D::getColumnName(), Interpolator::GenericFileReader1D::getValue(), Interpolator::SambaFileReader::Parse(), Interpolator::LowEnergyThetaBraggCorrectionReader::Parse(), Interpolator::GenericFileReader2D::Parse(), Interpolator::GenericFileReader1D::Parse(), and Interpolator::Table1D::Table1D(). 00221 { 00222 return _lNbData; 00223 }
|
|
|
Return the number of lines of the file.
Definition at line 214 of file FileReader.cpp. References _lNbFileLines. 00215 { 00216 return _lNbFileLines; 00217 }
|
|
|
Return the number of variables (the number of columns) of the file.
Definition at line 226 of file FileReader.cpp. References _lNbVariables. Referenced by Interpolator::GenericFileReader1D::displayAll(), Interpolator::FileWriter::FileWriter(), Interpolator::GenericFileReader1D::getValue(), Interpolator::SambaFileReader::Parse(), Interpolator::LowEnergyThetaBraggCorrectionReader::Parse(), Interpolator::GenericFileReader2D::Parse(), and Interpolator::GenericFileReader1D::Parse(). 00227 { 00228 return _lNbVariables; 00229 }
|
|
|
This method test if the file can be open and read.
Definition at line 77 of file FileReader.cpp. References _sFileName. Referenced by FileReader(). 00078 { 00079 00080 if (_sFileName.empty()) return false; 00081 else 00082 { 00083 ifstream mFile( _sFileName.c_str() ); 00084 return mFile != 0; 00085 } 00086 00087 }
|
|
|
Implemented in Interpolator::GenericFileReader1D, Interpolator::GenericFileReader2D, Interpolator::LowEnergyThetaBraggCorrectionReader, and Interpolator::SambaFileReader. |
|
|
Set the size of the buffer containing the file.
Definition at line 238 of file FileReader.cpp. References _lBufferSize. Referenced by copyFileToBuffer(), and FileReader(). 00239 { 00240 _lBufferSize = lBufferSize; 00241 }
|
|
|
Set the file size.
Definition at line 250 of file FileReader.cpp. References _lFileSize. Referenced by FileReader(). 00251 { 00252 _lFileSize = lFileSize; 00253 }
|
|
|
Set the number of Data (number of lines of Data).
Definition at line 262 of file FileReader.cpp. References _lNbData. 00263 { 00264 _lNbData = lNbData; 00265 }
|
|
|
Set the number of lines in the file.
Definition at line 256 of file FileReader.cpp. References _lNbFileLines. Referenced by FileReader(). 00257 { 00258 _lNbFileLines = lNbFileLines; 00259 }
|
|
|
Set the number of variables (the number of columns).
Definition at line 244 of file FileReader.cpp. References _lNbVariables. 00245 { 00246 _lNbVariables = lNbVariables; 00247 }
|
|
|
Definition at line 77 of file FileReader.h. Referenced by getBufferSize(), and setBufferSize(). |
|
|
Definition at line 78 of file FileReader.h. Referenced by getFileSize(), and setFileSize(). |
|
|
Definition at line 73 of file FileReader.h. Referenced by extractHeader(), getNbData(), and setNbData(). |
|
|
Definition at line 79 of file FileReader.h. Referenced by getNbFileLines(), and setNbFileLines(). |
|
|
Definition at line 72 of file FileReader.h. Referenced by extractHeader(), getNbVariables(), and setNbVariables(). |
|
|
Definition at line 75 of file FileReader.h. Referenced by copyFileToBuffer(), extractBufferSize(), extractLine(), and extractString(). |
|
|
Definition at line 70 of file FileReader.h. Referenced by copyFileToBuffer(), extractFileSize(), extractHeader(), extractNbFileLines(), and isReadable(). |
1.4.5