Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.hfa

    rd0502a3 rf451177  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 19 16:29:17 2020
    13 // Update Count     : 189
     12// Last Modified On : Tue Apr 27 22:00:30 2021
     13// Update Count     : 226
    1414//
    1515
    1616#pragma once
    1717
    18 #include "bits/weakso_locks.hfa"
     18#include "bits/weakso_locks.hfa"                                                // mutex_lock
    1919#include "iostream.hfa"
    2020#include <exception.hfa>
     
    2424
    2525
    26 enum { sepSize = 16 };
     26enum { ofstream_sepSize = 16 };
    2727struct 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[sepSize];
    36         char $tupleSeparator[sepSize];
    37 //      multiple_acquisition_lock lock;
     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        bool acquired$;
    3839}; // ofstream
    3940
     41// Satisfies ostream
     42
    4043// private
    41 bool $sepPrt( ofstream & );
    42 void $sepReset( ofstream & );
    43 void $sepReset( ofstream &, bool );
    44 const char * $sepGetCur( ofstream & );
    45 void $sepSetCur( ofstream &, const char [] );
    46 bool $getNL( ofstream & );
    47 void $setNL( ofstream &, bool );
    48 bool $getANL( ofstream & );
    49 bool $getPrt( ofstream & );
    50 void $setPrt( ofstream &, bool );
     44bool sepPrt$( ofstream & );
     45void sepReset$( ofstream & );
     46void sepReset$( ofstream &, bool );
     47const char * sepGetCur$( ofstream & );
     48void sepSetCur$( ofstream &, const char [] );
     49bool getNL$( ofstream & );
     50void setNL$( ofstream &, bool );
     51bool getANL$( ofstream & );
     52bool getPrt$( ofstream & );
     53void setPrt$( ofstream &, bool );
    5154
    5255// public
     
    6366void sepSetTuple( ofstream &, const char [] );
    6467
    65 void ends( ofstream & os );
    66 int fail( ofstream & );
     68void ends( ofstream & );
     69int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
     70
     71bool fail( ofstream & );
    6772int flush( ofstream & );
    68 void open( ofstream &, const char name[], const char mode[] );
     73void open( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w"
    6974void open( ofstream &, const char name[] );
    7075void close( ofstream & );
    7176ofstream & write( ofstream &, const char data[], size_t size );
    72 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    7377
    74 void ?{}( ofstream & os );
    75 void ?{}( ofstream & os, const char name[], const char mode[] );
    76 void ?{}( ofstream & os, const char name[] );
    77 void ^?{}( ofstream & os );
     78void acquire( ofstream & );
     79void release( ofstream & );
     80
     81struct osacquire {
     82        ofstream & os;
     83};
     84void ?{}( osacquire & acq, ofstream & );
     85void ^?{}( osacquire & acq );
     86
     87void ?{}( ofstream & );
     88void ?{}( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w"
     89void ?{}( ofstream &, const char name[] );
     90void ^?{}( ofstream & );
     91
     92// private
     93static inline ofstream & nl$( ofstream & os ) { return nl( os ); } // remember basic_ostream nl
     94// public
     95ofstream & nl( ofstream & os );                                                 // override basic_ostream nl
    7896
    7997extern ofstream & sout, & stdout, & serr, & stderr;             // aliases
     
    85103
    86104struct ifstream {
    87         void * $file;
    88         bool $nlOnOff;
     105        void * file$;
     106        bool nlOnOff$;
     107        multiple_acquisition_lock lock$;
     108        bool acquired$;
    89109}; // ifstream
     110
     111// Satisfies istream
    90112
    91113// public
     
    93115void nlOff( ifstream & );
    94116bool getANL( ifstream & );
    95 int fail( ifstream & is );
     117void ends( ifstream & );
     118int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
     119
     120bool fail( ifstream & is );
    96121int eof( ifstream & is );
    97 void open( ifstream & is, const char name[], const char mode[] );
     122void open( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r"
    98123void open( ifstream & is, const char name[] );
    99124void close( ifstream & is );
    100125ifstream & read( ifstream & is, char * data, size_t size );
    101126ifstream & ungetc( ifstream & is, char c );
    102 int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
     127
     128void acquire( ifstream & is );
     129void release( ifstream & is );
     130
     131struct isacquire {
     132        ifstream & is;
     133};
     134void ?{}( isacquire & acq, ifstream & is );
     135void ^?{}( isacquire & acq );
    103136
    104137void ?{}( ifstream & is );
    105 void ?{}( ifstream & is, const char name[], const char mode[] );
     138void ?{}( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r"
    106139void ?{}( ifstream & is, const char name[] );
    107140void ^?{}( ifstream & is );
     
    113146
    114147
    115 DATA_EXCEPTION(Open_Failure)(
     148EHM_EXCEPTION(Open_Failure)(
    116149        union {
    117150                ofstream * ostream;
     
    122155);
    123156
    124 void ?{}( Open_Failure & this, ofstream & ostream );
    125 void ?{}( Open_Failure & this, ifstream & istream );
     157void ?{}( Open_Failure & this, ofstream & );
     158void ?{}( Open_Failure & this, ifstream & );
    126159
    127160// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.