Changeset 00e9be9


Ignore:
Timestamp:
Apr 28, 2021, 9:29:07 PM (7 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
99b2407
Parents:
c7015e6b
Message:

add stream function clear, change eof to return bool

Location:
libcfa/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.cfa

    rc7015e6b r00e9be9  
    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:08:57 2021
    13 // Update Count     : 442
     12// Last Modified On : Wed Apr 28 20:37:53 2021
     13// Update Count     : 445
    1414//
    1515
     
    114114} // fail
    115115
     116void clear( ofstream & os ) {
     117        clearerr( (FILE *)(os.file$) );
     118} // clear
     119
    116120int flush( ofstream & os ) {
    117121        return fflush( (FILE *)(os.file$) );
     
    207211} // nl
    208212
     213
    209214// *********************************** ifstream ***********************************
    210215
     
    240245} // fail
    241246
     247void clear( ifstream & is ) {
     248        clearerr( (FILE *)(is.file$) );
     249} // clear
     250
    242251void ends( ifstream & is ) {
    243252        if ( is.acquired$ ) { is.acquired$ = false; release( is ); }
    244253} // ends
    245254
    246 int eof( ifstream & is ) {
     255bool eof( ifstream & is ) {
    247256        return feof( (FILE *)(is.file$) );
    248257} // eof
     
    273282} // close
    274283
    275 ifstream & read( ifstream & is, char * data, size_t size ) {
     284ifstream & read( ifstream & is, char data[], size_t size ) {
    276285        if ( fail( is ) ) {
    277286                abort | IO_MSG "attempt read I/O on failed stream";
  • libcfa/src/fstream.hfa

    rc7015e6b r00e9be9  
    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 : Wed Apr 28 20:37:57 2021
     13// Update Count     : 230
    1414//
    1515
     
    7070
    7171bool fail( ofstream & );
     72void clear( ofstream & );
    7273int flush( ofstream & );
    7374void open( ofstream &, const char name[], const char mode[] ); // FIX ME: use default = "w"
     
    119120
    120121bool fail( ifstream & is );
    121 int eof( ifstream & is );
     122void clear( ifstream & );
     123bool eof( ifstream & is );
    122124void open( ifstream & is, const char name[], const char mode[] ); // FIX ME: use default = "r"
    123125void open( ifstream & is, const char name[] );
    124126void close( ifstream & is );
    125 ifstream & read( ifstream & is, char * data, size_t size );
     127ifstream & read( ifstream & is, char data[], size_t size );
    126128ifstream & ungetc( ifstream & is, char c );
    127129
  • libcfa/src/iostream.hfa

    rc7015e6b r00e9be9  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 27 17:59:21 2021
    13 // Update Count     : 398
     12// Last Modified On : Wed Apr 28 20:37:56 2021
     13// Update Count     : 401
    1414//
    1515
     
    5252       
    5353trait ostream( ostype & | basic_ostream( ostype ) ) {
     54        bool fail( ostype & );                                                          // operation failed?
     55        void clear( ostype & );
    5456        int flush( ostype & );
    55         bool fail( ostype & );                                                          // operation failed?
    5657        void open( ostype &, const char name[], const char mode[] );
    5758        void close( ostype & );
     
    302303        int fmt( istype &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
    303304        istype & ungetc( istype &, char );
    304         int eof( istype & );
     305        bool eof( istype & );
    305306}; // basic_istream
    306307
    307308trait istream( istype & | basic_istream( istype ) ) {
    308309        bool fail( istype & );
     310        void clear( istype & );
    309311        void open( istype & is, const char name[] );
    310312        void close( istype & is );
    311         istype & read( istype &, char *, size_t );
     313        istype & read( istype &, char [], size_t );
    312314        void acquire( istype & );                                                       // concurrent access
    313315}; // istream
Note: See TracChangeset for help on using the changeset viewer.