00001 /* 00002 * $Id$ 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 ivector 00015 00016 00017 #ifdef __TURBOC__ 00018 #pragma hdrstop 00019 #include <iostream.h> 00020 #include <iomanip.h> 00021 #include <fstream.h> 00022 #define __USE_IOSTREAM__ 00023 #endif 00024 00025 #ifdef __ZTC__ 00026 #include <iostream.hpp> 00027 #include <iomanip.hpp> 00028 #include <fstream.hpp> 00029 #define __USE_IOSTREAM__ 00030 #endif 00031 00032 #include <string.h> 00033 #ifndef OPT_LIB 00034 #include <cassert> 00035 #endif 00036 00037 #ifdef __USE_IOSTREAM__ 00038 00043 uistream& operator>>(const uistream& _istr, const ivector& _z) 00044 { 00045 ivector& z=(ivector& )_z; 00046 uistream& istr= (uistream&) _istr; 00047 z.read_from(istr); 00048 return istr; 00049 } 00050 00055 void ivector::read_from(const uistream& _s) 00056 { 00057 ADUNCONST(uistream,s); 00058 char* p = (char*)(v + indexmin()); 00059 #ifndef OPT_LIB 00060 assert(indexmax() >= indexmin()); 00061 #endif 00062 int n = indexmax() - indexmin() + 1; 00063 n *= (int)sizeof(int); 00064 s.read(p, n); 00065 } 00066 00071 uostream& operator<<(const uostream& _ostr, const ivector& z) 00072 { 00073 uostream & ostr = (uostream&) _ostr; 00074 z.write_on(ostr); 00075 00076 return ostr; 00077 } 00078 00083 void ivector::write_on(const uostream& _s) const 00084 { 00085 ADUNCONST(uostream,s) 00086 char* p = (char*)(v + indexmin()); 00087 #ifndef OPT_LIB 00088 assert(indexmax() >= indexmin()); 00089 #endif 00090 int n = indexmax() - indexmin() + 1; 00091 n *= (int)sizeof(int); 00092 s.write(p, n); 00093 } 00094 #endif
Generated on Tue Mar 8 2016 19:51:34 for ADMB Documentation by 1.8.0 |