ADMB Documentation  11.1.1913
 All Classes Files Functions Variables Typedefs Friends Defines
d3_io.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: d3_io.cpp 1864 2014-04-08 00:50:10Z 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   int new_w = s.width();
00042   int new_p = s.precision();
00043 #if !defined(__cplusplus)
00044   long new_form = s.flags();
00045 #else
00046   ios::fmtflags new_form = s.flags();
00047 #endif
00048 
00049   char new_fill = s.fill();
00050 #endif
00051 
00052   for (int i=z.slicemin();i<=z.slicemax();i++)
00053   {
00054   #ifdef __USE_IOSTREAM__
00055      s.width(new_w);
00056      s.precision(new_p);
00057      s.flags(new_form);
00058      s.fill(new_fill);
00059   #endif
00060     s << z[i];
00061     if (i<z.slicemax())
00062     {
00063       s << endl;
00064     }
00065   }
00066   return s;
00067 }
00068 
00073 istream& operator>>(const istream& _istr, const d3_array& z)
00074 {
00075   istream& istr = (istream&) _istr;
00076   for (int i=z.slicemin();i<=z.slicemax();i++)
00077   {
00078     istr >> z[i];
00079   }
00080   return istr;
00081 }