// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // fstream -- // // Author : Peter A. Buhr // Created On : Wed May 27 17:56:53 2015 // Last Modified By : Peter A. Buhr // Last Modified On : Sun Feb 11 20:35:00 2024 // Update Count : 274 // #pragma once #include "bits/weakso_locks.hfa" // mutex_lock #include "iostream.hfa" // *********************************** ofstream *********************************** enum { ofstream_sepSize = 16 }; struct ofstream { void * file$; bool sepDefault$; bool sepOnOff$; bool nlOnOff$; bool prt$; // print text bool sawNL$; const char * sepCur$; char separator$[ofstream_sepSize]; char tupleSeparator$[ofstream_sepSize]; multiple_acquisition_lock lock$; // used by trait is_lock for mutex statement }; // ofstream // Satisfies ostream // private bool getNL$( ofstream & ); bool setNL$( ofstream &, bool ); bool getANL$( ofstream & ); bool setANL$( ofstream &, bool ); bool sepPrt$( ofstream & ); void sepReset$( ofstream & ); void sepReset$( ofstream &, bool ); const char * sepGetCur$( ofstream & ); void sepSetCur$( ofstream &, const char [] ); bool getPrt$( ofstream & ); bool setPrt$( ofstream &, bool ); void lock( ofstream & ); void unlock( ofstream & ); // public void nlOn( ofstream & ); void nlOff( ofstream & ); void sep( ofstream & ); void nosep( ofstream & ); bool sepOn( ofstream & ); bool sepOff( ofstream & ); const char * sepGet( ofstream & ); void sepSet( ofstream &, const char [] ); const char * sepGetTuple( ofstream & ); void sepSetTuple( ofstream &, const char [] ); void ends( ofstream & ); int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); bool fail( ofstream & ); void clear( ofstream & ); int flush( ofstream & ); void open( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w" void open( ofstream &, const char name[] ); void close( ofstream & ); ofstream & write( ofstream &, const char data[], size_t size ); void ?{}( ofstream & ); void ?{}( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w" void ?{}( ofstream &, const char name[] ); void ^?{}( ofstream & ); // private static inline ofstream & nl$( ofstream & os ) { return nl( os ); } // remember basic_ostream nl // public ofstream & nl( ofstream & os ); // override basic_ostream nl extern ofstream & sout, & stdout, & serr, & stderr; // aliases extern ofstream & exit, & abort; // *********************************** ifstream *********************************** struct ifstream { void * file$; bool nlOnOff$; multiple_acquisition_lock lock$; // used by trait is_lock for mutex statement }; // ifstream // Satisfies istream // private bool getANL$( ifstream & ); bool setANL$( ifstream &, bool ); void lock( ifstream & ); void unlock( ifstream & ); // public void nlOn( ifstream & ); void nlOff( ifstream & ); int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) )); ifstream & ungetc( ifstream & is, char c ); bool eof( ifstream & is ); bool fail( ifstream & is ); void clear( ifstream & ); void open( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r" void open( ifstream & is, const char name[] ); void close( ifstream & is ); ifstream & read( ifstream & is, char data[], size_t size ); void ?{}( ifstream & is ); void ?{}( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r" void ?{}( ifstream & is, const char name[] ); void ^?{}( ifstream & is ); extern ifstream & sin, & stdin; // aliases // *********************************** exceptions *********************************** ExceptionDecl( open_failure, union { ofstream * ostream; ifstream * istream; }; // TEMPORARY: need polymorphic exceptions int tag; // 1 => ostream; 0 => istream ); void ?{}( open_failure & this, ofstream & ); void ?{}( open_failure & this, ifstream & ); ExceptionDecl( close_failure, union { ofstream * ostream; ifstream * istream; }; // TEMPORARY: need polymorphic exceptions int tag; // 1 => ostream; 0 => istream ); void ?{}( close_failure & this, ofstream & ); void ?{}( close_failure & this, ifstream & ); ExceptionDecl( write_failure, union { ofstream * ostream; ifstream * istream; }; // TEMPORARY: need polymorphic exceptions int tag; // 1 => ostream; 0 => istream ); void ?{}( write_failure & this, ofstream & ); void ?{}( write_failure & this, ifstream & ); ExceptionDecl( read_failure, union { ofstream * ostream; ifstream * istream; }; // TEMPORARY: need polymorphic exceptions int tag; // 1 => ostream; 0 => istream ); void ?{}( read_failure & this, ofstream & ); void ?{}( read_failure & this, ifstream & ); // Local Variables: // // mode: c // // tab-width: 4 // // End: //