Changeset f5d9c37 for libcfa/src


Ignore:
Timestamp:
Jun 29, 2023, 12:07:50 PM (11 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
7d25f44
Parents:
70e47fec
Message:

harmonize separator manipulators names with newline names: change from sep, sepTuple, sepEnable, sepDisable, sepOn, sepOff to sepVal, sepTupleVal, sepOn, sepOff, sep, nosep; fix bug printing null string with WD so no separator

Location:
libcfa/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.cfa

    r70e47fec rf5d9c37  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 17 08:51:12 2023
    13 // Update Count     : 528
     12// Last Modified On : Thu Jun 29 11:09:52 2023
     13// Update Count     : 533
    1414//
    1515
     
    4343} // ?{}
    4444
     45inline bool getNL$( ofstream & os ) { return os.sawNL$; }
     46inline void setNL$( ofstream & os, bool state ) { os.sawNL$ = state; }
     47inline bool getANL$( ofstream & os ) { return os.nlOnOff$; }
     48
    4549inline bool sepPrt$( ofstream & os ) { setNL$( os, false ); return os.sepOnOff$; }
    4650inline void sepReset$( ofstream & os ) { os.sepOnOff$ = os.sepDefault$; }
     
    4852inline const char * sepGetCur$( ofstream & os ) { return os.sepCur$; }
    4953inline void sepSetCur$( ofstream & os, const char sepCur[] ) { os.sepCur$ = sepCur; }
    50 inline bool getNL$( ofstream & os ) { return os.sawNL$; }
    51 inline void setNL$( ofstream & os, bool state ) { os.sawNL$ = state; }
    52 inline bool getANL$( ofstream & os ) { return os.nlOnOff$; }
     54
    5355inline bool getPrt$( ofstream & os ) { return os.prt$; }
    5456inline void setPrt$( ofstream & os, bool state ) { os.prt$ = state; }
     
    6365void ^?{}( ofstream & os ) { close( os ); }
    6466
    65 void sepOn( ofstream & os ) { os.sepOnOff$ = ! getNL$( os ); }
    66 void sepOff( ofstream & os ) { os.sepOnOff$ = false; }
    67 
    68 bool sepDisable( ofstream & os ) {
     67void nlOn( ofstream & os ) { os.nlOnOff$ = true; }
     68void nlOff( ofstream & os ) { os.nlOnOff$ = false; }
     69
     70void sep( ofstream & os ) { os.sepOnOff$ = ! getNL$( os ); }
     71void nosep( ofstream & os ) { os.sepOnOff$ = false; }
     72
     73bool sepOn( ofstream & os ) {
     74        bool temp = os.sepDefault$;
     75        os.sepDefault$ = true;
     76        if ( os.sepOnOff$ ) sepReset$( os );                            // start of line ?
     77        return temp;
     78} // sepOn
     79
     80bool sepOff( ofstream & os ) {
    6981        bool temp = os.sepDefault$;
    7082        os.sepDefault$ = false;
    7183        sepReset$( os );
    7284        return temp;
    73 } // sepDisable
    74 
    75 bool sepEnable( ofstream & os ) {
    76         bool temp = os.sepDefault$;
    77         os.sepDefault$ = true;
    78         if ( os.sepOnOff$ ) sepReset$( os );                            // start of line ?
    79         return temp;
    80 } // sepEnable
    81 
    82 void nlOn( ofstream & os ) { os.nlOnOff$ = true; }
    83 void nlOff( ofstream & os ) { os.nlOnOff$ = false; }
     85} // sepOff
    8486
    8587const char * sepGet( ofstream & os ) { return os.separator$; }
  • libcfa/src/fstream.hfa

    r70e47fec rf5d9c37  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  5 22:00:20 2023
    13 // Update Count     : 246
     12// Last Modified On : Thu Jun 29 11:08:31 2023
     13// Update Count     : 251
    1414//
    1515
     
    4040
    4141// private
     42bool getNL$( ofstream & );
     43void setNL$( ofstream &, bool );
     44bool getANL$( ofstream & );
     45
    4246bool sepPrt$( ofstream & );
    4347void sepReset$( ofstream & );
     
    4549const char * sepGetCur$( ofstream & );
    4650void sepSetCur$( ofstream &, const char [] );
    47 bool getNL$( ofstream & );
    48 void setNL$( ofstream &, bool );
    49 bool getANL$( ofstream & );
     51
    5052bool getPrt$( ofstream & );
    5153void setPrt$( ofstream &, bool );
     
    5557
    5658// public
    57 void sepOn( ofstream & );
    58 void sepOff( ofstream & );
    59 bool sepDisable( ofstream & );
    60 bool sepEnable( ofstream & );
    6159void nlOn( ofstream & );
    6260void nlOff( ofstream & );
    6361
     62void sep( ofstream & );
     63void nosep( ofstream & );
     64bool sepOn( ofstream & );
     65bool sepOff( ofstream & );
    6466const char * sepGet( ofstream & );
    6567void sepSet( ofstream &, const char [] );
  • libcfa/src/iostream.cfa

    r70e47fec rf5d9c37  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  9 09:27:58 2023
    13 // Update Count     : 1361
     12// Last Modified On : Thu Jun 29 10:12:39 2023
     13// Update Count     : 1380
    1414//
    1515
     
    5050                fmt( os, "%c", c );
    5151                if ( c == '\n' ) setNL$( os, true );
    52                 return sepOff( os );
     52                return nosep( os );
    5353        } // ?|?
    5454        void ?|?( ostype & os, char c ) {
     
    284284
    285285          if ( s == 0p ) { fmt( os, "%s", "0p" ); return os; } // null pointer
    286           if ( s[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator
     286          if ( s[0] == '\0' ) { nosep( os ); return os; }       // null string => no leading/trailing separator
    287287
    288288                // first character IS NOT spacing or closing punctuation => add left separator
     
    300300                fmt( os, "%s", s );                                                             // fmt resets seperator, but reset it again
    301301                if ( sepPrt$( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    302                         sepOn( os );
     302                        sep( os );
    303303                } else {
    304                         sepOff( os );
     304                        nosep( os );
    305305                } // if
    306306                if ( ch == '\n' ) setNL$( os, true );                   // check *AFTER* sepPrt$ call above as it resets NL flag
     
    351351        } // ?|?
    352352
    353         ostype & sep( ostype & os ) {
    354                 return (ostype &)(os | sepGet( os ));
    355         } // sep
    356 
    357         ostype & sepTuple( ostype & os ) {
    358                 return os | sepGetTuple( os );
    359         } // sepTuple
    360 
    361353        ostype & nl( ostype & os ) {
    362354                (ostype &)(os | '\n');
    363355                setPrt$( os, false );                                                   // turn off
    364356                setNL$( os, true );
    365                 return sepOff( os );                                                    // prepare for next line
     357                return nosep( os );                                                             // prepare for next line
    366358        } // nl
    367359
     
    371363        } // nonl
    372364
     365        ostype & nlOn( ostype & os ) {
     366                nlOn( os );                                                                             // call void returning
     367                return os;
     368        } // nlOn
     369
     370        ostype & nlOff( ostype & os ) {
     371                nlOff( os );                                                                    // call void returning
     372                return os;
     373        } // nlOff
     374
     375        ostype & sepVal( ostype & os ) {
     376                return (ostype &)(os | sepGet( os ));
     377        } // sepVal
     378
     379        ostype & sepTupleVal( ostype & os ) {
     380                return os | sepGetTuple( os );
     381        } // sepTupleVal
     382
     383        ostype & sep( ostype & os ) {
     384                sep( os );                                                                              // call void returning
     385                return os;
     386        } // sep
     387
     388        ostype & nosep( ostype & os ) {
     389                nosep( os );                                                                    // call void returning
     390                return os;
     391        } // nosep
     392
    373393        ostype & sepOn( ostype & os ) {
    374394                sepOn( os );                                                                    // call void returning
     
    380400                return os;
    381401        } // sepOff
    382 
    383         ostype & sepEnable( ostype & os ) {
    384                 sepEnable( os );                                                                // call void returning
    385                 return os;
    386         } // sepEnable
    387 
    388         ostype & sepDisable( ostype & os ) {
    389                 sepDisable( os );                                                               // call void returning
    390                 return os;
    391         } // sepDisable
    392 
    393         ostype & nlOn( ostype & os ) {
    394                 nlOn( os );                                                                             // call void returning
    395                 return os;
    396         } // nlOn
    397 
    398         ostype & nlOff( ostype & os ) {
    399                 nlOff( os );                                                                    // call void returning
    400                 return os;
    401         } // nlOff
    402402} // distribution
    403403
     
    550550                if ( cnt == 1 ) {
    551551                        if ( f.flags.left ) { wd -= maxdig; f.wd = wd < 0 ? 1 : wd; } // update and restore f.wd for printing end chunk
    552                         sepOff( os );                                                           // no seperator between chunks
     552                        nosep( os );                                                            // no seperator between chunks
    553553                } // if
    554554        } else {                                                                                        // print start chunk
     
    595595                else { f.pc = maxdig; f.flags.pc = true; }              // left pad with precision
    596596
    597                 if ( cnt != 0 ) sepOff( os );                                   // no seperator between chunks
     597                if ( cnt != 0 ) nosep( os );                                    // no seperator between chunks
    598598                f.wd = wd;                                                                              // reset f.wd for next chunk
    599599                f.flags.sign = false;                                                   // no leading +/- sign
     
    773773                } // if
    774774
    775                 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
     775                if ( f.val[0] != '\0' &&                                                // null string => no leading separator
     776                         sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
    776777
    777778                #define SFMTNP "% * "
     
    795796                        fmt( os, &fmtstr[star], f.wd, f.pc, f.val );
    796797                } // if
     798                if ( f.val[0] == '\0' ) { nosep( os ); }                // null string => no trailing separator
    797799                return os;
    798800        } // ?|?
  • libcfa/src/iostream.hfa

    r70e47fec rf5d9c37  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 15 22:34:31 2023
    13 // Update Count     : 411
     12// Last Modified On : Thu Jun 29 11:07:25 2023
     13// Update Count     : 427
    1414//
    1515
     
    3636        void setPrt$( ostype &, bool );                                         // set fmt called in output cascade
    3737        // public
    38         void sepOn( ostype & );                                                         // turn separator state on
    39         void sepOff( ostype & );                                                        // turn separator state off
    40         bool sepDisable( ostype & );                                            // set default state to off, and return previous state
    41         bool sepEnable( ostype & );                                                     // set default state to on, and return previous state
    4238        void nlOn( ostype & );                                                          // turn auto-newline state on
    4339        void nlOff( ostype & );                                                         // turn auto-newline state off
    4440
     41        void sep( ostype & );                                                           // turn separator state on
     42        void nosep( ostype & );                                                         // turn separator state off
     43        bool sepOn( ostype & );                                                         // set default state to on, and return previous state
     44        bool sepOff( ostype & );                                                        // set default state to off, and return previous state
    4545        const char * sepGet( ostype & );                                        // get separator string
    4646        void sepSet( ostype &, const char [] );                         // set separator to string (15 character maximum)
     
    135135        ostype & ?|?( ostype &, ostype & (*)( ostype & ) );
    136136        void ?|?( ostype &, ostype & (*)( ostype & ) );
     137
    137138        ostype & nl( ostype & );
    138139        ostype & nonl( ostype & );
     140        ostype & nlOn( ostype & );
     141        ostype & nlOff( ostype & );
     142
     143        ostype & sepVal( ostype & );
     144        ostype & sepTupleVal( ostype & );
    139145        ostype & sep( ostype & );
    140         ostype & sepTuple( ostype & );
     146        ostype & nosep( ostype & );
    141147        ostype & sepOn( ostype & );
    142148        ostype & sepOff( ostype & );
    143         ostype & sepDisable( ostype & );
    144         ostype & sepEnable( ostype & );
    145         ostype & nlOn( ostype & );
    146         ostype & nlOff( ostype & );
    147149} // distribution
    148150
  • libcfa/src/strstream.cfa

    r70e47fec rf5d9c37  
    1010// Created On       : Thu Apr 22 22:24:35 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 10 16:13:20 2021
    13 // Update Count     : 101
     12// Last Modified On : Thu Jun 29 10:59:00 2023
     13// Update Count     : 105
    1414//
    1515
     
    3232
    3333// private
     34inline bool getNL$( ostrstream & os ) { return os.sawNL$; }
     35inline void setNL$( ostrstream & os, bool state ) { os.sawNL$ = state; }
     36inline bool getANL$( ostrstream & os ) { return os.nlOnOff$; }
    3437inline bool sepPrt$( ostrstream & os ) { setNL$( os, false ); return os.sepOnOff$; }
    3538inline void sepReset$( ostrstream & os ) { os.sepOnOff$ = os.sepDefault$; }
     
    3740inline const char * sepGetCur$( ostrstream & os ) { return os.sepCur$; }
    3841inline void sepSetCur$( ostrstream & os, const char sepCur[] ) { os.sepCur$ = sepCur; }
    39 inline bool getNL$( ostrstream & os ) { return os.sawNL$; }
    40 inline void setNL$( ostrstream & os, bool state ) { os.sawNL$ = state; }
    41 inline bool getANL$( ostrstream & os ) { return os.nlOnOff$; }
    4242inline bool getPrt$( ostrstream & os ) { return os.prt$; }
    4343inline void setPrt$( ostrstream & os, bool state ) { os.prt$ = state; }
    4444
    4545// public
     46void nlOn( ostrstream & os ) { os.nlOnOff$ = true; }
     47void nlOff( ostrstream & os ) { os.nlOnOff$ = false; }
     48
    4649void ?{}( ostrstream & os, char buf[], size_t size ) {
    4750        os.buf$ = buf;
     
    5861} // ?{}
    5962
    60 void sepOn( ostrstream & os ) { os.sepOnOff$ = ! getNL$( os ); }
    61 void sepOff( ostrstream & os ) { os.sepOnOff$ = false; }
     63void sep( ostrstream & os ) { os.sepOnOff$ = ! getNL$( os ); }
     64void nosep( ostrstream & os ) { os.sepOnOff$ = false; }
    6265
    63 bool sepDisable( ostrstream & os ) {
     66bool sepOn( ostrstream & os ) {
     67        bool temp = os.sepDefault$;
     68        os.sepDefault$ = true;
     69        if ( os.sepOnOff$ ) sepReset$( os );                            // start of line ?
     70        return temp;
     71} // sepOn
     72
     73bool sepOff( ostrstream & os ) {
    6474        bool temp = os.sepDefault$;
    6575        os.sepDefault$ = false;
    6676        sepReset$( os );
    6777        return temp;
    68 } // sepDisable
    69 
    70 bool sepEnable( ostrstream & os ) {
    71         bool temp = os.sepDefault$;
    72         os.sepDefault$ = true;
    73         if ( os.sepOnOff$ ) sepReset$( os );                            // start of line ?
    74         return temp;
    75 } // sepEnable
    76 
    77 void nlOn( ostrstream & os ) { os.nlOnOff$ = true; }
    78 void nlOff( ostrstream & os ) { os.nlOnOff$ = false; }
     78} // sepOff
    7979
    8080const char * sepGet( ostrstream & os ) { return os.separator$; }
  • libcfa/src/strstream.hfa

    r70e47fec rf5d9c37  
    1010// Created On       : Thu Apr 22 22:20:59 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 10 10:14:22 2021
    13 // Update Count     : 47
     12// Last Modified On : Thu Jun 29 10:58:58 2023
     13// Update Count     : 51
    1414//
    1515
     
    5353
    5454// public
    55 void sepOn( ostrstream & );
    56 void sepOff( ostrstream & );
    57 bool sepDisable( ostrstream & );
    58 bool sepEnable( ostrstream & );
    5955void nlOn( ostrstream & );
    6056void nlOff( ostrstream & );
    6157
     58void sep( ostrstream & );
     59void nosep( ostrstream & );
     60bool sepOn( ostrstream & );
     61bool sepOff( ostrstream & );
    6262const char * sepGet( ostrstream & );
    6363void sepSet( ostrstream &, const char [] );
Note: See TracChangeset for help on using the changeset viewer.