| [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
 | 
|---|
| [5cb2b8c] | 12 | // Last Modified On : Thu May 16 08:34:10 2019
 | 
|---|
 | 13 | // Update Count     : 157
 | 
|---|
| [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 | 
 | 
|---|
| [5cb2b8c] | 72 | // extern ofstream & sout, & serr, & sexit, & sabort;
 | 
|---|
 | 73 | // void nl( ofstream & os );
 | 
|---|
 | 74 | 
 | 
|---|
| [51b73452] | 75 | 
 | 
|---|
| [53ba273] | 76 | struct ifstream {
 | 
|---|
| [829c907] | 77 |         void * file;
 | 
|---|
| [0efb269] | 78 |         bool nlOnOff;
 | 
|---|
| [53ba273] | 79 | }; // ifstream
 | 
|---|
| [6ba0659] | 80 | 
 | 
|---|
| [09687aa] | 81 | // public
 | 
|---|
| [0efb269] | 82 | void nlOn( ifstream & );
 | 
|---|
 | 83 | void nlOff( ifstream & );
 | 
|---|
 | 84 | bool getANL( ifstream & );
 | 
|---|
| [09687aa] | 85 | int fail( ifstream & is );
 | 
|---|
 | 86 | int eof( ifstream & is );
 | 
|---|
| [8da74119] | 87 | void open( ifstream & is, const char * name, const char * mode );
 | 
|---|
| [09687aa] | 88 | void open( ifstream & is, const char * name );
 | 
|---|
 | 89 | void close( ifstream & is );
 | 
|---|
| [91d766d] | 90 | ifstream & read( ifstream & is, char * data, size_t size );
 | 
|---|
| [09687aa] | 91 | ifstream & ungetc( ifstream & is, char c );
 | 
|---|
| [9d362a0] | 92 | int fmt( ifstream &, const char format[], ... );
 | 
|---|
| [09687aa] | 93 | 
 | 
|---|
 | 94 | void ?{}( ifstream & is );
 | 
|---|
| [8da74119] | 95 | void ?{}( ifstream & is, const char * name, const char * mode );
 | 
|---|
| [09687aa] | 96 | void ?{}( ifstream & is, const char * name );
 | 
|---|
| [51b73452] | 97 | 
 | 
|---|
| [09687aa] | 98 | extern ifstream & sin;
 | 
|---|
| [51b73452] | 99 | 
 | 
|---|
| [86bd7c1f] | 100 | // Local Variables: //
 | 
|---|
| [d3b7937] | 101 | // mode: c //
 | 
|---|
| [86bd7c1f] | 102 | // tab-width: 4 //
 | 
|---|
 | 103 | // End: //
 | 
|---|