| [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 | 
|---|
| [9d362a0] | 12 | // Last Modified On : Mon Dec 24 18:33:41 2018 | 
|---|
|  | 13 | // Update Count     : 149 | 
|---|
| [86bd7c1f] | 14 | // | 
|---|
|  | 15 |  | 
|---|
| [53a6c2a] | 16 | #pragma once | 
|---|
| [51b73452] | 17 |  | 
|---|
| [58b6d1b] | 18 | #include "iostream.hfa" | 
|---|
| [51b73452] | 19 |  | 
|---|
| [53a6c2a] | 20 | enum { sepSize = 16 }; | 
|---|
| [53ba273] | 21 | struct ofstream { | 
|---|
| [829c907] | 22 | void * file; | 
|---|
| [93c2e0a] | 23 | bool sepDefault; | 
|---|
|  | 24 | bool sepOnOff; | 
|---|
| [200fcb3] | 25 | bool nlOnOff; | 
|---|
| [5ea5b28] | 26 | bool prt;                                                                                       // print text | 
|---|
| [93c2e0a] | 27 | bool sawNL; | 
|---|
| [829c907] | 28 | const char * sepCur; | 
|---|
| [53a6c2a] | 29 | char separator[sepSize]; | 
|---|
|  | 30 | char tupleSeparator[sepSize]; | 
|---|
| [53ba273] | 31 | }; // ofstream | 
|---|
| [90c3b1c] | 32 |  | 
|---|
| [9ebd778] | 33 | // private | 
|---|
| [93c2e0a] | 34 | bool sepPrt( ofstream & ); | 
|---|
| [09687aa] | 35 | void sepReset( ofstream & ); | 
|---|
| [93c2e0a] | 36 | void sepReset( ofstream &, bool ); | 
|---|
| [09687aa] | 37 | const char * sepGetCur( ofstream & ); | 
|---|
|  | 38 | void sepSetCur( ofstream &, const char * ); | 
|---|
| [93c2e0a] | 39 | bool getNL( ofstream & ); | 
|---|
|  | 40 | void setNL( ofstream &, bool ); | 
|---|
| [200fcb3] | 41 | bool getANL( ofstream & ); | 
|---|
| [5ea5b28] | 42 | bool getPrt( ofstream & ); | 
|---|
|  | 43 | void setPrt( ofstream &, bool ); | 
|---|
| [9ebd778] | 44 |  | 
|---|
|  | 45 | // public | 
|---|
| [09687aa] | 46 | void sepOn( ofstream & ); | 
|---|
|  | 47 | void sepOff( ofstream & ); | 
|---|
| [93c2e0a] | 48 | bool sepDisable( ofstream & ); | 
|---|
|  | 49 | bool sepEnable( ofstream & ); | 
|---|
| [200fcb3] | 50 | void nlOn( ofstream & ); | 
|---|
|  | 51 | void nlOff( ofstream & ); | 
|---|
| [9ebd778] | 52 |  | 
|---|
| [09687aa] | 53 | const char * sepGet( ofstream & ); | 
|---|
|  | 54 | void sepSet( ofstream &, const char * ); | 
|---|
|  | 55 | const char * sepGetTuple( ofstream & ); | 
|---|
|  | 56 | void sepSetTuple( ofstream &, const char * ); | 
|---|
| [6152c81] | 57 |  | 
|---|
| [09687aa] | 58 | int fail( ofstream & ); | 
|---|
|  | 59 | int flush( ofstream & ); | 
|---|
|  | 60 | void open( ofstream &, const char * name, const char * mode ); | 
|---|
| [8da74119] | 61 | void open( ofstream &, const char * name ); | 
|---|
| [09687aa] | 62 | void close( ofstream & ); | 
|---|
| [91d766d] | 63 | ofstream & write( ofstream &, const char * data, size_t size ); | 
|---|
| [9d362a0] | 64 | int fmt( ofstream &, const char format[], ... ); | 
|---|
| [829c907] | 65 |  | 
|---|
| [09687aa] | 66 | void ?{}( ofstream & os ); | 
|---|
|  | 67 | void ?{}( ofstream & os, const char * name, const char * mode ); | 
|---|
| [8da74119] | 68 | void ?{}( ofstream & os, const char * name ); | 
|---|
| [09687aa] | 69 |  | 
|---|
|  | 70 | extern ofstream & sout, & serr; | 
|---|
| [51b73452] | 71 |  | 
|---|
|  | 72 |  | 
|---|
| [53ba273] | 73 | struct ifstream { | 
|---|
| [829c907] | 74 | void * file; | 
|---|
| [53ba273] | 75 | }; // ifstream | 
|---|
| [6ba0659] | 76 |  | 
|---|
| [09687aa] | 77 | // public | 
|---|
|  | 78 | int fail( ifstream & is ); | 
|---|
|  | 79 | int eof( ifstream & is ); | 
|---|
| [8da74119] | 80 | void open( ifstream & is, const char * name, const char * mode ); | 
|---|
| [09687aa] | 81 | void open( ifstream & is, const char * name ); | 
|---|
|  | 82 | void close( ifstream & is ); | 
|---|
| [91d766d] | 83 | ifstream & read( ifstream & is, char * data, size_t size ); | 
|---|
| [09687aa] | 84 | ifstream & ungetc( ifstream & is, char c ); | 
|---|
| [9d362a0] | 85 | int fmt( ifstream &, const char format[], ... ); | 
|---|
| [09687aa] | 86 |  | 
|---|
|  | 87 | void ?{}( ifstream & is ); | 
|---|
| [8da74119] | 88 | void ?{}( ifstream & is, const char * name, const char * mode ); | 
|---|
| [09687aa] | 89 | void ?{}( ifstream & is, const char * name ); | 
|---|
| [51b73452] | 90 |  | 
|---|
| [09687aa] | 91 | extern ifstream & sin; | 
|---|
| [51b73452] | 92 |  | 
|---|
| [86bd7c1f] | 93 | // Local Variables: // | 
|---|
| [d3b7937] | 94 | // mode: c // | 
|---|
| [86bd7c1f] | 95 | // tab-width: 4 // | 
|---|
|  | 96 | // End: // | 
|---|