Changes in libcfa/src/iostream.cfa [d1a9ff5:4f37255]
- File:
-
- 1 edited
-
libcfa/src/iostream.cfa (modified) (39 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
rd1a9ff5 r4f37255 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 18:48:38 202013 // Update Count : 82 512 // Last Modified On : Sat Jul 13 08:07:59 2019 13 // Update Count : 821 14 14 // 15 15 … … 35 35 forall( dtype ostype | ostream( ostype ) ) { 36 36 ostype & ?|?( ostype & os, zero_t ) { 37 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );37 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 38 38 fmt( os, "%d", 0n ); 39 39 return os; … … 44 44 45 45 ostype & ?|?( ostype & os, one_t ) { 46 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );46 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 47 47 fmt( os, "%d", 1n ); 48 48 return os; … … 53 53 54 54 ostype & ?|?( ostype & os, bool b ) { 55 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );55 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 56 56 fmt( os, "%s", b ? "true" : "false" ); 57 57 return os; … … 63 63 ostype & ?|?( ostype & os, char c ) { 64 64 fmt( os, "%c", c ); 65 if ( c == '\n' ) $setNL( os, true );65 if ( c == '\n' ) setNL( os, true ); 66 66 return sepOff( os ); 67 67 } // ?|? … … 71 71 72 72 ostype & ?|?( ostype & os, signed char sc ) { 73 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );73 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 74 74 fmt( os, "%hhd", sc ); 75 75 return os; … … 80 80 81 81 ostype & ?|?( ostype & os, unsigned char usc ) { 82 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );82 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 83 83 fmt( os, "%hhu", usc ); 84 84 return os; … … 89 89 90 90 ostype & ?|?( ostype & os, short int si ) { 91 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );91 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 92 92 fmt( os, "%hd", si ); 93 93 return os; … … 98 98 99 99 ostype & ?|?( ostype & os, unsigned short int usi ) { 100 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );100 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 101 101 fmt( os, "%hu", usi ); 102 102 return os; … … 107 107 108 108 ostype & ?|?( ostype & os, int i ) { 109 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );109 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 110 110 fmt( os, "%d", i ); 111 111 return os; … … 116 116 117 117 ostype & ?|?( ostype & os, unsigned int ui ) { 118 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );118 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 119 119 fmt( os, "%u", ui ); 120 120 return os; … … 125 125 126 126 ostype & ?|?( ostype & os, long int li ) { 127 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );127 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 128 128 fmt( os, "%ld", li ); 129 129 return os; … … 134 134 135 135 ostype & ?|?( ostype & os, unsigned long int uli ) { 136 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );136 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 137 137 fmt( os, "%lu", uli ); 138 138 return os; … … 143 143 144 144 ostype & ?|?( ostype & os, long long int lli ) { 145 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );145 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 146 146 fmt( os, "%lld", lli ); 147 147 return os; … … 152 152 153 153 ostype & ?|?( ostype & os, unsigned long long int ulli ) { 154 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );154 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 155 155 fmt( os, "%llu", ulli ); 156 156 return os; … … 175 175 176 176 ostype & ?|?( ostype & os, float f ) { 177 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );177 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 178 178 PrintWithDP( os, "%g", f ); 179 179 return os; … … 184 184 185 185 ostype & ?|?( ostype & os, double d ) { 186 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );186 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 187 187 PrintWithDP( os, "%.*lg", d, DBL_DIG ); 188 188 return os; … … 193 193 194 194 ostype & ?|?( ostype & os, long double ld ) { 195 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );195 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 196 196 PrintWithDP( os, "%.*Lg", ld, LDBL_DIG ); 197 197 return os; … … 202 202 203 203 ostype & ?|?( ostype & os, float _Complex fc ) { 204 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );204 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 205 205 // os | crealf( fc ) | nonl; 206 206 PrintWithDP( os, "%g", crealf( fc ) ); … … 214 214 215 215 ostype & ?|?( ostype & os, double _Complex dc ) { 216 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );216 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 217 217 // os | creal( dc ) | nonl; 218 218 PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG ); … … 226 226 227 227 ostype & ?|?( ostype & os, long double _Complex ldc ) { 228 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );228 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 229 229 // os | creall( ldc ) || nonl; 230 230 PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG ); … … 237 237 } // ?|? 238 238 239 ostype & ?|?( ostype & os, const char str[]) {239 ostype & ?|?( ostype & os, const char * str ) { 240 240 enum { Open = 1, Close, OpenClose }; 241 241 static const unsigned char mask[256] @= { … … 257 257 // first character IS NOT spacing or closing punctuation => add left separator 258 258 unsigned char ch = str[0]; // must make unsigned 259 if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {260 fmt( os, "%s", $sepGetCur( os ) );259 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 260 fmt( os, "%s", sepGetCur( os ) ); 261 261 } // if 262 262 263 263 // if string starts line, must reset to determine open state because separator is off 264 $sepReset( os );// reset separator264 sepReset( os ); // reset separator 265 265 266 266 // last character IS spacing or opening punctuation => turn off separator for next item 267 267 size_t len = strlen( str ); 268 268 ch = str[len - 1]; // must make unsigned 269 if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {269 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 270 270 sepOn( os ); 271 271 } else { 272 272 sepOff( os ); 273 273 } // if 274 if ( ch == '\n' ) $setNL( os, true ); // check *AFTER* $sepPrt call above as it resets NL flag274 if ( ch == '\n' ) setNL( os, true ); // check *AFTER* sepPrt call above as it resets NL flag 275 275 return write( os, str, len ); 276 276 } // ?|? 277 278 void ?|?( ostype & os, const char str[] ) { 277 void ?|?( ostype & os, const char * str ) { 279 278 (ostype &)(os | str); ends( os ); 280 279 } // ?|? 281 280 282 281 // ostype & ?|?( ostype & os, const char16_t * str ) { 283 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );282 // if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 284 283 // fmt( os, "%ls", str ); 285 284 // return os; … … 288 287 // #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 289 288 // ostype & ?|?( ostype & os, const char32_t * str ) { 290 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );289 // if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 291 290 // fmt( os, "%ls", str ); 292 291 // return os; … … 295 294 296 295 // ostype & ?|?( ostype & os, const wchar_t * str ) { 297 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );296 // if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 298 297 // fmt( os, "%ls", str ); 299 298 // return os; … … 301 300 302 301 ostype & ?|?( ostype & os, const void * p ) { 303 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );302 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 304 303 fmt( os, "%p", p ); 305 304 return os; … … 316 315 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 317 316 (ostype &)(manip( os )); 318 if ( $getPrt( os ) ) ends( os );// something printed ?319 $setPrt( os, false ); // turn off317 if ( getPrt( os ) ) ends( os ); // something printed ? 318 setPrt( os, false ); // turn off 320 319 } // ?|? 321 320 … … 330 329 ostype & nl( ostype & os ) { 331 330 (ostype &)(os | '\n'); 332 $setPrt( os, false ); // turn off333 $setNL( os, true );331 setPrt( os, false ); // turn off 332 setNL( os, true ); 334 333 flush( os ); 335 334 return sepOff( os ); // prepare for next line … … 337 336 338 337 ostype & nonl( ostype & os ) { 339 $setPrt( os, false ); // turn off338 setPrt( os, false ); // turn off 340 339 return os; 341 340 } // nonl … … 376 375 ostype & ?|?( ostype & os, T arg, Params rest ) { 377 376 (ostype &)(os | arg); // print first argument 378 $sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator377 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 379 378 (ostype &)(os | rest); // print remaining arguments 380 $sepSetCur( os, sepGet( os ) ); // switch to regular separator379 sepSetCur( os, sepGet( os ) ); // switch to regular separator 381 380 return os; 382 381 } // ?|? … … 384 383 // (ostype &)(?|?( os, arg, rest )); ends( os ); 385 384 (ostype &)(os | arg); // print first argument 386 $sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator385 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 387 386 (ostype &)(os | rest); // print remaining arguments 388 $sepSetCur( os, sepGet( os ) ); // switch to regular separator387 sepSetCur( os, sepGet( os ) ); // switch to regular separator 389 388 ends( os ); 390 389 } // ?|? … … 415 414 forall( dtype ostype | ostream( ostype ) ) { \ 416 415 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 417 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \416 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \ 418 417 \ 419 418 if ( f.base == 'b' || f.base == 'B' ) { /* bespoke binary format */ \ … … 514 513 forall( dtype ostype | ostream( ostype ) ) { \ 515 514 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 516 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \515 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \ 517 516 char fmtstr[sizeof(DFMTP)]; /* sizeof includes '\0' */ \ 518 517 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ … … 537 536 return os; \ 538 537 } /* ?|? */ \ 539 \540 538 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 541 539 } // distribution … … 557 555 } // if 558 556 559 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );557 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 560 558 561 559 #define CFMTNP "% * " … … 573 571 return os; 574 572 } // ?|? 575 576 573 void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); } 577 574 } // distribution … … 595 592 } // if 596 593 597 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );594 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 598 595 599 596 #define SFMTNP "% * " … … 619 616 return os; 620 617 } // ?|? 621 622 618 void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); } 623 619 } // distribution … … 739 735 } // ?|? 740 736 741 // istype & ?|?( istype & is, const char fmt[]) {737 // istype & ?|?( istype & is, const char * fmt ) { 742 738 // fmt( is, fmt, "" ); 743 739 // return is;
Note:
See TracChangeset
for help on using the changeset viewer.