Changeset 9d362a0 for libcfa/src


Ignore:
Timestamp:
Dec 25, 2018, 5:47:50 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
ef346f7c
Parents:
bd07b15
Message:

simplify code

Location:
libcfa/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.cfa

    rbd07b15 r9d362a0  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Dec 22 17:01:54 2018
    13 // Update Count     : 302
     12// Last Modified On : Mon Dec 24 18:33:38 2018
     13// Update Count     : 304
    1414//
    1515
     
    150150        va_end( args );
    151151
    152         setPrt( os, true );
     152        setPrt( os, true );                                                                     // called in output cascade
    153153        sepReset( os );                                                                         // reset separator
    154154        return len;
  • libcfa/src/fstream.hfa

    rbd07b15 r9d362a0  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Dec 22 17:55:37 2018
    13 // Update Count     : 148
     12// Last Modified On : Mon Dec 24 18:33:41 2018
     13// Update Count     : 149
    1414//
    1515
     
    6262void close( ofstream & );
    6363ofstream & write( ofstream &, const char * data, size_t size );
    64 int fmt( ofstream &, const char fmt[], ... );
     64int fmt( ofstream &, const char format[], ... );
    6565
    6666void ?{}( ofstream & os );
     
    8383ifstream & read( ifstream & is, char * data, size_t size );
    8484ifstream & ungetc( ifstream & is, char c );
    85 int fmt( ifstream &, const char fmt[], ... );
     85int fmt( ifstream &, const char format[], ... );
    8686
    8787void ?{}( ifstream & is );
  • libcfa/src/iostream.cfa

    rbd07b15 r9d362a0  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Dec 22 23:09:56 2018
    13 // Update Count     : 569
     12// Last Modified On : Mon Dec 24 18:33:40 2018
     13// Update Count     : 589
    1414//
    1515
     
    3333        } // ?|?
    3434        void ?|?( ostype & os, bool b ) {
    35                 (ostype)(os | b); if ( getANL( os ) ) nl( os );
    36                 setPrt( os, false );                                                    // turn off
     35                (ostype &)(os | b); nl( os );
    3736        } // ?|?
    3837
     
    4342        } // ?|?
    4443        void ?|?( ostype & os, char c ) {
    45                 (ostype)(os | c); if ( getANL( os ) ) nl( os );
    46                 setPrt( os, false );                                                    // turn off
     44                (ostype &)(os | c); nl( os );
    4745        } // ?|?
    4846
     
    5351        } // ?|?
    5452        void ?|?( ostype & os, signed char sc ) {
    55                 (ostype)(os | sc); if ( getANL( os ) ) nl( os );
    56                 setPrt( os, false );                                                    // turn off
     53                (ostype &)(os | sc); nl( os );
    5754        } // ?|?
    5855
     
    6360        } // ?|?
    6461        void ?|?( ostype & os, unsigned char usc ) {
    65                 (ostype)(os | usc); if ( getANL( os ) ) nl( os );
    66                 setPrt( os, false );                                                    // turn off
     62                (ostype &)(os | usc); nl( os );
    6763        } // ?|?
    6864
     
    7369        } // ?|?
    7470        void & ?|?( ostype & os, short int si ) {
    75                 (ostype)(os | si); if ( getANL( os ) ) nl( os );
    76                 setPrt( os, false );                                                    // turn off
     71                (ostype &)(os | si); nl( os );
    7772        } // ?|?
    7873
     
    8378        } // ?|?
    8479        void & ?|?( ostype & os, unsigned short int usi ) {
    85                 (ostype)(os | usi); if ( getANL( os ) ) nl( os );
    86                 setPrt( os, false );                                                    // turn off
     80                (ostype &)(os | usi); nl( os );
    8781        } // ?|?
    8882
     
    9387        } // ?|?
    9488        void & ?|?( ostype & os, int i ) {
    95                 (ostype)(os | i); if ( getANL( os ) ) nl( os );
    96                 setPrt( os, false );                                                    // turn off
     89                (ostype &)(os | i); nl( os );
    9790        } // ?|?
    9891
     
    10396        } // ?|?
    10497        void & ?|?( ostype & os, unsigned int ui ) {
    105                 (ostype)(os | ui); if ( getANL( os ) ) nl( os );
    106                 setPrt( os, false );                                                    // turn off
     98                (ostype &)(os | ui); nl( os );
    10799        } // ?|?
    108100
     
    113105        } // ?|?
    114106        void & ?|?( ostype & os, long int li ) {
    115                 (ostype)(os | li); if ( getANL( os ) ) nl( os );
    116                 setPrt( os, false );                                                    // turn off
     107                (ostype &)(os | li); nl( os );
    117108        } // ?|?
    118109
     
    123114        } // ?|?
    124115        void & ?|?( ostype & os, unsigned long int uli ) {
    125                 (ostype)(os | uli); if ( getANL( os ) ) nl( os );
    126                 setPrt( os, false );                                                    // turn off
     116                (ostype &)(os | uli); nl( os );
    127117        } // ?|?
    128118
     
    133123        } // ?|?
    134124        void & ?|?( ostype & os, long long int lli ) {
    135                 (ostype)(os | lli); if ( getANL( os ) ) nl( os );
    136                 setPrt( os, false );                                                    // turn off
     125                (ostype &)(os | lli); nl( os );
    137126        } // ?|?
    138127
     
    143132        } // ?|?
    144133        void & ?|?( ostype & os, unsigned long long int ulli ) {
    145                 (ostype)(os | ulli); if ( getANL( os ) ) nl( os );
    146                 setPrt( os, false );                                                    // turn off
     134                (ostype &)(os | ulli); nl( os );
    147135        } // ?|?
    148136
     
    153141        } // ?|?
    154142        void & ?|?( ostype & os, float f ) {
    155                 (ostype)(os | f); if ( getANL( os ) ) nl( os );
    156                 setPrt( os, false );                                                    // turn off
     143                (ostype &)(os | f); nl( os );
    157144        } // ?|?
    158145
     
    163150        } // ?|?
    164151        void & ?|?( ostype & os, double d ) {
    165                 (ostype)(os | d); if ( getANL( os ) ) nl( os );
    166                 setPrt( os, false );                                                    // turn off
     152                (ostype &)(os | d); nl( os );
    167153        } // ?|?
    168154
     
    173159        } // ?|?
    174160        void & ?|?( ostype & os, long double ld ) {
    175                 (ostype)(os | ld); if ( getANL( os ) ) nl( os );
    176                 setPrt( os, false );                                                    // turn off
     161                (ostype &)(os | ld); nl( os );
    177162        } // ?|?
    178163
     
    183168        } // ?|?
    184169        void & ?|?( ostype & os, float _Complex fc ) {
    185                 (ostype)(os | fc); if ( getANL( os ) ) nl( os );
    186                 setPrt( os, false );                                                    // turn off
     170                (ostype &)(os | fc); nl( os );
    187171        } // ?|?
    188172
     
    193177        } // ?|?
    194178        void & ?|?( ostype & os, double _Complex dc ) {
    195                 (ostype)(os | dc); if ( getANL( os ) ) nl( os );
    196                 setPrt( os, false );                                                    // turn off
     179                (ostype &)(os | dc); nl( os );
    197180        } // ?|?
    198181
     
    203186        } // ?|?
    204187        void & ?|?( ostype & os, long double _Complex ldc ) {
    205                 (ostype)(os | ldc); if ( getANL( os ) ) nl( os );
    206                 setPrt( os, false );                                                    // turn off
     188                (ostype &)(os | ldc); nl( os );
    207189        } // ?|?
    208190
     
    246228        } // ?|?
    247229        void ?|?( ostype & os, const char * str ) {
    248                 (ostype)(os | str); if ( getANL( os ) ) nl( os );
    249                 setPrt( os, false );                                                    // turn off
     230                (ostype &)(os | str); nl( os );
    250231        } // ?|?
    251232
     
    276257        } // ?|?
    277258        void ?|?( ostype & os, const void * p ) {
    278                 (ostype)(os | p); if ( getANL( os ) ) nl( os );
    279                 setPrt( os, false );                                                    // turn off
     259                (ostype &)(os | p); nl( os );
    280260        } // ?|?
    281261
    282262        // manipulators
    283263        ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    284                 (ostype)(manip( os ));
     264                (ostype &)(manip( os ));
    285265                return os;
    286266        } // ?|?
    287267        void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    288                 (ostype)(manip( os ));
    289                 if ( getANL( os ) && getPrt( os ) ) nl( os );   // ignore auto nl?
     268                (ostype &)(manip( os ));
     269                if ( getPrt( os ) ) nl( os );                                   // something printed ?
    290270                setPrt( os, false );                                                    // turn off
    291271        } // ?|?
    292272
    293273        ostype & sep( ostype & os ) {
    294                 return (ostype)(os | sepGet( os ));
     274                return (ostype &)(os | sepGet( os ));
    295275        } // sep
    296276
     
    300280
    301281        ostype & nl( ostype & os ) {
    302                 (ostype)(os | '\n');
     282                (ostype &)(os | '\n');
    303283                setPrt( os, false );                                                    // turn off
    304284                setNL( os, true );
     
    307287        } // nl
    308288
     289        void nl( ostype & os ) {
     290                if ( getANL( os ) ) (ostype &)(nl( os ));               // implementation only
     291                else setPrt( os, false );                                               // turn off
     292        } // nl
     293
    309294        ostype & nonl( ostype & os ) {
    310295                setPrt( os, false );                                                    // turn off
     
    346331forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) {
    347332        ostype & ?|?( ostype & os, T arg, Params rest ) {
    348                 (ostype)(os | arg);                                                             // print first argument
     333                (ostype &)(os | arg);                                                   // print first argument
    349334                sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
    350                 (ostype)(os | rest);                                                    // print remaining arguments
     335                (ostype &)(os | rest);                                                  // print remaining arguments
    351336                sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
    352337                return os;
    353338        } // ?|?
    354339        void ?|?( ostype & os, T arg, Params rest ) {
    355 //              (ostype)(?|?( os, arg, rest )); if ( getANL( os ) ) nl( os );
    356                 (ostype)(os | arg);                                                             // print first argument
     340                // (ostype &)(?|?( os, arg, rest )); nl( os );
     341                (ostype &)(os | arg);                                                   // print first argument
    357342                sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
    358                 (ostype)(os | rest);                                                    // print remaining arguments
     343                (ostype &)(os | rest);                                                  // print remaining arguments
    359344                sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
    360                 if ( getANL( os ) ) nl( os );
    361                 setPrt( os, false );                                                    // turn off
     345                nl( os );
    362346        } // ?|?
    363347} // distribution
  • libcfa/src/iostream.hfa

    rbd07b15 r9d362a0  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Dec 22 17:00:39 2018
    13 // Update Count     : 218
     12// Last Modified On : Mon Dec 24 18:33:40 2018
     13// Update Count     : 220
    1414//
    1515
     
    2020trait ostream( dtype ostype ) {
    2121        // private
    22         bool sepPrt( ostype & );                                                        // return separator state (on/off)
     22        bool sepPrt( ostype & );                                                        // get separator state (on/off)
    2323        void sepReset( ostype & );                                                      // set separator state to default state
    2424        void sepReset( ostype &, bool );                                        // set separator and default state
     
    2727        bool getNL( ostype & );                                                         // check newline
    2828        void setNL( ostype &, bool );                                           // saw newline
    29         bool getANL( ostype & );                                                        // check auto newline
    30         bool getPrt( ostype & );                                                        // check ignore auto NL
    31         void setPrt( ostype &, bool );                                          // set ignore auto NL
     29        bool getANL( ostype & );                                                        // get auto newline (on/off)
     30        bool getPrt( ostype & );                                                        // get fmt called in output cascade
     31        void setPrt( ostype &, bool );                                          // set fmt called in output cascade
    3232        // public
    3333        void sepOn( ostype & );                                                         // turn separator state on
     
    4848        void close( ostype & os );
    4949        ostype & write( ostype &, const char *, size_t );
    50         int fmt( ostype &, const char fmt[], ... );
     50        int fmt( ostype &, const char format[], ... );
    5151}; // ostream
    5252
     
    117117        void ?|?( ostype &, ostype & (*)( ostype & ) );
    118118        ostype & nl( ostype & );
     119        void nl( ostype & );
    119120        ostype & nonl( ostype & );
    120121        ostype & sep( ostype & );
     
    149150        istype & read( istype &, char *, size_t );
    150151        istype & ungetc( istype &, char );
    151         int fmt( istype &, const char fmt[], ... );
     152        int fmt( istype &, const char format[], ... );
    152153}; // istream
    153154
Note: See TracChangeset for help on using the changeset viewer.