Changeset 94d2544 for libcfa/src
- Timestamp:
- Jul 18, 2023, 12:20:12 PM (13 months ago)
- Branches:
- master
- Children:
- 5454d77
- Parents:
- 8b84973
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
r8b84973 r94d2544 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jun 29 10:12:39202313 // Update Count : 1 38012 // Last Modified On : Tue Jul 18 10:42:51 2023 13 // Update Count : 1401 14 14 // 15 15 … … 34 34 #pragma GCC visibility push(default) 35 35 36 36 37 // *********************************** ostream *********************************** 37 38 … … 43 44 return os; 44 45 } // ?|? 45 void ?|?( ostype & os, bool b ) { 46 (ostype &)(os | b); ends( os ); 47 } // ?|? 46 OSTYPE_VOID_IMPL( bool ) 48 47 49 48 ostype & ?|?( ostype & os, char c ) { … … 52 51 return nosep( os ); 53 52 } // ?|? 54 void ?|?( ostype & os, char c ) { 55 (ostype &)(os | c); ends( os ); 56 } // ?|? 53 OSTYPE_VOID_IMPL( char ) 57 54 58 55 ostype & ?|?( ostype & os, signed char sc ) { … … 61 58 return os; 62 59 } // ?|? 63 void ?|?( ostype & os, signed char sc ) { 64 (ostype &)(os | sc); ends( os ); 65 } // ?|? 60 OSTYPE_VOID_IMPL( signed char ) 66 61 67 62 ostype & ?|?( ostype & os, unsigned char usc ) { … … 70 65 return os; 71 66 } // ?|? 72 void ?|?( ostype & os, unsigned char usc ) { 73 (ostype &)(os | usc); ends( os ); 74 } // ?|? 67 OSTYPE_VOID_IMPL( unsigned char ) 75 68 76 69 ostype & ?|?( ostype & os, short int si ) { … … 79 72 return os; 80 73 } // ?|? 81 void & ?|?( ostype & os, short int si ) { 82 (ostype &)(os | si); ends( os ); 83 } // ?|? 74 OSTYPE_VOID_IMPL( short int ) 84 75 85 76 ostype & ?|?( ostype & os, unsigned short int usi ) { … … 88 79 return os; 89 80 } // ?|? 90 void & ?|?( ostype & os, unsigned short int usi ) { 91 (ostype &)(os | usi); ends( os ); 92 } // ?|? 81 OSTYPE_VOID_IMPL( unsigned short int ) 93 82 94 83 ostype & ?|?( ostype & os, int i ) { … … 97 86 return os; 98 87 } // ?|? 99 void & ?|?( ostype & os, int i ) { 100 (ostype &)(os | i); ends( os ); 101 } // ?|? 88 OSTYPE_VOID_IMPL( int ) 102 89 103 90 ostype & ?|?( ostype & os, unsigned int ui ) { … … 106 93 return os; 107 94 } // ?|? 108 void & ?|?( ostype & os, unsigned int ui ) { 109 (ostype &)(os | ui); ends( os ); 110 } // ?|? 95 OSTYPE_VOID_IMPL( unsigned int ) 111 96 112 97 ostype & ?|?( ostype & os, long int li ) { … … 115 100 return os; 116 101 } // ?|? 117 void & ?|?( ostype & os, long int li ) { 118 (ostype &)(os | li); ends( os ); 119 } // ?|? 102 OSTYPE_VOID_IMPL( long int ) 120 103 121 104 ostype & ?|?( ostype & os, unsigned long int uli ) { … … 124 107 return os; 125 108 } // ?|? 126 void & ?|?( ostype & os, unsigned long int uli ) { 127 (ostype &)(os | uli); ends( os ); 128 } // ?|? 109 OSTYPE_VOID_IMPL( unsigned long int ) 129 110 130 111 ostype & ?|?( ostype & os, long long int lli ) { … … 133 114 return os; 134 115 } // ?|? 135 void & ?|?( ostype & os, long long int lli ) { 136 (ostype &)(os | lli); ends( os ); 137 } // ?|? 116 OSTYPE_VOID_IMPL( long long int ) 138 117 139 118 ostype & ?|?( ostype & os, unsigned long long int ulli ) { … … 142 121 return os; 143 122 } // ?|? 144 void & ?|?( ostype & os, unsigned long long int ulli ) { 145 (ostype &)(os | ulli); ends( os ); 146 } // ?|? 123 OSTYPE_VOID_IMPL( unsigned long long int ) 147 124 148 125 #if defined( __SIZEOF_INT128__ ) … … 176 153 return os; 177 154 } // ?|? 178 void & ?|?( ostype & os, int128 llli ) { 179 (ostype &)(os | llli); ends( os ); 180 } // ?|? 155 OSTYPE_VOID_IMPL( int128 ) 181 156 182 157 ostype & ?|?( ostype & os, unsigned int128 ullli ) { … … 185 160 return os; 186 161 } // ?|? 187 void & ?|?( ostype & os, unsigned int128 ullli ) { 188 (ostype &)(os | ullli); ends( os ); 189 } // ?|? 162 OSTYPE_VOID_IMPL( unsigned int128 ) 190 163 #endif // __SIZEOF_INT128__ 191 164 192 #define P rintWithDP( os, format, val, ... ) \165 #define PRINT_WITH_DP( os, format, val, ... ) \ 193 166 { \ 194 167 enum { size = 48 }; \ … … 206 179 ostype & ?|?( ostype & os, float f ) { 207 180 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 ) 214 185 215 186 ostype & ?|?( ostype & os, double d ) { 216 187 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 ) 223 192 224 193 ostype & ?|?( ostype & os, long double ld ) { 225 194 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 ) 232 199 233 200 ostype & ?|?( ostype & os, float _Complex fc ) { 234 201 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 235 202 // os | crealf( fc ) | nonl; 236 P rintWithDP( os, "%'g", crealf( fc ) );237 P rintWithDP( os, "%'+g", cimagf( fc ) );203 PRINT_WITH_DP( os, "%'g", crealf( fc ) ); 204 PRINT_WITH_DP( os, "%'+g", cimagf( fc ) ); 238 205 fmt( os, "i" ); 239 206 return os; 240 207 } // ?|? 241 void & ?|?( ostype & os, float _Complex fc ) { 242 (ostype &)(os | fc); ends( os ); 243 } // ?|? 208 OSTYPE_VOID_IMPL( float _Complex ) 244 209 245 210 ostype & ?|?( ostype & os, double _Complex dc ) { 246 211 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 247 212 // os | creal( dc ) | nonl; 248 P rintWithDP( os, "%'.*lg", creal( dc ), DBL_DIG );249 P rintWithDP( 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 ); 250 215 fmt( os, "i" ); 251 216 return os; 252 217 } // ?|? 253 void & ?|?( ostype & os, double _Complex dc ) { 254 (ostype &)(os | dc); ends( os ); 255 } // ?|? 218 OSTYPE_VOID_IMPL( double _Complex ) 256 219 257 220 ostype & ?|?( ostype & os, long double _Complex ldc ) { 258 221 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 259 222 // os | creall( ldc ) || nonl; 260 P rintWithDP( os, "%'.*Lg", creall( ldc ), LDBL_DIG );261 P rintWithDP( 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 ); 262 225 fmt( os, "i" ); 263 226 return os; 264 227 } // ?|? 265 void & ?|?( ostype & os, long double _Complex ldc ) { 266 (ostype &)(os | ldc); ends( os ); 267 } // ?|? 228 OSTYPE_VOID_IMPL( long double _Complex ) 268 229 269 230 ostype & ?|?( ostype & os, const char s[] ) { … … 308 269 // return write( os, s, len ); 309 270 } // ?|? 310 void ?|?( ostype & os, const char s[] ) { 311 (ostype &)(os | s); ends( os ); 312 } // ?|? 271 OSTYPE_VOID_IMPL( const char * ) 313 272 314 273 // ostype & ?|?( ostype & os, const char16_t * s ) { … … 337 296 return os; 338 297 } // ?|? 339 void ?|?( ostype & os, const void * p ) { 340 (ostype &)(os | p); ends( os ); 341 } // ?|? 298 OSTYPE_VOID_IMPL( const void * ) 342 299 343 300 // manipulators … … 442 399 443 400 // Default prefix for non-decimal prints is 0b, 0, 0x. 444 #define I ntegralFMTImpl( T, IFMTNP, IFMTP ) \401 #define INTEGRAL_FMT_IMPL( T, IFMTNP, IFMTP ) \ 445 402 forall( ostype & | basic_ostream( ostype ) ) { \ 446 403 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ … … 519 476 return os; \ 520 477 } /* ?|? */ \ 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 481 INTEGRAL_FMT_IMPL( signed char, " *hh ", " *.*hh " ) 482 INTEGRAL_FMT_IMPL( unsigned char, " *hh ", " *.*hh " ) 483 INTEGRAL_FMT_IMPL( signed short int, " *h ", " *.*h " ) 484 INTEGRAL_FMT_IMPL( unsigned short int, " *h ", " *.*h " ) 485 INTEGRAL_FMT_IMPL( signed int, " * ", " *.* " ) 486 INTEGRAL_FMT_IMPL( unsigned int, " * ", " *.* " ) 487 INTEGRAL_FMT_IMPL( signed long int, " *l ", " *.*l " ) 488 INTEGRAL_FMT_IMPL( unsigned long int, " *l ", " *.*l " ) 489 INTEGRAL_FMT_IMPL( signed long long int, " *ll ", " *.*ll " ) 490 INTEGRAL_FMT_IMPL( unsigned long long int, " *ll ", " *.*ll " ) 536 491 537 492 … … 602 557 } // base_128 603 558 604 #define I ntegralFMTImpl128( T ) \559 #define INTEGRAL_FMT_IMPL128( T ) \ 605 560 forall( ostype & | basic_ostream( ostype ) ) { \ 606 561 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ … … 619 574 return os; \ 620 575 } /* ?|? */ \ 621 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); }\622 } // distribution 623 624 I ntegralFMTImpl128( int128 )625 I ntegralFMTImpl128( unsigned int128 )576 OSTYPE_VOID_IMPL( _Ostream_Manip(T) ) \ 577 } // distribution 578 579 INTEGRAL_FMT_IMPL128( int128 ) 580 INTEGRAL_FMT_IMPL128( unsigned int128 ) 626 581 #endif // __SIZEOF_INT128__ 627 582 … … 635 590 #define SUFFIXES_END (SUFFIXES_START + (int)((sizeof(suffixes) / sizeof(char *) - 1) * 3)) 636 591 637 #define P rintWithDP2( os, format, ... ) \592 #define PRINT_WITH_DP2( os, format, ... ) \ 638 593 { \ 639 594 if ( ! f.flags.eng ) { \ … … 676 631 } 677 632 678 #define F loatingPointFMTImpl( T, DFMTNP, DFMTP ) \633 #define FLOATING_POINT_FMT_IMPL( T, DFMTNP, DFMTP ) \ 679 634 forall( ostype & | basic_ostream( ostype ) ) { \ 680 635 static void eng( T &value, int & pc, int & exp10 ) { \ … … 707 662 fmtstr[sizeof(DFMTNP)-2] = f.base; /* sizeof includes '\0' */ \ 708 663 /* printf( "%g %d %s\n", f.val, f.wd, &fmtstr[star] ); */ \ 709 P rintWithDP2( os, &fmtstr[star], f.wd, f.val ) \664 PRINT_WITH_DP2( os, &fmtstr[star], f.wd, f.val ) \ 710 665 } else { /* precision */ \ 711 666 fmtstr[sizeof(DFMTP)-2] = f.base; /* sizeof includes '\0' */ \ 712 667 /* printf( "%g %d %d %s\n", f.val, f.wd, f.pc, &fmtstr[star] ); */ \ 713 P rintWithDP2( os, &fmtstr[star], f.wd, f.pc, f.val ) \668 PRINT_WITH_DP2( os, &fmtstr[star], f.wd, f.pc, f.val ) \ 714 669 } /* if */ \ 715 670 return os; \ 716 671 } /* ?|? */ \ 717 672 \ 718 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); }\719 } // distribution 720 721 F loatingPointFMTImpl( double, " * ", " *.* " )722 F loatingPointFMTImpl( long double, " *L ", " *.*L " )673 OSTYPE_VOID_IMPL( _Ostream_Manip(T) ) \ 674 } // distribution 675 676 FLOATING_POINT_FMT_IMPL( double, " * ", " *.* " ) 677 FLOATING_POINT_FMT_IMPL( long double, " *L ", " *.*L " ) 723 678 724 679 // *********************************** character *********************************** … … 751 706 return os; 752 707 } // ?|? 753 754 void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); } 708 OSTYPE_VOID_IMPL( _Ostream_Manip(char) ) 755 709 } // distribution 756 710 … … 799 753 return os; 800 754 } // ?|? 801 802 void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); } 755 OSTYPE_VOID_IMPL( _Ostream_Manip(const char *) ) 803 756 } // distribution 804 757 … … 806 759 // *********************************** istream *********************************** 807 760 761 762 #define ISTYPE_VOID_VAL_IMPL( T ) \ 763 void ?|?( istype & is, T t ) { \ 764 (istype &)(is | t); ends( is ); \ 765 } // ?|? 808 766 809 767 forall( istype & | basic_istream( istype ) ) { … … 819 777 return is; 820 778 } // ?|? 821 void ?|?( istype & is, bool & b ) { 822 (istype &)(is | b); ends( is ); 823 } // ?|? 779 ISTYPE_VOID_IMPL( bool ) 824 780 825 781 istype & ?|?( istype & is, char & c ) { … … 833 789 return is; 834 790 } // ?|? 835 void ?|?( istype & is, char & c ) { 836 (istype &)(is | c); ends( is ); 837 } // ?|? 791 ISTYPE_VOID_IMPL( char ) 838 792 839 793 istype & ?|?( istype & is, signed char & sc ) { … … 841 795 return is; 842 796 } // ?|? 843 void ?|?( istype & is, signed char & sc ) { 844 (istype &)(is | sc); ends( is ); 845 } // ?|? 797 ISTYPE_VOID_IMPL( signed char ) 846 798 847 799 istype & ?|?( istype & is, unsigned char & usc ) { … … 849 801 return is; 850 802 } // ?|? 851 void ?|?( istype & is, unsigned char & usc ) { 852 (istype &)(is | usc); ends( is ); 853 } // ?|? 803 ISTYPE_VOID_IMPL( unsigned char ) 854 804 855 805 istype & ?|?( istype & is, short int & si ) { … … 857 807 return is; 858 808 } // ?|? 859 void ?|?( istype & is, short int & si ) { 860 (istype &)(is | si); ends( is ); 861 } // ?|? 809 ISTYPE_VOID_IMPL( short int ) 862 810 863 811 istype & ?|?( istype & is, unsigned short int & usi ) { … … 865 813 return is; 866 814 } // ?|? 867 void ?|?( istype & is, unsigned short int & usi ) { 868 (istype &)(is | usi); ends( is ); 869 } // ?|? 815 ISTYPE_VOID_IMPL( unsigned short int ) 870 816 871 817 istype & ?|?( istype & is, int & i ) { … … 873 819 return is; 874 820 } // ?|? 875 void ?|?( istype & is, int & i ) { 876 (istype &)(is | i); ends( is ); 877 } // ?|? 821 ISTYPE_VOID_IMPL( int ) 878 822 879 823 istype & ?|?( istype & is, unsigned int & ui ) { … … 881 825 return is; 882 826 } // ?|? 883 void ?|?( istype & is, unsigned int & ui ) { 884 (istype &)(is | ui); ends( is ); 885 } // ?|? 827 ISTYPE_VOID_IMPL( unsigned int ) 886 828 887 829 istype & ?|?( istype & is, long int & li ) { … … 889 831 return is; 890 832 } // ?|? 891 void ?|?( istype & is, long int & li ) { 892 (istype &)(is | li); ends( is ); 893 } // ?|? 833 ISTYPE_VOID_IMPL( long int ) 894 834 895 835 istype & ?|?( istype & is, unsigned long int & ulli ) { … … 897 837 return is; 898 838 } // ?|? 899 void ?|?( istype & is, unsigned long int & ulli ) { 900 (istype &)(is | ulli); ends( is ); 901 } // ?|? 839 ISTYPE_VOID_IMPL( unsigned long int ) 902 840 903 841 istype & ?|?( istype & is, long long int & lli ) { … … 905 843 return is; 906 844 } // ?|? 907 void ?|?( istype & is, long long int & lli ) { 908 (istype &)(is | lli); ends( is ); 909 } // ?|? 845 ISTYPE_VOID_IMPL( long long int ) 910 846 911 847 istype & ?|?( istype & is, unsigned long long int & ulli ) { … … 913 849 return is; 914 850 } // ?|? 915 void & ?|?( istype & is, unsigned long long int & ulli ) { 916 (istype &)(is | ulli); ends( is ); 917 } // ?|? 851 ISTYPE_VOID_IMPL( unsigned long long int ) 918 852 919 853 #if defined( __SIZEOF_INT128__ ) … … 921 855 return (istype &)(is | (unsigned int128 &)llli); 922 856 } // ?|? 923 void ?|?( istype & is, int128 & llli ) { 924 (istype &)(is | llli); ends( is ); 925 } // ?|? 857 ISTYPE_VOID_IMPL( int128 ) 926 858 927 859 istype & ?|?( istype & is, unsigned int128 & ullli ) { … … 940 872 return is; 941 873 } // ?|? 942 void ?|?( istype & is, unsigned int128 & ullli ) { 943 (istype &)(is | ullli); ends( is ); 944 } // ?|? 874 ISTYPE_VOID_IMPL( unsigned int128 ) 945 875 #endif // __SIZEOF_INT128__ 946 876 … … 949 879 return is; 950 880 } // ?|? 951 void ?|?( istype & is, float & f ) { 952 (istype &)(is | f); ends( is ); 953 } // ?|? 881 ISTYPE_VOID_IMPL( float ) 954 882 955 883 istype & ?|?( istype & is, double & d ) { … … 957 885 return is; 958 886 } // ?|? 959 void ?|?( istype & is, double & d ) { 960 (istype &)(is | d); ends( is ); 961 } // ?|? 887 ISTYPE_VOID_IMPL( double ) 962 888 963 889 istype & ?|?( istype & is, long double & ld ) { … … 965 891 return is; 966 892 } // ?|? 967 void ?|?( istype & is, long double & ld ) { 968 (istype &)(is | ld); ends( is ); 969 } // ?|? 893 ISTYPE_VOID_IMPL( long double ) 970 894 971 895 istype & ?|?( istype & is, float _Complex & fc ) { … … 975 899 return is; 976 900 } // ?|? 977 void ?|?( istype & is, float _Complex & fc ) { 978 (istype &)(is | fc); ends( is ); 979 } // ?|? 901 ISTYPE_VOID_IMPL( float _Complex ) 980 902 981 903 istype & ?|?( istype & is, double _Complex & dc ) { … … 985 907 return is; 986 908 } // ?|? 987 void ?|?( istype & is, double _Complex & dc ) { 988 (istype &)(is | dc); ends( is ); 989 } // ?|? 909 ISTYPE_VOID_IMPL( double _Complex ) 990 910 991 911 istype & ?|?( istype & is, long double _Complex & ldc ) { … … 995 915 return is; 996 916 } // ?|? 997 void ?|?( istype & is, long double _Complex & ldc ) { 998 (istype &)(is | ldc); ends( is ); 999 } // ?|? 917 ISTYPE_VOID_IMPL( long double _Complex ) 1000 918 1001 919 // istype & ?|?( istype & is, const char fmt[] ) { … … 1008 926 return is; 1009 927 } // ?|? 1010 void ?|?( istype & is, char s[] ) { 1011 (istype &)(is | s); ends( is ); 1012 } // ?|? 928 ISTYPE_VOID_VAL_IMPL( char * ) 1013 929 1014 930 // manipulators … … 1072 988 return is; 1073 989 } // ?|? 1074 void ?|?( istype & is, _Istream_Cstr f ) { 1075 (istype &)(is | f); ends( is ); 1076 } // ?|? 990 ISTYPE_VOID_VAL_IMPL( _Istream_Cstr ) 1077 991 1078 992 istype & ?|?( istype & is, _Istream_Char f ) { … … 1080 994 return is; 1081 995 } // ?|? 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 ) \ 1088 1000 forall( istype & | basic_istream( istype ) ) { \ 1089 1001 istype & ?|?( istype & is, _Istream_Manip(T) f ) { \ … … 1099 1011 return is; \ 1100 1012 } /* ?|? */ \ 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 1016 INPUT_FMT_IMPL( signed char, "hhi" ) 1017 INPUT_FMT_IMPL( unsigned char, "hhi" ) 1018 INPUT_FMT_IMPL( signed short int, "hi" ) 1019 INPUT_FMT_IMPL( unsigned short int, "hi" ) 1020 INPUT_FMT_IMPL( signed int, "i" ) 1021 INPUT_FMT_IMPL( unsigned int, "i" ) 1022 INPUT_FMT_IMPL( signed long int, "li" ) 1023 INPUT_FMT_IMPL( unsigned long int, "li" ) 1024 INPUT_FMT_IMPL( signed long long int, "lli" ) 1025 INPUT_FMT_IMPL( unsigned long long int, "lli" ) 1026 1027 INPUT_FMT_IMPL( float, "f" ) 1028 INPUT_FMT_IMPL( double, "lf" ) 1029 INPUT_FMT_IMPL( long double, "Lf" ) 1120 1030 1121 1031 forall( istype & | basic_istream( istype ) ) { … … 1129 1039 return is; 1130 1040 } // ?|? 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) ) 1134 1042 1135 1043 istype & ?|?( istype & is, _Istream_Manip(double _Complex) dc ) { … … 1142 1050 return is; 1143 1051 } // ?|? 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) ) 1147 1053 1148 1054 istype & ?|?( istype & is, _Istream_Manip(long double _Complex) ldc ) { … … 1155 1061 return is; 1156 1062 } // ?|? 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) ) 1160 1064 } // distribution 1161 1065 -
libcfa/src/iostream.hfa
r8b84973 r94d2544 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jun 29 11:07:25202313 // Update Count : 4 2712 // Last Modified On : Tue Jul 18 10:42:52 2023 13 // Update Count : 438 14 14 // 15 15 … … 74 74 // implement writable for intrinsic types 75 75 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 76 82 forall( ostype & | basic_ostream( ostype ) ) { 77 83 ostype & ?|?( ostype &, bool ); 78 void ?|?( ostype &,bool );84 OSTYPE_VOID( bool ); 79 85 80 86 ostype & ?|?( ostype &, char ); 81 void ?|?( ostype &,char );87 OSTYPE_VOID( char ); 82 88 ostype & ?|?( ostype &, signed char ); 83 void ?|?( ostype &,signed char );89 OSTYPE_VOID( signed char ); 84 90 ostype & ?|?( ostype &, unsigned char ); 85 void ?|?( ostype &,unsigned char );91 OSTYPE_VOID( unsigned char ); 86 92 87 93 ostype & ?|?( ostype &, short int ); 88 void ?|?( ostype &,short int );94 OSTYPE_VOID( short int ); 89 95 ostype & ?|?( ostype &, unsigned short int ); 90 void ?|?( ostype &,unsigned short int );96 OSTYPE_VOID( unsigned short int ); 91 97 ostype & ?|?( ostype &, int ); 92 void ?|?( ostype &,int );98 OSTYPE_VOID( int ); 93 99 ostype & ?|?( ostype &, unsigned int ); 94 void ?|?( ostype &,unsigned int );100 OSTYPE_VOID( unsigned int ); 95 101 ostype & ?|?( ostype &, long int ); 96 void ?|?( ostype &,long int );102 OSTYPE_VOID( long int ); 97 103 ostype & ?|?( ostype &, long long int ); 98 void ?|?( ostype &,long long int );104 OSTYPE_VOID( long long int ); 99 105 ostype & ?|?( ostype &, unsigned long int ); 100 void ?|?( ostype &,unsigned long int );106 OSTYPE_VOID( unsigned long int ); 101 107 ostype & ?|?( ostype &, unsigned long long int ); 102 void ?|?( ostype &,unsigned long long int );108 OSTYPE_VOID( unsigned long long int ); 103 109 #if defined( __SIZEOF_INT128__ ) 104 110 ostype & ?|?( ostype &, int128 ); 105 void ?|?( ostype &,int128 );111 OSTYPE_VOID( int128 ); 106 112 ostype & ?|?( ostype &, unsigned int128 ); 107 void ?|?( ostype &,unsigned int128 );113 OSTYPE_VOID( unsigned int128 ); 108 114 #endif // __SIZEOF_INT128__ 109 115 110 116 ostype & ?|?( ostype &, float ); 111 void ?|?( ostype &,float );117 OSTYPE_VOID( float ); 112 118 ostype & ?|?( ostype &, double ); 113 void ?|?( ostype &,double );119 OSTYPE_VOID( double ); 114 120 ostype & ?|?( ostype &, long double ); 115 void ?|?( ostype &,long double );121 OSTYPE_VOID( long double ); 116 122 117 123 ostype & ?|?( ostype &, float _Complex ); 118 void ?|?( ostype &,float _Complex );124 OSTYPE_VOID( float _Complex ); 119 125 ostype & ?|?( ostype &, double _Complex ); 120 void ?|?( ostype &,double _Complex );126 OSTYPE_VOID( double _Complex ); 121 127 ostype & ?|?( ostype &, long double _Complex ); 122 void ?|?( ostype &,long double _Complex );128 OSTYPE_VOID( long double _Complex ); 123 129 124 130 ostype & ?|?( ostype &, const char [] ); 125 void ?|?( ostype &,const char [] );131 OSTYPE_VOID( const char [] ); 126 132 // ostype & ?|?( ostype &, const char16_t * ); 127 133 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous … … 130 136 // ostype & ?|?( ostype &, const wchar_t * ); 131 137 ostype & ?|?( ostype &, const void * ); 132 void ?|?( ostype &,const void * );138 OSTYPE_VOID( const void * ); 133 139 134 140 // manipulators 135 141 ostype & ?|?( ostype &, ostype & (*)( ostype & ) ); 136 void ?|?( ostype &,ostype & (*)( ostype & ) );142 OSTYPE_VOID( ostype & (*)( ostype & ) ); 137 143 138 144 ostype & nl( ostype & ); … … 190 196 // initialized explicitly shall be initialized implicitly the same as objects that have static storage duration.*** 191 197 192 #define I ntegralFMTDecl( T, CODE ) \198 #define INTEGRAL_FMT_DECL( T, CODE ) \ 193 199 static inline { \ 194 200 _Ostream_Manip(T) bin( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'b', { .all : 0 } }; } \ … … 211 217 } // ?|? 212 218 213 I ntegralFMTDecl( signed char, 'd' )214 I ntegralFMTDecl( unsigned char, 'u' )215 I ntegralFMTDecl( signed short int, 'd' )216 I ntegralFMTDecl( unsigned short int, 'u' )217 I ntegralFMTDecl( signed int, 'd' )218 I ntegralFMTDecl( unsigned int, 'u' )219 I ntegralFMTDecl( signed long int, 'd' )220 I ntegralFMTDecl( unsigned long int, 'u' )221 I ntegralFMTDecl( signed long long int, 'd' )222 I ntegralFMTDecl( unsigned long long int, 'u' )219 INTEGRAL_FMT_DECL( signed char, 'd' ) 220 INTEGRAL_FMT_DECL( unsigned char, 'u' ) 221 INTEGRAL_FMT_DECL( signed short int, 'd' ) 222 INTEGRAL_FMT_DECL( unsigned short int, 'u' ) 223 INTEGRAL_FMT_DECL( signed int, 'd' ) 224 INTEGRAL_FMT_DECL( unsigned int, 'u' ) 225 INTEGRAL_FMT_DECL( signed long int, 'd' ) 226 INTEGRAL_FMT_DECL( unsigned long int, 'u' ) 227 INTEGRAL_FMT_DECL( signed long long int, 'd' ) 228 INTEGRAL_FMT_DECL( unsigned long long int, 'u' ) 223 229 #if defined( __SIZEOF_INT128__ ) 224 I ntegralFMTDecl( int128, 'd' )225 I ntegralFMTDecl( unsigned int128, 'u' )230 INTEGRAL_FMT_DECL( int128, 'd' ) 231 INTEGRAL_FMT_DECL( unsigned int128, 'u' ) 226 232 #endif // __SIZEOF_INT128__ 227 233 … … 229 235 230 236 // Default suffix for values with no fraction is "." 231 #define F loatingPointFMTDecl( T ) \237 #define FLOATING_POINT_FMT_DECL( T ) \ 232 238 static inline { \ 233 239 _Ostream_Manip(T) hex( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'a', { .all : 0 } }; } \ … … 256 262 } // ?|? 257 263 258 F loatingPointFMTDecl( double )259 F loatingPointFMTDecl( long double )264 FLOATING_POINT_FMT_DECL( double ) 265 FLOATING_POINT_FMT_DECL( long double ) 260 266 261 267 // *********************************** character *********************************** … … 297 303 // *********************************** istream *********************************** 298 304 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 } // ?|? 299 311 300 312 forall( istype & ) … … 327 339 forall( istype & | basic_istream( istype ) ) { 328 340 istype & ?|?( istype &, bool & ); 329 void ?|?( istype &,bool & );341 ISTYPE_VOID( bool & ); 330 342 331 343 istype & ?|?( istype &, char & ); 332 void ?|?( istype &,char & );344 ISTYPE_VOID( char & ); 333 345 istype & ?|?( istype &, signed char & ); 334 void ?|?( istype &,signed char & );346 ISTYPE_VOID( signed char & ); 335 347 istype & ?|?( istype &, unsigned char & ); 336 void ?|?( istype &,unsigned char & );348 ISTYPE_VOID( unsigned char & ); 337 349 338 350 istype & ?|?( istype &, short int & ); 339 void ?|?( istype &,short int & );351 ISTYPE_VOID( short int & ); 340 352 istype & ?|?( istype &, unsigned short int & ); 341 void ?|?( istype &,unsigned short int & );353 ISTYPE_VOID( unsigned short int & ); 342 354 istype & ?|?( istype &, int & ); 343 void ?|?( istype &,int & );355 ISTYPE_VOID( int & ); 344 356 istype & ?|?( istype &, unsigned int & ); 345 void ?|?( istype &,unsigned int & );357 ISTYPE_VOID( unsigned int & ); 346 358 istype & ?|?( istype &, long int & ); 347 void ?|?( istype &,long int & );359 ISTYPE_VOID( long int & ); 348 360 istype & ?|?( istype &, unsigned long int & ); 349 void ?|?( istype &,unsigned long int & );361 ISTYPE_VOID( unsigned long int & ); 350 362 istype & ?|?( istype &, long long int & ); 351 void ?|?( istype &,long long int & );363 ISTYPE_VOID( long long int & ); 352 364 istype & ?|?( istype &, unsigned long long int & ); 353 void ?|?( istype &,unsigned long long int & );365 ISTYPE_VOID( unsigned long long int & ); 354 366 #if defined( __SIZEOF_INT128__ ) 355 367 istype & ?|?( istype &, int128 & ); 356 void ?|?( istype &,int128 & );368 ISTYPE_VOID( int128 & ); 357 369 istype & ?|?( istype &, unsigned int128 & ); 358 void ?|?( istype &,unsigned int128 & );370 ISTYPE_VOID( unsigned int128 & ); 359 371 #endif // __SIZEOF_INT128__ 360 372 361 373 istype & ?|?( istype &, float & ); 362 void ?|?( istype &,float & );374 ISTYPE_VOID( float & ); 363 375 istype & ?|?( istype &, double & ); 364 void ?|?( istype &,double & );376 ISTYPE_VOID( double & ); 365 377 istype & ?|?( istype &, long double & ); 366 void ?|?( istype &,long double & );378 ISTYPE_VOID( long double & ); 367 379 368 380 istype & ?|?( istype &, float _Complex & ); 369 void ?|?( istype &,float _Complex & );381 ISTYPE_VOID( float _Complex & ); 370 382 istype & ?|?( istype &, double _Complex & ); 371 void ?|?( istype &,double _Complex & );383 ISTYPE_VOID( double _Complex & ); 372 384 istype & ?|?( istype &, long double _Complex & ); 373 void ?|?( istype &,long double _Complex & );385 ISTYPE_VOID( long double _Complex & ); 374 386 375 387 // istype & ?|?( istype &, const char [] ); … … 379 391 // manipulators 380 392 istype & ?|?( istype &, istype & (*)( istype & ) ); 381 void ?|?( istype &,istype & (*)( istype & ) );393 ISTYPE_VOID( istype & (*)( istype & ) ); 382 394 istype & nl( istype & is ); 383 395 istype & nlOn( istype & ); … … 437 449 }; // _Istream_Manip 438 450 439 #define I nputFMTDecl( T ) \451 #define INPUT_FMT_DECL( T ) \ 440 452 static inline { \ 441 453 _Istream_Manip(T) ignore( const T & val ) { return (_Istream_Manip(T))@{ (T &)val, -1, true }; } \ … … 449 461 } // ?|? 450 462 451 I nputFMTDecl( signed char )452 I nputFMTDecl( unsigned char )453 I nputFMTDecl( signed short int )454 I nputFMTDecl( unsigned short int )455 I nputFMTDecl( signed int )456 I nputFMTDecl( unsigned int )457 I nputFMTDecl( signed long int )458 I nputFMTDecl( unsigned long int )459 I nputFMTDecl( signed long long int )460 I nputFMTDecl( unsigned long long int )461 462 I nputFMTDecl( float )463 I nputFMTDecl( double )464 I nputFMTDecl( long double )465 466 I nputFMTDecl( float _Complex )467 I nputFMTDecl( double _Complex )468 I nputFMTDecl( long double _Complex )463 INPUT_FMT_DECL( signed char ) 464 INPUT_FMT_DECL( unsigned char ) 465 INPUT_FMT_DECL( signed short int ) 466 INPUT_FMT_DECL( unsigned short int ) 467 INPUT_FMT_DECL( signed int ) 468 INPUT_FMT_DECL( unsigned int ) 469 INPUT_FMT_DECL( signed long int ) 470 INPUT_FMT_DECL( unsigned long int ) 471 INPUT_FMT_DECL( signed long long int ) 472 INPUT_FMT_DECL( unsigned long long int ) 473 474 INPUT_FMT_DECL( float ) 475 INPUT_FMT_DECL( double ) 476 INPUT_FMT_DECL( long double ) 477 478 INPUT_FMT_DECL( float _Complex ) 479 INPUT_FMT_DECL( double _Complex ) 480 INPUT_FMT_DECL( long double _Complex ) 469 481 470 482
Note: See TracChangeset
for help on using the changeset viewer.