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

IffInputFile Class Reference

A wrapper around an istream used for reading an IFF file. More...

#include <iffInputFile.h>

Inheritance diagram for IffInputFile:

TypedObject LwoInputFile List of all members.

Public Member Functions

 IffInputFile ()
virtual ~IffInputFile ()
bool open_read (Filename filename)
 Attempts to open the indicated filename for reading.

void set_input (istream *input, bool owns_istream)
 Sets up the input to use an arbitrary istream.

void set_filename (const Filename &filename)
 Indicates the filename that the InputFile is currently opened on.

const Filenameget_filename () const
 Returns the filename that the InputFile is currently opened on, if available.

bool is_eof () const
 Returns true if the last read operation failed because of reaching EOF, false otherwise.

size_t get_bytes_read () const
 Returns the number of bytes read so far from the input file.

void align ()
 If the current file pointer is not positioned on an even-byte boundary, reads and discards one byte so that it is.

PN_int8 get_int8 ()
 Extracts a signed 8-bit integer.

PN_uint8 get_uint8 ()
 Extracts an unsigned 8-bit integer.

PN_int16 get_be_int16 ()
 Extracts a signed 16-bit big-endian integer.

PN_int32 get_be_int32 ()
 Extracts a signed 32-bit big-endian integer.

PN_uint16 get_be_uint16 ()
 Extracts an unsigned 16-bit big-endian integer.

PN_uint32 get_be_uint32 ()
 Extracts an unsigned 32-bit big-endian integer.

float get_be_float32 ()
 Extracts a 32-bit big-endian single-precision floating-point number.

string get_string ()
 Extracts a null-terminated string.

IffId get_id ()
 Extracts a 4-character IFF ID.

PointerTo< IffChunkget_chunk ()
 Reads a single IffChunk, determining its type based on its ID.

PointerTo< IffChunkget_subchunk (IffChunk *context)
 Similar to get_chunk(), except the chunk size is only a 16-bit number instead of 32-bit, and it takes a context, which is the chunk in which this chunk is encountered.

bool read_byte (char &byte)
 Reads a single byte.

bool read_bytes (Datagram &datagram, int length)
 Reads a series of bytes, and stores them in the indicated Datagram.

bool skip_bytes (int length)
 Reads a series of bytes, but does not store them.

virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
int get_type_index () const
bool is_of_type (TypeHandle handle) const
bool is_exact_type (TypeHandle handle) const

Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()

Protected Member Functions

virtual IffChunkmake_new_chunk (IffId id)
 Allocates and returns a new chunk of the appropriate type based on the given ID.


Protected Attributes

istream * _input
Filename _filename
bool _owns_istream
bool _eof
bool _unexpected_eof
size_t _bytes_read

Static Private Attributes

TypeHandle _type_handle

Friends

class IffChunk

Detailed Description

A wrapper around an istream used for reading an IFF file.

Definition at line 44 of file iffInputFile.h.


Constructor & Destructor Documentation

IffInputFile::IffInputFile  ) 
 

Definition at line 38 of file iffInputFile.cxx.

References _bytes_read.

IffInputFile::~IffInputFile  )  [virtual]
 

Definition at line 54 of file iffInputFile.cxx.

References Filename::open_read(), Filename::set_binary(), set_filename(), and set_input().


Member Function Documentation

void IffInputFile::align  )  [inline]
 

If the current file pointer is not positioned on an even-byte boundary, reads and discards one byte so that it is.

Definition at line 96 of file iffInputFile.I.

virtual TypeHandle IffInputFile::force_init_type void   )  [inline, virtual]
 

Implements TypedObject.

Reimplemented in LwoInputFile.

Definition at line 94 of file iffInputFile.h.

float IffInputFile::get_be_float32  ) 
 

Extracts a 32-bit big-endian single-precision floating-point number.

Definition at line 226 of file iffInputFile.cxx.

Referenced by LwoVertexMap::get_value().

PN_int16 IffInputFile::get_be_int16  ) 
 

Extracts a signed 16-bit big-endian integer.

Definition at line 152 of file iffInputFile.cxx.

References DatagramIterator::get_be_uint16(), PN_uint16, and read_bytes().

Referenced by LwoPolygonTags::get_tag().

PN_int32 IffInputFile::get_be_int32  ) 
 

Extracts a signed 32-bit big-endian integer.

Definition at line 170 of file iffInputFile.cxx.

References DatagramIterator::get_be_uint32(), PN_uint32, and read_bytes().

PN_uint16 IffInputFile::get_be_uint16  ) 
 

Extracts an unsigned 16-bit big-endian integer.

Definition at line 188 of file iffInputFile.cxx.

References DatagramIterator::get_be_float32(), and read_bytes().

Referenced by get_chunk(), LwoPolygons::get_polygon(), LwoVertexMap::get_value(), LwoLayer::make_generic(), and LwoInputFile::~LwoInputFile().

PN_uint32 IffInputFile::get_be_uint32  ) 
 

Extracts an unsigned 32-bit big-endian integer.

Definition at line 206 of file iffInputFile.cxx.

size_t IffInputFile::get_bytes_read  )  const [inline]
 

Returns the number of bytes read so far from the input file.

Definition at line 79 of file iffInputFile.I.

Referenced by LwoGroupChunk::get_chunk(), get_chunk(), LwoPoints::get_point(), LwoPolygons::get_polygon(), LwoTags::get_tag(), LwoPolygonTags::get_tag(), LwoVertexMap::get_value(), LwoLayer::make_generic(), and LwoGroupChunk::read_chunks_iff().

PointerTo< IffChunk > IffInputFile::get_chunk  ) 
 

Reads a single IffChunk, determining its type based on its ID.

Allocates and returns a new IffChunk object of the appropriate type. Returns NULL if EOF is reached before the chunk can be read completely, or if there is some other error in reading the chunk.

Definition at line 293 of file iffInputFile.cxx.

References _unexpected_eof, get_be_uint16(), get_bytes_read(), get_id(), is_eof(), length, IffChunk::make_new_chunk(), nout, NULL, PN_uint16, PT, size_t, and skip_bytes().

Referenced by LwoGroupChunk::get_chunk().

TypeHandle IffInputFile::get_class_type void   )  [inline, static]
 

Reimplemented from TypedObject.

Reimplemented in LwoInputFile.

Definition at line 95 of file iffInputFile.h.

const Filename & IffInputFile::get_filename  )  const [inline]
 

Returns the filename that the InputFile is currently opened on, if available.

Definition at line 49 of file iffInputFile.I.

References _eof.

IffId IffInputFile::get_id void   ) 
 

Extracts a 4-character IFF ID.

Definition at line 267 of file iffInputFile.cxx.

References length, nout, and NULL.

Referenced by get_chunk(), LwoPolygons::get_polygon(), LwoPolygonTags::get_tag(), LwoVertexMap::get_value(), and LwoHeader::LwoHeader().

PN_int8 IffInputFile::get_int8  ) 
 

Extracts a signed 8-bit integer.

Definition at line 116 of file iffInputFile.cxx.

Referenced by is_eof().

string IffInputFile::get_string  ) 
 

Extracts a null-terminated string.

Definition at line 244 of file iffInputFile.cxx.

References NULL.

Referenced by LwoTags::get_tag(), LwoVertexMap::get_value(), LwoInputFile::get_vec3(), and LwoLayer::make_generic().

PointerTo< IffChunk > IffInputFile::get_subchunk IffChunk context  ) 
 

Similar to get_chunk(), except the chunk size is only a 16-bit number instead of 32-bit, and it takes a context, which is the chunk in which this chunk is encountered.

The parent chunk may (or may not) decide what kind of chunk is meant by the various id's encountered.

Definition at line 355 of file iffInputFile.cxx.

Referenced by LwoGroupChunk::read_chunks_iff().

virtual TypeHandle IffInputFile::get_type void   )  const [inline, virtual]
 

Implements TypedObject.

Reimplemented in LwoInputFile.

Definition at line 91 of file iffInputFile.h.

References _type_handle, TypedObject::init_type(), and register_type().

PN_uint8 IffInputFile::get_uint8  ) 
 

Extracts an unsigned 8-bit integer.

Definition at line 134 of file iffInputFile.cxx.

void IffInputFile::init_type void   )  [inline, static]
 

Reimplemented from TypedObject.

Reimplemented in LwoInputFile.

Definition at line 98 of file iffInputFile.h.

References _type_handle.

Referenced by ConfigureFn(), and LwoInputFile::get_type().

bool IffInputFile::is_eof  )  const [inline]
 

Returns true if the last read operation failed because of reaching EOF, false otherwise.

Definition at line 64 of file iffInputFile.I.

References _bytes_read, get_int8(), and INLINE.

Referenced by LwoGroupChunk::get_chunk(), get_chunk(), LwoPoints::get_point(), LwoPolygons::get_polygon(), LwoTags::get_tag(), LwoPolygonTags::get_tag(), LwoVertexMap::get_value(), and LwoGroupChunk::read_chunks_iff().

IffChunk * IffInputFile::make_new_chunk IffId  id  )  [protected, virtual]
 

Allocates and returns a new chunk of the appropriate type based on the given ID.

Reimplemented in LwoInputFile.

Definition at line 487 of file iffInputFile.cxx.

Referenced by IffChunk::write().

bool IffInputFile::open_read Filename  filename  ) 
 

Attempts to open the indicated filename for reading.

Returns true if successful, false otherwise.

Definition at line 71 of file iffInputFile.cxx.

References _bytes_read, _eof, _input, _owns_istream, and _unexpected_eof.

bool IffInputFile::read_byte char &  byte  ) 
 

Reads a single byte.

Returns true if successful, false otherwise.

Definition at line 409 of file iffInputFile.cxx.

bool IffInputFile::read_bytes Datagram datagram,
int  length
 

Reads a series of bytes, and stores them in the indicated Datagram.

Returns true if successful, false otherwise.

Definition at line 433 of file iffInputFile.cxx.

Referenced by get_be_int16(), get_be_int32(), get_be_uint16(), and set_input().

void IffInputFile::set_filename const Filename filename  )  [inline]
 

Indicates the filename that the InputFile is currently opened on.

Definition at line 34 of file iffInputFile.I.

References _filename, and INLINE.

Referenced by ~IffInputFile().

void IffInputFile::set_input istream *  input,
bool  owns_istream
 

Sets up the input to use an arbitrary istream.

If owns_istream is true, the istream will be deleted when the IffInputFile destructs.

Definition at line 96 of file iffInputFile.cxx.

References DatagramIterator::get_int8(), PN_int8, and read_bytes().

Referenced by ~IffInputFile().

bool IffInputFile::skip_bytes int  length  ) 
 

Reads a series of bytes, but does not store them.

Returns true if successful, false otherwise.

Definition at line 462 of file iffInputFile.cxx.

Referenced by get_chunk().


Friends And Related Function Documentation

friend class IffChunk [friend]
 

Definition at line 107 of file iffInputFile.h.


Member Data Documentation

size_t IffInputFile::_bytes_read [protected]
 

Definition at line 88 of file iffInputFile.h.

Referenced by IffInputFile(), is_eof(), and open_read().

bool IffInputFile::_eof [protected]
 

Definition at line 86 of file iffInputFile.h.

Referenced by get_filename(), and open_read().

Filename IffInputFile::_filename [protected]
 

Definition at line 84 of file iffInputFile.h.

Referenced by set_filename().

istream* IffInputFile::_input [protected]
 

Definition at line 83 of file iffInputFile.h.

Referenced by open_read().

bool IffInputFile::_owns_istream [protected]
 

Definition at line 85 of file iffInputFile.h.

Referenced by open_read().

TypeHandle IffInputFile::_type_handle [static, private]
 

Reimplemented from TypedObject.

Reimplemented in LwoInputFile.

Definition at line 28 of file iffInputFile.cxx.

Referenced by get_type(), and init_type().

bool IffInputFile::_unexpected_eof [protected]
 

Definition at line 87 of file iffInputFile.h.

Referenced by get_chunk(), and open_read().


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