ADMB Documentation  11.1.2428
 All Classes Files Functions Variables Typedefs Friends Defines
ufstream.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: ufstream.cpp 1906 2014-04-17 20:52:49Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00013 void uistream::sss(void){}
00014 void uostream::sss(void){}
00015 
00016 #define INSERT_IMPLEMENT(TYPE) \
00017 uostream& uostream::operator<< (TYPE x) \
00018 { \
00019   write((char*)&x, sizeof(TYPE)); \
00020   return *this; \
00021 }
00022 
00023 #define EXTRACT_IMPLEMENT(TYPE) \
00024 uistream& uistream::operator>> (const TYPE& x) \
00025 { \
00026   read((char*)&x, sizeof(TYPE)); \
00027   return *this; \
00028 }
00029 
00030 uostream::uostream(const char* name, int  m, int prot)
00031   :ofstream(name, std::ios::binary | std::ios::openmode(m))
00032 {
00033 }
00034 
00039 void uistream::open(const char* name, int m, int prot)
00040 {
00041   ifstream::open(name, std::ios::binary | std::ios::openmode(m));
00042 }
00043 
00048 void uostream::open(const char* name, int m, int prot)
00049 {
00050   ofstream::open(name, std::ios::binary | std::ios::openmode(m));
00051 }
00052 
00057 uistream::uistream(const char* name, int m, int prot)
00058   :ifstream(name, std::ios::binary | std::ios::openmode(m))
00059 {
00060 }
00061 
00062 #ifdef __ZTC__
00063 uostream::uostream(const char* name, int  m, int prot)
00064 :ios(&buffer), ofstream(name, m, prot) { }
00065 
00066 uistream::uistream(const char* name, int m, int prot)
00067 :ios(&buffer), ifstream(name, m| ios::nocreate , prot) { }
00068 #endif
00069 
00070 // implement insertion operators for various types in class uostream
00071 #ifndef __SUN__
00072 INSERT_IMPLEMENT(signed char)
00073 #endif
00074 INSERT_IMPLEMENT(unsigned char)
00075 INSERT_IMPLEMENT(short)
00076 INSERT_IMPLEMENT(int)
00077 INSERT_IMPLEMENT(long)
00078 INSERT_IMPLEMENT(unsigned short)
00079 INSERT_IMPLEMENT(unsigned long)
00080 INSERT_IMPLEMENT(float)
00081 INSERT_IMPLEMENT(double)
00082 
00083 #ifdef __TURBOC__
00084 INSERT_IMPLEMENT(long double)
00085 #endif
00086 
00087 // implement extraction operators for various types in class uistream
00088 #ifndef __SUN__
00089 //#  if (__BORLANDC__  > 0x0520 || defined(__linux__))
00090 EXTRACT_IMPLEMENT(signed char)
00091 EXTRACT_IMPLEMENT(unsigned char)
00092 EXTRACT_IMPLEMENT(char)
00093 EXTRACT_IMPLEMENT(short)
00094 EXTRACT_IMPLEMENT(int)
00095 EXTRACT_IMPLEMENT(long)
00096 EXTRACT_IMPLEMENT(unsigned short)
00097 EXTRACT_IMPLEMENT(unsigned long)
00098 EXTRACT_IMPLEMENT(float)
00099 EXTRACT_IMPLEMENT(double)
00100  // #  else
00101  // EXTRACT_IMPLEMENT(const signed char)
00102  // EXTRACT_IMPLEMENT(const unsigned char)
00103  // EXTRACT_IMPLEMENT(const char)
00104  // EXTRACT_IMPLEMENT(const short)
00105  // EXTRACT_IMPLEMENT(const int)
00106  // EXTRACT_IMPLEMENT(const long)
00107  // EXTRACT_IMPLEMENT(const unsigned short)
00108  // EXTRACT_IMPLEMENT(const unsigned long)
00109  // EXTRACT_IMPLEMENT(const float)
00110  // EXTRACT_IMPLEMENT(const double)
00111  // #  endif
00112 #endif
00113 
00114 #ifdef __TURBOC__
00115 #  if (__BORLANDC__  > 0x0520)
00116 EXTRACT_IMPLEMENT(long double)
00117 #  else
00118 EXTRACT_IMPLEMENT(const long double)
00119 #endif
00120 #endif
00121