Panda3D
Loading...
Searching...
No Matches
iffGenericChunk.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file iffGenericChunk.cxx
10 * @author drose
11 * @date 2001-04-23
12 */
13
14#include "iffGenericChunk.h"
15#include "iffInputFile.h"
16
17#include "indent.h"
18
19TypeHandle IffGenericChunk::_type_handle;
20
21
22/**
23 * Reads the data of the chunk in from the given input file, if possible. The
24 * ID and length of the chunk have already been read. stop_at is the byte
25 * position of the file to stop at (based on the current position at
26 * in->get_bytes_read()). Returns true on success, false otherwise.
27 */
29read_iff(IffInputFile *in, size_t stop_at) {
30 size_t length = stop_at - in->get_bytes_read();
31 bool result = in->read_bytes(_data, length);
32 in->align();
33 return result;
34}
35
36/**
37 *
38 */
39void IffGenericChunk::
40write(std::ostream &out, int indent_level) const {
41 indent(out, indent_level)
42 << get_id() << " { " << _data.get_length() << " bytes }\n";
43}
size_t get_length() const
Returns the number of bytes in the datagram.
Definition datagram.I:335
IffId get_id() const
Returns the ID associated with this chunk.
Definition iffChunk.I:25
virtual bool read_iff(IffInputFile *in, size_t stop_at)
Reads the data of the chunk in from the given input file, if possible.
A wrapper around an istream used for reading an IFF file.
bool read_bytes(Datagram &datagram, int length)
Reads a series of bytes, and stores them in the indicated Datagram.
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 s...
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.