00001 // Filename: iffId.cxx 00002 // Created by: drose (23Apr01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "iffId.h" 00020 00021 #include <ctype.h> 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function: IffId::output 00025 // Access: Public 00026 // Description: 00027 //////////////////////////////////////////////////////////////////// 00028 void IffId:: 00029 output(ostream &out) const { 00030 // If all of the characters are printable, just output them. 00031 if (isprint(_id._c[0]) && isprint(_id._c[1]) && 00032 isprint(_id._c[2]) && isprint(_id._c[3])) { 00033 out << _id._c[0] << _id._c[1] << _id._c[2] << _id._c[3]; 00034 00035 } else if (isprint(_id._c[0]) && isprint(_id._c[1]) && 00036 isprint(_id._c[2]) && _id._c[3] == '\0') { 00037 // If the last character is 0, output a 3-letter ID. 00038 out << _id._c[0] << _id._c[1] << _id._c[2]; 00039 00040 } else { 00041 // Otherwise, write out the hex. 00042 out << "0x" << hex << setfill('0'); 00043 for (int i = 0; i < 4; i++) { 00044 out << setw(2) << (int)(unsigned char)_id._c[i]; 00045 } 00046 out << dec << setfill(' '); 00047 } 00048 }