Isis 3 Programmer Reference
CisscalFile.cpp
Go to the documentation of this file.
1 
23 #include <string>
24 #include "IException.h"
25 #include "FileName.h"
26 #include "Message.h"
27 #include "CisscalFile.h"
28 #include "TextFile.h"
29 #include "IString.h"
30 
31 using namespace std;
32 namespace Isis {
59  CisscalFile::CisscalFile(const QString &filename, const char *openmode,
60  const char *extension): TextFile(filename, openmode, extension) {
61  p_begindataFound = false;
62  }
63 
77  bool CisscalFile::p_GetLine(QString &line) {
78  OpenChk(true);
79  // Try to read the next line
80  std::string lineTmp;
81  getline(p_stream, lineTmp);
82  line = lineTmp.c_str();
83 
84  // Check for end of file
85  if(p_stream.eof()) {
86  line = "";
87  return false;
88  }
89  // See if an error occured
90  if(!p_stream.good()) {
91  line = "";
92  QString message = "TextFile:GetLine: -> Error reading text file: ["
93  + p_filename + "]";
94  throw IException(IException::Io, message, _FILEINFO_);
95  }
96  // Search for tag "\begindata" if it was not already found by recursively using this method
97  if(!p_begindataFound) {
98  if(!line.contains("\\begindata")) {
99  return p_GetLine(line);
100  }
101  p_begindataFound = true;
102  return p_GetLine(line);
103  }
104  // We have a good line
105  return true;
106  }
107 
125  bool CisscalFile::GetLine(QString &line) {
126  return p_GetLine(line);
127  }
128 
129 }//end CisscalFile.cpp
QString p_filename
FileName of the opened file.
Definition: TextFile.h:60
Namespace for the standard library.
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:171
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
bool p_GetLine(QString &line)
Flag variable indicates whether the tag "\begindata" has been found.
Definition: CisscalFile.cpp:77
bool GetLine(QString &line)
Get next line of valid data.
Provides access to sequential ASCII stream I/O.
Definition: TextFile.h:54
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
std::fstream p_stream
File stream handle.
Definition: TextFile.h:57