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

mslio.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------
00002 //               The Motion Strategy Library (MSL)
00003 //----------------------------------------------------------------------
00004 //
00005 // Copyright (c) University of Illinois and Steven M. LaValle.     
00006 // All Rights Reserved.
00007 //
00008 // Permission to use, copy, and distribute this software and its
00009 // documentation is hereby granted free of charge, provided that
00010 // (1) it is not a component of a commercial product, and
00011 // (2) this notice appears in all copies of the software and
00012 //     related documentation.
00013 //
00014 // The University of Illinois and the author make no representations
00015 // about the suitability or fitness of this software for any purpose.
00016 // It is provided "as is" without express or implied warranty.
00017 //----------------------------------------------------------------------
00018 
00019 #ifndef MSL_IO_H
00020 #define MSL_IO_H
00021 
00022 #ifdef WIN32
00023   #include <list>
00024   #include <fstream>
00025   #include <vector>
00026   using namespace std;
00027 #else
00028   #include <list.h>
00029   #include <stream.h>
00030   #include <fstream.h>
00031   #include <vector.h>
00032   using namespace std;
00033 #endif
00034 
00035 template<class T> ostream& operator<<(ostream& out, const list<T>& L);
00036 template<class T> istream& operator>>(istream& in, list<T>& L);
00037 template<class T> ostream& operator<<(ostream& out, const vector<T>& L);
00038 template<class T> istream& operator>>(istream& in, vector<T>& L);
00039 
00040 template<class T> ostream& operator<<(ostream& out, const list<T>& L)
00041 {
00042   list<T>::iterator x; 
00043   list<T> vl;
00044   vl = L;
00045   for (x = vl.begin(); x != vl.end(); x++) 
00046     out << " " << *x;
00047   return out;
00048 }
00049 
00050 template<class T> istream& operator>>(istream& in, list<T>& L)
00051 { 
00052   L.clear();
00053   T x;
00054   for(;;)
00055     { 
00056       char c;
00057       while (in.get(c) && isspace(c));
00058       if (!in) break;
00059       in.putback(c);
00060       x = T(); in >> x; L.push_back(x);
00061    }
00062   return in;
00063 }
00064 
00065 
00066 template<class T> ofstream& operator<<(ofstream& out, const vector<T>& L)
00067 {
00068   vector<T>::iterator x; 
00069   vector<T> vl;
00070   vl = L;
00071   for (x = vl.begin(); x != vl.end(); x++) 
00072     out << " " << *x;
00073   return out;
00074 }
00075 
00076 
00077 template<class T> ifstream& operator>>(ifstream& in, vector<T>& L)
00078 { 
00079   L.clear();
00080   T x;
00081   for(;;)
00082     { 
00083       char c;
00084       while (in.get(c) && isspace(c));
00085       if (!in) break;
00086       in.putback(c);
00087       x = T(); in >> x; L.push_back(x);
00088    }
00089   return in;
00090 }
00091 
00092 
00093 #endif
Motion Strategy Library


Web page maintained by Steve LaValle
Partial support provided by NSF CAREER Award IRI-970228 (LaValle), Honda Research.
Contributors: Anna Atramentov, Peng Cheng, James Kuffner, Steve LaValle, and Libo Yang.