source: libcfa/src/fstream.hfa @ a82a8f4

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since a82a8f4 was 8d321f9, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

adjust / comments, change exception name from IO_OPEN_FAILURE to Open_Failure, add temporary Open_Failure tag in lieu of polymorphic exceptions

  • Property mode set to 100644
File size: 3.3 KB
Line 
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 Jun 19 16:29:17 2020
13// Update Count     : 189
14//
15
16#pragma once
17
18#include "iostream.hfa"
19#include <exception.hfa>
20
21
22// *********************************** ofstream ***********************************
23
24
25enum { sepSize = 16 };
26struct ofstream {
27        void * $file;
28        bool $sepDefault;
29        bool $sepOnOff;
30        bool $nlOnOff;
31        bool $prt;                                                                                      // print text
32        bool $sawNL;
33        const char * $sepCur;
34        char $separator[sepSize];
35        char $tupleSeparator[sepSize];
36}; // ofstream
37
38// private
39bool $sepPrt( ofstream & );
40void $sepReset( ofstream & );
41void $sepReset( ofstream &, bool );
42const char * $sepGetCur( ofstream & );
43void $sepSetCur( ofstream &, const char [] );
44bool $getNL( ofstream & );
45void $setNL( ofstream &, bool );
46bool $getANL( ofstream & );
47bool $getPrt( ofstream & );
48void $setPrt( ofstream &, bool );
49
50// public
51void sepOn( ofstream & );
52void sepOff( ofstream & );
53bool sepDisable( ofstream & );
54bool sepEnable( ofstream & );
55void nlOn( ofstream & );
56void nlOff( ofstream & );
57
58const char * sepGet( ofstream & );
59void sepSet( ofstream &, const char [] );
60const char * sepGetTuple( ofstream & );
61void sepSetTuple( ofstream &, const char [] );
62
63void ends( ofstream & os );
64int fail( ofstream & );
65int flush( ofstream & );
66void open( ofstream &, const char name[], const char mode[] );
67void open( ofstream &, const char name[] );
68void close( ofstream & );
69ofstream & write( ofstream &, const char data[], size_t size );
70int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
71
72void ?{}( ofstream & os );
73void ?{}( ofstream & os, const char name[], const char mode[] );
74void ?{}( ofstream & os, const char name[] );
75void ^?{}( ofstream & os );
76
77extern ofstream & sout, & stdout, & serr, & stderr;             // aliases
78extern ofstream & exit, & abort;
79
80
81// *********************************** ifstream ***********************************
82
83
84struct ifstream {
85        void * $file;
86        bool $nlOnOff;
87}; // ifstream
88
89// public
90void nlOn( ifstream & );
91void nlOff( ifstream & );
92bool getANL( ifstream & );
93int fail( ifstream & is );
94int eof( ifstream & is );
95void open( ifstream & is, const char name[], const char mode[] );
96void open( ifstream & is, const char name[] );
97void close( ifstream & is );
98ifstream & read( ifstream & is, char * data, size_t size );
99ifstream & ungetc( ifstream & is, char c );
100int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
101
102void ?{}( ifstream & is );
103void ?{}( ifstream & is, const char name[], const char mode[] );
104void ?{}( ifstream & is, const char name[] );
105void ^?{}( ifstream & is );
106
107extern ifstream & sin, & stdin;                                                 // aliases
108
109
110// *********************************** exceptions ***********************************
111
112
113DATA_EXCEPTION(Open_Failure)(
114        union {
115                ofstream * ostream;
116                ifstream * istream;
117        };
118        // TEMPORARY: need polymorphic exceptions
119        int tag;                                                                                        // 1 => ostream; 0 => istream
120);
121
122void ?{}( Open_Failure & this, ofstream & ostream );
123void ?{}( Open_Failure & this, ifstream & istream );
124
125// Local Variables: //
126// mode: c //
127// tab-width: 4 //
128// End: //
Note: See TracBrowser for help on using the repository browser.