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 #include <list>
00023 #include <fstream>
00024 #include <sstream>
00025 #include <vector>
00026 using namespace std;
00027 
00028 template<class T> ostream& operator<<(ostream& out, const list<T>& L);
00029 template<class T> istream& operator>>(istream& in, list<T>& L);
00030 template<class T> ostream& operator<<(ostream& out, const vector<T>& L);
00031 template<class T> istream& operator>>(istream& in, vector<T>& L);
00032 
00033 template<class T> ostream& operator<<(ostream& out, const list<T>& L)
00034 {
00035   typename list<T>::iterator x; 
00036   list<T> vl;
00037   vl = L;
00038   for (x = vl.begin(); x != vl.end(); x++) 
00039     out << " " << *x;
00040   return out;
00041 }
00042 
00043 template<class T> istream& operator>>(istream& in, list<T>& L)
00044 { 
00045   L.clear();
00046   T x;
00047   for(;;)
00048     { 
00049       char c;
00050       while (in.get(c) && isspace(c));
00051       if (!in) break;
00052       in.putback(c);
00053       x = T(); in >> x; L.push_back(x);
00054    }
00055   return in;
00056 }
00057 
00058 
00059 template<class T> ofstream& operator<<(ofstream& out, const vector<T>& L)
00060 {
00061   typename vector<T>::iterator x; 
00062   vector<T> vl;
00063   vl = L;
00064   for (x = vl.begin(); x != vl.end(); x++) 
00065     out << " " << *x;
00066   return out;
00067 }
00068 
00069 
00070 template<class T> ifstream& operator>>(ifstream& in, vector<T>& L)
00071 { 
00072   L.clear();
00073   T x;
00074   for(;;)
00075     { 
00076       char c;
00077       while (in.get(c) && isspace(c));
00078       if (!in) break;
00079       in.putback(c);
00080       x = T(); in >> x; L.push_back(x);
00081    }
00082   return in;
00083 }
00084 
00085 
00086 #endif
Motion Strategy Library


Web page maintained by Steve LaValle