Isis 3 Programmer Reference
CisscalFile.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include <string>
10 #include "IException.h"
11 #include "FileName.h"
12 #include "Message.h"
13 #include "CisscalFile.h"
14 #include "TextFile.h"
15 #include "IString.h"
16 
17 using namespace std;
18 namespace Isis {
45  CisscalFile::CisscalFile(const QString &filename, const char *openmode,
46  const char *extension): TextFile(filename, openmode, extension) {
47  p_begindataFound = false;
48  }
49 
63  bool CisscalFile::p_GetLine(QString &line) {
64  OpenChk(true);
65  // Try to read the next line
66  std::string lineTmp;
67  getline(p_stream, lineTmp);
68  line = lineTmp.c_str();
69 
70  // Check for end of file
71  if(p_stream.eof()) {
72  line = "";
73  return false;
74  }
75  // See if an error occured
76  if(!p_stream.good()) {
77  line = "";
78  QString message = "TextFile:GetLine: -> Error reading text file: ["
79  + p_filename + "]";
80  throw IException(IException::Io, message, _FILEINFO_);
81  }
82  // Search for tag "\begindata" if it was not already found by recursively using this method
83  if(!p_begindataFound) {
84  if(!line.contains("\\begindata")) {
85  return p_GetLine(line);
86  }
87  p_begindataFound = true;
88  return p_GetLine(line);
89  }
90  // We have a good line
91  return true;
92  }
93 
111  bool CisscalFile::GetLine(QString &line) {
112  return p_GetLine(line);
113  }
114 
115 }//end CisscalFile.cpp
Isis::IException::Io
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:155
Isis::TextFile
Provides access to sequential ASCII stream I/O.
Definition: TextFile.h:38
Isis::CisscalFile::GetLine
bool GetLine(QString &line)
Get next line of valid data.
Definition: CisscalFile.cpp:111
Isis::CisscalFile::p_GetLine
bool p_GetLine(QString &line)
Flag variable indicates whether the tag "\begindata" has been found.
Definition: CisscalFile.cpp:63
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::TextFile::p_filename
QString p_filename
FileName of the opened file.
Definition: TextFile.h:44
std
Namespace for the standard library.
Isis::TextFile::p_stream
std::fstream p_stream
File stream handle.
Definition: TextFile.h:41
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16