CoCoALib-0.9905 date: 23 May 2007


io.H

Go to the documentation of this file.
00001 #ifndef CoCoA_io_H
00002 #define CoCoA_io_H
00003 
00004 //   Copyright (c)  2005  John Abbott
00005 
00006 //   This file is part of the source of CoCoALib, the CoCoA Library.
00007 
00008 //   CoCoALib is free software; you can redistribute it and/or modify
00009 //   it under the terms of the GNU General Public License (version 2)
00010 //   as published by the Free Software Foundation.  A copy of the full
00011 //   licence may be found in the file COPYING in this directory.
00012 
00013 //   CoCoALib is distributed in the hope that it will be useful,
00014 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 //   GNU General Public License for more details.
00017 
00018 //   You should have received a copy of the GNU General Public License
00019 //   along with CoCoA; if not, write to the Free Software
00020 //   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022 
00023 #include <iostream>
00024 // using std::istream;
00025 // using std::ostream;
00026 #include <vector>
00027 //using std::vector;
00028 #include <list>
00029 //using std::list;
00030 
00031 namespace CoCoA
00032 {
00033 
00034   /*-----------------------------------------------------------------*/
00035   /** \include io.txt  */
00036   /*-----------------------------------------------------------------*/
00037   std::istream& GlobalInput();
00038   std::ostream& GlobalOutput();
00039   std::ostream& GlobalErrput();
00040   std::ostream& GlobalLogput();
00041 
00042   std::istream& SetGlobalInput(std::istream& in);
00043   std::ostream& SetGlobalOutput(std::ostream& out);
00044   std::ostream& SetGlobalErrput(std::ostream& err);
00045   std::ostream& SetGlobalLogput(std::ostream& log);
00046 
00047 
00048   // This should print out a list or vector of any printable type.
00049   // Empty list appears as []; otherwise ",  " separated elements
00050   // between "[" and "]".
00051   template <typename FwdIterator_t>
00052   void OutputRange(std::ostream& out, FwdIterator_t start, const FwdIterator_t& end)
00053   {
00054     if (start == end) { out << "[]"; return; }
00055     out << "[" << *start;
00056     while (++start != end)
00057       out << ",  " << *start;
00058     out << "]";
00059   }
00060 
00061   // Use cout << v syntax to print out a std::vector of printable values.
00062   // Do I really want to do this globally?
00063   template <typename entry_t>
00064   inline std::ostream& operator<<(std::ostream& out, const std::vector<entry_t>& v)
00065   {
00066     OutputRange(out, v.begin(), v.end());
00067     return out;
00068   }
00069 
00070   // Use cout << l syntax to print out a std::list of printable values.
00071   // Do I really want to do this globally?
00072   template <typename entry_t>
00073   inline std::ostream& operator<<(std::ostream& out, const std::list<entry_t>& v)
00074   {
00075     OutputRange(out, v.begin(), v.end());
00076     return out;
00077   }
00078 
00079 } // end of namespace CoCoA
00080 
00081 
00082 // RCS header/log in the next few lines
00083 // $Header: /Volumes/Home/cocoa/cvs-repository/CoCoALib-0.99/include/CoCoA/io.H,v 1.1.1.1 2007/03/09 15:16:11 abbott Exp $
00084 // $Log: io.H,v $
00085 // Revision 1.1.1.1  2007/03/09 15:16:11  abbott
00086 // Imported files
00087 //
00088 // Revision 1.4  2006/12/06 17:17:44  cocoa
00089 // -- removed #include "config.H"
00090 //
00091 // Revision 1.3  2006/10/06 14:04:15  cocoa
00092 // Corrected position of #ifndef in header files.
00093 // Separated CoCoA_ASSERT into assert.H from config.H;
00094 // many minor consequential changes (have to #include assert.H).
00095 // A little tidying of #include directives (esp. in Max's code).
00096 //
00097 // Revision 1.2  2006/08/17 09:46:02  cocoa
00098 // -- added:  comma between list elements
00099 //
00100 // Revision 1.1.1.1  2006/05/30 11:39:36  cocoa
00101 // Imported files
00102 //
00103 // Revision 1.2  2006/03/27 16:15:39  cocoa
00104 // Checking in functions for printing lists and vectors of things,
00105 // so that GPoly.C will compile.  Will reorganize things another day.
00106 //
00107 // Revision 1.1.1.1  2005/10/17 10:46:54  cocoa
00108 // Imported files
00109 //
00110 // Revision 1.1.1.1  2005/05/03 15:47:30  cocoa
00111 // Imported files
00112 //
00113 // Revision 1.2  2005/04/19 14:06:04  cocoa
00114 // Added GPL and GFDL licence stuff.
00115 //
00116 // Revision 1.1.1.1  2005/01/27 15:12:13  cocoa
00117 // Imported files
00118 //
00119 // Revision 1.3  2004/11/11 13:20:47  cocoa
00120 // -- added \include *.txt for doxygen
00121 //
00122 // Revision 1.2  2004/06/29 17:10:22  cocoa
00123 // Partially tidied use of "protected" and "private" in various
00124 // base classes.  Checking in at the end of the day -- it works,
00125 // and I wouldn't want it to be lost next time point's disk
00126 // misbehaves.
00127 //
00128 
00129 #endif

Generated on Wed May 23 13:45:22 2007 for CoCoALib by  doxygen 1.4.6