00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
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