Panda3D
iffId.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 iffId.cxx
10  * @author drose
11  * @date 2001-04-23
12  */
13 
14 #include "iffId.h"
15 
16 #include <ctype.h>
17 
18 /**
19  *
20  */
21 void IffId::
22 output(std::ostream &out) const {
23  // If all of the characters are printable, just output them.
24  if (isprint(_id._c[0]) && isprint(_id._c[1]) &&
25  isprint(_id._c[2]) && isprint(_id._c[3])) {
26  out << _id._c[0] << _id._c[1] << _id._c[2] << _id._c[3];
27 
28  } else if (isprint(_id._c[0]) && isprint(_id._c[1]) &&
29  isprint(_id._c[2]) && _id._c[3] == '\0') {
30  // If the last character is 0, output a 3-letter ID.
31  out << _id._c[0] << _id._c[1] << _id._c[2];
32 
33  } else {
34  // Otherwise, write out the hex.
35  out << "0x" << std::hex << std::setfill('0');
36  for (int i = 0; i < 4; i++) {
37  out << std::setw(2) << (int)(unsigned char)_id._c[i];
38  }
39  out << std::dec << std::setfill(' ');
40  }
41 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.