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

DatagramInputFile Class Reference

This class can be used to read a binary file that consists of an arbitrary header followed by a number of datagrams. More...

#include <datagramInputFile.h>

Inheritance diagram for DatagramInputFile:

DatagramGenerator List of all members.

Public Member Functions

 DatagramInputFile ()
bool open (Filename filename)
 Opens the indicated filename for reading.

bool read_header (string &header, size_t num_bytes)
 Reads a sequence of bytes from the beginning of the datagram file.

virtual bool get_datagram (Datagram &data)
 Reads the next datagram from the file.

virtual bool is_eof ()
 Returns true if the file has reached the end-of-file.

virtual bool is_error ()
 Returns true if the file has reached an error condition.

void close ()
 Closes the file.


Private Attributes

bool _read_first_datagram
bool _error
ifstream _in_file
istream * _in
bool _owns_in

Detailed Description

This class can be used to read a binary file that consists of an arbitrary header followed by a number of datagrams.

Definition at line 41 of file datagramInputFile.h.


Constructor & Destructor Documentation

DatagramInputFile::DatagramInputFile  )  [inline]
 

Definition at line 31 of file datagramInputFile.I.


Member Function Documentation

void DatagramInputFile::close  )  [inline]
 

Closes the file.

This is also implicitly done when the DatagramInputFile destructs.

Definition at line 49 of file datagramInputFile.I.

bool DatagramInputFile::get_datagram Datagram data  )  [virtual]
 

Reads the next datagram from the file.

Returns true on success, false if there is an error or end of file.

Implements DatagramGenerator.

Definition at line 117 of file datagramInputFile.cxx.

References _error, _in, and PN_uint32.

bool DatagramInputFile::is_eof  )  [virtual]
 

Returns true if the file has reached the end-of-file.

This test may only be made after a call to read_header() or get_datagram() has failed.

Implements DatagramGenerator.

Definition at line 173 of file datagramInputFile.cxx.

bool DatagramInputFile::is_error  )  [virtual]
 

Returns true if the file has reached an error condition.

Implements DatagramGenerator.

Definition at line 188 of file datagramInputFile.cxx.

bool DatagramInputFile::open Filename  filename  ) 
 

Opens the indicated filename for reading.

Returns true if successful, false on failure.

Definition at line 48 of file datagramInputFile.cxx.

References NULL.

bool DatagramInputFile::read_header string &  header,
size_t  num_bytes
 

Reads a sequence of bytes from the beginning of the datagram file.

This may be called any number of times after the file has been opened and before the first datagram is read. It may not be called once the first datagram has been read.

Definition at line 89 of file datagramInputFile.cxx.

References _in, _read_first_datagram, and PN_uint32.


Member Data Documentation

bool DatagramInputFile::_error [private]
 

Definition at line 56 of file datagramInputFile.h.

Referenced by get_datagram().

istream* DatagramInputFile::_in [private]
 

Definition at line 58 of file datagramInputFile.h.

Referenced by get_datagram(), and read_header().

ifstream DatagramInputFile::_in_file [private]
 

Definition at line 57 of file datagramInputFile.h.

bool DatagramInputFile::_owns_in [private]
 

Definition at line 59 of file datagramInputFile.h.

bool DatagramInputFile::_read_first_datagram [private]
 

Definition at line 55 of file datagramInputFile.h.

Referenced by read_header().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:49:10 2003 for Panda by doxygen1.3