| 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 | // | 
|---|
| 7 | // fstream -- | 
|---|
| 8 | // | 
|---|
| 9 | // Author           : Peter A. Buhr | 
|---|
| 10 | // Created On       : Wed May 27 17:56:53 2015 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr | 
|---|
| 12 | // Last Modified On : Fri Nov 29 06:56:02 2019 | 
|---|
| 13 | // Update Count     : 168 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #pragma once | 
|---|
| 17 |  | 
|---|
| 18 | #include "iostream.hfa" | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | //*********************************** ofstream *********************************** | 
|---|
| 22 |  | 
|---|
| 23 |  | 
|---|
| 24 | enum { sepSize = 16 }; | 
|---|
| 25 | struct ofstream { | 
|---|
| 26 | void * file; | 
|---|
| 27 | bool sepDefault; | 
|---|
| 28 | bool sepOnOff; | 
|---|
| 29 | bool nlOnOff; | 
|---|
| 30 | bool prt;                                                                                       // print text | 
|---|
| 31 | bool sawNL; | 
|---|
| 32 | const char * sepCur; | 
|---|
| 33 | char separator[sepSize]; | 
|---|
| 34 | char tupleSeparator[sepSize]; | 
|---|
| 35 | }; // ofstream | 
|---|
| 36 |  | 
|---|
| 37 | // private | 
|---|
| 38 | bool sepPrt( ofstream & ); | 
|---|
| 39 | void sepReset( ofstream & ); | 
|---|
| 40 | void sepReset( ofstream &, bool ); | 
|---|
| 41 | const char * sepGetCur( ofstream & ); | 
|---|
| 42 | void sepSetCur( ofstream &, const char * ); | 
|---|
| 43 | bool getNL( ofstream & ); | 
|---|
| 44 | void setNL( ofstream &, bool ); | 
|---|
| 45 | bool getANL( ofstream & ); | 
|---|
| 46 | bool getPrt( ofstream & ); | 
|---|
| 47 | void setPrt( ofstream &, bool ); | 
|---|
| 48 |  | 
|---|
| 49 | // public | 
|---|
| 50 | void sepOn( ofstream & ); | 
|---|
| 51 | void sepOff( ofstream & ); | 
|---|
| 52 | bool sepDisable( ofstream & ); | 
|---|
| 53 | bool sepEnable( ofstream & ); | 
|---|
| 54 | void nlOn( ofstream & ); | 
|---|
| 55 | void nlOff( ofstream & ); | 
|---|
| 56 |  | 
|---|
| 57 | const char * sepGet( ofstream & ); | 
|---|
| 58 | void sepSet( ofstream &, const char * ); | 
|---|
| 59 | const char * sepGetTuple( ofstream & ); | 
|---|
| 60 | void sepSetTuple( ofstream &, const char * ); | 
|---|
| 61 |  | 
|---|
| 62 | void ends( ofstream & os ); | 
|---|
| 63 | int fail( ofstream & ); | 
|---|
| 64 | int flush( ofstream & ); | 
|---|
| 65 | void open( ofstream &, const char * name, const char * mode ); | 
|---|
| 66 | void open( ofstream &, const char * name ); | 
|---|
| 67 | void close( ofstream & ); | 
|---|
| 68 | ofstream & write( ofstream &, const char * data, size_t size ); | 
|---|
| 69 | int fmt( ofstream &, const char format[], ... ); | 
|---|
| 70 |  | 
|---|
| 71 | void ?{}( ofstream & os ); | 
|---|
| 72 | void ?{}( ofstream & os, const char * name, const char * mode ); | 
|---|
| 73 | void ?{}( ofstream & os, const char * name ); | 
|---|
| 74 | void ^?{}( ofstream & os ); | 
|---|
| 75 |  | 
|---|
| 76 | extern ofstream & sout, & stdout, & serr, & stderr;             // aliases | 
|---|
| 77 | extern ofstream & exit, & abort; | 
|---|
| 78 |  | 
|---|
| 79 |  | 
|---|
| 80 | //*********************************** ifstream *********************************** | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|
| 83 | struct ifstream { | 
|---|
| 84 | void * file; | 
|---|
| 85 | bool nlOnOff; | 
|---|
| 86 | }; // ifstream | 
|---|
| 87 |  | 
|---|
| 88 | // public | 
|---|
| 89 | void nlOn( ifstream & ); | 
|---|
| 90 | void nlOff( ifstream & ); | 
|---|
| 91 | bool getANL( ifstream & ); | 
|---|
| 92 | int fail( ifstream & is ); | 
|---|
| 93 | int eof( ifstream & is ); | 
|---|
| 94 | void open( ifstream & is, const char * name, const char * mode ); | 
|---|
| 95 | void open( ifstream & is, const char * name ); | 
|---|
| 96 | void close( ifstream & is ); | 
|---|
| 97 | ifstream & read( ifstream & is, char * data, size_t size ); | 
|---|
| 98 | ifstream & ungetc( ifstream & is, char c ); | 
|---|
| 99 | int fmt( ifstream &, const char format[], ... ); | 
|---|
| 100 |  | 
|---|
| 101 | void ?{}( ifstream & is ); | 
|---|
| 102 | void ?{}( ifstream & is, const char * name, const char * mode ); | 
|---|
| 103 | void ?{}( ifstream & is, const char * name ); | 
|---|
| 104 | void ^?{}( ifstream & is ); | 
|---|
| 105 |  | 
|---|
| 106 | extern ifstream & sin, & stdin;                                                 // aliases | 
|---|
| 107 |  | 
|---|
| 108 | // Local Variables: // | 
|---|
| 109 | // mode: c // | 
|---|
| 110 | // tab-width: 4 // | 
|---|
| 111 | // End: // | 
|---|