Ignore:
Timestamp:
Jul 18, 2023, 12:20:12 PM (11 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.