00001 // Filename: eggTable.cxx 00002 // Created by: drose (19Feb99) 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 "eggTable.h" 00020 00021 #include <string_utils.h> 00022 #include <indent.h> 00023 00024 TypeHandle EggTable::_type_handle; 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Function: EggTable::write 00028 // Access: Public, Virtual 00029 // Description: Writes the table and all of its children to the 00030 // indicated output stream in Egg format. 00031 //////////////////////////////////////////////////////////////////// 00032 void EggTable:: 00033 write(ostream &out, int indent_level) const { 00034 test_under_integrity(); 00035 00036 switch (get_table_type()) { 00037 case TT_table: 00038 write_header(out, indent_level, "<Table>"); 00039 break; 00040 00041 case TT_bundle: 00042 write_header(out, indent_level, "<Bundle>"); 00043 break; 00044 00045 default: 00046 // invalid table type 00047 nassertv(false); 00048 } 00049 00050 EggGroupNode::write(out, indent_level + 2); 00051 indent(out, indent_level) << "}\n"; 00052 } 00053 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: EggTable::string_table_type 00057 // Access: Public, Static 00058 // Description: Returns the TableType value associated with the given 00059 // string representation, or TT_invalid if the string 00060 // does not match any known TableType value. 00061 //////////////////////////////////////////////////////////////////// 00062 EggTable::TableType EggTable:: 00063 string_table_type(const string &string) { 00064 if (cmp_nocase_uh(string, "table") == 0) { 00065 return TT_table; 00066 } else if (cmp_nocase_uh(string, "bundle") == 0) { 00067 return TT_bundle; 00068 } else { 00069 return TT_invalid; 00070 } 00071 } 00072 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: TableType output operator 00076 // Description: 00077 //////////////////////////////////////////////////////////////////// 00078 ostream &operator << (ostream &out, EggTable::TableType t) { 00079 switch (t) { 00080 case EggTable::TT_invalid: 00081 return out << "invalid table"; 00082 case EggTable::TT_table: 00083 return out << "table"; 00084 case EggTable::TT_bundle: 00085 return out << "bundle"; 00086 } 00087 00088 nassertr(false, out); 00089 return out << "(**invalid**)"; 00090 }