00001 // Filename: eggNamedObject.cxx 00002 // Created by: drose (16Jan99) 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 "eggNamedObject.h" 00016 #include "eggMiscFuncs.h" 00017 00018 #include "indent.h" 00019 00020 TypeHandle EggNamedObject::_type_handle; 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Function: EggNamedObject::output 00024 // Access: Public 00025 // Description: 00026 //////////////////////////////////////////////////////////////////// 00027 void EggNamedObject:: 00028 output(ostream &out) const { 00029 out << get_type(); 00030 if (has_name()) { 00031 out << " " << get_name(); 00032 } 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: EggNamedObject::write_header 00037 // Access: Public 00038 // Description: Writes the first line of the egg object, 00039 // e.g. "<Group> group_name {" or some such. It 00040 // automatically enquotes the name if it contains any 00041 // special characters. egg_keyword is the keyword that 00042 // begins the line, e.g. "<Group>". 00043 //////////////////////////////////////////////////////////////////// 00044 void EggNamedObject:: 00045 write_header(ostream &out, int indent_level, const char *egg_keyword) const { 00046 indent(out, indent_level) << egg_keyword << " "; 00047 00048 if (has_name()) { 00049 enquote_string(out, get_name()) << " {\n"; 00050 } else { 00051 out << "{\n"; 00052 } 00053 }