Changeset 8e4aa05 for libcfa/src/iostream.hfa
- Timestamp:
- Mar 4, 2021, 7:40:25 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 77d601f
- Parents:
- 342af53 (diff), a5040fe (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.hfa
r342af53 r8e4aa05 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 11 22:16:14 202013 // Update Count : 3 5012 // Last Modified On : Tue Mar 2 14:05:08 2021 13 // Update Count : 369 14 14 // 15 15 … … 22 22 23 23 24 trait ostream( dtype ostype) {24 trait ostream( ostype & ) { 25 25 // private 26 26 bool $sepPrt( ostype & ); // get separator state (on/off) … … 54 54 ostype & write( ostype &, const char [], size_t ); 55 55 int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 56 void acquire( ostype & ); 56 57 }; // ostream 57 58 58 // trait writeable( otypeT ) {59 // forall( dtype ostype| ostream( ostype ) ) ostype & ?|?( ostype &, T );59 // trait writeable( T ) { 60 // forall( ostype & | ostream( ostype ) ) ostype & ?|?( ostype &, T ); 60 61 // }; // writeable 61 62 62 trait writeable( otype T, dtype ostype| ostream( ostype ) ) {63 trait writeable( T, ostype & | ostream( ostype ) ) { 63 64 ostype & ?|?( ostype &, T ); 64 65 }; // writeable … … 66 67 // implement writable for intrinsic types 67 68 68 forall( dtype ostype| ostream( ostype ) ) {69 forall( ostype & | ostream( ostype ) ) { 69 70 ostype & ?|?( ostype &, bool ); 70 71 void ?|?( ostype &, bool ); … … 137 138 ostype & nlOn( ostype & ); 138 139 ostype & nlOff( ostype & ); 140 ostype & acquire( ostype & ); 139 141 } // distribution 140 142 141 143 // tuples 142 forall( dtype ostype, otype T, ttype Params| writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) {144 forall( ostype &, T, Params... | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) { 143 145 ostype & ?|?( ostype & os, T arg, Params rest ); 144 146 void ?|?( ostype & os, T arg, Params rest ); … … 146 148 147 149 // writes the range [begin, end) to the given stream 148 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otypeiterator_type | iterator( iterator_type, elt_type ) ) {150 forall( ostype &, elt_type | writeable( elt_type, ostype ), iterator_type | iterator( iterator_type, elt_type ) ) { 149 151 void write( iterator_type begin, iterator_type end, ostype & os ); 150 152 void write_reverse( iterator_type begin, iterator_type end, ostype & os ); … … 153 155 // *********************************** manipulators *********************************** 154 156 155 forall( otypeT )157 forall( T ) 156 158 struct _Ostream_Manip { 157 159 T val; // polymorphic base-type … … 193 195 _Ostream_Manip(T) & sign( _Ostream_Manip(T) & fmt ) { fmt.flags.sign = true; return fmt; } \ 194 196 } /* distribution */ \ 195 forall( dtype ostype| ostream( ostype ) ) { \197 forall( ostype & | ostream( ostype ) ) { \ 196 198 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \ 197 199 void ?|?( ostype & os, _Ostream_Manip(T) f ); \ … … 234 236 _Ostream_Manip(T) & nodp( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \ 235 237 } /* distribution */ \ 236 forall( dtype ostype| ostream( ostype ) ) { \238 forall( ostype & | ostream( ostype ) ) { \ 237 239 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \ 238 240 void ?|?( ostype & os, _Ostream_Manip(T) f ); \ … … 254 256 _Ostream_Manip(char) & nobase( _Ostream_Manip(char) & fmt ) { fmt.flags.nobsdp = true; return fmt; } 255 257 } // distribution 256 forall( dtype ostype| ostream( ostype ) ) {258 forall( ostype & | ostream( ostype ) ) { 257 259 ostype & ?|?( ostype & os, _Ostream_Manip(char) f ); 258 260 void ?|?( ostype & os, _Ostream_Manip(char) f ); … … 272 274 _Ostream_Manip(const char *) & nobase( _Ostream_Manip(const char *) & fmt ) { fmt.flags.nobsdp = true; return fmt; } 273 275 } // distribution 274 forall( dtype ostype| ostream( ostype ) ) {276 forall( ostype & | ostream( ostype ) ) { 275 277 ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f ); 276 278 void ?|?( ostype & os, _Ostream_Manip(const char *) f ); … … 281 283 282 284 283 trait istream( dtype istype) {285 trait istream( istype & ) { 284 286 void nlOn( istype & ); // read newline 285 287 void nlOff( istype & ); // scan newline 286 288 bool getANL( istype & ); // get scan newline (on/off) 289 290 void ends( istype & os ); // end of output statement 287 291 int fail( istype & ); 288 292 int eof( istype & ); … … 292 296 istype & ungetc( istype &, char ); 293 297 int fmt( istype &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) )); 298 void acquire( istype & ); 294 299 }; // istream 295 300 296 trait readable( otypeT ) {297 forall( dtype istype| istream( istype ) ) istype & ?|?( istype &, T );301 trait readable( T ) { 302 forall( istype & | istream( istype ) ) istype & ?|?( istype &, T ); 298 303 }; // readable 299 304 300 forall( dtype istype| istream( istype ) ) {305 forall( istype & | istream( istype ) ) { 301 306 istype & ?|?( istype &, bool & ); 307 void ?|?( istype &, bool & ); 302 308 303 309 istype & ?|?( istype &, char & ); 310 void ?|?( istype &, char & ); 304 311 istype & ?|?( istype &, signed char & ); 312 void ?|?( istype &, signed char & ); 305 313 istype & ?|?( istype &, unsigned char & ); 314 void ?|?( istype &, unsigned char & ); 306 315 307 316 istype & ?|?( istype &, short int & ); 317 void ?|?( istype &, short int & ); 308 318 istype & ?|?( istype &, unsigned short int & ); 319 void ?|?( istype &, unsigned short int & ); 309 320 istype & ?|?( istype &, int & ); 321 void ?|?( istype &, int & ); 310 322 istype & ?|?( istype &, unsigned int & ); 323 void ?|?( istype &, unsigned int & ); 311 324 istype & ?|?( istype &, long int & ); 325 void ?|?( istype &, long int & ); 312 326 istype & ?|?( istype &, unsigned long int & ); 327 void ?|?( istype &, unsigned long int & ); 313 328 istype & ?|?( istype &, long long int & ); 329 void ?|?( istype &, long long int & ); 314 330 istype & ?|?( istype &, unsigned long long int & ); 331 void ?|?( istype &, unsigned long long int & ); 315 332 #if defined( __SIZEOF_INT128__ ) 316 333 istype & ?|?( istype &, int128 & ); 334 void ?|?( istype &, int128 & ); 317 335 istype & ?|?( istype &, unsigned int128 & ); 336 void ?|?( istype &, unsigned int128 & ); 318 337 #endif // __SIZEOF_INT128__ 319 338 320 339 istype & ?|?( istype &, float & ); 340 void ?|?( istype &, float & ); 321 341 istype & ?|?( istype &, double & ); 342 void ?|?( istype &, double & ); 322 343 istype & ?|?( istype &, long double & ); 344 void ?|?( istype &, long double & ); 323 345 324 346 istype & ?|?( istype &, float _Complex & ); 347 void ?|?( istype &, float _Complex & ); 325 348 istype & ?|?( istype &, double _Complex & ); 349 void ?|?( istype &, double _Complex & ); 326 350 istype & ?|?( istype &, long double _Complex & ); 351 void ?|?( istype &, long double _Complex & ); 327 352 328 353 // istype & ?|?( istype &, const char [] ); 329 istype & ?|?( istype &, char * ); 354 istype & ?|?( istype &, char [] ); 355 void ?|?( istype &, char [] ); 330 356 331 357 // manipulators 332 358 istype & ?|?( istype &, istype & (*)( istype & ) ); 359 void ?|?( istype &, istype & (*)( istype & ) ); 333 360 istype & nl( istype & is ); 334 361 istype & nlOn( istype & ); 335 362 istype & nlOff( istype & ); 363 istype & acquire( istype & ); 336 364 } // distribution 337 365 … … 363 391 _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; } 364 392 } // distribution 365 forall( dtype istype | istream( istype ) ) istype & ?|?( istype & is, _Istream_Cstr f ); 393 forall( istype & | istream( istype ) ) { 394 istype & ?|?( istype & is, _Istream_Cstr f ); 395 void ?|?( istype & is, _Istream_Cstr f ); 396 } 366 397 367 398 struct _Istream_Char { … … 373 404 _Istream_Char & ignore( _Istream_Char & fmt ) { fmt.ignore = true; return fmt; } 374 405 } // distribution 375 forall( dtype istype | istream( istype ) ) istype & ?|?( istype & is, _Istream_Char f ); 376 377 forall( dtype T | sized( T ) ) 406 forall( istype & | istream( istype ) ) { 407 istype & ?|?( istype & is, _Istream_Char f ); 408 void ?|?( istype & is, _Istream_Char f ); 409 } 410 411 forall( T & | sized( T ) ) 378 412 struct _Istream_Manip { 379 413 T & val; // polymorphic base-type … … 389 423 _Istream_Manip(T) & wdi( unsigned int w, _Istream_Manip(T) & fmt ) { fmt.wd = w; return fmt; } \ 390 424 } /* distribution */ \ 391 forall( dtype istype| istream( istype ) ) { \425 forall( istype & | istream( istype ) ) { \ 392 426 istype & ?|?( istype & is, _Istream_Manip(T) f ); \ 427 void ?|?( istype & is, _Istream_Manip(T) f ); \ 393 428 } // ?|? 394 429 … … 418 453 #include <time_t.hfa> // Duration (constructors) / Time (constructors) 419 454 420 forall( dtype ostype| ostream( ostype ) ) {455 forall( ostype & | ostream( ostype ) ) { 421 456 ostype & ?|?( ostype & os, Duration dur ); 422 457 void ?|?( ostype & os, Duration dur );
Note:
See TracChangeset
for help on using the changeset viewer.