source: libcfa/src/fstream.hfa @ fa2a3b1

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since fa2a3b1 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
RevLine 
[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
[c8371b5]12// Last Modified On : Sun Oct 10 09:37:32 2021
13// Update Count     : 243
[86bd7c1f]14//
15
[53a6c2a]16#pragma once
[51b7345]17
[e474cf09]18#include "bits/weakso_locks.hfa"                                                // mutex_lock
[58b6d1b]19#include "iostream.hfa"
[91e52be]20#include <exception.hfa>
[51b7345]21
[65240bb]22
[8d321f9]23// *********************************** ofstream ***********************************
[65240bb]24
25
[b431515]26enum { ofstream_sepSize = 16 };
[53ba273]27struct ofstream {
[6c5d92f]28        void * file$;
29        bool sepDefault$;
30        bool sepOnOff$;
31        bool nlOnOff$;
32        bool prt$;                                                                                      // print text
33        bool sawNL$;
34        const char * sepCur$;
[b431515]35        char separator$[ofstream_sepSize];
36        char tupleSeparator$[ofstream_sepSize];
[6c5d92f]37        multiple_acquisition_lock lock$;
[53ba273]38}; // ofstream
[90c3b1c]39
[b431515]40// Satisfies ostream
41
[9ebd778]42// private
[6c5d92f]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 );
[9ebd778]53
[7ce2483]54void lock( ofstream & );
55void unlock( ofstream & );
56
[9ebd778]57// public
[09687aa]58void sepOn( ofstream & );
59void sepOff( ofstream & );
[93c2e0a]60bool sepDisable( ofstream & );
61bool sepEnable( ofstream & );
[200fcb3]62void nlOn( ofstream & );
63void nlOff( ofstream & );
[9ebd778]64
[09687aa]65const char * sepGet( ofstream & );
[e3fea42]66void sepSet( ofstream &, const char [] );
[09687aa]67const char * sepGetTuple( ofstream & );
[e3fea42]68void sepSetTuple( ofstream &, const char [] );
[6152c81]69
[b431515]70void ends( ofstream & );
71int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
72
73bool fail( ofstream & );
[00e9be9]74void clear( ofstream & );
[09687aa]75int flush( ofstream & );
[f451177]76void open( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w"
[e3fea42]77void open( ofstream &, const char name[] );
[09687aa]78void close( ofstream & );
[c8371b5]79
[e3fea42]80ofstream & write( ofstream &, const char data[], size_t size );
[b431515]81
82void ?{}( ofstream & );
[f451177]83void ?{}( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w"
[b431515]84void ?{}( ofstream &, const char name[] );
85void ^?{}( ofstream & );
[09687aa]86
[f451177]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
[a87d40b]92extern ofstream & sout, & stdout, & serr, & stderr;             // aliases
[65240bb]93extern ofstream & exit, & abort;
94
[51b7345]95
[8d321f9]96// *********************************** ifstream ***********************************
[5cb2b8c]97
[51b7345]98
[53ba273]99struct ifstream {
[6c5d92f]100        void * file$;
101        bool nlOnOff$;
102        multiple_acquisition_lock lock$;
[53ba273]103}; // ifstream
[6ba0659]104
[b431515]105// Satisfies istream
106
[7ce2483]107// private
[c8371b5]108bool getANL$( ifstream & );
109
[7ce2483]110void lock( ifstream & );
111void unlock( ifstream & );
112
[09687aa]113// public
[0efb269]114void nlOn( ifstream & );
115void nlOff( ifstream & );
[e474cf09]116void ends( ifstream & );
[f451177]117int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
118
[b431515]119bool fail( ifstream & is );
[00e9be9]120void clear( ifstream & );
121bool eof( ifstream & is );
[f451177]122void open( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r"
[e3fea42]123void open( ifstream & is, const char name[] );
[09687aa]124void close( ifstream & is );
[c8371b5]125
[00e9be9]126ifstream & read( ifstream & is, char data[], size_t size );
[09687aa]127ifstream & ungetc( ifstream & is, char c );
[f451177]128
[09687aa]129void ?{}( ifstream & is );
[f451177]130void ?{}( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r"
[e3fea42]131void ?{}( ifstream & is, const char name[] );
[4cae032]132void ^?{}( ifstream & is );
[51b7345]133
[a87d40b]134extern ifstream & sin, & stdin;                                                 // aliases
[51b7345]135
[91e52be]136
[8d321f9]137// *********************************** exceptions ***********************************
[91e52be]138
139
[f9d8755]140exception Open_Failure {
[91e52be]141        union {
142                ofstream * ostream;
143                ifstream * istream;
144        };
[8d321f9]145        // TEMPORARY: need polymorphic exceptions
146        int tag;                                                                                        // 1 => ostream; 0 => istream
[f9d8755]147};
[91e52be]148
[b431515]149void ?{}( Open_Failure & this, ofstream & );
150void ?{}( Open_Failure & this, ifstream & );
[91e52be]151
[ba0d2ea]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
[86bd7c1f]188// Local Variables: //
[d3b7937]189// mode: c //
[86bd7c1f]190// tab-width: 4 //
191// End: //
Note: See TracBrowser for help on using the repository browser.