FFStream Class Reference
[Formatted file I/O]

#include <FFStream.hpp>

Inheritance diagram for FFStream:

Inheritance graph
[legend]
Collaboration diagram for FFStream:

Collaboration graph
[legend]
List of all members.

Detailed Description

Formatted File Stream (FFStream).

This is just a root class to provide the single point formatted i/o operators (such as '<<' & '>>' ).

As a special design consideration, all exceptions thrown are based on gpstk::Exception - all std::exception throws are rethrown as gpstk::Exception. Furthermore, exceptions will not be thrown unless exceptions are set to be thrown:

 fs.exceptions(std::fstream::failbit);
where fs is the name of your file stream. Then when an exception occurs, conditionalThrow() will throw the last thrown exception. Otherwise when an exception occurs, the stream sets ios::fail and will not read any more. Exceptions for this class store the record number of the file for when the exception occurred as well as the file name and any detailed information about the error. For gpstk::FFTextStream, the line number of the file where the error was found is also recorded, allowing for easy location of file problems.

When operating on the file, recordNumber will automatically increment with each read and write operation. When a file is opened with the constructor or with open(), all internal FFStream variables are reset. Derived classes should make sure any of their internal variables are reset when either of those function are called.

Many file types have header data as part of the file format. When reading the file, the reader is not required to explicitly read in the header to access the data. To facilitate this, each of these stream classes has an internal header object that will store the header. The stream keeps track of whether it read the header or not, and reads the header if the internal state says it hasn't been read. When writing a file, the stream's internal header is used for those formats which use header information to determine what data is in the records. See RinexObsHeader::reallyGetRecord() and RinexObsData::reallyGetRecord() for an example of this.

See also:
FFData for more information

RinexObsData::reallyGetRecord() and RinexObsHeader::reallyGetRecord() for more information for files that read header data.

Warning:
When using open(), the internal header data of the stream is not guaranteed to be retained.

Definition at line 130 of file FFStream.hpp.

Public Member Functions

virtual ~FFStream (void)
 Virtual destructor.
 FFStream ()
 Default constructor.
 FFStream (const char *fn, std::ios::openmode mode=std::ios::in)
 Common constructor.
 FFStream (const std::string &fn, std::ios::openmode mode=std::ios::in)
 Common constructor.
virtual void open (const char *fn, std::ios::openmode mode)
 Overrides fstream:open so derived classes can make appropriate internal changes (line count, header info, etc).
virtual void open (const std::string &fn, std::ios::openmode mode)
 Overrides fstream:open so derived classes can make appropriate internal changes (line count, header info, etc).
void dumpState (std::ostream &s=std::cout) const
 A function to help debug FFStreams.
void conditionalThrow (void) throw (FFStreamError)
 Throws mostRecentException only if the stream is enabled to throw exceptions when failbit is set.

Static Public Member Functions

bool IsFFStream (std::istream &i)
 Check if the input stream is the kind of RinexObsStream.

Public Attributes

Data members
This stores the most recently thrown exception.

FFStreamError mostRecentException
unsigned int recordNumber
 keeps track of the number of records read
std::string filename
 file name

Protected Member Functions

virtual void tryFFStreamGet (FFData &rec) throw (FFStreamError, gpstk::StringUtils::StringException)
 Encapsulates shared try/catch blocks for all file types to hide std::exception.
virtual void tryFFStreamPut (const FFData &rec) throw (FFStreamError, gpstk::StringUtils::StringException)
 Encapsulates shared try/catch blocks for all file types to hide std::exception.

Friends

class FFData
 FFData is a friend so it can access the try* functions.


Constructor & Destructor Documentation

virtual ~FFStream void   )  [inline, virtual]
 

Virtual destructor.

Definition at line 135 of file FFStream.hpp.

FFStream  )  [inline]
 

Default constructor.

Definition at line 141 of file FFStream.hpp.

FFStream const char *  fn,
std::ios::openmode  mode = std::ios::in
[inline]
 

Common constructor.

Parameters:
fn file name.
mode file open mode (std::ios)

Definition at line 150 of file FFStream.hpp.

FFStream const std::string &  fn,
std::ios::openmode  mode = std::ios::in
[inline]
 

Common constructor.

Parameters:
fn file name.
mode file open mode (std::ios)

Definition at line 160 of file FFStream.hpp.


Member Function Documentation

void conditionalThrow void   )  throw (FFStreamError) [inline]
 

Throws mostRecentException only if the stream is enabled to throw exceptions when failbit is set.

You can set this behavior with the following line of code:

 ffstreamobject.exceptions(ifstream::failbit);
where ffstreamobject is the name of your stream object.

Definition at line 193 of file FFStream.hpp.

void dumpState std::ostream &  s = std::cout  )  const
 

A function to help debug FFStreams.

Definition at line 68 of file FFStream.cpp.

References FFStream::filename.

Referenced by gpstk::operator>>().

bool IsFFStream std::istream &  i  )  [inline, static]
 

Check if the input stream is the kind of RinexObsStream.

Definition at line 204 of file FFStream.hpp.

virtual void open const std::string &  fn,
std::ios::openmode  mode
[inline, virtual]
 

Overrides fstream:open so derived classes can make appropriate internal changes (line count, header info, etc).

Reimplemented in FFTextStream, Rinex3ClockStream, Rinex3ObsStream, and RinexObsStream.

Definition at line 176 of file FFStream.hpp.

void open const char *  fn,
std::ios::openmode  mode
[virtual]
 

Overrides fstream:open so derived classes can make appropriate internal changes (line count, header info, etc).

Reimplemented in AntexStream, AshtechStream, ATSStream, MDPStream, NovatelStream, BinexStream, FFBinaryStream, FFTextStream, FICAStream, FICStream, IonexStream, Rinex3ClockStream, Rinex3NavStream, Rinex3ObsStream, RinexClockStream, RinexMetStream, RinexNavStream, RinexObsStream, SEMStream, SMODFStream, SP3Stream, and YumaStream.

Definition at line 55 of file FFStream.cpp.

References FFStream::filename, and FFStream::recordNumber.

void tryFFStreamGet FFData rec  )  throw (FFStreamError, gpstk::StringUtils::StringException) [protected, virtual]
 

Encapsulates shared try/catch blocks for all file types to hide std::exception.

Reimplemented in FFTextStream.

Definition at line 95 of file FFStream.cpp.

References FILE_LOCATION, and GPSTK_RETHROW.

void tryFFStreamPut const FFData rec  )  throw (FFStreamError, gpstk::StringUtils::StringException) [protected, virtual]
 

Encapsulates shared try/catch blocks for all file types to hide std::exception.

Reimplemented in FFTextStream.

Definition at line 210 of file FFStream.cpp.

References FILE_LOCATION, and GPSTK_RETHROW.


Friends And Related Function Documentation

friend class FFData [friend]
 

FFData is a friend so it can access the try* functions.

Definition at line 236 of file FFStream.hpp.


Member Data Documentation

std::string filename
 

file name

Definition at line 230 of file FFStream.hpp.

Referenced by FFStream::dumpState(), and FFStream::open().

FFStreamError mostRecentException
 

Definition at line 222 of file FFStream.hpp.

unsigned int recordNumber
 

keeps track of the number of records read

Definition at line 226 of file FFStream.hpp.

Referenced by main(), FFStream::open(), MDPHeader::reallyGetRecord(), FICData::reallyGetRecord(), and ATSData::reallyGetRecord().


The documentation for this class was generated from the following files:
Generated on Sat May 18 03:31:44 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1