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

LwoInputFile Class Reference

A specialization of IffInputFile to handle reading a Lightwave Object file. More...

#include <lwoInputFile.h>

Inheritance diagram for LwoInputFile:

IffInputFile TypedObject List of all members.

Public Member Functions

 LwoInputFile ()
 ~LwoInputFile ()
double get_lwo_version () const
 Returns the version of the Lightwave file being read.

void set_lwo_version (double version)
 Changes the version number reported for the Lightwave file.

int get_vx ()
 Reads a Lightwave variable-length index.

LVecBase3f get_vec3 ()
 Reads a three-component vector of floats.

Filename get_filename ()
 Reads a Lightwave platform-neutral filename and converts it to a Panda platform-neutral filename.

virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
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.

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

Private Attributes

double _lwo_version

Static Private Attributes

TypeHandle _type_handle

Detailed Description

A specialization of IffInputFile to handle reading a Lightwave Object file.

Definition at line 40 of file lwoInputFile.h.


Constructor & Destructor Documentation

LwoInputFile::LwoInputFile  ) 
 

Definition at line 45 of file lwoInputFile.cxx.

LwoInputFile::~LwoInputFile  ) 
 

Definition at line 56 of file lwoInputFile.cxx.

References IffInputFile::get_be_uint16(), and PN_uint16.


Member Function Documentation

void IffInputFile::align  )  [inline, inherited]
 

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 LwoInputFile::force_init_type void   )  [inline, virtual]
 

Reimplemented from IffInputFile.

Definition at line 62 of file lwoInputFile.h.

float IffInputFile::get_be_float32  )  [inherited]
 

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  )  [inherited]
 

Extracts a signed 16-bit big-endian integer.

Definition at line 152 of file iffInputFile.cxx.

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

Referenced by LwoPolygonTags::get_tag().

PN_int32 IffInputFile::get_be_int32  )  [inherited]
 

Extracts a signed 32-bit big-endian integer.

Definition at line 170 of file iffInputFile.cxx.

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

PN_uint16 IffInputFile::get_be_uint16  )  [inherited]
 

Extracts an unsigned 16-bit big-endian integer.

Definition at line 188 of file iffInputFile.cxx.

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

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

PN_uint32 IffInputFile::get_be_uint32  )  [inherited]
 

Extracts an unsigned 32-bit big-endian integer.

Definition at line 206 of file iffInputFile.cxx.

size_t IffInputFile::get_bytes_read  )  const [inline, inherited]
 

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(), IffInputFile::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  )  [inherited]
 

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 IffInputFile::_unexpected_eof, IffInputFile::get_be_uint16(), IffInputFile::get_bytes_read(), IffInputFile::get_id(), IffInputFile::is_eof(), length, IffChunk::make_new_chunk(), nout, NULL, PN_uint16, PT, size_t, and IffInputFile::skip_bytes().

Referenced by LwoGroupChunk::get_chunk().

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

Reimplemented from IffInputFile.

Definition at line 63 of file lwoInputFile.h.

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

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

Definition at line 49 of file iffInputFile.I.

References IffInputFile::_eof.

Filename LwoInputFile::get_filename  ) 
 

Reads a Lightwave platform-neutral filename and converts it to a Panda platform-neutral filename.

Definition at line 112 of file lwoInputFile.cxx.

IffId IffInputFile::get_id void   )  [inherited]
 

Extracts a 4-character IFF ID.

Definition at line 267 of file iffInputFile.cxx.

References length, nout, and NULL.

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

PN_int8 IffInputFile::get_int8  )  [inherited]
 

Extracts a signed 8-bit integer.

Definition at line 116 of file iffInputFile.cxx.

Referenced by IffInputFile::is_eof().

double LwoInputFile::get_lwo_version  )  const [inline]
 

Returns the version of the Lightwave file being read.

This is unknown until the header record has been read; then it will be set by the header.

Definition at line 36 of file lwoInputFile.I.

References _lwo_version, and INLINE.

Referenced by LwoPolygons::get_polygon().

string IffInputFile::get_string  )  [inherited]
 

Extracts a null-terminated string.

Definition at line 244 of file iffInputFile.cxx.

References NULL.

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

PointerTo< IffChunk > IffInputFile::get_subchunk IffChunk context  )  [inherited]
 

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 LwoInputFile::get_type void   )  const [inline, virtual]
 

Reimplemented from IffInputFile.

Definition at line 59 of file lwoInputFile.h.

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

PN_uint8 IffInputFile::get_uint8  )  [inherited]
 

Extracts an unsigned 8-bit integer.

Definition at line 134 of file iffInputFile.cxx.

LVecBase3f LwoInputFile::get_vec3  ) 
 

Reads a three-component vector of floats.

Definition at line 93 of file lwoInputFile.cxx.

References Filename, IffInputFile::get_string(), nout, path, and size_t.

Referenced by LwoPoints::get_point(), and LwoLayer::make_generic().

int LwoInputFile::get_vx  ) 
 

Reads a Lightwave variable-length index.

This is either a 2-byte or 4-byte integer.

Definition at line 70 of file lwoInputFile.cxx.

Referenced by LwoPolygonTags::get_tag(), LwoVertexMap::get_value(), and LwoPolygons::read_iff().

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

Reimplemented from IffInputFile.

Definition at line 66 of file lwoInputFile.h.

References _type_handle.

bool IffInputFile::is_eof  )  const [inline, inherited]
 

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

Definition at line 64 of file iffInputFile.I.

References IffInputFile::_bytes_read, IffInputFile::get_int8(), and INLINE.

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

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

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

Reimplemented from IffInputFile.

Definition at line 139 of file lwoInputFile.cxx.

bool IffInputFile::open_read Filename  filename  )  [inherited]
 

Attempts to open the indicated filename for reading.

Returns true if successful, false otherwise.

Definition at line 71 of file iffInputFile.cxx.

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

bool IffInputFile::read_byte char &  byte  )  [inherited]
 

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
[inherited]
 

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 IffInputFile::get_be_int16(), IffInputFile::get_be_int32(), IffInputFile::get_be_uint16(), and IffInputFile::set_input().

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

Indicates the filename that the InputFile is currently opened on.

Definition at line 34 of file iffInputFile.I.

References IffInputFile::_filename, and INLINE.

Referenced by IffInputFile::~IffInputFile().

void IffInputFile::set_input istream *  input,
bool  owns_istream
[inherited]
 

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 IffInputFile::read_bytes().

Referenced by IffInputFile::~IffInputFile().

void LwoInputFile::set_lwo_version double  version  )  [inline]
 

Changes the version number reported for the Lightwave file.

Normally this is only called by LwoHeader as it is read.

Definition at line 54 of file lwoInputFile.I.

Referenced by LwoHeader::read_iff().

bool IffInputFile::skip_bytes int  length  )  [inherited]
 

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 IffInputFile::get_chunk().


Member Data Documentation

size_t IffInputFile::_bytes_read [protected, inherited]
 

Definition at line 88 of file iffInputFile.h.

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

bool IffInputFile::_eof [protected, inherited]
 

Definition at line 86 of file iffInputFile.h.

Referenced by IffInputFile::get_filename(), and IffInputFile::open_read().

Filename IffInputFile::_filename [protected, inherited]
 

Definition at line 84 of file iffInputFile.h.

Referenced by IffInputFile::set_filename().

istream* IffInputFile::_input [protected, inherited]
 

Definition at line 83 of file iffInputFile.h.

Referenced by IffInputFile::open_read().

double LwoInputFile::_lwo_version [private]
 

Definition at line 56 of file lwoInputFile.h.

Referenced by get_lwo_version().

bool IffInputFile::_owns_istream [protected, inherited]
 

Definition at line 85 of file iffInputFile.h.

Referenced by IffInputFile::open_read().

TypeHandle LwoInputFile::_type_handle [static, private]
 

Reimplemented from IffInputFile.

Definition at line 35 of file lwoInputFile.cxx.

Referenced by get_type(), and init_type().

bool IffInputFile::_unexpected_eof [protected, inherited]
 

Definition at line 87 of file iffInputFile.h.

Referenced by IffInputFile::get_chunk(), and IffInputFile::open_read().


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