InputFile Class Reference

List of all members.

Public Member Functions

 InputFile (G4String filename, G4int _maxline=1024)
 ~InputFile ()
const char * filename ()
bool good ()
int linenumber ()
char * getline ()
void setMaxline (int _maxline)
void close ()
void repeatLine ()

Private Attributes

std::ifstream in
G4String name
char * line
int maxline
int lineno
bool repeatline

Detailed Description

class InputFile handles input file I/O

Definition at line 32 of file MyBLFieldMap.cc.


Constructor & Destructor Documentation

InputFile::InputFile ( G4String  filename,
G4int  _maxline = 1024 
) [inline]

Definition at line 40 of file MyBLFieldMap.cc.

References in, line, lineno, maxline, name, and repeatline.

00040                                                           : in(), name() {
00041             name = filename;
00042             in.open(name.c_str());
00043             maxline = _maxline;
00044             line = new char[maxline];
00045             assert(line != 0);
00046             lineno = 0;
00047             repeatline = false;
00048         }

InputFile::~InputFile (  )  [inline]

Definition at line 49 of file MyBLFieldMap.cc.

References close().

00049 { close(); }


Member Function Documentation

void InputFile::close (  )  [inline]

Definition at line 77 of file MyBLFieldMap.cc.

References in, and line.

Referenced by MyBLFieldMap::readFile(), and ~InputFile().

00077                      {
00078             if(line) {
00079                 in.close(); delete line; line = 0;
00080             }
00081         }

const char* InputFile::filename (  )  [inline]

Definition at line 50 of file MyBLFieldMap.cc.

References name.

Referenced by MyBLFieldMap::readFile().

00050 { return name.c_str(); }

char* InputFile::getline (  )  [inline]

Definition at line 53 of file MyBLFieldMap.cc.

References in, line, lineno, maxline, and repeatline.

Referenced by CylinderImpl::handleCommand(), GridImpl::handleCommand(), FieldMapImpl::readBlock(), MyBLFieldMap::readFile(), and TimeImpl::readTime().

00053                         {                             // skips blank lines and comments
00054             if(repeatline) {
00055                 repeatline = false;
00056                 return line;
00057             }
00058             while(in.good()) {
00059                 line[0] = '\0';
00060                 in.getline(line,maxline);
00061                 ++lineno;
00062                 if(line[0] == '*')
00063                     printf("%s\n",line);
00064                 if(line[0] == '\0' || line[0] == '#' || line[0] == '*')
00065                     continue;
00066                 return line;
00067             }
00068             return 0;
00069         }

bool InputFile::good (  )  [inline]

Definition at line 51 of file MyBLFieldMap.cc.

References in.

Referenced by MyBLFieldMap::readFile().

00051 { return in.good(); }

int InputFile::linenumber (  )  [inline]

Definition at line 52 of file MyBLFieldMap.cc.

References lineno.

Referenced by CylinderImpl::handleCommand(), GridImpl::handleCommand(), and MyBLFieldMap::readFile().

00052 { return lineno; }

void InputFile::repeatLine (  )  [inline]

Definition at line 82 of file MyBLFieldMap.cc.

References repeatline.

Referenced by CylinderImpl::handleCommand(), GridImpl::handleCommand(), and TimeImpl::readTime().

00082 { repeatline = true; }

void InputFile::setMaxline ( int  _maxline  )  [inline]

Definition at line 70 of file MyBLFieldMap.cc.

References line, and maxline.

Referenced by MyBLFieldMap::readFile().

00070                                       {
00071             maxline = _maxline;
00072             assert(maxline >= 80);
00073             if(line) delete line;
00074             line = new char[maxline];
00075             assert(line != 0);
00076         }


Member Data Documentation

std::ifstream InputFile::in [private]

Definition at line 33 of file MyBLFieldMap.cc.

Referenced by close(), getline(), good(), and InputFile().

char* InputFile::line [private]

Definition at line 35 of file MyBLFieldMap.cc.

Referenced by close(), getline(), InputFile(), and setMaxline().

int InputFile::lineno [private]

Definition at line 37 of file MyBLFieldMap.cc.

Referenced by getline(), InputFile(), and linenumber().

int InputFile::maxline [private]

Definition at line 36 of file MyBLFieldMap.cc.

Referenced by getline(), InputFile(), and setMaxline().

G4String InputFile::name [private]

Definition at line 34 of file MyBLFieldMap.cc.

Referenced by filename(), and InputFile().

bool InputFile::repeatline [private]

Definition at line 38 of file MyBLFieldMap.cc.

Referenced by getline(), InputFile(), and repeatLine().


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

Generated on 15 Jun 2016 for g4sim by  doxygen 1.6.1