source: libcfa/src/fstream.hfa @ 8ee163e2

ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change on this file since 8ee163e2 was c8371b5, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

change getANL to getANL$ (private)

  • Property mode set to 100644
File size: 4.8 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 : Sun Oct 10 09:37:32 2021
13// Update Count     : 243
14//
15
16#pragma once
17
18#include "bits/weakso_locks.hfa"                                                // mutex_lock
19#include "iostream.hfa"
20#include <exception.hfa>
21
22
23// *********************************** ofstream ***********************************
24
25
26enum { ofstream_sepSize = 16 };
27struct ofstream {
28        void * file$;
29        bool sepDefault$;
30        bool sepOnOff$;
31        bool nlOnOff$;
32        bool prt$;                                                                                      // print text
33        bool sawNL$;
34        const char * sepCur$;
35        char separator$[ofstream_sepSize];
36        char tupleSeparator$[ofstream_sepSize];
37        multiple_acquisition_lock lock$;
38}; // ofstream
39
40// Satisfies ostream
41
42// private
43bool sepPrt$( ofstream & );
44void sepReset$( ofstream & );
45void sepReset$( ofstream &, bool );
46const char * sepGetCur$( ofstream & );
47void sepSetCur$( ofstream &, const char [] );
48bool getNL$( ofstream & );
49void setNL$( ofstream &, bool );
50bool getANL$( ofstream & );
51bool getPrt$( ofstream & );
52void setPrt$( ofstream &, bool );
53
54void lock( ofstream & );
55void unlock( ofstream & );
56
57// public
58void sepOn( ofstream & );
59void sepOff( ofstream & );
60bool sepDisable( ofstream & );
61bool sepEnable( ofstream & );
62void nlOn( ofstream & );
63void nlOff( ofstream & );
64
65const char * sepGet( ofstream & );
66void sepSet( ofstream &, const char [] );
67const char * sepGetTuple( ofstream & );
68void sepSetTuple( ofstream &, const char [] );
69
70void ends( ofstream & );
71int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
72
73bool fail( ofstream & );
74void clear( ofstream & );
75int flush( ofstream & );
76void open( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w"
77void open( ofstream &, const char name[] );
78void close( ofstream & );
79
80ofstream & write( ofstream &, const char data[], size_t size );
81
82void ?{}( ofstream & );
83void ?{}( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w"
84void ?{}( ofstream &, const char name[] );
85void ^?{}( ofstream & );
86
87// private
88static inline ofstream & nl$( ofstream & os ) { return nl( os ); } // remember basic_ostream nl
89// public
90ofstream & nl( ofstream & os );                                                 // override basic_ostream nl
91
92extern ofstream & sout, & stdout, & serr, & stderr;             // aliases
93extern ofstream & exit, & abort;
94
95
96// *********************************** ifstream ***********************************
97
98
99struct ifstream {
100        void * file$;
101        bool nlOnOff$;
102        multiple_acquisition_lock lock$;
103}; // ifstream
104
105// Satisfies istream
106
107// private
108bool getANL$( ifstream & );
109
110void lock( ifstream & );
111void unlock( ifstream & );
112
113// public
114void nlOn( ifstream & );
115void nlOff( ifstream & );
116void ends( ifstream & );
117int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
118
119bool fail( ifstream & is );
120void clear( ifstream & );
121bool eof( ifstream & is );
122void open( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r"
123void open( ifstream & is, const char name[] );
124void close( ifstream & is );
125
126ifstream & read( ifstream & is, char data[], size_t size );
127ifstream & ungetc( ifstream & is, char c );
128
129void ?{}( ifstream & is );
130void ?{}( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r"
131void ?{}( ifstream & is, const char name[] );
132void ^?{}( ifstream & is );
133
134extern ifstream & sin, & stdin;                                                 // aliases
135
136
137// *********************************** exceptions ***********************************
138
139
140exception Open_Failure {
141        union {
142                ofstream * ostream;
143                ifstream * istream;
144        };
145        // TEMPORARY: need polymorphic exceptions
146        int tag;                                                                                        // 1 => ostream; 0 => istream
147};
148
149void ?{}( Open_Failure & this, ofstream & );
150void ?{}( Open_Failure & this, ifstream & );
151
152exception Close_Failure {
153        union {
154                ofstream * ostream;
155                ifstream * istream;
156        };
157        // TEMPORARY: need polymorphic exceptions
158        int tag;                                                                                        // 1 => ostream; 0 => istream
159};
160
161void ?{}( Close_Failure & this, ofstream & );
162void ?{}( Close_Failure & this, ifstream & );
163
164exception Write_Failure {
165        union {
166                ofstream * ostream;
167                ifstream * istream;
168        };
169        // TEMPORARY: need polymorphic exceptions
170        int tag;                                                                                        // 1 => ostream; 0 => istream
171};
172
173void ?{}( Write_Failure & this, ofstream & );
174void ?{}( Write_Failure & this, ifstream & );
175
176exception Read_Failure {
177        union {
178                ofstream * ostream;
179                ifstream * istream;
180        };
181        // TEMPORARY: need polymorphic exceptions
182        int tag;                                                                                        // 1 => ostream; 0 => istream
183};
184
185void ?{}( Read_Failure & this, ofstream & );
186void ?{}( Read_Failure & this, ifstream & );
187
188// Local Variables: //
189// mode: c //
190// tab-width: 4 //
191// End: //
Note: See TracBrowser for help on using the repository browser.