Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    rd1a9ff5 r4f37255  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb  7 18:48:38 2020
    13 // Update Count     : 825
     12// Last Modified On : Sat Jul 13 08:07:59 2019
     13// Update Count     : 821
    1414//
    1515
     
    3535forall( dtype ostype | ostream( ostype ) ) {
    3636        ostype & ?|?( ostype & os, zero_t ) {
    37                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     37                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    3838                fmt( os, "%d", 0n );
    3939                return os;
     
    4444
    4545        ostype & ?|?( ostype & os, one_t ) {
    46                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     46                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    4747                fmt( os, "%d", 1n );
    4848                return os;
     
    5353
    5454        ostype & ?|?( ostype & os, bool b ) {
    55                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     55                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    5656                fmt( os, "%s", b ? "true" : "false" );
    5757                return os;
     
    6363        ostype & ?|?( ostype & os, char c ) {
    6464                fmt( os, "%c", c );
    65                 if ( c == '\n' ) $setNL( os, true );
     65                if ( c == '\n' ) setNL( os, true );
    6666                return sepOff( os );
    6767        } // ?|?
     
    7171
    7272        ostype & ?|?( ostype & os, signed char sc ) {
    73                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     73                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    7474                fmt( os, "%hhd", sc );
    7575                return os;
     
    8080
    8181        ostype & ?|?( ostype & os, unsigned char usc ) {
    82                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     82                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    8383                fmt( os, "%hhu", usc );
    8484                return os;
     
    8989
    9090        ostype & ?|?( ostype & os, short int si ) {
    91                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     91                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    9292                fmt( os, "%hd", si );
    9393                return os;
     
    9898
    9999        ostype & ?|?( ostype & os, unsigned short int usi ) {
    100                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     100                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    101101                fmt( os, "%hu", usi );
    102102                return os;
     
    107107
    108108        ostype & ?|?( ostype & os, int i ) {
    109                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     109                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    110110                fmt( os, "%d", i );
    111111                return os;
     
    116116
    117117        ostype & ?|?( ostype & os, unsigned int ui ) {
    118                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     118                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    119119                fmt( os, "%u", ui );
    120120                return os;
     
    125125
    126126        ostype & ?|?( ostype & os, long int li ) {
    127                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     127                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    128128                fmt( os, "%ld", li );
    129129                return os;
     
    134134
    135135        ostype & ?|?( ostype & os, unsigned long int uli ) {
    136                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     136                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    137137                fmt( os, "%lu", uli );
    138138                return os;
     
    143143
    144144        ostype & ?|?( ostype & os, long long int lli ) {
    145                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     145                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    146146                fmt( os, "%lld", lli );
    147147                return os;
     
    152152
    153153        ostype & ?|?( ostype & os, unsigned long long int ulli ) {
    154                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     154                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    155155                fmt( os, "%llu", ulli );
    156156                return os;
     
    175175
    176176        ostype & ?|?( ostype & os, float f ) {
    177                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     177                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    178178                PrintWithDP( os, "%g", f );
    179179                return os;
     
    184184
    185185        ostype & ?|?( ostype & os, double d ) {
    186                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     186                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    187187                PrintWithDP( os, "%.*lg", d, DBL_DIG );
    188188                return os;
     
    193193
    194194        ostype & ?|?( ostype & os, long double ld ) {
    195                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     195                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    196196                PrintWithDP( os, "%.*Lg", ld, LDBL_DIG );
    197197                return os;
     
    202202
    203203        ostype & ?|?( ostype & os, float _Complex fc ) {
    204                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     204                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    205205//              os | crealf( fc ) | nonl;
    206206                PrintWithDP( os, "%g", crealf( fc ) );
     
    214214
    215215        ostype & ?|?( ostype & os, double _Complex dc ) {
    216                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     216                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    217217//              os | creal( dc ) | nonl;
    218218                PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG );
     
    226226
    227227        ostype & ?|?( ostype & os, long double _Complex ldc ) {
    228                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     228                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    229229//              os | creall( ldc ) || nonl;
    230230                PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG );
     
    237237        } // ?|?
    238238
    239         ostype & ?|?( ostype & os, const char str[] ) {
     239        ostype & ?|?( ostype & os, const char * str ) {
    240240                enum { Open = 1, Close, OpenClose };
    241241                static const unsigned char mask[256] @= {
     
    257257                // first character IS NOT spacing or closing punctuation => add left separator
    258258                unsigned char ch = str[0];                                              // must make unsigned
    259                 if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {
    260                         fmt( os, "%s", $sepGetCur( os ) );
     259                if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {
     260                        fmt( os, "%s", sepGetCur( os ) );
    261261                } // if
    262262
    263263                // if string starts line, must reset to determine open state because separator is off
    264                 $sepReset( os );                                                                // reset separator
     264                sepReset( os );                                                                 // reset separator
    265265
    266266                // last character IS spacing or opening punctuation => turn off separator for next item
    267267                size_t len = strlen( str );
    268268                ch = str[len - 1];                                                              // must make unsigned
    269                 if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
     269                if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    270270                        sepOn( os );
    271271                } else {
    272272                        sepOff( os );
    273273                } // if
    274                 if ( ch == '\n' ) $setNL( os, true );                   // check *AFTER* $sepPrt call above as it resets NL flag
     274                if ( ch == '\n' ) setNL( os, true );                    // check *AFTER* sepPrt call above as it resets NL flag
    275275                return write( os, str, len );
    276276        } // ?|?
    277 
    278         void ?|?( ostype & os, const char str[] ) {
     277        void ?|?( ostype & os, const char * str ) {
    279278                (ostype &)(os | str); ends( os );
    280279        } // ?|?
    281280
    282281//      ostype & ?|?( ostype & os, const char16_t * str ) {
    283 //              if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     282//              if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    284283//              fmt( os, "%ls", str );
    285284//              return os;
     
    288287// #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
    289288//      ostype & ?|?( ostype & os, const char32_t * str ) {
    290 //              if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     289//              if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    291290//              fmt( os, "%ls", str );
    292291//              return os;
     
    295294
    296295//      ostype & ?|?( ostype & os, const wchar_t * str ) {
    297 //              if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     296//              if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    298297//              fmt( os, "%ls", str );
    299298//              return os;
     
    301300
    302301        ostype & ?|?( ostype & os, const void * p ) {
    303                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     302                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    304303                fmt( os, "%p", p );
    305304                return os;
     
    316315        void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    317316                (ostype &)(manip( os ));
    318                 if ( $getPrt( os ) ) ends( os );                                // something printed ?
    319                 $setPrt( os, false );                                                   // turn off
     317                if ( getPrt( os ) ) ends( os );                                 // something printed ?
     318                setPrt( os, false );                                                    // turn off
    320319        } // ?|?
    321320
     
    330329        ostype & nl( ostype & os ) {
    331330                (ostype &)(os | '\n');
    332                 $setPrt( os, false );                                                   // turn off
    333                 $setNL( os, true );
     331                setPrt( os, false );                                                    // turn off
     332                setNL( os, true );
    334333                flush( os );
    335334                return sepOff( os );                                                    // prepare for next line
     
    337336
    338337        ostype & nonl( ostype & os ) {
    339                 $setPrt( os, false );                                                   // turn off
     338                setPrt( os, false );                                                    // turn off
    340339                return os;
    341340        } // nonl
     
    376375        ostype & ?|?( ostype & os, T arg, Params rest ) {
    377376                (ostype &)(os | arg);                                                   // print first argument
    378                 $sepSetCur( os, sepGetTuple( os ) );                    // switch to tuple separator
     377                sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
    379378                (ostype &)(os | rest);                                                  // print remaining arguments
    380                 $sepSetCur( os, sepGet( os ) );                                 // switch to regular separator
     379                sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
    381380                return os;
    382381        } // ?|?
     
    384383                // (ostype &)(?|?( os, arg, rest )); ends( os );
    385384                (ostype &)(os | arg);                                                   // print first argument
    386                 $sepSetCur( os, sepGetTuple( os ) );                    // switch to tuple separator
     385                sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
    387386                (ostype &)(os | rest);                                                  // print remaining arguments
    388                 $sepSetCur( os, sepGet( os ) );                                 // switch to regular separator
     387                sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
    389388                ends( os );
    390389        } // ?|?
     
    415414forall( dtype ostype | ostream( ostype ) ) { \
    416415        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    417                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \
     416                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \
    418417\
    419418                if ( f.base == 'b' || f.base == 'B' ) {                 /* bespoke binary format */ \
     
    514513forall( dtype ostype | ostream( ostype ) ) { \
    515514        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    516                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \
     515                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \
    517516                char fmtstr[sizeof(DFMTP)];                                             /* sizeof includes '\0' */ \
    518517                if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \
     
    537536                return os; \
    538537        } /* ?|? */ \
    539 \
    540538        void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \
    541539} // distribution
     
    557555                } // if
    558556
    559                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     557                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    560558
    561559                #define CFMTNP "% * "
     
    573571                return os;
    574572        } // ?|?
    575 
    576573        void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); }
    577574} // distribution
     
    595592                } // if
    596593
    597                 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );
     594                if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
    598595
    599596                #define SFMTNP "% * "
     
    619616                return os;
    620617        } // ?|?
    621 
    622618        void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); }
    623619} // distribution
     
    739735        } // ?|?
    740736
    741         // istype & ?|?( istype & is, const char fmt[] ) {
     737        // istype & ?|?( istype & is, const char * fmt ) {
    742738        //      fmt( is, fmt, "" );
    743739        //      return is;
Note: See TracChangeset for help on using the changeset viewer.