Panda3D
|
A wrapper around an istream used for reading an IFF file. More...
#include "iffInputFile.h"
Public Member Functions | |
void | align () |
If the current file pointer is not positioned on an even-byte boundary, reads and discards one byte so that it is. | |
virtual TypeHandle | force_init_type () |
PN_stdfloat | get_be_float32 () |
Extracts a 32-bit big-endian single-precision floating-point number. | |
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. | |
size_t | get_bytes_read () const |
Returns the number of bytes read so far from the input file. | |
const Filename & | get_filename () const |
Returns the filename that the InputFile is currently opened on, if available. | |
IffId | get_id () |
Extracts a 4-character IFF ID. | |
PN_int8 | get_int8 () |
Extracts a signed 8-bit integer. | |
string | get_string () |
Extracts a null-terminated string. | |
virtual TypeHandle | get_type () const |
PN_uint8 | get_uint8 () |
Extracts an unsigned 8-bit integer. | |
bool | is_eof () const |
Returns true if the last read operation failed because of reaching EOF, false otherwise. | |
bool | open_read (Filename filename) |
Attempts to open the indicated filename for reading. | |
PT (IffChunk) get_chunk() | |
PT (IffChunk) get_subchunk(IffChunk *context) | |
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. | |
void | set_filename (const Filename &filename) |
Indicates the filename that the InputFile is currently opened on. | |
void | set_input (istream *input, bool owns_istream) |
Sets up the input to use an arbitrary istream. | |
bool | skip_bytes (int length) |
Reads a series of bytes, but does not store them. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Protected Member Functions | |
virtual IffChunk * | make_new_chunk (IffId id) |
Allocates and returns a new chunk of the appropriate type based on the given ID. | |
Protected Attributes | |
size_t | _bytes_read |
bool | _eof |
Filename | _filename |
istream * | _input |
bool | _owns_istream |
bool | _unexpected_eof |
Friends | |
class | IffChunk |
A wrapper around an istream used for reading an IFF file.
Definition at line 33 of file iffInputFile.h.
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 68 of file iffInputFile.I.
References get_int8().
Referenced by get_string(), and IffGenericChunk::read_iff().
PN_stdfloat IffInputFile::get_be_float32 | ( | ) |
Extracts a 32-bit big-endian single-precision floating-point number.
Definition at line 190 of file iffInputFile.cxx.
References DatagramIterator::get_be_float32(), and read_bytes().
Referenced by LwoInputFile::get_vec3(), LwoSurfaceSmoothingAngle::read_iff(), LwoSurfaceParameter::read_iff(), LwoSurfaceBlockRepeat::read_iff(), LwoVertexMap::read_iff(), LwoDiscontinuousVertexMap::read_iff(), and LwoSurfaceBlockOpacity::read_iff().
PN_int16 IffInputFile::get_be_int16 | ( | ) |
Extracts a signed 16-bit big-endian integer.
Definition at line 129 of file iffInputFile.cxx.
References DatagramIterator::get_be_int16(), and read_bytes().
Referenced by LwoPolygonTags::read_iff(), LwoSurfaceSidedness::read_iff(), and LwoPolygons::read_iff().
PN_int32 IffInputFile::get_be_int32 | ( | ) |
Extracts a signed 32-bit big-endian integer.
Definition at line 144 of file iffInputFile.cxx.
References DatagramIterator::get_be_int32(), and read_bytes().
Referenced by LwoClip::read_iff().
PN_uint16 IffInputFile::get_be_uint16 | ( | ) |
Extracts an unsigned 16-bit big-endian integer.
Definition at line 159 of file iffInputFile.cxx.
References DatagramIterator::get_be_uint16(), and read_bytes().
Referenced by LwoInputFile::get_vx(), LwoSurfaceBlockEnabled::read_iff(), LwoSurfaceBlockWrap::read_iff(), LwoSurfaceBlockCoordSys::read_iff(), LwoSurfaceBlockAxis::read_iff(), LwoVertexMap::read_iff(), LwoDiscontinuousVertexMap::read_iff(), LwoSurfaceBlockProjection::read_iff(), LwoSurfaceBlockOpacity::read_iff(), LwoLayer::read_iff(), and LwoPolygons::read_iff().
PN_uint32 IffInputFile::get_be_uint32 | ( | ) |
Extracts an unsigned 32-bit big-endian integer.
Definition at line 174 of file iffInputFile.cxx.
References DatagramIterator::get_be_uint32(), and read_bytes().
size_t IffInputFile::get_bytes_read | ( | ) | const [inline] |
Returns the number of bytes read so far from the input file.
Definition at line 56 of file iffInputFile.I.
Referenced by LwoGroupChunk::read_chunks_iff(), LwoPoints::read_iff(), LwoPolygonTags::read_iff(), IffGenericChunk::read_iff(), LwoVertexMap::read_iff(), LwoDiscontinuousVertexMap::read_iff(), LwoTags::read_iff(), LwoLayer::read_iff(), LwoPolygons::read_iff(), and LwoGroupChunk::read_subchunks_iff().
const Filename & IffInputFile::get_filename | ( | ) | const [inline] |
Returns the filename that the InputFile is currently opened on, if available.
Definition at line 34 of file iffInputFile.I.
Extracts a 4-character IFF ID.
Definition at line 225 of file iffInputFile.cxx.
References Datagram::get_data(), and read_bytes().
Referenced by LwoSurfaceBlockChannel::read_iff(), LwoHeader::read_iff(), LwoPolygonTags::read_iff(), LwoVertexMap::read_iff(), LwoDiscontinuousVertexMap::read_iff(), and LwoPolygons::read_iff().
PN_int8 IffInputFile::get_int8 | ( | ) |
Extracts a signed 8-bit integer.
Definition at line 99 of file iffInputFile.cxx.
References DatagramIterator::get_int8(), and read_bytes().
Referenced by align().
string IffInputFile::get_string | ( | ) |
Extracts a null-terminated string.
Definition at line 205 of file iffInputFile.cxx.
References align(), and read_byte().
Referenced by LwoInputFile::get_filename(), LwoSurfaceBlockHeader::read_iff(), LwoSurfaceBlockRefObj::read_iff(), LwoSurfaceBlockVMapName::read_iff(), LwoSurface::read_iff(), LwoVertexMap::read_iff(), LwoDiscontinuousVertexMap::read_iff(), LwoTags::read_iff(), and LwoLayer::read_iff().
PN_uint8 IffInputFile::get_uint8 | ( | ) |
Extracts an unsigned 8-bit integer.
Definition at line 114 of file iffInputFile.cxx.
References DatagramIterator::get_int8(), and read_bytes().
static void IffInputFile::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from TypedObject.
Reimplemented in LwoInputFile.
Definition at line 87 of file iffInputFile.h.
bool IffInputFile::is_eof | ( | ) | const [inline] |
Returns true if the last read operation failed because of reaching EOF, false otherwise.
Definition at line 45 of file iffInputFile.I.
Referenced by read_byte(), read_bytes(), LwoGroupChunk::read_chunks_iff(), LwoPoints::read_iff(), LwoPolygonTags::read_iff(), LwoVertexMap::read_iff(), LwoTags::read_iff(), LwoDiscontinuousVertexMap::read_iff(), LwoPolygons::read_iff(), LwoGroupChunk::read_subchunks_iff(), and skip_bytes().
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 413 of file iffInputFile.cxx.
Referenced by IffChunk::make_new_chunk().
bool IffInputFile::open_read | ( | Filename | filename | ) |
Attempts to open the indicated filename for reading.
Returns true if successful, false otherwise.
Definition at line 57 of file iffInputFile.cxx.
References VirtualFileSystem::get_global_ptr(), VirtualFileSystem::open_read_file(), Filename::set_binary(), set_filename(), and set_input().
Referenced by LwoToEggConverter::convert_file().
bool IffInputFile::read_byte | ( | char & | byte | ) |
Reads a single byte.
Returns true if successful, false otherwise.
Definition at line 348 of file iffInputFile.cxx.
References is_eof().
Referenced by get_string(), and skip_bytes().
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 367 of file iffInputFile.cxx.
References is_eof().
Referenced by get_be_float32(), get_be_int16(), get_be_int32(), get_be_uint16(), get_be_uint32(), get_id(), get_int8(), get_uint8(), and IffGenericChunk::read_iff().
void IffInputFile::set_filename | ( | const Filename & | filename | ) | [inline] |
Indicates the filename that the InputFile is currently opened on.
Definition at line 23 of file iffInputFile.I.
Referenced by open_read().
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 (via vfs->close_read_file()) when the IffInputFile destructs.
Definition at line 81 of file iffInputFile.cxx.
References VirtualFileSystem::close_read_file(), and VirtualFileSystem::get_global_ptr().
Referenced by open_read().
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 392 of file iffInputFile.cxx.
References is_eof(), and read_byte().