Changeset 94d2544


Ignore:
Timestamp:
Jul 18, 2023, 12:20:12 PM (10 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
5454d77
Parents:
8b84973
Message:

formatting, create macros OSTYPE_VOID, OSTYPE_VOID_IMPL. ISTYPE_VOID, ISTYPE_VOID_IMPL to create companion void print routine

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    r8b84973 r94d2544  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 29 10:12:39 2023
    13 // Update Count     : 1380
     12// Last Modified On : Tue Jul 18 10:42:51 2023
     13// Update Count     : 1401
    1414//
    1515
     
    3434#pragma GCC visibility push(default)
    3535
     36
    3637// *********************************** ostream ***********************************
    3738
     
    4344                return os;
    4445        } // ?|?
    45         void ?|?( ostype & os, bool b ) {
    46                 (ostype &)(os | b); ends( os );
    47         } // ?|?
     46        OSTYPE_VOID_IMPL( bool )
    4847
    4948        ostype & ?|?( ostype & os, char c ) {
     
    5251                return nosep( os );
    5352        } // ?|?
    54         void ?|?( ostype & os, char c ) {
    55                 (ostype &)(os | c); ends( os );
    56         } // ?|?
     53        OSTYPE_VOID_IMPL( char )
    5754
    5855        ostype & ?|?( ostype & os, signed char sc ) {
     
    6158                return os;
    6259        } // ?|?
    63         void ?|?( ostype & os, signed char sc ) {
    64                 (ostype &)(os | sc); ends( os );
    65         } // ?|?
     60        OSTYPE_VOID_IMPL( signed char )
    6661
    6762        ostype & ?|?( ostype & os, unsigned char usc ) {
     
    7065                return os;
    7166        } // ?|?
    72         void ?|?( ostype & os, unsigned char usc ) {
    73                 (ostype &)(os | usc); ends( os );
    74         } // ?|?
     67        OSTYPE_VOID_IMPL( unsigned char )
    7568
    7669        ostype & ?|?( ostype & os, short int si ) {
     
    7972                return os;
    8073        } // ?|?
    81         void & ?|?( ostype & os, short int si ) {
    82                 (ostype &)(os | si); ends( os );
    83         } // ?|?
     74        OSTYPE_VOID_IMPL( short int )
    8475
    8576        ostype & ?|?( ostype & os, unsigned short int usi ) {
     
    8879                return os;
    8980        } // ?|?
    90         void & ?|?( ostype & os, unsigned short int usi ) {
    91                 (ostype &)(os | usi); ends( os );
    92         } // ?|?
     81        OSTYPE_VOID_IMPL( unsigned short int )
    9382
    9483        ostype & ?|?( ostype & os, int i ) {
     
    9786                return os;
    9887        } // ?|?
    99         void & ?|?( ostype & os, int i ) {
    100                 (ostype &)(os | i); ends( os );
    101         } // ?|?
     88        OSTYPE_VOID_IMPL( int )
    10289
    10390        ostype & ?|?( ostype & os, unsigned int ui ) {
     
    10693                return os;
    10794        } // ?|?
    108         void & ?|?( ostype & os, unsigned int ui ) {
    109                 (ostype &)(os | ui); ends( os );
    110         } // ?|?
     95        OSTYPE_VOID_IMPL( unsigned int )
    11196
    11297        ostype & ?|?( ostype & os, long int li ) {
     
    115100                return os;
    116101        } // ?|?
    117         void & ?|?( ostype & os, long int li ) {
    118                 (ostype &)(os | li); ends( os );
    119         } // ?|?
     102        OSTYPE_VOID_IMPL( long int )
    120103
    121104        ostype & ?|?( ostype & os, unsigned long int uli ) {
     
    124107                return os;
    125108        } // ?|?
    126         void & ?|?( ostype & os, unsigned long int uli ) {
    127                 (ostype &)(os | uli); ends( os );
    128         } // ?|?
     109        OSTYPE_VOID_IMPL( unsigned long int )
    129110
    130111        ostype & ?|?( ostype & os, long long int lli ) {
     
    133114                return os;
    134115        } // ?|?
    135         void & ?|?( ostype & os, long long int lli ) {
    136                 (ostype &)(os | lli); ends( os );
    137         } // ?|?
     116        OSTYPE_VOID_IMPL( long long int )
    138117
    139118        ostype & ?|?( ostype & os, unsigned long long int ulli ) {
     
    142121                return os;
    143122        } // ?|?
    144         void & ?|?( ostype & os, unsigned long long int ulli ) {
    145                 (ostype &)(os | ulli); ends( os );
    146         } // ?|?
     123        OSTYPE_VOID_IMPL( unsigned long long int )
    147124
    148125        #if defined( __SIZEOF_INT128__ )
     
    176153                return os;
    177154        } // ?|?
    178         void & ?|?( ostype & os, int128 llli ) {
    179                 (ostype &)(os | llli); ends( os );
    180         } // ?|?
     155        OSTYPE_VOID_IMPL( int128 )
    181156
    182157        ostype & ?|?( ostype & os, unsigned int128 ullli ) {
     
    185160                return os;
    186161        } // ?|?
    187         void & ?|?( ostype & os, unsigned int128 ullli ) {
    188                 (ostype &)(os | ullli); ends( os );
    189         } // ?|?
     162        OSTYPE_VOID_IMPL( unsigned int128 )
    190163        #endif // __SIZEOF_INT128__
    191164
    192         #define PrintWithDP( os, format, val, ... ) \
     165        #define PRINT_WITH_DP( os, format, val, ... ) \
    193166                { \
    194167                        enum { size = 48 }; \
     
    206179        ostype & ?|?( ostype & os, float f ) {
    207180                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
    208                 PrintWithDP( os, "%'g", f );
    209                 return os;
    210         } // ?|?
    211         void & ?|?( ostype & os, float f ) {
    212                 (ostype &)(os | f); ends( os );
    213         } // ?|?
     181                PRINT_WITH_DP( os, "%'g", f );
     182                return os;
     183        } // ?|?
     184        OSTYPE_VOID_IMPL( float )
    214185
    215186        ostype & ?|?( ostype & os, double d ) {
    216187                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
    217                 PrintWithDP( os, "%'.*lg", d, DBL_DIG );
    218                 return os;
    219         } // ?|?
    220         void & ?|?( ostype & os, double d ) {
    221                 (ostype &)(os | d); ends( os );
    222         } // ?|?
     188                PRINT_WITH_DP( os, "%'.*lg", d, DBL_DIG );
     189                return os;
     190        } // ?|?
     191        OSTYPE_VOID_IMPL( double )
    223192
    224193        ostype & ?|?( ostype & os, long double ld ) {
    225194                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
    226                 PrintWithDP( os, "%'.*Lg", ld, LDBL_DIG );
    227                 return os;
    228         } // ?|?
    229         void & ?|?( ostype & os, long double ld ) {
    230                 (ostype &)(os | ld); ends( os );
    231         } // ?|?
     195                PRINT_WITH_DP( os, "%'.*Lg", ld, LDBL_DIG );
     196                return os;
     197        } // ?|?
     198        OSTYPE_VOID_IMPL( long double )
    232199
    233200        ostype & ?|?( ostype & os, float _Complex fc ) {
    234201                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
    235202//              os | crealf( fc ) | nonl;
    236                 PrintWithDP( os, "%'g", crealf( fc ) );
    237                 PrintWithDP( os, "%'+g", cimagf( fc ) );
     203                PRINT_WITH_DP( os, "%'g", crealf( fc ) );
     204                PRINT_WITH_DP( os, "%'+g", cimagf( fc ) );
    238205                fmt( os, "i" );
    239206                return os;
    240207        } // ?|?
    241         void & ?|?( ostype & os, float _Complex fc ) {
    242                 (ostype &)(os | fc); ends( os );
    243         } // ?|?
     208        OSTYPE_VOID_IMPL( float _Complex )
    244209
    245210        ostype & ?|?( ostype & os, double _Complex dc ) {
    246211                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
    247212//              os | creal( dc ) | nonl;
    248                 PrintWithDP( os, "%'.*lg", creal( dc ), DBL_DIG );
    249                 PrintWithDP( os, "%'+.*lg", cimag( dc ), DBL_DIG );
     213                PRINT_WITH_DP( os, "%'.*lg", creal( dc ), DBL_DIG );
     214                PRINT_WITH_DP( os, "%'+.*lg", cimag( dc ), DBL_DIG );
    250215                fmt( os, "i" );
    251216                return os;
    252217        } // ?|?
    253         void & ?|?( ostype & os, double _Complex dc ) {
    254                 (ostype &)(os | dc); ends( os );
    255         } // ?|?
     218        OSTYPE_VOID_IMPL( double _Complex )
    256219
    257220        ostype & ?|?( ostype & os, long double _Complex ldc ) {
    258221                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
    259222//              os | creall( ldc ) || nonl;
    260                 PrintWithDP( os, "%'.*Lg", creall( ldc ), LDBL_DIG );
    261                 PrintWithDP( os, "%'+.*Lg", cimagl( ldc ), LDBL_DIG );
     223                PRINT_WITH_DP( os, "%'.*Lg", creall( ldc ), LDBL_DIG );
     224                PRINT_WITH_DP( os, "%'+.*Lg", cimagl( ldc ), LDBL_DIG );
    262225                fmt( os, "i" );
    263226                return os;
    264227        } // ?|?
    265         void & ?|?( ostype & os, long double _Complex ldc ) {
    266                 (ostype &)(os | ldc); ends( os );
    267         } // ?|?
     228        OSTYPE_VOID_IMPL( long double _Complex )
    268229
    269230        ostype & ?|?( ostype & os, const char s[] ) {
     
    308269//              return write( os, s, len );
    309270        } // ?|?
    310         void ?|?( ostype & os, const char s[] ) {
    311                 (ostype &)(os | s); ends( os );
    312         } // ?|?
     271        OSTYPE_VOID_IMPL( const char * )
    313272
    314273//      ostype & ?|?( ostype & os, const char16_t * s ) {
     
    337296                return os;
    338297        } // ?|?
    339         void ?|?( ostype & os, const void * p ) {
    340                 (ostype &)(os | p); ends( os );
    341         } // ?|?
     298        OSTYPE_VOID_IMPL( const void * )
    342299
    343300        // manipulators
     
    442399
    443400// Default prefix for non-decimal prints is 0b, 0, 0x.
    444 #define IntegralFMTImpl( T, IFMTNP, IFMTP ) \
     401#define INTEGRAL_FMT_IMPL( T, IFMTNP, IFMTP ) \
    445402forall( ostype & | basic_ostream( ostype ) ) { \
    446403        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
     
    519476                return os; \
    520477        } /* ?|? */ \
    521         void ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    522                 (ostype &)(os | f); ends( os ); \
    523         } /* ?|? */ \
    524 } // distribution
    525 
    526 IntegralFMTImpl( signed char,            "      *hh ", "      *.*hh " )
    527 IntegralFMTImpl( unsigned char,          "      *hh ", "      *.*hh " )
    528 IntegralFMTImpl( signed short int,       "      *h ",  "      *.*h " )
    529 IntegralFMTImpl( unsigned short int,     "      *h ",  "      *.*h " )
    530 IntegralFMTImpl( signed int,             "      * ",   "      *.* " )
    531 IntegralFMTImpl( unsigned int,           "      * ",   "      *.* " )
    532 IntegralFMTImpl( signed long int,        "      *l ",  "      *.*l " )
    533 IntegralFMTImpl( unsigned long int,      "      *l ",  "      *.*l " )
    534 IntegralFMTImpl( signed long long int,   "      *ll ", "      *.*ll " )
    535 IntegralFMTImpl( unsigned long long int, "      *ll ", "      *.*ll " )
     478        OSTYPE_VOID_IMPL( _Ostream_Manip(T) ) \
     479} // distribution
     480
     481INTEGRAL_FMT_IMPL( signed char,            "      *hh ", "      *.*hh " )
     482INTEGRAL_FMT_IMPL( unsigned char,          "      *hh ", "      *.*hh " )
     483INTEGRAL_FMT_IMPL( signed short int,       "      *h ",  "      *.*h " )
     484INTEGRAL_FMT_IMPL( unsigned short int,     "      *h ",  "      *.*h " )
     485INTEGRAL_FMT_IMPL( signed int,             "      * ",   "      *.* " )
     486INTEGRAL_FMT_IMPL( unsigned int,           "      * ",   "      *.* " )
     487INTEGRAL_FMT_IMPL( signed long int,        "      *l ",  "      *.*l " )
     488INTEGRAL_FMT_IMPL( unsigned long int,      "      *l ",  "      *.*l " )
     489INTEGRAL_FMT_IMPL( signed long long int,   "      *ll ", "      *.*ll " )
     490INTEGRAL_FMT_IMPL( unsigned long long int, "      *ll ", "      *.*ll " )
    536491
    537492
     
    602557} // base_128
    603558
    604 #define IntegralFMTImpl128( T ) \
     559#define INTEGRAL_FMT_IMPL128( T ) \
    605560forall( ostype & | basic_ostream( ostype ) ) { \
    606561        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
     
    619574                return os; \
    620575        } /* ?|? */ \
    621         void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \
    622 } // distribution
    623 
    624 IntegralFMTImpl128( int128 )
    625 IntegralFMTImpl128( unsigned int128 )
     576        OSTYPE_VOID_IMPL( _Ostream_Manip(T) ) \
     577} // distribution
     578
     579INTEGRAL_FMT_IMPL128( int128 )
     580INTEGRAL_FMT_IMPL128( unsigned int128 )
    626581#endif // __SIZEOF_INT128__
    627582
     
    635590#define SUFFIXES_END (SUFFIXES_START + (int)((sizeof(suffixes) / sizeof(char *) - 1) * 3))
    636591
    637 #define PrintWithDP2( os, format, ... ) \
     592#define PRINT_WITH_DP2( os, format, ... ) \
    638593        { \
    639594                if ( ! f.flags.eng ) { \
     
    676631        }
    677632
    678 #define FloatingPointFMTImpl( T, DFMTNP, DFMTP ) \
     633#define FLOATING_POINT_FMT_IMPL( T, DFMTNP, DFMTP ) \
    679634forall( ostype & | basic_ostream( ostype ) ) { \
    680635        static void eng( T &value, int & pc, int & exp10 ) { \
     
    707662                        fmtstr[sizeof(DFMTNP)-2] = f.base;                      /* sizeof includes '\0' */ \
    708663                        /* printf( "%g %d %s\n", f.val, f.wd, &fmtstr[star] ); */ \
    709                         PrintWithDP2( os, &fmtstr[star], f.wd, f.val ) \
     664                        PRINT_WITH_DP2( os, &fmtstr[star], f.wd, f.val ) \
    710665                } else {                                                                                /* precision */ \
    711666                        fmtstr[sizeof(DFMTP)-2] = f.base;                       /* sizeof includes '\0' */ \
    712667                        /* printf( "%g %d %d %s\n", f.val, f.wd, f.pc, &fmtstr[star] ); */ \
    713                         PrintWithDP2( os, &fmtstr[star], f.wd, f.pc, f.val ) \
     668                        PRINT_WITH_DP2( os, &fmtstr[star], f.wd, f.pc, f.val ) \
    714669                } /* if */ \
    715670                return os; \
    716671        } /* ?|? */ \
    717672\
    718         void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \
    719 } // distribution
    720 
    721 FloatingPointFMTImpl( double,      "      * ",  "      *.* " )
    722 FloatingPointFMTImpl( long double, "      *L ", "      *.*L " )
     673        OSTYPE_VOID_IMPL( _Ostream_Manip(T) ) \
     674} // distribution
     675
     676FLOATING_POINT_FMT_IMPL( double,      "      * ",  "      *.* " )
     677FLOATING_POINT_FMT_IMPL( long double, "      *L ", "      *.*L " )
    723678
    724679// *********************************** character ***********************************
     
    751706                return os;
    752707        } // ?|?
    753 
    754         void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); }
     708        OSTYPE_VOID_IMPL( _Ostream_Manip(char) )
    755709} // distribution
    756710
     
    799753                return os;
    800754        } // ?|?
    801 
    802         void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); }
     755        OSTYPE_VOID_IMPL( _Ostream_Manip(const char *) )
    803756} // distribution
    804757
     
    806759// *********************************** istream ***********************************
    807760
     761
     762#define ISTYPE_VOID_VAL_IMPL( T ) \
     763        void ?|?( istype & is, T t ) { \
     764                (istype &)(is | t); ends( is ); \
     765        } // ?|?
    808766
    809767forall( istype & | basic_istream( istype ) ) {
     
    819777                return is;
    820778        } // ?|?
    821         void ?|?( istype & is, bool & b ) {
    822                 (istype &)(is | b); ends( is );
    823         } // ?|?
     779        ISTYPE_VOID_IMPL( bool )
    824780
    825781        istype & ?|?( istype & is, char & c ) {
     
    833789                return is;
    834790        } // ?|?
    835         void ?|?( istype & is, char & c ) {
    836                 (istype &)(is | c); ends( is );
    837         } // ?|?
     791        ISTYPE_VOID_IMPL( char )
    838792
    839793        istype & ?|?( istype & is, signed char & sc ) {
     
    841795                return is;
    842796        } // ?|?
    843         void ?|?( istype & is, signed char & sc ) {
    844                 (istype &)(is | sc); ends( is );
    845         } // ?|?
     797        ISTYPE_VOID_IMPL( signed char )
    846798
    847799        istype & ?|?( istype & is, unsigned char & usc ) {
     
    849801                return is;
    850802        } // ?|?
    851         void ?|?( istype & is, unsigned char & usc ) {
    852                 (istype &)(is | usc); ends( is );
    853         } // ?|?
     803        ISTYPE_VOID_IMPL( unsigned char )
    854804
    855805        istype & ?|?( istype & is, short int & si ) {
     
    857807                return is;
    858808        } // ?|?
    859         void ?|?( istype & is, short int & si ) {
    860                 (istype &)(is | si); ends( is );
    861         } // ?|?
     809        ISTYPE_VOID_IMPL( short int )
    862810
    863811        istype & ?|?( istype & is, unsigned short int & usi ) {
     
    865813                return is;
    866814        } // ?|?
    867         void ?|?( istype & is, unsigned short int & usi ) {
    868                 (istype &)(is | usi); ends( is );
    869         } // ?|?
     815        ISTYPE_VOID_IMPL( unsigned short int )
    870816
    871817        istype & ?|?( istype & is, int & i ) {
     
    873819                return is;
    874820        } // ?|?
    875         void ?|?( istype & is, int & i ) {
    876                 (istype &)(is | i); ends( is );
    877         } // ?|?
     821        ISTYPE_VOID_IMPL( int )
    878822
    879823        istype & ?|?( istype & is, unsigned int & ui ) {
     
    881825                return is;
    882826        } // ?|?
    883         void ?|?( istype & is, unsigned int & ui ) {
    884                 (istype &)(is | ui); ends( is );
    885         } // ?|?
     827        ISTYPE_VOID_IMPL( unsigned int )
    886828
    887829        istype & ?|?( istype & is, long int & li ) {
     
    889831                return is;
    890832        } // ?|?
    891         void ?|?( istype & is, long int & li ) {
    892                 (istype &)(is | li); ends( is );
    893         } // ?|?
     833        ISTYPE_VOID_IMPL( long int )
    894834
    895835        istype & ?|?( istype & is, unsigned long int & ulli ) {
     
    897837                return is;
    898838        } // ?|?
    899         void ?|?( istype & is, unsigned long int & ulli ) {
    900                 (istype &)(is | ulli); ends( is );
    901         } // ?|?
     839        ISTYPE_VOID_IMPL( unsigned long int )
    902840
    903841        istype & ?|?( istype & is, long long int & lli ) {
     
    905843                return is;
    906844        } // ?|?
    907         void ?|?( istype & is, long long int & lli ) {
    908                 (istype &)(is | lli); ends( is );
    909         } // ?|?
     845        ISTYPE_VOID_IMPL( long long int )
    910846
    911847        istype & ?|?( istype & is, unsigned long long int & ulli ) {
     
    913849                return is;
    914850        } // ?|?
    915         void & ?|?( istype & is, unsigned long long int & ulli ) {
    916                 (istype &)(is | ulli); ends( is );
    917         } // ?|?
     851        ISTYPE_VOID_IMPL( unsigned long long int )
    918852
    919853        #if defined( __SIZEOF_INT128__ )
     
    921855                return (istype &)(is | (unsigned int128 &)llli);
    922856        } // ?|?
    923         void ?|?( istype & is, int128 & llli ) {
    924                 (istype &)(is | llli); ends( is );
    925         } // ?|?
     857        ISTYPE_VOID_IMPL( int128 )
    926858
    927859        istype & ?|?( istype & is, unsigned int128 & ullli ) {
     
    940872                return is;
    941873        } // ?|?
    942         void ?|?( istype & is, unsigned int128 & ullli ) {
    943                 (istype &)(is | ullli); ends( is );
    944         } // ?|?
     874        ISTYPE_VOID_IMPL( unsigned int128 )
    945875        #endif // __SIZEOF_INT128__
    946876
     
    949879                return is;
    950880        } // ?|?
    951         void ?|?( istype & is, float & f ) {
    952                 (istype &)(is | f); ends( is );
    953         } // ?|?
     881        ISTYPE_VOID_IMPL( float )
    954882
    955883        istype & ?|?( istype & is, double & d ) {
     
    957885                return is;
    958886        } // ?|?
    959         void ?|?( istype & is, double & d ) {
    960                 (istype &)(is | d); ends( is );
    961         } // ?|?
     887        ISTYPE_VOID_IMPL( double )
    962888
    963889        istype & ?|?( istype & is, long double & ld ) {
     
    965891                return is;
    966892        } // ?|?
    967         void ?|?( istype & is, long double & ld ) {
    968                 (istype &)(is | ld); ends( is );
    969         } // ?|?
     893        ISTYPE_VOID_IMPL( long double )
    970894
    971895        istype & ?|?( istype & is, float _Complex & fc ) {
     
    975899                return is;
    976900        } // ?|?
    977         void ?|?( istype & is, float _Complex & fc ) {
    978                 (istype &)(is | fc); ends( is );
    979         } // ?|?
     901        ISTYPE_VOID_IMPL( float _Complex )
    980902
    981903        istype & ?|?( istype & is, double _Complex & dc ) {
     
    985907                return is;
    986908        } // ?|?
    987         void ?|?( istype & is, double _Complex & dc ) {
    988                 (istype &)(is | dc); ends( is );
    989         } // ?|?
     909        ISTYPE_VOID_IMPL( double _Complex )
    990910
    991911        istype & ?|?( istype & is, long double _Complex & ldc ) {
     
    995915                return is;
    996916        } // ?|?
    997         void ?|?( istype & is, long double _Complex & ldc ) {
    998                 (istype &)(is | ldc); ends( is );
    999         } // ?|?
     917        ISTYPE_VOID_IMPL( long double _Complex )
    1000918
    1001919        // istype & ?|?( istype & is, const char fmt[] ) {
     
    1008926                return is;
    1009927        } // ?|?
    1010         void ?|?( istype & is, char s[] ) {
    1011                 (istype &)(is | s); ends( is );
    1012         } // ?|?
     928        ISTYPE_VOID_VAL_IMPL( char * )
    1013929
    1014930        // manipulators
     
    1072988                return is;
    1073989        } // ?|?
    1074         void ?|?( istype & is, _Istream_Cstr f ) {
    1075                 (istype &)(is | f); ends( is );
    1076         } // ?|?
     990        ISTYPE_VOID_VAL_IMPL( _Istream_Cstr )
    1077991
    1078992        istype & ?|?( istype & is, _Istream_Char f ) {
     
    1080994                return is;
    1081995        } // ?|?
    1082         void ?|?( istype & is, _Istream_Char f ) {
    1083                 (istype &)(is | f); ends( is );
    1084         } // ?|?
    1085 } // distribution
    1086 
    1087 #define InputFMTImpl( T, CODE ) \
     996        ISTYPE_VOID_VAL_IMPL( _Istream_Char )
     997} // distribution
     998
     999#define INPUT_FMT_IMPL( T, CODE ) \
    10881000forall( istype & | basic_istream( istype ) ) { \
    10891001        istype & ?|?( istype & is, _Istream_Manip(T) f ) { \
     
    10991011                return is; \
    11001012        } /* ?|? */ \
    1101         void ?|?( istype & is, _Istream_Manip(T) f ) { \
    1102                 (istype &)(is | f); ends( is ); \
    1103         } /* ?|? */ \
    1104 } // distribution
    1105 
    1106 InputFMTImpl( signed char, "hhi" )
    1107 InputFMTImpl( unsigned char, "hhi" )
    1108 InputFMTImpl( signed short int, "hi" )
    1109 InputFMTImpl( unsigned short int, "hi" )
    1110 InputFMTImpl( signed int, "i" )
    1111 InputFMTImpl( unsigned int, "i" )
    1112 InputFMTImpl( signed long int, "li" )
    1113 InputFMTImpl( unsigned long int, "li" )
    1114 InputFMTImpl( signed long long int, "lli" )
    1115 InputFMTImpl( unsigned long long int, "lli" )
    1116 
    1117 InputFMTImpl( float, "f" )
    1118 InputFMTImpl( double, "lf" )
    1119 InputFMTImpl( long double, "Lf" )
     1013        ISTYPE_VOID_VAL_IMPL( _Istream_Manip(T) ) \
     1014} // distribution
     1015
     1016INPUT_FMT_IMPL( signed char, "hhi" )
     1017INPUT_FMT_IMPL( unsigned char, "hhi" )
     1018INPUT_FMT_IMPL( signed short int, "hi" )
     1019INPUT_FMT_IMPL( unsigned short int, "hi" )
     1020INPUT_FMT_IMPL( signed int, "i" )
     1021INPUT_FMT_IMPL( unsigned int, "i" )
     1022INPUT_FMT_IMPL( signed long int, "li" )
     1023INPUT_FMT_IMPL( unsigned long int, "li" )
     1024INPUT_FMT_IMPL( signed long long int, "lli" )
     1025INPUT_FMT_IMPL( unsigned long long int, "lli" )
     1026
     1027INPUT_FMT_IMPL( float, "f" )
     1028INPUT_FMT_IMPL( double, "lf" )
     1029INPUT_FMT_IMPL( long double, "Lf" )
    11201030
    11211031forall( istype & | basic_istream( istype ) ) {
     
    11291039                return is;
    11301040        } // ?|?
    1131         void ?|?( istype & is, _Istream_Manip(float _Complex) fc ) {
    1132                 (istype &)(is | fc); ends( is );
    1133         } // ?|?
     1041        ISTYPE_VOID_VAL_IMPL( _Istream_Manip(float _Complex) )
    11341042
    11351043        istype & ?|?( istype & is, _Istream_Manip(double _Complex) dc ) {
     
    11421050                return is;
    11431051        } // ?|?
    1144         void ?|?( istype & is, _Istream_Manip(double _Complex) dc ) {
    1145                 (istype &)(is | dc); ends( is );
    1146         } // ?|?
     1052        ISTYPE_VOID_VAL_IMPL( _Istream_Manip(double _Complex) )
    11471053
    11481054        istype & ?|?( istype & is, _Istream_Manip(long double _Complex) ldc ) {
     
    11551061                return is;
    11561062        } // ?|?
    1157         void ?|?( istype & is, _Istream_Manip(long double _Complex) ldc ) {
    1158                 (istype &)(is | ldc); ends( is );
    1159         } // ?|?
     1063        ISTYPE_VOID_VAL_IMPL( _Istream_Manip(long double _Complex) )
    11601064} // distribution
    11611065
  • libcfa/src/iostream.hfa

    r8b84973 r94d2544  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 29 11:07:25 2023
    13 // Update Count     : 427
     12// Last Modified On : Tue Jul 18 10:42:52 2023
     13// Update Count     : 438
    1414//
    1515
     
    7474// implement writable for intrinsic types
    7575
     76#define OSTYPE_VOID( T ) void ?|?( ostype &, T )
     77#define OSTYPE_VOID_IMPL( T ) \
     78        void ?|?( ostype & os, T t ) { \
     79                (ostype &)(os | t); ends( os ); \
     80        } // ?|?
     81
    7682forall( ostype & | basic_ostream( ostype ) ) {
    7783        ostype & ?|?( ostype &, bool );
    78         void ?|?( ostype &, bool );
     84        OSTYPE_VOID( bool );
    7985
    8086        ostype & ?|?( ostype &, char );
    81         void ?|?( ostype &, char );
     87        OSTYPE_VOID( char );
    8288        ostype & ?|?( ostype &, signed char );
    83         void ?|?( ostype &, signed char );
     89        OSTYPE_VOID( signed char );
    8490        ostype & ?|?( ostype &, unsigned char );
    85         void ?|?( ostype &, unsigned char );
     91        OSTYPE_VOID( unsigned char );
    8692
    8793        ostype & ?|?( ostype &, short int );
    88         void ?|?( ostype &, short int );
     94        OSTYPE_VOID( short int );
    8995        ostype & ?|?( ostype &, unsigned short int );
    90         void ?|?( ostype &, unsigned short int );
     96        OSTYPE_VOID( unsigned short int );
    9197        ostype & ?|?( ostype &, int );
    92         void ?|?( ostype &, int );
     98        OSTYPE_VOID( int );
    9399        ostype & ?|?( ostype &, unsigned int );
    94         void ?|?( ostype &, unsigned int );
     100        OSTYPE_VOID( unsigned int );
    95101        ostype & ?|?( ostype &, long int );
    96         void ?|?( ostype &, long int );
     102        OSTYPE_VOID( long int );
    97103        ostype & ?|?( ostype &, long long int );
    98         void ?|?( ostype &, long long int );
     104        OSTYPE_VOID( long long int );
    99105        ostype & ?|?( ostype &, unsigned long int );
    100         void ?|?( ostype &, unsigned long int );
     106        OSTYPE_VOID( unsigned long int );
    101107        ostype & ?|?( ostype &, unsigned long long int );
    102         void ?|?( ostype &, unsigned long long int );
     108        OSTYPE_VOID( unsigned long long int );
    103109        #if defined( __SIZEOF_INT128__ )
    104110        ostype & ?|?( ostype &, int128 );
    105         void ?|?( ostype &, int128 );
     111        OSTYPE_VOID( int128 );
    106112        ostype & ?|?( ostype &, unsigned int128 );
    107         void ?|?( ostype &, unsigned int128 );
     113        OSTYPE_VOID( unsigned int128 );
    108114        #endif // __SIZEOF_INT128__
    109115
    110116        ostype & ?|?( ostype &, float );
    111         void ?|?( ostype &, float );
     117        OSTYPE_VOID( float );
    112118        ostype & ?|?( ostype &, double );
    113         void ?|?( ostype &, double );
     119        OSTYPE_VOID( double );
    114120        ostype & ?|?( ostype &, long double );
    115         void ?|?( ostype &, long double );
     121        OSTYPE_VOID( long double );
    116122
    117123        ostype & ?|?( ostype &, float _Complex );
    118         void ?|?( ostype &, float _Complex );
     124        OSTYPE_VOID( float _Complex );
    119125        ostype & ?|?( ostype &, double _Complex );
    120         void ?|?( ostype &, double _Complex );
     126        OSTYPE_VOID( double _Complex );
    121127        ostype & ?|?( ostype &, long double _Complex );
    122         void ?|?( ostype &, long double _Complex );
     128        OSTYPE_VOID( long double _Complex );
    123129
    124130        ostype & ?|?( ostype &, const char [] );
    125         void ?|?( ostype &, const char [] );
     131        OSTYPE_VOID( const char [] );
    126132        // ostype & ?|?( ostype &, const char16_t * );
    127133        #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
     
    130136        // ostype & ?|?( ostype &, const wchar_t * );
    131137        ostype & ?|?( ostype &, const void * );
    132         void ?|?( ostype &, const void * );
     138        OSTYPE_VOID( const void * );
    133139
    134140        // manipulators
    135141        ostype & ?|?( ostype &, ostype & (*)( ostype & ) );
    136         void ?|?( ostype &, ostype & (*)( ostype & ) );
     142        OSTYPE_VOID( ostype & (*)( ostype & ) );
    137143
    138144        ostype & nl( ostype & );
     
    190196// initialized explicitly shall be initialized implicitly the same as objects that have static storage duration.***
    191197
    192 #define IntegralFMTDecl( T, CODE ) \
     198#define INTEGRAL_FMT_DECL( T, CODE ) \
    193199static inline { \
    194200        _Ostream_Manip(T) bin( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'b', { .all : 0 } }; } \
     
    211217} // ?|?
    212218
    213 IntegralFMTDecl( signed char, 'd' )
    214 IntegralFMTDecl( unsigned char, 'u' )
    215 IntegralFMTDecl( signed short int, 'd' )
    216 IntegralFMTDecl( unsigned short int, 'u' )
    217 IntegralFMTDecl( signed int, 'd' )
    218 IntegralFMTDecl( unsigned int, 'u' )
    219 IntegralFMTDecl( signed long int, 'd' )
    220 IntegralFMTDecl( unsigned long int, 'u' )
    221 IntegralFMTDecl( signed long long int, 'd' )
    222 IntegralFMTDecl( unsigned long long int, 'u' )
     219INTEGRAL_FMT_DECL( signed char, 'd' )
     220INTEGRAL_FMT_DECL( unsigned char, 'u' )
     221INTEGRAL_FMT_DECL( signed short int, 'd' )
     222INTEGRAL_FMT_DECL( unsigned short int, 'u' )
     223INTEGRAL_FMT_DECL( signed int, 'd' )
     224INTEGRAL_FMT_DECL( unsigned int, 'u' )
     225INTEGRAL_FMT_DECL( signed long int, 'd' )
     226INTEGRAL_FMT_DECL( unsigned long int, 'u' )
     227INTEGRAL_FMT_DECL( signed long long int, 'd' )
     228INTEGRAL_FMT_DECL( unsigned long long int, 'u' )
    223229#if defined( __SIZEOF_INT128__ )
    224 IntegralFMTDecl( int128, 'd' )
    225 IntegralFMTDecl( unsigned int128, 'u' )
     230INTEGRAL_FMT_DECL( int128, 'd' )
     231INTEGRAL_FMT_DECL( unsigned int128, 'u' )
    226232#endif // __SIZEOF_INT128__
    227233
     
    229235
    230236// Default suffix for values with no fraction is "."
    231 #define FloatingPointFMTDecl( T ) \
     237#define FLOATING_POINT_FMT_DECL( T ) \
    232238static inline { \
    233239        _Ostream_Manip(T) hex( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'a', { .all : 0 } }; } \
     
    256262} // ?|?
    257263
    258 FloatingPointFMTDecl( double )
    259 FloatingPointFMTDecl( long double )
     264FLOATING_POINT_FMT_DECL( double )
     265FLOATING_POINT_FMT_DECL( long double )
    260266
    261267// *********************************** character ***********************************
     
    297303// *********************************** istream ***********************************
    298304
     305
     306#define ISTYPE_VOID( T ) void ?|?( istype &, T )
     307#define ISTYPE_VOID_IMPL( T ) \
     308        void ?|?( istype & is, T & t ) { \
     309                (istype &)(is | t); ends( is ); \
     310        } // ?|?
    299311
    300312forall( istype & )
     
    327339forall( istype & | basic_istream( istype ) ) {
    328340        istype & ?|?( istype &, bool & );
    329         void ?|?( istype &, bool & );
     341        ISTYPE_VOID( bool & );
    330342
    331343        istype & ?|?( istype &, char & );
    332         void ?|?( istype &, char & );
     344        ISTYPE_VOID( char & );
    333345        istype & ?|?( istype &, signed char & );
    334         void ?|?( istype &, signed char & );
     346        ISTYPE_VOID( signed char & );
    335347        istype & ?|?( istype &, unsigned char & );
    336         void ?|?( istype &, unsigned char & );
     348        ISTYPE_VOID( unsigned char & );
    337349
    338350        istype & ?|?( istype &, short int & );
    339         void ?|?( istype &, short int & );
     351        ISTYPE_VOID( short int & );
    340352        istype & ?|?( istype &, unsigned short int & );
    341         void ?|?( istype &, unsigned short int & );
     353        ISTYPE_VOID( unsigned short int & );
    342354        istype & ?|?( istype &, int & );
    343         void ?|?( istype &, int & );
     355        ISTYPE_VOID( int & );
    344356        istype & ?|?( istype &, unsigned int & );
    345         void ?|?( istype &, unsigned int & );
     357        ISTYPE_VOID( unsigned int & );
    346358        istype & ?|?( istype &, long int & );
    347         void ?|?( istype &, long int & );
     359        ISTYPE_VOID( long int & );
    348360        istype & ?|?( istype &, unsigned long int & );
    349         void ?|?( istype &, unsigned long int & );
     361        ISTYPE_VOID( unsigned long int & );
    350362        istype & ?|?( istype &, long long int & );
    351         void ?|?( istype &, long long int & );
     363        ISTYPE_VOID( long long int & );
    352364        istype & ?|?( istype &, unsigned long long int & );
    353         void ?|?( istype &, unsigned long long int & );
     365        ISTYPE_VOID( unsigned long long int & );
    354366        #if defined( __SIZEOF_INT128__ )
    355367        istype & ?|?( istype &, int128 & );
    356         void ?|?( istype &, int128 & );
     368        ISTYPE_VOID( int128 & );
    357369        istype & ?|?( istype &, unsigned int128 & );
    358         void ?|?( istype &, unsigned int128 & );
     370        ISTYPE_VOID( unsigned int128 & );
    359371        #endif // __SIZEOF_INT128__
    360372
    361373        istype & ?|?( istype &, float & );
    362         void ?|?( istype &, float & );
     374        ISTYPE_VOID( float & );
    363375        istype & ?|?( istype &, double & );
    364         void ?|?( istype &, double & );
     376        ISTYPE_VOID( double & );
    365377        istype & ?|?( istype &, long double & );
    366         void ?|?( istype &, long double & );
     378        ISTYPE_VOID( long double & );
    367379
    368380        istype & ?|?( istype &, float _Complex & );
    369         void ?|?( istype &, float _Complex & );
     381        ISTYPE_VOID( float _Complex & );
    370382        istype & ?|?( istype &, double _Complex & );
    371         void ?|?( istype &, double _Complex & );
     383        ISTYPE_VOID( double _Complex & );
    372384        istype & ?|?( istype &, long double _Complex & );
    373         void ?|?( istype &, long double _Complex & );
     385        ISTYPE_VOID( long double _Complex & );
    374386
    375387//      istype & ?|?( istype &, const char [] );
     
    379391        // manipulators
    380392        istype & ?|?( istype &, istype & (*)( istype & ) );
    381         void ?|?( istype &, istype & (*)( istype & ) );
     393        ISTYPE_VOID( istype & (*)( istype & ) );
    382394        istype & nl( istype & is );
    383395        istype & nlOn( istype & );
     
    437449}; // _Istream_Manip
    438450
    439 #define InputFMTDecl( T ) \
     451#define INPUT_FMT_DECL( T ) \
    440452static inline { \
    441453        _Istream_Manip(T) ignore( const T & val ) { return (_Istream_Manip(T))@{ (T &)val, -1, true }; } \
     
    449461} // ?|?
    450462
    451 InputFMTDecl( signed char )
    452 InputFMTDecl( unsigned char )
    453 InputFMTDecl( signed short int )
    454 InputFMTDecl( unsigned short int )
    455 InputFMTDecl( signed int )
    456 InputFMTDecl( unsigned int )
    457 InputFMTDecl( signed long int )
    458 InputFMTDecl( unsigned long int )
    459 InputFMTDecl( signed long long int )
    460 InputFMTDecl( unsigned long long int )
    461 
    462 InputFMTDecl( float )
    463 InputFMTDecl( double )
    464 InputFMTDecl( long double )
    465 
    466 InputFMTDecl( float _Complex )
    467 InputFMTDecl( double _Complex )
    468 InputFMTDecl( long double _Complex )
     463INPUT_FMT_DECL( signed char )
     464INPUT_FMT_DECL( unsigned char )
     465INPUT_FMT_DECL( signed short int )
     466INPUT_FMT_DECL( unsigned short int )
     467INPUT_FMT_DECL( signed int )
     468INPUT_FMT_DECL( unsigned int )
     469INPUT_FMT_DECL( signed long int )
     470INPUT_FMT_DECL( unsigned long int )
     471INPUT_FMT_DECL( signed long long int )
     472INPUT_FMT_DECL( unsigned long long int )
     473
     474INPUT_FMT_DECL( float )
     475INPUT_FMT_DECL( double )
     476INPUT_FMT_DECL( long double )
     477
     478INPUT_FMT_DECL( float _Complex )
     479INPUT_FMT_DECL( double _Complex )
     480INPUT_FMT_DECL( long double _Complex )
    469481
    470482
Note: See TracChangeset for help on using the changeset viewer.