[86bd7c1f] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
[356189a] | 7 | // fstream.c -- |
---|
[86bd7c1f] | 8 | // |
---|
[90c3b1c] | 9 | // Author : Peter A. Buhr |
---|
[86bd7c1f] | 10 | // Created On : Wed May 27 17:56:53 2015 |
---|
[5d125e4] | 11 | // Last Modified By : Peter A. Buhr |
---|
[3bf3b6b] | 12 | // Last Modified On : Tue Sep 21 21:51:38 2021 |
---|
| 13 | // Update Count : 460 |
---|
[86bd7c1f] | 14 | // |
---|
| 15 | |
---|
[f451177] | 16 | #include "fstream.hfa" // also includes iostream.hfa |
---|
[51b7345] | 17 | |
---|
[90c3b1c] | 18 | #include <stdio.h> // vfprintf, vfscanf |
---|
| 19 | #include <stdlib.h> // exit |
---|
| 20 | #include <stdarg.h> // varargs |
---|
[b431515] | 21 | #include <string.h> // strncpy, strerror |
---|
[91c389a] | 22 | #include <assert.h> |
---|
[8a25be9] | 23 | #include <errno.h> // errno |
---|
[51b7345] | 24 | |
---|
[8d321f9] | 25 | // *********************************** ofstream *********************************** |
---|
[65240bb] | 26 | |
---|
| 27 | |
---|
[53ba273] | 28 | #define IO_MSG "I/O error: " |
---|
[6ba0659] | 29 | |
---|
[3bf3b6b] | 30 | void ?{}( ofstream & os, void * file ) with(os) { |
---|
| 31 | file$ = file; |
---|
| 32 | sepDefault$ = true; |
---|
| 33 | sepOnOff$ = false; |
---|
| 34 | nlOnOff$ = true; |
---|
| 35 | prt$ = false; |
---|
| 36 | sawNL$ = false; |
---|
| 37 | acquired$ = false; |
---|
[6c5d92f] | 38 | sepSetCur$( os, sepGet( os ) ); |
---|
[5cb2b8c] | 39 | sepSet( os, " " ); |
---|
| 40 | sepSetTuple( os, ", " ); |
---|
[65240bb] | 41 | } // ?{} |
---|
[0583064b] | 42 | |
---|
[9ebd778] | 43 | // private |
---|
[6c5d92f] | 44 | bool sepPrt$( ofstream & os ) { setNL$( os, false ); return os.sepOnOff$; } |
---|
| 45 | void sepReset$( ofstream & os ) { os.sepOnOff$ = os.sepDefault$; } |
---|
| 46 | void sepReset$( ofstream & os, bool reset ) { os.sepDefault$ = reset; os.sepOnOff$ = os.sepDefault$; } |
---|
| 47 | const char * sepGetCur$( ofstream & os ) { return os.sepCur$; } |
---|
| 48 | void sepSetCur$( ofstream & os, const char sepCur[] ) { os.sepCur$ = sepCur; } |
---|
| 49 | bool getNL$( ofstream & os ) { return os.sawNL$; } |
---|
| 50 | void setNL$( ofstream & os, bool state ) { os.sawNL$ = state; } |
---|
| 51 | bool getANL$( ofstream & os ) { return os.nlOnOff$; } |
---|
| 52 | bool getPrt$( ofstream & os ) { return os.prt$; } |
---|
| 53 | void setPrt$( ofstream & os, bool state ) { os.prt$ = state; } |
---|
[829c907] | 54 | |
---|
[9ebd778] | 55 | // public |
---|
[6c5d92f] | 56 | void ?{}( ofstream & os ) { os.file$ = 0p; } |
---|
[829c907] | 57 | |
---|
[e3fea42] | 58 | void ?{}( ofstream & os, const char name[], const char mode[] ) { |
---|
[09687aa] | 59 | open( os, name, mode ); |
---|
[65240bb] | 60 | } // ?{} |
---|
| 61 | |
---|
[e3fea42] | 62 | void ?{}( ofstream & os, const char name[] ) { |
---|
[8da74119] | 63 | open( os, name, "w" ); |
---|
[65240bb] | 64 | } // ?{} |
---|
[09687aa] | 65 | |
---|
[4cae032] | 66 | void ^?{}( ofstream & os ) { |
---|
| 67 | close( os ); |
---|
| 68 | } // ^?{} |
---|
| 69 | |
---|
[6c5d92f] | 70 | void sepOn( ofstream & os ) { os.sepOnOff$ = ! getNL$( os ); } |
---|
| 71 | void sepOff( ofstream & os ) { os.sepOnOff$ = false; } |
---|
[09687aa] | 72 | |
---|
[93c2e0a] | 73 | bool sepDisable( ofstream & os ) { |
---|
[6c5d92f] | 74 | bool temp = os.sepDefault$; |
---|
| 75 | os.sepDefault$ = false; |
---|
| 76 | sepReset$( os ); |
---|
[53ba273] | 77 | return temp; |
---|
| 78 | } // sepDisable |
---|
[6152c81] | 79 | |
---|
[93c2e0a] | 80 | bool sepEnable( ofstream & os ) { |
---|
[6c5d92f] | 81 | bool temp = os.sepDefault$; |
---|
| 82 | os.sepDefault$ = true; |
---|
| 83 | if ( os.sepOnOff$ ) sepReset$( os ); // start of line ? |
---|
[53ba273] | 84 | return temp; |
---|
| 85 | } // sepEnable |
---|
[90c3b1c] | 86 | |
---|
[6c5d92f] | 87 | void nlOn( ofstream & os ) { os.nlOnOff$ = true; } |
---|
| 88 | void nlOff( ofstream & os ) { os.nlOnOff$ = false; } |
---|
[200fcb3] | 89 | |
---|
[6c5d92f] | 90 | const char * sepGet( ofstream & os ) { return os.separator$; } |
---|
[e3fea42] | 91 | void sepSet( ofstream & os, const char s[] ) { |
---|
[9ebd778] | 92 | assert( s ); |
---|
[b431515] | 93 | strncpy( os.separator$, s, ofstream_sepSize - 1 ); |
---|
| 94 | os.separator$[ofstream_sepSize - 1] = '\0'; |
---|
[9ebd778] | 95 | } // sepSet |
---|
| 96 | |
---|
[6c5d92f] | 97 | const char * sepGetTuple( ofstream & os ) { return os.tupleSeparator$; } |
---|
[e3fea42] | 98 | void sepSetTuple( ofstream & os, const char s[] ) { |
---|
[9ebd778] | 99 | assert( s ); |
---|
[b431515] | 100 | strncpy( os.tupleSeparator$, s, ofstream_sepSize - 1 ); |
---|
| 101 | os.tupleSeparator$[ofstream_sepSize - 1] = '\0'; |
---|
[9ebd778] | 102 | } // sepSet |
---|
| 103 | |
---|
[65240bb] | 104 | void ends( ofstream & os ) { |
---|
[6c5d92f] | 105 | if ( getANL$( os ) ) nl( os ); |
---|
| 106 | else setPrt$( os, false ); // turn off |
---|
[65240bb] | 107 | if ( &os == &exit ) exit( EXIT_FAILURE ); |
---|
| 108 | if ( &os == &abort ) abort(); |
---|
[6c5d92f] | 109 | if ( os.acquired$ ) { os.acquired$ = false; release( os ); } |
---|
[65240bb] | 110 | } // ends |
---|
| 111 | |
---|
[b431515] | 112 | bool fail( ofstream & os ) { |
---|
[6c5d92f] | 113 | return os.file$ == 0 || ferror( (FILE *)(os.file$) ); |
---|
[6ba0659] | 114 | } // fail |
---|
| 115 | |
---|
[00e9be9] | 116 | void clear( ofstream & os ) { |
---|
| 117 | clearerr( (FILE *)(os.file$) ); |
---|
| 118 | } // clear |
---|
| 119 | |
---|
[09687aa] | 120 | int flush( ofstream & os ) { |
---|
[6c5d92f] | 121 | return fflush( (FILE *)(os.file$) ); |
---|
[6ba0659] | 122 | } // flush |
---|
| 123 | |
---|
[e3fea42] | 124 | void open( ofstream & os, const char name[], const char mode[] ) { |
---|
[5cb2b8c] | 125 | FILE * file = fopen( name, mode ); |
---|
[d1a9ff5] | 126 | if ( file == 0p ) { |
---|
[8d321f9] | 127 | throw (Open_Failure){ os }; |
---|
| 128 | // abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno ); |
---|
[93c2e0a] | 129 | } // if |
---|
[3bf3b6b] | 130 | (os){ file }; // initialize |
---|
[6ba0659] | 131 | } // open |
---|
| 132 | |
---|
[e3fea42] | 133 | void open( ofstream & os, const char name[] ) { |
---|
[8da74119] | 134 | open( os, name, "w" ); |
---|
| 135 | } // open |
---|
| 136 | |
---|
[3bf3b6b] | 137 | void close( ofstream & os ) with(os) { |
---|
| 138 | if ( (FILE *)(file$) == 0p ) return; |
---|
| 139 | if ( (FILE *)(file$) == (FILE *)stdout || (FILE *)(file$) == (FILE *)stderr ) return; |
---|
[6ba0659] | 140 | |
---|
[3bf3b6b] | 141 | if ( fclose( (FILE *)(file$) ) == EOF ) { |
---|
[ba0d2ea] | 142 | throw (Close_Failure){ os }; |
---|
| 143 | // abort | IO_MSG "close output" | nl | strerror( errno ); |
---|
[356189a] | 144 | } // if |
---|
[3bf3b6b] | 145 | file$ = 0p; |
---|
[6ba0659] | 146 | } // close |
---|
| 147 | |
---|
[e3fea42] | 148 | ofstream & write( ofstream & os, const char data[], size_t size ) { |
---|
[6ba0659] | 149 | if ( fail( os ) ) { |
---|
[ba0d2ea] | 150 | throw (Write_Failure){ os }; |
---|
| 151 | // abort | IO_MSG "attempt write I/O on failed stream"; |
---|
[6ba0659] | 152 | } // if |
---|
| 153 | |
---|
[6c5d92f] | 154 | if ( fwrite( data, 1, size, (FILE *)(os.file$) ) != size ) { |
---|
[ba0d2ea] | 155 | throw (Write_Failure){ os }; |
---|
| 156 | // abort | IO_MSG "write" | nl | strerror( errno ); |
---|
[839ccbb] | 157 | } // if |
---|
[86bd7c1f] | 158 | return os; |
---|
[839ccbb] | 159 | } // write |
---|
[51b7345] | 160 | |
---|
[09687aa] | 161 | int fmt( ofstream & os, const char format[], ... ) { |
---|
[5d125e4] | 162 | va_list args; |
---|
[829c907] | 163 | va_start( args, format ); |
---|
[6c5d92f] | 164 | int len = vfprintf( (FILE *)(os.file$), format, args ); |
---|
[90c3b1c] | 165 | if ( len == EOF ) { |
---|
[6c5d92f] | 166 | if ( ferror( (FILE *)(os.file$) ) ) { |
---|
[ff2a33e] | 167 | abort | IO_MSG "invalid write"; |
---|
[90c3b1c] | 168 | } // if |
---|
| 169 | } // if |
---|
[5d125e4] | 170 | va_end( args ); |
---|
[b72bad4f] | 171 | |
---|
[6c5d92f] | 172 | setPrt$( os, true ); // called in output cascade |
---|
| 173 | sepReset$( os ); // reset separator |
---|
[90c3b1c] | 174 | return len; |
---|
[829c907] | 175 | } // fmt |
---|
| 176 | |
---|
[3bf3b6b] | 177 | inline void acquire( ofstream & os ) with(os) { |
---|
| 178 | lock( lock$ ); // may increase recursive lock |
---|
| 179 | if ( ! acquired$ ) acquired$ = true; // not locked ? |
---|
| 180 | else unlock( lock$ ); // unwind recursive lock at start |
---|
[e474cf09] | 181 | } // acquire |
---|
| 182 | |
---|
| 183 | inline void release( ofstream & os ) { |
---|
[6c5d92f] | 184 | unlock( os.lock$ ); |
---|
[e474cf09] | 185 | } // release |
---|
| 186 | |
---|
[3bf3b6b] | 187 | void ?{}( osacquire & acq, ofstream & os ) { lock( os.lock$ ); &acq.os = &os; } |
---|
[e474cf09] | 188 | void ^?{}( osacquire & acq ) { release( acq.os ); } |
---|
| 189 | |
---|
[fd8f88f] | 190 | static ofstream soutFile = { (FILE *)stdout }; |
---|
[a87d40b] | 191 | ofstream & sout = soutFile, & stdout = soutFile; |
---|
[fd8f88f] | 192 | static ofstream serrFile = { (FILE *)stderr }; |
---|
[a87d40b] | 193 | ofstream & serr = serrFile, & stderr = serrFile; |
---|
[51b7345] | 194 | |
---|
[e474cf09] | 195 | static ofstream lsoutFile = { (FILE *)stdout }; |
---|
| 196 | ofstream & lsout = lsoutFile; |
---|
| 197 | |
---|
[fd8f88f] | 198 | static ofstream exitFile = { (FILE *)stdout }; |
---|
[65240bb] | 199 | ofstream & exit = exitFile; |
---|
[fd8f88f] | 200 | static ofstream abortFile = { (FILE *)stderr }; |
---|
[65240bb] | 201 | ofstream & abort = abortFile; |
---|
[5cb2b8c] | 202 | |
---|
[f451177] | 203 | ofstream & nl( ofstream & os ) { |
---|
| 204 | nl$( os ); // call basic_ostream nl |
---|
| 205 | flush( os ); |
---|
| 206 | return os; |
---|
| 207 | // (ofstream &)(os | '\n'); |
---|
| 208 | // setPrt$( os, false ); // turn off |
---|
| 209 | // setNL$( os, true ); |
---|
| 210 | // flush( os ); |
---|
| 211 | // return sepOff( os ); // prepare for next line |
---|
| 212 | } // nl |
---|
[90c3b1c] | 213 | |
---|
[00e9be9] | 214 | |
---|
[8d321f9] | 215 | // *********************************** ifstream *********************************** |
---|
[65240bb] | 216 | |
---|
[51b7345] | 217 | |
---|
[09687aa] | 218 | // private |
---|
[3bf3b6b] | 219 | void ?{}( ifstream & is, void * file ) with(is) { |
---|
| 220 | file$ = file; |
---|
| 221 | nlOnOff$ = false; |
---|
| 222 | acquired$ = false; |
---|
[65240bb] | 223 | } // ?{} |
---|
[09687aa] | 224 | |
---|
| 225 | // public |
---|
[6c5d92f] | 226 | void ?{}( ifstream & is ) { is.file$ = 0p; } |
---|
[51b7345] | 227 | |
---|
[e3fea42] | 228 | void ?{}( ifstream & is, const char name[], const char mode[] ) { |
---|
[8da74119] | 229 | open( is, name, mode ); |
---|
[65240bb] | 230 | } // ?{} |
---|
| 231 | |
---|
[e3fea42] | 232 | void ?{}( ifstream & is, const char name[] ) { |
---|
[8da74119] | 233 | open( is, name, "r" ); |
---|
[65240bb] | 234 | } // ?{} |
---|
[09687aa] | 235 | |
---|
[4cae032] | 236 | void ^?{}( ifstream & is ) { |
---|
| 237 | close( is ); |
---|
| 238 | } // ^?{} |
---|
| 239 | |
---|
[6c5d92f] | 240 | void nlOn( ifstream & os ) { os.nlOnOff$ = true; } |
---|
| 241 | void nlOff( ifstream & os ) { os.nlOnOff$ = false; } |
---|
| 242 | bool getANL( ifstream & os ) { return os.nlOnOff$; } |
---|
[0efb269] | 243 | |
---|
[b431515] | 244 | bool fail( ifstream & is ) { |
---|
[6c5d92f] | 245 | return is.file$ == 0p || ferror( (FILE *)(is.file$) ); |
---|
[6ba0659] | 246 | } // fail |
---|
| 247 | |
---|
[00e9be9] | 248 | void clear( ifstream & is ) { |
---|
| 249 | clearerr( (FILE *)(is.file$) ); |
---|
| 250 | } // clear |
---|
| 251 | |
---|
[e474cf09] | 252 | void ends( ifstream & is ) { |
---|
[6c5d92f] | 253 | if ( is.acquired$ ) { is.acquired$ = false; release( is ); } |
---|
[e474cf09] | 254 | } // ends |
---|
| 255 | |
---|
[00e9be9] | 256 | bool eof( ifstream & is ) { |
---|
[6c5d92f] | 257 | return feof( (FILE *)(is.file$) ); |
---|
[6ba0659] | 258 | } // eof |
---|
| 259 | |
---|
[e3fea42] | 260 | void open( ifstream & is, const char name[], const char mode[] ) { |
---|
[8a25be9] | 261 | FILE * file = fopen( name, mode ); |
---|
[d1a9ff5] | 262 | if ( file == 0p ) { |
---|
[8d321f9] | 263 | throw (Open_Failure){ is }; |
---|
| 264 | // abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno ); |
---|
[93c2e0a] | 265 | } // if |
---|
[3bf3b6b] | 266 | (is){ file }; // initialize |
---|
[90c3b1c] | 267 | } // open |
---|
[6ba0659] | 268 | |
---|
[e3fea42] | 269 | void open( ifstream & is, const char name[] ) { |
---|
[8da74119] | 270 | open( is, name, "r" ); |
---|
| 271 | } // open |
---|
| 272 | |
---|
[3bf3b6b] | 273 | void close( ifstream & is ) with(is) { |
---|
| 274 | if ( (FILE *)(file$) == 0p ) return; |
---|
| 275 | if ( (FILE *)(file$) == (FILE *)stdin ) return; |
---|
[90c3b1c] | 276 | |
---|
[3bf3b6b] | 277 | if ( fclose( (FILE *)(file$) ) == EOF ) { |
---|
[ba0d2ea] | 278 | throw (Close_Failure){ is }; |
---|
| 279 | // abort | IO_MSG "close input" | nl | strerror( errno ); |
---|
[356189a] | 280 | } // if |
---|
[3bf3b6b] | 281 | file$ = 0p; |
---|
[90c3b1c] | 282 | } // close |
---|
| 283 | |
---|
[00e9be9] | 284 | ifstream & read( ifstream & is, char data[], size_t size ) { |
---|
[6ba0659] | 285 | if ( fail( is ) ) { |
---|
[ba0d2ea] | 286 | throw (Read_Failure){ is }; |
---|
| 287 | // abort | IO_MSG "attempt read I/O on failed stream"; |
---|
[6ba0659] | 288 | } // if |
---|
| 289 | |
---|
[6c5d92f] | 290 | if ( fread( data, size, 1, (FILE *)(is.file$) ) == 0 ) { |
---|
[ba0d2ea] | 291 | throw (Read_Failure){ is }; |
---|
| 292 | // abort | IO_MSG "read" | nl | strerror( errno ); |
---|
[6ba0659] | 293 | } // if |
---|
[86bd7c1f] | 294 | return is; |
---|
[6ba0659] | 295 | } // read |
---|
[356189a] | 296 | |
---|
[09687aa] | 297 | ifstream &ungetc( ifstream & is, char c ) { |
---|
[6ba0659] | 298 | if ( fail( is ) ) { |
---|
[ff2a33e] | 299 | abort | IO_MSG "attempt ungetc I/O on failed stream"; |
---|
[6ba0659] | 300 | } // if |
---|
[51b7345] | 301 | |
---|
[6c5d92f] | 302 | if ( ungetc( c, (FILE *)(is.file$) ) == EOF ) { |
---|
[ff2a33e] | 303 | abort | IO_MSG "ungetc" | nl | strerror( errno ); |
---|
[6ba0659] | 304 | } // if |
---|
| 305 | return is; |
---|
| 306 | } // ungetc |
---|
[51b7345] | 307 | |
---|
[09687aa] | 308 | int fmt( ifstream & is, const char format[], ... ) { |
---|
[5d125e4] | 309 | va_list args; |
---|
[51b7345] | 310 | |
---|
[829c907] | 311 | va_start( args, format ); |
---|
[6c5d92f] | 312 | int len = vfscanf( (FILE *)(is.file$), format, args ); |
---|
[90c3b1c] | 313 | if ( len == EOF ) { |
---|
[6c5d92f] | 314 | if ( ferror( (FILE *)(is.file$) ) ) { |
---|
[ff2a33e] | 315 | abort | IO_MSG "invalid read"; |
---|
[90c3b1c] | 316 | } // if |
---|
| 317 | } // if |
---|
[5d125e4] | 318 | va_end( args ); |
---|
[90c3b1c] | 319 | return len; |
---|
[829c907] | 320 | } // fmt |
---|
[51b7345] | 321 | |
---|
[3bf3b6b] | 322 | inline void acquire( ifstream & is ) with(is) { |
---|
| 323 | lock( lock$ ); // may increase recursive lock |
---|
| 324 | if ( ! acquired$ ) acquired$ = true; // not locked ? |
---|
| 325 | else unlock( lock$ ); // unwind recursive lock at start |
---|
[e474cf09] | 326 | } // acquire |
---|
| 327 | |
---|
| 328 | inline void release( ifstream & is ) { |
---|
[6c5d92f] | 329 | unlock( is.lock$ ); |
---|
[e474cf09] | 330 | } // release |
---|
| 331 | |
---|
[3bf3b6b] | 332 | void ?{}( isacquire & acq, ifstream & is ) { lock( is.lock$ ); &acq.is = &is; } |
---|
[e474cf09] | 333 | void ^?{}( isacquire & acq ) { release( acq.is ); } |
---|
| 334 | |
---|
[fd8f88f] | 335 | static ifstream sinFile = { (FILE *)stdin }; |
---|
[a87d40b] | 336 | ifstream & sin = sinFile, & stdin = sinFile; |
---|
[86bd7c1f] | 337 | |
---|
[91e52be] | 338 | |
---|
[8d321f9] | 339 | // *********************************** exceptions *********************************** |
---|
[91e52be] | 340 | |
---|
| 341 | |
---|
[ba0d2ea] | 342 | static vtable(Open_Failure) Open_Failure_vt; |
---|
[a5a6a1a8] | 343 | |
---|
| 344 | // exception I/O constructors |
---|
[3bf3b6b] | 345 | void ?{}( Open_Failure & ex, ofstream & ostream ) with(ex) { |
---|
| 346 | virtual_table = &Open_Failure_vt; |
---|
| 347 | ostream = &ostream; |
---|
| 348 | tag = 1; |
---|
[a5a6a1a8] | 349 | } // ?{} |
---|
| 350 | |
---|
[3bf3b6b] | 351 | void ?{}( Open_Failure & ex, ifstream & istream ) with(ex) { |
---|
| 352 | virtual_table = &Open_Failure_vt; |
---|
| 353 | istream = &istream; |
---|
| 354 | tag = 0; |
---|
[a5a6a1a8] | 355 | } // ?{} |
---|
| 356 | |
---|
| 357 | |
---|
[ba0d2ea] | 358 | static vtable(Close_Failure) Close_Failure_vt; |
---|
| 359 | |
---|
| 360 | // exception I/O constructors |
---|
[3bf3b6b] | 361 | void ?{}( Close_Failure & ex, ofstream & ostream ) with(ex) { |
---|
| 362 | virtual_table = &Close_Failure_vt; |
---|
| 363 | ostream = &ostream; |
---|
| 364 | tag = 1; |
---|
[ba0d2ea] | 365 | } // ?{} |
---|
| 366 | |
---|
[3bf3b6b] | 367 | void ?{}( Close_Failure & ex, ifstream & istream ) with(ex) { |
---|
| 368 | virtual_table = &Close_Failure_vt; |
---|
| 369 | istream = &istream; |
---|
| 370 | tag = 0; |
---|
[ba0d2ea] | 371 | } // ?{} |
---|
| 372 | |
---|
| 373 | |
---|
| 374 | static vtable(Write_Failure) Write_Failure_vt; |
---|
| 375 | |
---|
| 376 | // exception I/O constructors |
---|
[3bf3b6b] | 377 | void ?{}( Write_Failure & ex, ofstream & ostream ) with(ex) { |
---|
| 378 | virtual_table = &Write_Failure_vt; |
---|
| 379 | ostream = &ostream; |
---|
| 380 | tag = 1; |
---|
[ba0d2ea] | 381 | } // ?{} |
---|
| 382 | |
---|
[3bf3b6b] | 383 | void ?{}( Write_Failure & ex, ifstream & istream ) with(ex) { |
---|
| 384 | virtual_table = &Write_Failure_vt; |
---|
| 385 | istream = &istream; |
---|
| 386 | tag = 0; |
---|
[ba0d2ea] | 387 | } // ?{} |
---|
| 388 | |
---|
| 389 | |
---|
| 390 | static vtable(Read_Failure) Read_Failure_vt; |
---|
| 391 | |
---|
| 392 | // exception I/O constructors |
---|
[3bf3b6b] | 393 | void ?{}( Read_Failure & ex, ofstream & ostream ) with(ex) { |
---|
| 394 | virtual_table = &Read_Failure_vt; |
---|
| 395 | ostream = &ostream; |
---|
| 396 | tag = 1; |
---|
[ba0d2ea] | 397 | } // ?{} |
---|
| 398 | |
---|
[3bf3b6b] | 399 | void ?{}( Read_Failure & ex, ifstream & istream ) with(ex) { |
---|
| 400 | virtual_table = &Read_Failure_vt; |
---|
| 401 | istream = &istream; |
---|
| 402 | tag = 0; |
---|
[ba0d2ea] | 403 | } // ?{} |
---|
| 404 | |
---|
| 405 | // void throwOpen_Failure( ofstream & ostream ) { |
---|
| 406 | // Open_Failure exc = { ostream }; |
---|
| 407 | // } |
---|
| 408 | |
---|
| 409 | // void throwOpen_Failure( ifstream & istream ) { |
---|
| 410 | // Open_Failure exc = { istream }; |
---|
| 411 | // } |
---|
[91e52be] | 412 | |
---|
[86bd7c1f] | 413 | // Local Variables: // |
---|
| 414 | // tab-width: 4 // |
---|
| 415 | // End: // |
---|