Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/interrogatedb/interrogate_datafile.I

Go to the documentation of this file.
00001 // Filename: interrogate_datafile.I
00002 // Created by:  drose (09Aug00)
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 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: idf_output_vector
00022 //  Description: Writes the indicated vector to the output file.  Each
00023 //               component is written using its normal ostream output
00024 //               operator.
00025 ////////////////////////////////////////////////////////////////////
00026 template<class Element>
00027 void
00028 idf_output_vector(ostream &out, const vector<Element> &vec) {
00029   out << vec.size() << " ";
00030   TYPENAME vector<Element>::const_iterator vi;
00031   for (vi = vec.begin(); vi != vec.end(); ++vi) {
00032     out << (*vi) << " ";
00033   }
00034 }
00035 
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: idf_input_vector
00039 //  Description: Reads the given vector from the input file, as
00040 //               previously written by output_string().  Each
00041 //               component is read using its normal istream input
00042 //               operator.
00043 ////////////////////////////////////////////////////////////////////
00044 template<class Element>
00045 void
00046 idf_input_vector(istream &in, vector<Element> &vec) {
00047   int length;
00048   in >> length;
00049   if (in.fail()) {
00050     return;
00051   }
00052 
00053   vec.clear();
00054   vec.reserve(length);
00055   while (length > 0) {
00056     Element elem;
00057     in >> elem;
00058     vec.push_back(elem);
00059     length--;
00060   }
00061 }

Generated on Thu May 1 22:13:04 2003 for DTool by doxygen1.3