| [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 | // | 
|---|
| [bb82c03] | 7 | // fstream -- | 
|---|
| [86bd7c1f] | 8 | // | 
|---|
| [90c3b1c] | 9 | // Author           : Peter A. Buhr | 
|---|
| [86bd7c1f] | 10 | // Created On       : Wed May 27 17:56:53 2015 | 
|---|
|  | 11 | // Last Modified By : Peter A. Buhr | 
|---|
| [40cac90] | 12 | // Last Modified On : Mon Feb 17 08:29:23 2020 | 
|---|
|  | 13 | // Update Count     : 175 | 
|---|
| [86bd7c1f] | 14 | // | 
|---|
|  | 15 |  | 
|---|
| [53a6c2a] | 16 | #pragma once | 
|---|
| [51b73452] | 17 |  | 
|---|
| [58b6d1b] | 18 | #include "iostream.hfa" | 
|---|
| [51b73452] | 19 |  | 
|---|
| [65240bb] | 20 |  | 
|---|
|  | 21 | //*********************************** ofstream *********************************** | 
|---|
|  | 22 |  | 
|---|
|  | 23 |  | 
|---|
| [53a6c2a] | 24 | enum { sepSize = 16 }; | 
|---|
| [53ba273] | 25 | struct ofstream { | 
|---|
| [d1a9ff5] | 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]; | 
|---|
| [53ba273] | 35 | }; // ofstream | 
|---|
| [90c3b1c] | 36 |  | 
|---|
| [9ebd778] | 37 | // private | 
|---|
| [d1a9ff5] | 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 ); | 
|---|
| [9ebd778] | 48 |  | 
|---|
|  | 49 | // public | 
|---|
| [09687aa] | 50 | void sepOn( ofstream & ); | 
|---|
|  | 51 | void sepOff( ofstream & ); | 
|---|
| [93c2e0a] | 52 | bool sepDisable( ofstream & ); | 
|---|
|  | 53 | bool sepEnable( ofstream & ); | 
|---|
| [200fcb3] | 54 | void nlOn( ofstream & ); | 
|---|
|  | 55 | void nlOff( ofstream & ); | 
|---|
| [9ebd778] | 56 |  | 
|---|
| [09687aa] | 57 | const char * sepGet( ofstream & ); | 
|---|
| [e3fea42] | 58 | void sepSet( ofstream &, const char [] ); | 
|---|
| [09687aa] | 59 | const char * sepGetTuple( ofstream & ); | 
|---|
| [e3fea42] | 60 | void sepSetTuple( ofstream &, const char [] ); | 
|---|
| [6152c81] | 61 |  | 
|---|
| [65240bb] | 62 | void ends( ofstream & os ); | 
|---|
| [09687aa] | 63 | int fail( ofstream & ); | 
|---|
|  | 64 | int flush( ofstream & ); | 
|---|
| [e3fea42] | 65 | void open( ofstream &, const char name[], const char mode[] ); | 
|---|
|  | 66 | void open( ofstream &, const char name[] ); | 
|---|
| [09687aa] | 67 | void close( ofstream & ); | 
|---|
| [e3fea42] | 68 | ofstream & write( ofstream &, const char data[], size_t size ); | 
|---|
| [40cac90] | 69 | int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); | 
|---|
| [829c907] | 70 |  | 
|---|
| [09687aa] | 71 | void ?{}( ofstream & os ); | 
|---|
| [e3fea42] | 72 | void ?{}( ofstream & os, const char name[], const char mode[] ); | 
|---|
|  | 73 | void ?{}( ofstream & os, const char name[] ); | 
|---|
| [4cae032] | 74 | void ^?{}( ofstream & os ); | 
|---|
| [09687aa] | 75 |  | 
|---|
| [a87d40b] | 76 | extern ofstream & sout, & stdout, & serr, & stderr;             // aliases | 
|---|
| [65240bb] | 77 | extern ofstream & exit, & abort; | 
|---|
|  | 78 |  | 
|---|
| [51b73452] | 79 |  | 
|---|
| [65240bb] | 80 | //*********************************** ifstream *********************************** | 
|---|
| [5cb2b8c] | 81 |  | 
|---|
| [51b73452] | 82 |  | 
|---|
| [53ba273] | 83 | struct ifstream { | 
|---|
| [d1a9ff5] | 84 | void * $file; | 
|---|
|  | 85 | bool $nlOnOff; | 
|---|
| [53ba273] | 86 | }; // ifstream | 
|---|
| [6ba0659] | 87 |  | 
|---|
| [09687aa] | 88 | // public | 
|---|
| [0efb269] | 89 | void nlOn( ifstream & ); | 
|---|
|  | 90 | void nlOff( ifstream & ); | 
|---|
|  | 91 | bool getANL( ifstream & ); | 
|---|
| [09687aa] | 92 | int fail( ifstream & is ); | 
|---|
|  | 93 | int eof( ifstream & is ); | 
|---|
| [e3fea42] | 94 | void open( ifstream & is, const char name[], const char mode[] ); | 
|---|
|  | 95 | void open( ifstream & is, const char name[] ); | 
|---|
| [09687aa] | 96 | void close( ifstream & is ); | 
|---|
| [91d766d] | 97 | ifstream & read( ifstream & is, char * data, size_t size ); | 
|---|
| [09687aa] | 98 | ifstream & ungetc( ifstream & is, char c ); | 
|---|
| [40cac90] | 99 | int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) )); | 
|---|
| [09687aa] | 100 |  | 
|---|
|  | 101 | void ?{}( ifstream & is ); | 
|---|
| [e3fea42] | 102 | void ?{}( ifstream & is, const char name[], const char mode[] ); | 
|---|
|  | 103 | void ?{}( ifstream & is, const char name[] ); | 
|---|
| [4cae032] | 104 | void ^?{}( ifstream & is ); | 
|---|
| [51b73452] | 105 |  | 
|---|
| [a87d40b] | 106 | extern ifstream & sin, & stdin;                                                 // aliases | 
|---|
| [51b73452] | 107 |  | 
|---|
| [86bd7c1f] | 108 | // Local Variables: // | 
|---|
| [d3b7937] | 109 | // mode: c // | 
|---|
| [86bd7c1f] | 110 | // tab-width: 4 // | 
|---|
|  | 111 | // End: // | 
|---|