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