ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ufstream.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include "fvar.hpp"
12 
13 #define INSERT_IMPLEMENT(TYPE) \
14 uostream& uostream::operator<< (TYPE x) \
15 { \
16  write((char*)&x, sizeof(TYPE)); \
17  return *this; \
18 }
19 
20 #define EXTRACT_IMPLEMENT(TYPE) \
21 uistream& uistream::operator>> (const TYPE& x) \
22 { \
23  read((char*)&x, sizeof(TYPE)); \
24  return *this; \
25 }
26 
27 uostream::uostream(const char* name, int m, int prot)
28  :ofstream(name, std::ios::binary | std::ios::openmode(m))
29 {
30 }
31 
36 void uistream::open(const char* name, int m, int prot)
37 {
38  ifstream::open(name, std::ios::binary | std::ios::openmode(m));
39 }
40 
45 void uostream::open(const char* name, int m, int prot)
46 {
47  ofstream::open(name, std::ios::binary | std::ios::openmode(m));
48 }
49 
54 uistream::uistream(const char* name, int m, int prot)
55  :ifstream(name, std::ios::binary | std::ios::openmode(m))
56 {
57 }
58 
60 {
61  read((char*)&x, sizeof(int));
62  return *this;
63 }
64 
65 #ifdef __ZTC__
66 uostream::uostream(const char* name, int m, int prot)
67 :ios(&buffer), ofstream(name, m, prot) { }
68 
69 uistream::uistream(const char* name, int m, int prot)
70 :ios(&buffer), ifstream(name, m| ios::nocreate , prot) { }
71 #endif
72 
73 // implement insertion operators for various types in class uostream
74 #ifndef __SUN__
75 INSERT_IMPLEMENT(signed char)
76 #endif
77 INSERT_IMPLEMENT(unsigned char)
78 INSERT_IMPLEMENT(short)
80 INSERT_IMPLEMENT(long)
81 INSERT_IMPLEMENT(unsigned short)
82 INSERT_IMPLEMENT(unsigned long)
83 INSERT_IMPLEMENT(float)
84 INSERT_IMPLEMENT(double)
85 
86 #ifdef __TURBOC__
87 INSERT_IMPLEMENT(long double)
88 #endif
89 
90 // implement extraction operators for various types in class uistream
91 #ifndef __SUN__
92 //# if (__BORLANDC__ > 0x0520 || defined(__linux__))
93 EXTRACT_IMPLEMENT(signed char)
94 EXTRACT_IMPLEMENT(unsigned char)
96 EXTRACT_IMPLEMENT(short)
99 EXTRACT_IMPLEMENT(unsigned short)
100 EXTRACT_IMPLEMENT(unsigned long)
101 EXTRACT_IMPLEMENT(float)
102 EXTRACT_IMPLEMENT(double)
103  // # else
104  // EXTRACT_IMPLEMENT(const signed char)
105  // EXTRACT_IMPLEMENT(const unsigned char)
106  // EXTRACT_IMPLEMENT(const char)
107  // EXTRACT_IMPLEMENT(const short)
108  // EXTRACT_IMPLEMENT(const int)
109  // EXTRACT_IMPLEMENT(const long)
110  // EXTRACT_IMPLEMENT(const unsigned short)
111  // EXTRACT_IMPLEMENT(const unsigned long)
112  // EXTRACT_IMPLEMENT(const float)
113  // EXTRACT_IMPLEMENT(const double)
114  // # endif
115 #endif
116 
117 #ifdef __TURBOC__
118 # if (__BORLANDC__ > 0x0520)
119 EXTRACT_IMPLEMENT(long double)
120 # else
121 EXTRACT_IMPLEMENT(const long double)
122 #endif
123 #endif
124 
void read(const test_smartlist &, void *, int nsize)
void open(const char *name, int mode=ios::in|ios::binary, int prot=0664)
Description not yet available.
Definition: ufstream.cpp:36
#define x
void open(const char *name, int mode=ios::out|ios::binary, int prot=0664)
Description not yet available.
Definition: ufstream.cpp:45
uostream(const char *name, int mode=ios::out|ios::binary, int prot=0664)
Definition: ufstream.cpp:27
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
#define INSERT_IMPLEMENT(TYPE)
Definition: ufstream.cpp:13
uistream(const char *name, int mode=ios::in|ios::binary, int prot=0664)
Description not yet available.
Definition: ufstream.cpp:54
#define EXTRACT_IMPLEMENT(TYPE)
Definition: ufstream.cpp:20
Description not yet available.
Definition: fvar.hpp:3516
uistream & operator>>(int &)
Definition: ufstream.cpp:59