00001 // Filename: interrogateComponent.cxx 00002 // Created by: drose (08Aug00) 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 "interrogateComponent.h" 00016 #include "interrogate_datafile.h" 00017 00018 // This static string is just kept around as a handy bogus return 00019 // value for functions that must return a const string reference. 00020 string InterrogateComponent::_empty_string; 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Function: InterrogateComponent::output 00024 // Access: Public 00025 // Description: Formats the component for output to a data file. 00026 //////////////////////////////////////////////////////////////////// 00027 void InterrogateComponent:: 00028 output(ostream &out) const { 00029 idf_output_string(out, _name); 00030 out << _alt_names.size() << " "; 00031 00032 Strings::const_iterator vi; 00033 for (vi = _alt_names.begin(); vi != _alt_names.end(); ++vi) { 00034 idf_output_string(out, *vi); 00035 } 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: InterrogateComponent::input 00040 // Access: Public 00041 // Description: Reads the data file as previously formatted by 00042 // output(). 00043 //////////////////////////////////////////////////////////////////// 00044 void InterrogateComponent:: 00045 input(istream &in) { 00046 idf_input_string(in, _name); 00047 00048 int num_alt_names; 00049 in >> num_alt_names; 00050 _alt_names.reserve(num_alt_names); 00051 for (int i = 0; i < num_alt_names; ++i) { 00052 string alt_name; 00053 idf_input_string(in, alt_name); 00054 _alt_names.push_back(alt_name); 00055 } 00056 }