/** * @brief Get next line of valid data, protected * * This method overwrites <b>TextFile</b>'s protected method of * the same name. It is called by the public overwritten method * <b>GetLine()</b>, as in the parent class. * * @param line String to be rewritten with contents of the * next line read from file * @returns <b>bool</b> Indicates whether line was read * @throws Isis::iException::Io "Error reading text file" * @see GetLine() */ bool CisscalFile::p_GetLine(string &line) { OpenChk(true); // Try to read the next line getline(p_stream, line); // Check for end of file if (p_stream.eof()) { line = ""; return false; } // See if an error occured if (!p_stream.good()) { line = ""; string message = "TextFile:GetLine: -> Error reading text file: [" + p_filename + "]"; throw Isis::iException::Message(Isis::iException::Io,message,_FILEINFO_); } // Search for tag "\begindata" if it was not already found by recursively using this method if (!p_begindataFound) { if(line.find("\\begindata") == string::npos){ return p_GetLine(line); } p_begindataFound = true; return p_GetLine(line); } // We have a good line return true; }
/** * @brief Get next line of valid data, protected * * This method overwrites <b>TextFile</b>'s protected method of * the same name. It is called by the public overwritten method * <b>GetLine()</b>, as in the parent class. * * @param line String to be rewritten with contents of the * next line read from file * @returns <b>bool</b> Indicates whether line was read * @throws Isis::iException::Io "Error reading text file" * @see GetLine() */ bool CisscalFile::p_GetLine(QString &line) { OpenChk(true); // Try to read the next line std::string lineTmp; getline(p_stream, lineTmp); line = lineTmp.c_str(); // Check for end of file if(p_stream.eof()) { line = ""; return false; } // See if an error occured if(!p_stream.good()) { line = ""; QString message = "TextFile:GetLine: -> Error reading text file: [" + p_filename + "]"; throw IException(IException::Io, message, _FILEINFO_); } // Search for tag "\begindata" if it was not already found by recursively using this method if(!p_begindataFound) { if(!line.contains("\\begindata")) { return p_GetLine(line); } p_begindataFound = true; return p_GetLine(line); } // We have a good line return true; }