00001 // Filename: iffGenericChunk.cxx 00002 // Created by: drose (23Apr01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "iffGenericChunk.h" 00016 #include "iffInputFile.h" 00017 00018 #include "indent.h" 00019 00020 TypeHandle IffGenericChunk::_type_handle; 00021 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function: IffGenericChunk::read_iff 00025 // Access: Public, Virtual 00026 // Description: Reads the data of the chunk in from the given input 00027 // file, if possible. The ID and length of the chunk 00028 // have already been read. stop_at is the byte position 00029 // of the file to stop at (based on the current position 00030 // at in->get_bytes_read()). Returns true on success, 00031 // false otherwise. 00032 //////////////////////////////////////////////////////////////////// 00033 bool IffGenericChunk:: 00034 read_iff(IffInputFile *in, size_t stop_at) { 00035 size_t length = stop_at - in->get_bytes_read(); 00036 bool result = in->read_bytes(_data, length); 00037 in->align(); 00038 return result; 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: IffGenericChunk::write 00043 // Access: Public, Virtual 00044 // Description: 00045 //////////////////////////////////////////////////////////////////// 00046 void IffGenericChunk:: 00047 write(ostream &out, int indent_level) const { 00048 indent(out, indent_level) 00049 << get_id() << " { " << _data.get_length() << " bytes }\n"; 00050 } 00051