CEPS  24.01
Cardiac ElectroPhysiology Simulator
FileReader Class Reference

Detailed Description

Base class that regroups common reader functionalities.

Definition at line 42 of file FileReader.hpp.

#include <FileReader.hpp>

Inheritance diagram for FileReader:
[legend]

Public Member Functions

 FileReader ()
 Alternative constructor. More...
 
 FileReader (const CepsString &fileName)
 Default constructor. More...
 
 FileReader (const FileReader &that)
 Copy constructor. More...
 
FileReaderoperator= (const FileReader &that)
 Copy constructor. More...
 
virtual ~FileReader ()
 Destructor. Calls FileReader::close. More...
 
void setFileName (const CepsString &fileName)
 Set file to read. More...
 
virtual CepsBool open ()
 Opens the designated file in read mode. More...
 
virtual void close ()
 Close the file. More...
 
virtual CepsBool good ()
 true if stream is still readable More...
 
void reset ()
 Set file stream to the beginning of the file. More...
 
CepsUInt find (const CepsString &pattern)
 Advance stream until pattern is found. More...
 
CepsBool findNext (const CepsString &pattern)
 Advance stream until pattern is found. More...
 
CepsUInt findNextOf (const CepsVector< CepsString > &patterns)
 Advance stream until one of patterns is found. More...
 
CepsString getFileName ()
 Name of parsed file. More...
 
CepsUInt skipLines (CepsUInt nbLines)
 Skip given number of lines. More...
 
void oneLine (CepsString &line)
 Get one line from the stream. More...
 
template<typename T >
FileReaderoperator>> (T &var)
 Reading operator. More...
 
CepsInt lineIndex (const CepsString &word)
 Index of first line starting with word, search starting from the current stream position. More...
 
CepsUInt checkEOF ()
 Checks if the reader reached end of file. More...
 

Protected Attributes

CepsString m_fileName
 file to open More...
 
std::ifstream m_file
 stream More...
 

Constructor & Destructor Documentation

◆ FileReader() [1/3]

FileReader::FileReader ( )

Alternative constructor.

Definition at line 36 of file FileReader.cpp.

◆ FileReader() [2/3]

FileReader::FileReader ( const CepsString fileName)
explicit

Default constructor.

The designated file is not opened.

Parameters
fileNamethe file the reader is meant to read

Definition at line 40 of file FileReader.cpp.

◆ FileReader() [3/3]

FileReader::FileReader ( const FileReader that)

Copy constructor.

Definition at line 45 of file FileReader.cpp.

◆ ~FileReader()

FileReader::~FileReader ( )
virtual

Destructor. Calls FileReader::close.

Definition at line 58 of file FileReader.cpp.

Member Function Documentation

◆ checkEOF()

CepsUInt FileReader::checkEOF ( )

Checks if the reader reached end of file.

Returns
non-zero value if EOF reached.

Definition at line 228 of file FileReader.cpp.

◆ close()

void FileReader::close ( )
virtual

Close the file.

Definition at line 84 of file FileReader.cpp.

◆ find()

CepsUInt FileReader::find ( const CepsString pattern)

Advance stream until pattern is found.

Returns
non-zero value on positive find

Definition at line 131 of file FileReader.cpp.

◆ findNext()

CepsBool FileReader::findNext ( const CepsString pattern)

Advance stream until pattern is found.

Returns
true on positive find

Definition at line 107 of file FileReader.cpp.

◆ findNextOf()

CepsUInt FileReader::findNextOf ( const CepsVector< CepsString > &  patterns)

Advance stream until one of patterns is found.

Returns
non-zero value on positive find

Definition at line 154 of file FileReader.cpp.

◆ getFileName()

CepsString FileReader::getFileName ( )

Name of parsed file.

Definition at line 173 of file FileReader.cpp.

◆ good()

CepsBool FileReader::good ( )
virtual

true if stream is still readable

Definition at line 92 of file FileReader.cpp.

◆ lineIndex()

CepsInt FileReader::lineIndex ( const CepsString word)

Index of first line starting with word, search starting from the current stream position.

Definition at line 209 of file FileReader.cpp.

◆ oneLine()

void FileReader::oneLine ( CepsString line)

Get one line from the stream.

Definition at line 202 of file FileReader.cpp.

◆ open()

CepsBool FileReader::open ( )
virtual

Opens the designated file in read mode.

Returns
false on failure. Users should always check if this method failed. Will fail if no file to read has been specified

Reimplemented in TetgenMeshReader.

Definition at line 70 of file FileReader.cpp.

◆ operator=()

FileReader & FileReader::operator= ( const FileReader that)

Copy constructor.

Definition at line 51 of file FileReader.cpp.

◆ operator>>()

template<typename T >
FileReader& FileReader::operator>> ( T &  var)
inline

Reading operator.

Definition at line 126 of file FileReader.hpp.

◆ reset()

void FileReader::reset ( )

Set file stream to the beginning of the file.

Definition at line 98 of file FileReader.cpp.

◆ setFileName()

void FileReader::setFileName ( const CepsString fileName)

Set file to read.

Definition at line 63 of file FileReader.cpp.

◆ skipLines()

CepsUInt FileReader::skipLines ( CepsUInt  nbLines)

Skip given number of lines.

Returns
non-zero value on failure

Definition at line 179 of file FileReader.cpp.

Field Documentation

◆ m_file

std::ifstream FileReader::m_file
protected

stream

Definition at line 146 of file FileReader.hpp.

◆ m_fileName

CepsString FileReader::m_fileName
protected

file to open

Definition at line 145 of file FileReader.hpp.


The documentation for this class was generated from the following files: