Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.hfa

    rf451177 rd0502a3  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 27 22:00:30 2021
    13 // Update Count     : 226
     12// Last Modified On : Fri Jun 19 16:29:17 2020
     13// Update Count     : 189
    1414//
    1515
    1616#pragma once
    1717
    18 #include "bits/weakso_locks.hfa"                                                // mutex_lock
     18#include "bits/weakso_locks.hfa"
    1919#include "iostream.hfa"
    2020#include <exception.hfa>
     
    2424
    2525
    26 enum { ofstream_sepSize = 16 };
     26enum { 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$[ofstream_sepSize];
    36         char tupleSeparator$[ofstream_sepSize];
    37         multiple_acquisition_lock lock$;
    38         bool acquired$;
     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;
    3938}; // ofstream
    4039
    41 // Satisfies ostream
    42 
    4340// private
    44 bool sepPrt$( ofstream & );
    45 void sepReset$( ofstream & );
    46 void sepReset$( ofstream &, bool );
    47 const char * sepGetCur$( ofstream & );
    48 void sepSetCur$( ofstream &, const char [] );
    49 bool getNL$( ofstream & );
    50 void setNL$( ofstream &, bool );
    51 bool getANL$( ofstream & );
    52 bool getPrt$( ofstream & );
    53 void setPrt$( ofstream &, bool );
     41bool $sepPrt( ofstream & );
     42void $sepReset( ofstream & );
     43void $sepReset( ofstream &, bool );
     44const char * $sepGetCur( ofstream & );
     45void $sepSetCur( ofstream &, const char [] );
     46bool $getNL( ofstream & );
     47void $setNL( ofstream &, bool );
     48bool $getANL( ofstream & );
     49bool $getPrt( ofstream & );
     50void $setPrt( ofstream &, bool );
    5451
    5552// public
     
    6663void sepSetTuple( ofstream &, const char [] );
    6764
    68 void ends( ofstream & );
    69 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    70 
    71 bool fail( ofstream & );
     65void ends( ofstream & os );
     66int fail( ofstream & );
    7267int flush( ofstream & );
    73 void open( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w"
     68void open( ofstream &, const char name[], const char mode[] );
    7469void open( ofstream &, const char name[] );
    7570void close( ofstream & );
    7671ofstream & write( ofstream &, const char data[], size_t size );
     72int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    7773
    78 void acquire( ofstream & );
    79 void release( ofstream & );
    80 
    81 struct osacquire {
    82         ofstream & os;
    83 };
    84 void ?{}( osacquire & acq, ofstream & );
    85 void ^?{}( osacquire & acq );
    86 
    87 void ?{}( ofstream & );
    88 void ?{}( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w"
    89 void ?{}( ofstream &, const char name[] );
    90 void ^?{}( ofstream & );
    91 
    92 // private
    93 static inline ofstream & nl$( ofstream & os ) { return nl( os ); } // remember basic_ostream nl
    94 // public
    95 ofstream & nl( ofstream & os );                                                 // override basic_ostream nl
     74void ?{}( ofstream & os );
     75void ?{}( ofstream & os, const char name[], const char mode[] );
     76void ?{}( ofstream & os, const char name[] );
     77void ^?{}( ofstream & os );
    9678
    9779extern ofstream & sout, & stdout, & serr, & stderr;             // aliases
     
    10385
    10486struct ifstream {
    105         void * file$;
    106         bool nlOnOff$;
    107         multiple_acquisition_lock lock$;
    108         bool acquired$;
     87        void * $file;
     88        bool $nlOnOff;
    10989}; // ifstream
    110 
    111 // Satisfies istream
    11290
    11391// public
     
    11593void nlOff( ifstream & );
    11694bool getANL( ifstream & );
    117 void ends( ifstream & );
    118 int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
    119 
    120 bool fail( ifstream & is );
     95int fail( ifstream & is );
    12196int eof( ifstream & is );
    122 void open( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r"
     97void open( ifstream & is, const char name[], const char mode[] );
    12398void open( ifstream & is, const char name[] );
    12499void close( ifstream & is );
    125100ifstream & read( ifstream & is, char * data, size_t size );
    126101ifstream & ungetc( ifstream & is, char c );
    127 
    128 void acquire( ifstream & is );
    129 void release( ifstream & is );
    130 
    131 struct isacquire {
    132         ifstream & is;
    133 };
    134 void ?{}( isacquire & acq, ifstream & is );
    135 void ^?{}( isacquire & acq );
     102int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
    136103
    137104void ?{}( ifstream & is );
    138 void ?{}( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r"
     105void ?{}( ifstream & is, const char name[], const char mode[] );
    139106void ?{}( ifstream & is, const char name[] );
    140107void ^?{}( ifstream & is );
     
    146113
    147114
    148 EHM_EXCEPTION(Open_Failure)(
     115DATA_EXCEPTION(Open_Failure)(
    149116        union {
    150117                ofstream * ostream;
     
    155122);
    156123
    157 void ?{}( Open_Failure & this, ofstream & );
    158 void ?{}( Open_Failure & this, ifstream & );
     124void ?{}( Open_Failure & this, ofstream & ostream );
     125void ?{}( Open_Failure & this, ifstream & istream );
    159126
    160127// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.