USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::CisscalFile Class Reference
[Cassini]

#include <CisscalFile.h>

Inheritance diagram for Isis::CisscalFile:

Inheritance graph
[legend]
Collaboration diagram for Isis::CisscalFile:

Collaboration graph
[legend]
List of all members.

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
History:
2008-03-27 Jeannie Walldren - Original Version.

Definition at line 44 of file CisscalFile.h.

Public Member Functions

 CisscalFile (const string &filename, const char *openmode="input", const char *extension="")
 Constructs a CisscalFile object and opens the specified file (including path).
 ~CisscalFile ()
bool GetLine (string &line)
 Get next line of valid data.
void Open (const std::string &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< std::string > &lines, const int &maxLinesToRead=0, const bool skipComments=true)
void GetFile (std::string *lines, const int &maxLinesToRead, const bool skipComments=true)
void PutFile (std::vector< std::string > &lines, const int &maxLinesToWrite=0)
void PutFile (const std::string *lines, const int &maxLinesToWrite)
bool GetLine (std::string &line, const bool skipComments=true)
 Gets next line from file.
bool GetLine (const bool skipComments=true)
 Gets next line from file.
bool GetLineNoFilter (std::string &line)
 Gets next NON-COMMENT line from file.
bool GetLineNoFilter ()
 Gets next NON-COMMENT line from file.
void PutLine (const std::string &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 std::string &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.
std::string GetComment ()
std::string 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 (string &line)
 Get next line of valid data, protected.
bool p_GetLine (std::string &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
std::string p_filename
 Filename of the opened file.
std::string p_commentString
 'comment' string used by GetLine and PutLineComment
std::string p_newLineString
 'newline' string used by PutLine and PutLineComment


Constructor & Destructor Documentation

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

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

Parameters:
filename Filename (including path) to be opened by TextFile object.
openmode Open 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".
extension Extension to be added to filename (added only if not already on filename). Defaults to ""

Definition at line 59 of file CisscalFile.cpp.

References p_begindataFound.


Member Function Documentation

void Isis::TextFile::Close (  )  [inherited]

Closes file. Called automatically by TextFile destructor.

Definition at line 319 of file TextFile.cpp.

References Isis::TextFile::p_stream.

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

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:
skipComments Controls whether comments lines are filtered; true=filter, false=return any line read from fileDefaults to true
Returns:
bool

Definition at line 409 of file TextFile.cpp.

References line, and Isis::TextFile::p_GetLine().

bool Isis::TextFile::GetLine ( std::string &  line,
const bool  skipComments = true 
) [inherited]

Gets next line from file.

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

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

Definition at line 396 of file TextFile.cpp.

References Isis::TextFile::p_GetLine().

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

bool Isis::CisscalFile::GetLine ( string &  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:
line String 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()

Definition at line 122 of file CisscalFile.cpp.

References p_GetLine().

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

Definition at line 432 of file TextFile.cpp.

References line, and Isis::TextFile::p_GetLine().

bool Isis::TextFile::GetLineNoFilter ( std::string &  line  )  [inherited]

Gets next NON-COMMENT line from file.

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

Parameters:
line Line read from file, with newline removed.
Returns:
bool

Definition at line 422 of file TextFile.cpp.

References Isis::TextFile::p_GetLine().

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

Counts number of lines in file.

Parameters:
maxLinesToRead Limits 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

Definition at line 591 of file TextFile.cpp.

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

Referenced by Isis::UserInterface::LoadBatchList().

void Isis::TextFile::Open ( const std::string &  filename,
const char *  openmode = "input",
const char *  extension = "" 
) [inherited]

Opens a text file.

Parameters:
filename Filename (including path) to be opened.
openmode Open Mode of file to be opened. InputOpens file for Input: Read Only OutputOpens file for Output: Read / Write - Truncates if file exists. AppendOpens file for Append: Read / Write - Appends if file exists.Defaults to "input"
extension Extension 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

Definition at line 224 of file TextFile.cpp.

References _FILEINFO_, Isis::Filename::AddExtension(), Isis::Filename::Expanded(), in, Isis::iException::Message(), Isis::TextFile::p_filename, Isis::TextFile::p_openmode, and Isis::TextFile::p_stream.

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

bool Isis::TextFile::p_GetLine ( std::string &  line,
bool  chkComment 
) [protected, inherited]

Gets next line from file.

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

Parameters:
line Line read from file, with newline removed.
chkComment True=Skip Comment Lines, False=Return All Lines.
Returns:
bool
Exceptions:
Isis::iException::Io - error reading text file

Definition at line 448 of file TextFile.cpp.

References _FILEINFO_, Isis::iException::Message(), Isis::TextFile::OpenChk(), Isis::TextFile::p_commentString, Isis::TextFile::p_filename, and Isis::TextFile::p_stream.

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

bool Isis::CisscalFile::p_GetLine ( string &  line  )  [protected]

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:
line String 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()

Definition at line 77 of file CisscalFile.cpp.

References _FILEINFO_, Isis::iException::Message(), Isis::TextFile::OpenChk(), p_begindataFound, Isis::TextFile::p_filename, and Isis::TextFile::p_stream.

Referenced by GetLine().

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

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

See SetNewLine method.

Parameters:
line Char 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

Definition at line 504 of file TextFile.cpp.

References _FILEINFO_, Isis::iException::Message(), Isis::TextFile::OpenChk(), Isis::TextFile::p_filename, Isis::TextFile::p_newLineString, Isis::TextFile::p_openmode, and Isis::TextFile::p_stream.

void Isis::TextFile::PutLine ( const std::string &  line  )  [inherited]

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

See SetNewLine method.

Parameters:
line iString to be written to file. Defaults to ""

Definition at line 490 of file TextFile.cpp.

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

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:
line Char string to be written to file.Defaults to ""

Definition at line 543 of file TextFile.cpp.

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

void Isis::TextFile::PutLineComment ( const std::string &  line  )  [inherited]

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

See SetComment method and SetNewLine method.

Parameters:
line iString to be written to file.Defaults to ""

Definition at line 533 of file TextFile.cpp.

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

void Isis::TextFile::Rewind (  )  [inherited]

Sets Read / Write pointer to begining of opened file.

Definition at line 312 of file TextFile.cpp.

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

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:
commentString The string of characters to be used for 'comment' lines. Defaults to "#"

Definition at line 561 of file TextFile.cpp.

References Isis::TextFile::p_commentString.

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

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:
newLineString The string of characters to be used for 'comment' lines. Defaults to "\n"

Definition at line 577 of file TextFile.cpp.

References Isis::TextFile::p_newLineString.

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

streamsize Isis::TextFile::Size (  )  [inherited]

Counts number of bytes in file.

Returns:
streamsize

Definition at line 632 of file TextFile.cpp.

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


Member Data Documentation

std::string Isis::TextFile::p_commentString [protected, inherited]

'comment' string used by GetLine and PutLineComment

Definition at line 54 of file TextFile.h.

Referenced by Isis::TextFile::GetComment(), Isis::TextFile::p_GetLine(), Isis::TextFile::PutLineComment(), and Isis::TextFile::SetComment().

std::string Isis::TextFile::p_filename [protected, inherited]

Filename of the opened file.

Definition at line 53 of file TextFile.h.

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

std::string Isis::TextFile::p_newLineString [protected, inherited]

'newline' string used by PutLine and PutLineComment

Definition at line 56 of file TextFile.h.

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

int Isis::TextFile::p_openmode [protected, inherited]

openmode of file: Input, Output, Overwrite, Append

Definition at line 51 of file TextFile.h.

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

std::fstream Isis::TextFile::p_stream [protected, inherited]

File stream handle.

Definition at line 50 of file TextFile.h.

Referenced by Isis::TextFile::Close(), Isis::TextFile::LineCount(), Isis::TextFile::Open(), Isis::TextFile::OpenChk(), p_GetLine(), Isis::TextFile::p_GetLine(), Isis::TextFile::PutLine(), Isis::TextFile::Rewind(), and Isis::TextFile::Size().


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