ADMB Documentation  11.1.2503
 All Classes Files Functions Variables Typedefs Friends Defines
lvec_io1.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: lvec_io1.cpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 // file: dvect_io.cpp
00012 #include "fvar.hpp"
00013 
00014 // i/o ooperations for class lvector
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 
00033 // unformatted
00034 
00035 #ifdef __USE_IOSTREAM__
00036 
00041 uistream& operator>>(const uistream& _istr, const lvector& _z)
00042 {
00043   ADUNCONST(lvector,z)
00044   uistream & istr = (uistream&) _istr;
00045   z.read_from(istr);
00046 
00047   return istr;
00048 }
00049 
00054 void lvector::read_from(const uistream& _s)
00055 {
00056   ADUNCONST(uistream,s)
00057   int n = indexmax() - indexmin() + 1;
00058   char* p = (char*)(v + indexmin());
00059 
00060   s.read(p, n*sizeof(int) );
00061 }
00062 
00067 uostream& operator<<(const uostream& _ostr, const lvector& z)
00068 {
00069   uostream & ostr = (uostream&) _ostr;
00070   z.write_on(ostr);
00071 
00072   return ostr;
00073 }
00074 
00079 void lvector::write_on(const uostream& _s) const
00080 {
00081   ADUNCONST (uostream,s)
00082   int n = indexmax() - indexmin() + 1;
00083   char* p = (char*)(v + indexmin());
00084 
00085   s.write(p, n*sizeof(int) );
00086 }
00087 #endif
00088