| 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 Jul 7 08:32:38 2017
|
|---|
| 13 | // Update Count : 117
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | #pragma once
|
|---|
| 17 |
|
|---|
| 18 | #include "iostream"
|
|---|
| 19 |
|
|---|
| 20 | enum { sepSize = 16 };
|
|---|
| 21 | struct ofstream {
|
|---|
| 22 | void * file;
|
|---|
| 23 | _Bool sepDefault;
|
|---|
| 24 | _Bool sepOnOff;
|
|---|
| 25 | _Bool sawNL;
|
|---|
| 26 | const char * sepCur;
|
|---|
| 27 | char separator[sepSize];
|
|---|
| 28 | char tupleSeparator[sepSize];
|
|---|
| 29 | }; // ofstream
|
|---|
| 30 |
|
|---|
| 31 | // private
|
|---|
| 32 | _Bool sepPrt( ofstream * );
|
|---|
| 33 | void sepReset( ofstream * );
|
|---|
| 34 | void sepReset( ofstream *, _Bool );
|
|---|
| 35 | const char * sepGetCur( ofstream * );
|
|---|
| 36 | void sepSetCur( ofstream *, const char * );
|
|---|
| 37 | _Bool getNL( ofstream * );
|
|---|
| 38 | void setNL( ofstream *, _Bool );
|
|---|
| 39 |
|
|---|
| 40 | // public
|
|---|
| 41 | void sepOn( ofstream * );
|
|---|
| 42 | void sepOff( ofstream * );
|
|---|
| 43 | _Bool sepDisable( ofstream * );
|
|---|
| 44 | _Bool sepEnable( ofstream * );
|
|---|
| 45 |
|
|---|
| 46 | const char * sepGet( ofstream * );
|
|---|
| 47 | void sepSet( ofstream *, const char * );
|
|---|
| 48 | const char * sepGetTuple( ofstream * );
|
|---|
| 49 | void sepSetTuple( ofstream *, const char * );
|
|---|
| 50 |
|
|---|
| 51 | int fail( ofstream * );
|
|---|
| 52 | int flush( ofstream * );
|
|---|
| 53 | void open( ofstream *, const char * name, const char * mode );
|
|---|
| 54 | void close( ofstream * );
|
|---|
| 55 | ofstream * write( ofstream *, const char * data, unsigned long int size );
|
|---|
| 56 | int fmt( ofstream *, const char fmt[], ... );
|
|---|
| 57 |
|
|---|
| 58 | void ?{}( ofstream & );
|
|---|
| 59 |
|
|---|
| 60 | extern ofstream * sout, * serr;
|
|---|
| 61 |
|
|---|
| 62 | // implement context istream
|
|---|
| 63 | struct ifstream {
|
|---|
| 64 | void * file;
|
|---|
| 65 | }; // ifstream
|
|---|
| 66 |
|
|---|
| 67 | int fail( ifstream * is );
|
|---|
| 68 | int eof( ifstream * is );
|
|---|
| 69 | void open( ifstream * is, const char * name, const char * mode );
|
|---|
| 70 | void close( ifstream * is );
|
|---|
| 71 | ifstream * read( ifstream * is, char * data, unsigned long int size );
|
|---|
| 72 | ifstream * ungetc( ifstream * is, char c );
|
|---|
| 73 | int fmt( ifstream *, const char fmt[], ... );
|
|---|
| 74 |
|
|---|
| 75 | extern ifstream * sin;
|
|---|
| 76 |
|
|---|
| 77 | // Local Variables: //
|
|---|
| 78 | // mode: c //
|
|---|
| 79 | // tab-width: 4 //
|
|---|
| 80 | // End: //
|
|---|