Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

FltRecordReader Class Reference

This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extracting the opcode from each one. More...

#include <fltRecordReader.h>

List of all members.

Public Member Functions

 FltRecordReader (istream &in)
 ~FltRecordReader ()
FltOpcode get_opcode () const
 Returns the opcode associated with the current record.

DatagramIteratorget_iterator ()
 Returns an iterator suitable for extracting data from the current record.

const Datagramget_datagram ()
 Returns the datagram representing the entire record, less the four-byte header.

int get_record_length () const
 Returns the entire length of the record, including the four-byte header.

FltError advance (bool ok_eof=false)
 Extracts the next record from the file.

bool eof () const
 Returns true if end-of-file has been reached without error.

bool error () const
 Returns true if some error has been encountered while reading (for instance, a truncated file).


Private Types

enum  State { S_begin, S_normal, S_eof, S_error }

Private Member Functions

void read_next_header ()
 Reads the four-byte header for the next record, which contains the next opcode and record length.


Private Attributes

istream & _in
Datagram _datagram
FltOpcode _opcode
int _record_length
DatagramIterator_iterator
FltError _next_error
FltOpcode _next_opcode
int _next_record_length
State _state


Detailed Description

This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extracting the opcode from each one.

It remembers where it is in the file and what the current record is.

Definition at line 48 of file fltRecordReader.h.


Member Enumeration Documentation

enum FltRecordReader::State [private]
 

Enumeration values:
S_begin 
S_normal 
S_eof 
S_error 

Definition at line 76 of file fltRecordReader.h.


Constructor & Destructor Documentation

FltRecordReader::FltRecordReader istream &  in  ) 
 

Definition at line 37 of file fltRecordReader.cxx.

References FE_ok, FO_none, and NULL.

FltRecordReader::~FltRecordReader  ) 
 

Definition at line 60 of file fltRecordReader.cxx.

References _opcode, _state, FltOpcode, FO_none, nassertr, and S_normal.


Member Function Documentation

FltError FltRecordReader::advance bool  ok_eof = false  ) 
 

Extracts the next record from the file.

Returns true if there is another record, or false if the end of file has been reached.

Definition at line 146 of file fltRecordReader.cxx.

References _next_opcode, _next_record_length, _opcode, and _record_length.

bool FltRecordReader::eof  )  const
 

Returns true if end-of-file has been reached without error.

Definition at line 256 of file fltRecordReader.cxx.

References _next_error, and FE_end_of_file.

bool FltRecordReader::error  )  const
 

Returns true if some error has been encountered while reading (for instance, a truncated file).

Definition at line 271 of file fltRecordReader.cxx.

References _next_error, and FE_invalid_record.

const Datagram & FltRecordReader::get_datagram void   ) 
 

Returns the datagram representing the entire record, less the four-byte header.

Definition at line 110 of file fltRecordReader.cxx.

References _iterator, _state, FE_end_of_file, FE_read_error, flt_error_abort, FltError, NULL, S_eof, and S_error.

DatagramIterator & FltRecordReader::get_iterator  ) 
 

Returns an iterator suitable for extracting data from the current record.

Definition at line 94 of file fltRecordReader.cxx.

References _iterator.

FltOpcode FltRecordReader::get_opcode  )  const
 

Returns the opcode associated with the current record.

Definition at line 78 of file fltRecordReader.cxx.

References _iterator, _state, nassertr, and S_normal.

int FltRecordReader::get_record_length  )  const
 

Returns the entire length of the record, including the four-byte header.

Definition at line 129 of file fltRecordReader.cxx.

References _iterator, and NULL.

void FltRecordReader::read_next_header  )  [private]
 

Reads the four-byte header for the next record, which contains the next opcode and record length.

We need read the next header in advance so we can check to see if it happens to be a continuation record. If it is, we will need to concatenate the records together before returning.

Definition at line 296 of file fltRecordReader.cxx.


Member Data Documentation

Datagram FltRecordReader::_datagram [private]
 

Definition at line 67 of file fltRecordReader.h.

istream& FltRecordReader::_in [private]
 

Definition at line 66 of file fltRecordReader.h.

DatagramIterator* FltRecordReader::_iterator [private]
 

Definition at line 70 of file fltRecordReader.h.

Referenced by get_datagram(), get_iterator(), get_opcode(), and get_record_length().

FltError FltRecordReader::_next_error [private]
 

Definition at line 72 of file fltRecordReader.h.

Referenced by eof(), and error().

FltOpcode FltRecordReader::_next_opcode [private]
 

Definition at line 73 of file fltRecordReader.h.

Referenced by advance().

int FltRecordReader::_next_record_length [private]
 

Definition at line 74 of file fltRecordReader.h.

Referenced by advance().

FltOpcode FltRecordReader::_opcode [private]
 

Definition at line 68 of file fltRecordReader.h.

Referenced by advance(), and ~FltRecordReader().

int FltRecordReader::_record_length [private]
 

Definition at line 69 of file fltRecordReader.h.

Referenced by advance().

State FltRecordReader::_state [private]
 

Definition at line 82 of file fltRecordReader.h.

Referenced by get_datagram(), get_opcode(), and ~FltRecordReader().


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:26:54 2003 for Panda-Tool by doxygen1.3