Isis Developer Reference
Isis::CisscalFile Class Reference

Extends TextFile to handle Cassini ISS calibration files. More...

#include <CisscalFile.h>

Inheritance diagram for Isis::CisscalFile:
Inheritance graph
Collaboration diagram for Isis::CisscalFile:
Collaboration graph

Public Member Functions

 CisscalFile (const QString &filename, const char *openmode="input", const char *extension="")
 Constructs a CisscalFile object and opens the specified file (including path).
 
 ~CisscalFile ()
 

‍Destructor closes the text file.


 
bool GetLine (QString &line)
 Get next line of valid data.
 
void Open (const QString &filename, const char *openmode="input", const char *extension="")
 Opens a text file.
 
void Open (const char *filename, const char *openmode="input", const char *extension="")
 
bool OpenChk (bool bailIfNotOpen=false)
 
void Rewind ()
 Sets Read / Write pointer to begining of opened file.
 
void Close ()
 Closes file. Called automatically by TextFile destructor.
 
void GetFile (std::vector< QString > &lines, const int &maxLinesToRead=0, const bool skipComments=true)
 
void GetFile (QString *lines, const int &maxLinesToRead, const bool skipComments=true)
 
void PutFile (std::vector< QString > &lines, const int &maxLinesToWrite=0)
 
void PutFile (const QString *lines, const int &maxLinesToWrite)
 
bool GetLine (QString &line, const bool skipComments=true)
 Gets next line from file.
 
bool GetLine (const bool skipComments=true)
 Gets next line from file.
 
bool GetLineNoFilter (QString &line)
 Gets next NON-COMMENT line from file.
 
bool GetLineNoFilter ()
 Gets next NON-COMMENT line from file.
 
void PutLine (const QString &line)
 Writes string to file and appends a 'newline' string.
 
void PutLine (const char *line="")
 Writes char string to file and appends a 'newline' string.
 
void PutLineComment (const QString &line)
 Writes string to file, prepends a 'comment' string and appends a 'newline' string.
 
void PutLineComment (const char *line="")
 Writes char string to file, prepends a 'comment' string and appends a 'newline' string.
 
QString GetComment ()
 
QString GetNewLine ()
 
void SetComment (const char *commentString="#")
 Sets the 'comment' string.
 
void SetNewLine (const char *newLineString="\n")
 Sets the 'newline' string.
 
int LineCount (const int &maxLinesToRead=0)
 Counts number of lines in file.
 
std::streamsize Size ()
 Counts number of bytes in file.
 

Protected Member Functions

bool p_GetLine (QString &line)
 

‍Flag variable indicates whether the tag "\begindata" has been found.


 
bool p_GetLine (QString &line, bool chkComment)
 Gets next line from file.
 

Protected Attributes

bool p_begindataFound
 
std::fstream p_stream
 File stream handle.
 
int p_openmode
 openmode of file: Input, Output, Overwrite, Append
 
QString p_filename
 FileName of the opened file.
 
QString p_commentString
 'comment' string used by GetLine and PutLineComment
 
QString p_newLineString
 'newline' string used by PutLine and PutLineComment
 

Detailed Description

Extends TextFile to handle Cassini ISS calibration files.

This class was created as an extension of TextFile to be able to read in Cassini ISS calibration files used by the Isis ciss2isis and cisscal applications. It is able to read PDS style text files and skip all header info that exists before the tag "\begindata".

Author
2008-03-27 Jeannie Walldren

Constructor & Destructor Documentation

◆ CisscalFile()

Isis::CisscalFile::CisscalFile ( const QString & filename,
const char * openmode = "input",
const char * extension = "" )

Constructs a CisscalFile object and opens the specified file (including path).

Parameters
filenameFileName (including path) to be opened by TextFile object.
openmodeOpen Mode of file opened by TextFile object.
  • "input" Opens file for Input: Read Only. Fails if file does not exist.
  • "output" Opens file for Output: Read/Write. Creates file, fails if file exists.
  • "overwrite" Opens file for Output: Read/Write. Creates file, truncates if file exists.
  • "append" Opens file for Append: Read/Write. Creates file, appends if file exists.
Defaults to "input".
extensionExtension to be added to filename (added only if not already on filename). Defaults to ""

References p_begindataFound.

◆ ~CisscalFile()

Isis::CisscalFile::~CisscalFile ( )
inline

‍Destructor closes the text file.

References Isis::TextFile::Close().

Member Function Documentation

◆ Close()

void Isis::TextFile::Close ( )
inherited

Closes file. Called automatically by TextFile destructor.

References Isis::TextFile::p_stream.

Referenced by ~CisscalFile(), and Isis::TextFile::~TextFile().

◆ GetComment()

QString Isis::TextFile::GetComment ( )
inherited

◆ GetFile() [1/2]

void Isis::TextFile::GetFile ( QString * lines,
const int & maxLinesToRead,
const bool skipComments = true )
inherited

◆ GetFile() [2/2]

void Isis::TextFile::GetFile ( std::vector< QString > & lines,
const int & maxLinesToRead = 0,
const bool skipComments = true )
inherited

◆ GetLine() [1/3]

bool Isis::TextFile::GetLine ( const bool skipComments = true)
inherited

Gets next line from file.

Returns True if read a line, False if End Of File.

Parameters
skipCommentsControls whether comments lines are filtered; true=filter, false=return any line read from fileDefaults to true
Returns
bool

References Isis::TextFile::p_GetLine().

◆ GetLine() [2/3]

bool Isis::CisscalFile::GetLine ( QString & line)

Get next line of valid data.

This protected method overrides the base class method from TextFile of the same name. It finds the next line of valid data. If the "\begindata" tag has not been already found, it searches for that tag. Once found, every line beyond that is considered data and the method will retrieve the next line. Returns True if read a line, False if End Of File.

Parameters
lineString to be rewritten with contents of the next line read from file
Returns
bool Indicates whether line was read
Exceptions
Isis::iException::Io"Error reading text file"
See also
p_GetLine()

References p_GetLine().

◆ GetLine() [3/3]

bool Isis::TextFile::GetLine ( QString & line,
const bool skipComments = true )
inherited

Gets next line from file.

Returns True if read a line, False if End Of File.

Parameters
lineLine read from file, with newline removed.
skipCommentsControls whether comments lines are filtered; true=filter, false=return any line read from fileDefaults to true
Returns
bool

References Isis::TextFile::p_GetLine().

Referenced by Isis::TextFile::GetFile(), and Isis::TextFile::GetFile().

◆ GetLineNoFilter() [1/2]

bool Isis::TextFile::GetLineNoFilter ( )
inherited

Gets next NON-COMMENT line from file.

Returns True if read a line, False if End Of File. See SetComment method.

Returns
bool

References Isis::TextFile::p_GetLine().

◆ GetLineNoFilter() [2/2]

bool Isis::TextFile::GetLineNoFilter ( QString & line)
inherited

Gets next NON-COMMENT line from file.

Returns True if read a line, False if End Of File. See SetComment method.

Parameters
lineLine read from file, with newline removed.
Returns
bool

References Isis::TextFile::p_GetLine().

◆ GetNewLine()

QString Isis::TextFile::GetNewLine ( )
inherited

◆ LineCount()

int Isis::TextFile::LineCount ( const int & maxLinesToRead = 0)
inherited

Counts number of lines in file.

Parameters
maxLinesToReadLimits lines counted - intended for large files. 0=count all lines. n=count up to and including n lines; if file longer than n lines, returns n+1. Defaults to 0
Returns
streamsize

References Isis::TextFile::OpenChk(), and Isis::TextFile::p_stream.

◆ Open() [1/2]

void Isis::TextFile::Open ( const char * filename,
const char * openmode = "input",
const char * extension = "" )
inherited

◆ Open() [2/2]

void Isis::TextFile::Open ( const QString & filename,
const char * openmode = "input",
const char * extension = "" )
inherited

Opens a text file.

Parameters
filenameFileName (including path) to be opened.
openmodeOpen Mode of file to be opened. There are four options, "input", "output", "overwrite", and "append". "input" opens with in fstream option, "output" opens with in, out, and trunc fstream options and verifies the file does not exist, "overwrite" opens with in, out, and trunc fstream options, and "append" opens with in, out, and ate(at end) fstream options, "append" will open with in and out options if the file does not exist.
extensionExtension to be added to filename (added only if not already on filename). Defaults to ""
Exceptions
Isis::IException::Programmer
Isis::IException::Io- output file already exists
Isis::IException::Io- unable to open file

References _FILEINFO_, Isis::IString::DownCase(), Isis::IException::Io, Isis::TextFile::p_filename, Isis::TextFile::p_openmode, Isis::TextFile::p_stream, and Isis::IException::Programmer.

Referenced by Isis::TextFile::TextFile(), Isis::TextFile::TextFile(), and Isis::TextFile::TextFile().

◆ OpenChk()

◆ p_GetLine() [1/2]

bool Isis::CisscalFile::p_GetLine ( QString & line)
protected

‍Flag variable indicates whether the tag "\begindata" has been found.

Get next line of valid data, protected.

This method overwrites TextFile's protected method of the same name. It is called by the public overwritten method GetLine(), as in the parent class.

Parameters
lineString to be rewritten with contents of the next line read from file
Returns
bool Indicates whether line was read
Exceptions
Isis::iException::Io"Error reading text file"
See also
GetLine()

References _FILEINFO_, Isis::IException::Io, Isis::TextFile::OpenChk(), p_begindataFound, Isis::TextFile::p_filename, p_GetLine(), and Isis::TextFile::p_stream.

Referenced by GetLine(), and p_GetLine().

◆ p_GetLine() [2/2]

bool Isis::TextFile::p_GetLine ( QString & line,
bool chkComment )
protectedinherited

Gets next line from file.

Returns True if read a line, False if End Of File.

Parameters
lineLine read from file, with newline removed.
chkCommentTrue=Skip Comment Lines, False=Return All Lines.
Returns
bool
Exceptions
Isis::IException::Io- error reading text file

References _FILEINFO_, Isis::IException::Io, Isis::TextFile::OpenChk(), Isis::TextFile::p_commentString, Isis::TextFile::p_filename, Isis::TextFile::p_GetLine(), and Isis::TextFile::p_stream.

Referenced by Isis::TextFile::GetLine(), Isis::TextFile::GetLine(), Isis::TextFile::GetLineNoFilter(), Isis::TextFile::GetLineNoFilter(), and Isis::TextFile::p_GetLine().

◆ PutFile() [1/2]

void Isis::TextFile::PutFile ( const QString * lines,
const int & maxLinesToWrite )
inherited

◆ PutFile() [2/2]

void Isis::TextFile::PutFile ( std::vector< QString > & lines,
const int & maxLinesToWrite = 0 )
inherited

◆ PutLine() [1/2]

void Isis::TextFile::PutLine ( const char * line = "")
inherited

Writes char string to file and appends a 'newline' string.

See SetNewLine method.

Parameters
lineChar string to be written to file.Defaults to ""
Exceptions
Isis::IException::Io- error writing text to file
Isis::IException::Programmer- input is read only text file, cannot write to file

References _FILEINFO_, Isis::IException::Io, Isis::TextFile::OpenChk(), Isis::TextFile::p_filename, Isis::TextFile::p_newLineString, Isis::TextFile::p_openmode, Isis::TextFile::p_stream, and Isis::IException::Programmer.

◆ PutLine() [2/2]

void Isis::TextFile::PutLine ( const QString & line)
inherited

Writes string to file and appends a 'newline' string.

See SetNewLine method.

Parameters
lineIString to be written to file. Defaults to ""

References Isis::TextFile::PutLine().

Referenced by Isis::TextFile::PutFile(), Isis::TextFile::PutFile(), Isis::TextFile::PutLine(), Isis::TextFile::PutLineComment(), and Isis::TextFile::PutLineComment().

◆ PutLineComment() [1/2]

void Isis::TextFile::PutLineComment ( const char * line = "")
inherited

Writes char string to file, prepends a 'comment' string and appends a 'newline' string.

See SetComment method and SetNewLine method.

Parameters
lineChar string to be written to file.Defaults to ""

References Isis::TextFile::p_commentString, and Isis::TextFile::PutLine().

◆ PutLineComment() [2/2]

void Isis::TextFile::PutLineComment ( const QString & line)
inherited

Writes string to file, prepends a 'comment' string and appends a 'newline' string.

See SetComment method and SetNewLine method.

Parameters
lineIString to be written to file.Defaults to ""

References Isis::TextFile::p_commentString, and Isis::TextFile::PutLine().

◆ Rewind()

void Isis::TextFile::Rewind ( )
inherited

Sets Read / Write pointer to begining of opened file.

References Isis::TextFile::OpenChk(), and Isis::TextFile::p_stream.

◆ SetComment()

void Isis::TextFile::SetComment ( const char * commentString = "#")
inherited

Sets the 'comment' string.

Default = '#' See ReadFilter method. Skips lines that begin with this string. See PutLineComment method. Prepends 'comment' string to output line.

Parameters
commentStringThe string of characters to be used for 'comment' lines. Defaults to "#"

References Isis::TextFile::p_commentString.

Referenced by Isis::TextFile::TextFile(), Isis::TextFile::TextFile(), and Isis::TextFile::TextFile().

◆ SetNewLine()

void Isis::TextFile::SetNewLine ( const char * newLineString = "\n")
inherited

Sets the 'newline' string.

Default = '
'. See PutLine and PutLineComment methods. Appends 'newline' string to output line.

Parameters
newLineStringThe string of characters to be used for 'comment' lines. Defaults to "\n"

References Isis::TextFile::p_newLineString.

Referenced by Isis::TextFile::TextFile(), Isis::TextFile::TextFile(), and Isis::TextFile::TextFile().

◆ Size()

streamsize Isis::TextFile::Size ( )
inherited

Counts number of bytes in file.

Returns
streamsize

References Isis::TextFile::OpenChk(), and Isis::TextFile::p_stream.

Member Data Documentation

◆ p_begindataFound

bool Isis::CisscalFile::p_begindataFound
protected

Referenced by CisscalFile(), and p_GetLine().

◆ p_commentString

QString Isis::TextFile::p_commentString
protectedinherited

◆ p_filename

QString Isis::TextFile::p_filename
protectedinherited

◆ p_newLineString

QString Isis::TextFile::p_newLineString
protectedinherited

'newline' string used by PutLine and PutLineComment

Referenced by Isis::TextFile::GetNewLine(), Isis::TextFile::PutLine(), and Isis::TextFile::SetNewLine().

◆ p_openmode

int Isis::TextFile::p_openmode
protectedinherited

openmode of file: Input, Output, Overwrite, Append

Referenced by Isis::TextFile::Open(), Isis::TextFile::PutLine(), Isis::TextFile::TextFile(), and Isis::TextFile::TextFile().

◆ p_stream


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