contrib/oul/ouml/io.txx
Go to the documentation of this file.
00001 #ifndef ouml_io_txx_
00002 #define ouml_io_txx_
00003 // miscellaneous io operators
00004 
00005 #include "io.h"
00006 #include <vcl_iostream.h>
00007 
00008 template <class T>
00009 vcl_ostream &operator <<(vcl_ostream &os, const vnl_vector<T> &vec)
00010 {
00011   typename vnl_vector<T>::const_iterator iter, end_iter;
00012 
00013   end_iter = vec.end();
00014   vcl_cout << "<Vector: ";
00015   for (iter=vec.begin(); iter!=end_iter; iter++)
00016   {
00017     vcl_cout << ' ' << *iter;
00018   }
00019   vcl_cout << "> ";
00020 
00021   return os;
00022 }
00023 
00024 template <class T>
00025 vcl_ostream &operator <<(vcl_ostream &os, const vcl_vector<T> &vec)
00026 {
00027   typename vcl_vector<T>::const_iterator iter, end_iter;
00028 
00029   end_iter = vec.end();
00030   vcl_cout << "<Vector: ";
00031   for (iter=vec.begin(); iter!=end_iter; iter++)
00032   {
00033     vcl_cout << ' ' << *iter;
00034   }
00035   vcl_cout << "> ";
00036 
00037   return os;
00038 }
00039 
00040 template <class T, class S>
00041 vcl_ostream &operator<<(vcl_ostream &os, const vcl_map<T, S> &omap)
00042 {
00043   typename vcl_map<T, S>::const_iterator iter, end_iter;
00044 
00045   end_iter = omap.end();
00046   os << "<Map: ";
00047   for (iter=omap.begin(); iter!=end_iter; iter++)
00048   {
00049     os << " <" << (*iter).first << ", " << (*iter).second << '>';
00050   }
00051   os << "> ";
00052 
00053   return os;
00054 }
00055 
00056 template <class T>
00057 vcl_ostream &operator <<(vcl_ostream &os, const vcl_set<T> &vec)
00058 {
00059   typename vcl_set<T>::const_iterator iter, end_iter;
00060 
00061   end_iter = vec.end();
00062   os << "<Set: ";
00063   for (iter=vec.begin(); iter!=end_iter; iter++)
00064   {
00065     os << ' ' << *iter;
00066   }
00067   os << "> ";
00068 
00069   return os;
00070 }
00071 
00072 
00073 vcl_ostream &operator<<(vcl_ostream &os, const vil1_rgb<unsigned char> &colour)
00074 {
00075   os << "<RGB = " << (int)colour.R() << ", " << (int)colour.G() << ", "
00076      << (int)colour.B() << ">\n";
00077   return os;
00078 }
00079 
00080 #endif // ouml_io_txx_