ADMB Documentation  11.1.2274
 All Classes Files Functions Variables Typedefs Friends Defines
d3_io.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: d3_io.cpp 2273 2014-08-29 23:08:22Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 // file: dmat_io.cpp
00012 
00013 // i/o operations for class dmatrix
00014 #include "fvar.hpp"
00015 
00016 #ifdef __TURBOC__
00017   #pragma hdrstop
00018   #include <iostream.h>
00019   #include <iomanip.h>
00020   #include <fstream.h>
00021   #define __USE_IOSTREAM__
00022 #endif
00023 
00024 #ifdef __ZTC__
00025   #include <iostream.hpp>
00026   #include <iomanip.hpp>
00027   #include <fstream.hpp>
00028   #define __USE_IOSTREAM__
00029 #endif
00030 
00031 #include <string.h>
00032 
00037 ostream& operator<<(const ostream& _s, const d3_array& z)
00038 {
00039   ostream& s = (ostream&) _s;
00040 #ifdef __USE_IOSTREAM__
00041   using std::streamsize;
00042   streamsize new_w = s.width();
00043   streamsize new_p = s.precision();
00044 #if !defined(__cplusplus)
00045   long new_form = s.flags();
00046 #else
00047   ios::fmtflags new_form = s.flags();
00048 #endif
00049 
00050   char new_fill = s.fill();
00051 #endif
00052 
00053   for (int i=z.slicemin();i<=z.slicemax();i++)
00054   {
00055   #ifdef __USE_IOSTREAM__
00056      s.width(new_w);
00057      s.precision(new_p);
00058      s.flags(new_form);
00059      s.fill(new_fill);
00060   #endif
00061     s << z[i];
00062     if (i<z.slicemax())
00063     {
00064       s << endl;
00065     }
00066   }
00067   return s;
00068 }
00069 
00074 istream& operator>>(const istream& _istr, const d3_array& z)
00075 {
00076   istream& istr = (istream&) _istr;
00077   for (int i=z.slicemin();i<=z.slicemax();i++)
00078   {
00079     istr >> z[i];
00080   }
00081   return istr;
00082 }