- Timestamp:
- Dec 12, 2018, 9:16:12 AM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 5ebb1368
- Parents:
- 3d99498
- Location:
- libcfa/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.cfa
r3d99498 r200fcb3 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 10 18:19:40201813 // Update Count : 2 8412 // Last Modified On : Wed Dec 12 08:34:28 2018 13 // Update Count : 298 14 14 // 15 15 … … 20 20 #include <stdarg.h> // varargs 21 21 #include <string.h> // strlen 22 #include <stdbool.h> // true/false23 22 #include <float.h> // DBL_DIG, LDBL_DIG 24 23 #include <complex.h> // creal, cimag … … 27 26 #define IO_MSG "I/O error: " 28 27 29 void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, const char * separator, const char * tupleSeparator ) {28 void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, bool nlOnOff, bool nonlManip, const char * separator, const char * tupleSeparator ) { 30 29 os.file = file; 31 30 os.sepDefault = sepDefault; 32 31 os.sepOnOff = sepOnOff; 32 os.nlOnOff = nlOnOff; 33 os.nonlManip = nonlManip; 33 34 sepSet( os, separator ); 34 35 sepSetCur( os, sepGet( os ) ); … … 44 45 bool getNL( ofstream & os ) { return os.sawNL; } 45 46 void setNL( ofstream & os, bool state ) { os.sawNL = state; } 47 bool getANL( ofstream & os ) { return os.nlOnOff; } 48 bool getNonl( ofstream & os ) { return os.nonlManip; } 49 void setNonl( ofstream & os, bool state ) { os.nonlManip = state; } 46 50 47 51 // public … … 72 76 } // sepEnable 73 77 78 void nlOn( ofstream & os ) { os.nlOnOff = true; } 79 void nlOff( ofstream & os ) { os.nlOnOff = false; } 80 74 81 const char * sepGet( ofstream & os ) { return os.separator; } 75 82 void sepSet( ofstream & os, const char * s ) { … … 103 110 } // if 104 111 #endif // __CFA_DEBUG__ 105 (os){ file, true, false, " ", ", " };112 (os){ file, true, false, true, false, " ", ", " }; 106 113 } // open 107 114 … … 147 154 } // fmt 148 155 149 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " };156 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, true, false, " ", ", " }; 150 157 ofstream & sout = soutFile; 151 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " };158 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, true, false, " ", ", " }; 152 159 ofstream & serr = serrFile; 153 160 -
libcfa/src/fstream.hfa
r3d99498 r200fcb3 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 11 13:54:27201813 // Update Count : 1 3212 // Last Modified On : Wed Dec 12 07:52:41 2018 13 // Update Count : 143 14 14 // 15 15 … … 23 23 bool sepDefault; 24 24 bool sepOnOff; 25 bool nlOnOff; 26 bool nonlManip; 25 27 bool sawNL; 26 28 const char * sepCur; … … 37 39 bool getNL( ofstream & ); 38 40 void setNL( ofstream &, bool ); 41 bool getANL( ofstream & ); 42 bool getNonl( ofstream & ); 43 void setNonl( ofstream &, bool ); 39 44 40 45 // public … … 43 48 bool sepDisable( ofstream & ); 44 49 bool sepEnable( ofstream & ); 50 void nlOn( ofstream & ); 51 void nlOff( ofstream & ); 45 52 46 53 const char * sepGet( ofstream & ); -
libcfa/src/gmp.hfa
r3d99498 r200fcb3 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Dec 7 09:10:41 201713 // Update Count : 2 112 // Last Modified On : Tue Dec 4 23:25:51 2018 13 // Update Count : 22 14 14 // 15 15 … … 262 262 } // ?|? 263 263 264 static inline forall( dtype ostype | ostream( ostype ) ) 265 ostype & ?|?( ostype & os, Int mp ) { 266 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 267 gmp_printf( "%Zd", mp.mpz ); 268 sepOn( os ); 269 return os; 270 } // ?|? 264 static inline forall( dtype ostype | ostream( ostype ) ) { 265 ostype & ?|?( ostype & os, Int mp ) { 266 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 267 gmp_printf( "%Zd", mp.mpz ); 268 sepOn( os ); 269 return os; 270 } // ?|? 271 272 void ?|?( ostype & os, Int mp ) { 273 (ostype)(os | mp); if ( getANL( os ) ) nl( os ); 274 } // ?|? 275 } // distribution 271 276 272 277 // Local Variables: // -
libcfa/src/iostream.cfa
r3d99498 r200fcb3 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Nov 2 07:17:05201813 // Update Count : 47412 // Last Modified On : Tue Dec 11 22:02:03 2018 13 // Update Count : 546 14 14 // 15 15 … … 19 19 #include <stdio.h> 20 20 #include <stdbool.h> // true/false 21 //#include <string.h> 21 //#include <string.h> // strlen, strcmp 22 22 extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); 23 23 extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); … … 32 32 return os; 33 33 } // ?|? 34 35 ostype & ?|?( ostype & os, char ch ) { 36 fmt( os, "%c", ch ); 37 if ( ch == '\n' ) setNL( os, true ); 38 sepOff( os ); 39 return os; 40 } // ?|? 41 42 ostype & ?|?( ostype & os, signed char c ) { 43 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 44 fmt( os, "%hhd", c ); 45 return os; 46 } // ?|? 47 48 ostype & ?|?( ostype & os, unsigned char c ) { 49 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 50 fmt( os, "%hhu", c ); 51 return os; 34 void ?|?( ostype & os, bool b ) { 35 (ostype)(os | b); if ( getANL( os ) ) nl( os ); 36 } // ?|? 37 38 ostype & ?|?( ostype & os, char c ) { 39 fmt( os, "%c", c ); 40 if ( c == '\n' ) setNL( os, true ); 41 return sepOff( os ); 42 } // ?|? 43 void ?|?( ostype & os, char c ) { 44 (ostype)(os | c); if ( getANL( os ) ) nl( os ); 45 } // ?|? 46 47 ostype & ?|?( ostype & os, signed char sc ) { 48 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 49 fmt( os, "%hhd", sc ); 50 return os; 51 } // ?|? 52 void ?|?( ostype & os, signed char sc ) { 53 (ostype)(os | sc); if ( getANL( os ) ) nl( os ); 54 } // ?|? 55 56 ostype & ?|?( ostype & os, unsigned char usc ) { 57 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 58 fmt( os, "%hhu", usc ); 59 return os; 60 } // ?|? 61 void ?|?( ostype & os, unsigned char usc ) { 62 (ostype)(os | usc); if ( getANL( os ) ) nl( os ); 52 63 } // ?|? 53 64 … … 57 68 return os; 58 69 } // ?|? 70 void & ?|?( ostype & os, short int si ) { 71 (ostype)(os | si); if ( getANL( os ) ) nl( os ); 72 } // ?|? 59 73 60 74 ostype & ?|?( ostype & os, unsigned short int usi ) { … … 63 77 return os; 64 78 } // ?|? 79 void & ?|?( ostype & os, unsigned short int usi ) { 80 (ostype)(os | usi); if ( getANL( os ) ) nl( os ); 81 } // ?|? 65 82 66 83 ostype & ?|?( ostype & os, int i ) { … … 69 86 return os; 70 87 } // ?|? 88 void & ?|?( ostype & os, int i ) { 89 (ostype)(os | i); if ( getANL( os ) ) nl( os ); 90 } // ?|? 71 91 72 92 ostype & ?|?( ostype & os, unsigned int ui ) { … … 75 95 return os; 76 96 } // ?|? 97 void & ?|?( ostype & os, unsigned int ui ) { 98 (ostype)(os | ui); if ( getANL( os ) ) nl( os ); 99 } // ?|? 77 100 78 101 ostype & ?|?( ostype & os, long int li ) { … … 81 104 return os; 82 105 } // ?|? 106 void & ?|?( ostype & os, long int li ) { 107 (ostype)(os | li); if ( getANL( os ) ) nl( os ); 108 } // ?|? 83 109 84 110 ostype & ?|?( ostype & os, unsigned long int uli ) { … … 87 113 return os; 88 114 } // ?|? 115 void & ?|?( ostype & os, unsigned long int uli ) { 116 (ostype)(os | uli); if ( getANL( os ) ) nl( os ); 117 } // ?|? 89 118 90 119 ostype & ?|?( ostype & os, long long int lli ) { … … 93 122 return os; 94 123 } // ?|? 124 void & ?|?( ostype & os, long long int lli ) { 125 (ostype)(os | lli); if ( getANL( os ) ) nl( os ); 126 } // ?|? 95 127 96 128 ostype & ?|?( ostype & os, unsigned long long int ulli ) { … … 99 131 return os; 100 132 } // ?|? 133 void & ?|?( ostype & os, unsigned long long int ulli ) { 134 (ostype)(os | ulli); if ( getANL( os ) ) nl( os ); 135 } // ?|? 101 136 102 137 ostype & ?|?( ostype & os, float f ) { … … 105 140 return os; 106 141 } // ?|? 142 void & ?|?( ostype & os, float f ) { 143 (ostype)(os | f); if ( getANL( os ) ) nl( os ); 144 } // ?|? 107 145 108 146 ostype & ?|?( ostype & os, double d ) { … … 111 149 return os; 112 150 } // ?|? 151 void & ?|?( ostype & os, double d ) { 152 (ostype)(os | d); if ( getANL( os ) ) nl( os ); 153 } // ?|? 113 154 114 155 ostype & ?|?( ostype & os, long double ld ) { … … 117 158 return os; 118 159 } // ?|? 160 void & ?|?( ostype & os, long double ld ) { 161 (ostype)(os | ld); if ( getANL( os ) ) nl( os ); 162 } // ?|? 119 163 120 164 ostype & ?|?( ostype & os, float _Complex fc ) { … … 123 167 return os; 124 168 } // ?|? 169 void & ?|?( ostype & os, float _Complex fc ) { 170 (ostype)(os | fc); if ( getANL( os ) ) nl( os ); 171 } // ?|? 125 172 126 173 ostype & ?|?( ostype & os, double _Complex dc ) { … … 129 176 return os; 130 177 } // ?|? 178 void & ?|?( ostype & os, double _Complex dc ) { 179 (ostype)(os | dc); if ( getANL( os ) ) nl( os ); 180 } // ?|? 131 181 132 182 ostype & ?|?( ostype & os, long double _Complex ldc ) { … … 134 184 fmt( os, "%.*Lg%+.*Lgi", LDBL_DIG, creall( ldc ), LDBL_DIG, cimagl( ldc ) ); 135 185 return os; 186 } // ?|? 187 void & ?|?( ostype & os, long double _Complex ldc ) { 188 (ostype)(os | ldc); if ( getANL( os ) ) nl( os ); 136 189 } // ?|? 137 190 … … 174 227 return write( os, str, len ); 175 228 } // ?|? 229 void ?|?( ostype & os, const char * str ) { 230 (ostype)(os | str); if ( getANL( os ) ) nl( os ); 231 } // ?|? 176 232 177 233 // ostype & ?|?( ostype & os, const char16_t * str ) { … … 200 256 return os; 201 257 } // ?|? 202 258 void ?|?( ostype & os, const void * p ) { 259 (ostype)(os | p); if ( getANL( os ) ) nl( os ); 260 } // ?|? 203 261 204 262 // manipulators 205 263 ostype & ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 206 return manip( os ); 264 (ostype)(manip( os )); 265 setNonl( os, false ); // ignore nonl in middle 266 return os; 267 } // ?|? 268 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 269 (ostype)(manip( os )); 270 if ( getANL( os ) && ! getNonl( os ) ) nl( os ); // ignore nl if nonl at end 271 setNonl( os, false ); 207 272 } // ?|? 208 273 209 274 ostype & sep( ostype & os ) { 210 os | sepGet( os ); 211 return os; 275 return (ostype)(os | sepGet( os )); 212 276 } // sep 213 277 214 278 ostype & sepTuple( ostype & os ) { 215 os | sepGetTuple( os ); 216 return os; 279 return os | sepGetTuple( os ); 217 280 } // sepTuple 218 281 219 ostype & endl( ostype & os ) {220 os | '\n';282 ostype & nl( ostype & os ) { 283 (ostype)(os | '\n'); 221 284 setNL( os, true ); 222 285 flush( os ); 223 sepOff( os ); // prepare for next line 224 return os; 225 } // endl 286 return sepOff( os ); // prepare for next line 287 } // nl 288 289 ostype & nonl( ostype & os ) { 290 setNonl( os, true ); // indicate nonl manipulator 291 return os; 292 } // nonl 226 293 227 294 ostype & sepOn( ostype & os ) { 228 sepOn( os ); 295 sepOn( os ); // call void returning 229 296 return os; 230 297 } // sepOn 231 298 232 299 ostype & sepOff( ostype & os ) { 233 sepOff( os ); 300 sepOff( os ); // call void returning 234 301 return os; 235 302 } // sepOff 236 303 237 304 ostype & sepEnable( ostype & os ) { 238 sepEnable( os ); 305 sepEnable( os ); // call void returning 239 306 return os; 240 307 } // sepEnable 241 308 242 309 ostype & sepDisable( ostype & os ) { 243 sepDisable( os ); 310 sepDisable( os ); // call void returning 244 311 return os; 245 312 } // sepDisable 313 314 ostype & nlOn( ostype & os ) { 315 nlOn( os ); // call void returning 316 return os; 317 } // nlOn 318 319 ostype & nlOff( ostype & os ) { 320 nlOff( os ); // call void returning 321 return os; 322 } // nlOff 246 323 } // distribution 247 324 248 249 325 // tuples 250 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) 251 ostype & ?|?( ostype & os, T arg, Params rest ) { 252 os | arg; // print first argument 253 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 254 os | rest; // print remaining arguments 255 sepSetCur( os, sepGet( os ) ); // switch to regular separator 256 return os; 257 } // ?|? 326 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) { 327 ostype & ?|?( ostype & os, T arg, Params rest ) { 328 (ostype)(os | arg); // print first argument 329 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 330 (ostype)(os | rest); // print remaining arguments 331 sepSetCur( os, sepGet( os ) ); // switch to regular separator 332 return os; 333 } // ?|? 334 void ?|?( ostype & os, T arg, Params rest ) { 335 // (ostype)(?|?( os, arg, rest )); if ( getANL( os ) ) nl( os ); 336 (ostype)(os | arg); // print first argument 337 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 338 (ostype)(os | rest); // print remaining arguments 339 sepSetCur( os, sepGet( os ) ); // switch to regular separator 340 if ( getANL( os ) ) nl( os ); 341 } // ?|? 342 } // distribution 258 343 259 344 //--------------------------------------- 260 345 261 346 // writes the range [begin, end) to the given stream 262 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 263 void write( iterator_type begin, iterator_type end, ostype & os ) {264 void print( elt_type i ) { os | i; }265 for_each( begin, end, print );266 } // ?|?267 268 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 269 void write_reverse( iterator_type begin, iterator_type end, ostype & os ) { 270 void print( elt_type i ) { os | i; }271 for_each_reverse( begin, end, print );272 } // ?|?347 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) { 348 void write( iterator_type begin, iterator_type end, ostype & os ) { 349 void print( elt_type i ) { os | i; } 350 for_each( begin, end, print ); 351 } // ?|? 352 353 void write_reverse( iterator_type begin, iterator_type end, ostype & os ) { 354 void print( elt_type i ) { os | i; } 355 for_each_reverse( begin, end, print ); 356 } // ?|? 357 } // distribution 273 358 274 359 //--------------------------------------- … … 386 471 } // ?|? 387 472 388 istype & endl( istype & is ) {473 istype & nl( istype & is ) { 389 474 fmt( is, "%*[ \t\f\n\r\v]" ); // ignore whitespace 390 475 return is; 391 } // endl476 } // nl 392 477 } // distribution 393 478 -
libcfa/src/iostream.hfa
r3d99498 r200fcb3 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 11 08:22:49201813 // Update Count : 15612 // Last Modified On : Tue Dec 11 22:01:31 2018 13 // Update Count : 213 14 14 // 15 15 … … 25 25 const char * sepGetCur( ostype & ); // get current separator string 26 26 void sepSetCur( ostype &, const char * ); // set current separator string 27 bool getNL( ostype & ); // check newline27 bool getNL( ostype & ); // check newline 28 28 void setNL( ostype &, bool ); // saw newline 29 bool getANL( ostype & ); // check auto newline 30 bool getNonl( ostype & ); // check nonnl manipulator 31 void setNonl( ostype &, bool ); // set nonnl manipulator 29 32 // public 30 33 void sepOn( ostype & ); // turn separator state on 31 34 void sepOff( ostype & ); // turn separator state off 32 35 bool sepDisable( ostype & ); // set default state to off, and return previous state 33 bool sepEnable( ostype & ); // set default state to on, and return previous state 36 bool sepEnable( ostype & ); // set default state to on, and return previous state 37 void nlOn( ostype & ); // turn auto-newline state on 38 void nlOff( ostype & ); // turn auto-newline state off 34 39 35 40 const char * sepGet( ostype & ); // get separator string … … 58 63 forall( dtype ostype | ostream( ostype ) ) { 59 64 ostype & ?|?( ostype &, bool ); 65 void & ?|?( ostype &, bool ); 60 66 61 67 ostype & ?|?( ostype &, char ); 68 void & ?|?( ostype &, char ); 62 69 ostype & ?|?( ostype &, signed char ); 70 void & ?|?( ostype &, signed char ); 63 71 ostype & ?|?( ostype &, unsigned char ); 72 void & ?|?( ostype &, unsigned char ); 64 73 65 74 ostype & ?|?( ostype &, short int ); 75 void & ?|?( ostype &, short int ); 66 76 ostype & ?|?( ostype &, unsigned short int ); 77 void & ?|?( ostype &, unsigned short int ); 67 78 ostype & ?|?( ostype &, int ); 79 void & ?|?( ostype &, int ); 68 80 ostype & ?|?( ostype &, unsigned int ); 81 void & ?|?( ostype &, unsigned int ); 69 82 ostype & ?|?( ostype &, long int ); 83 void & ?|?( ostype &, long int ); 70 84 ostype & ?|?( ostype &, long long int ); 85 void & ?|?( ostype &, long long int ); 71 86 ostype & ?|?( ostype &, unsigned long int ); 87 void & ?|?( ostype &, unsigned long int ); 72 88 ostype & ?|?( ostype &, unsigned long long int ); 89 void & ?|?( ostype &, unsigned long long int ); 73 90 74 91 ostype & ?|?( ostype &, float ); // FIX ME: should not be required 92 void & ?|?( ostype &, float ); // FIX ME: should not be required 75 93 ostype & ?|?( ostype &, double ); 94 void & ?|?( ostype &, double ); 76 95 ostype & ?|?( ostype &, long double ); 96 void & ?|?( ostype &, long double ); 77 97 78 98 ostype & ?|?( ostype &, float _Complex ); 99 void & ?|?( ostype &, float _Complex ); 79 100 ostype & ?|?( ostype &, double _Complex ); 101 void & ?|?( ostype &, double _Complex ); 80 102 ostype & ?|?( ostype &, long double _Complex ); 103 void & ?|?( ostype &, long double _Complex ); 81 104 82 105 ostype & ?|?( ostype &, const char * ); 106 void & ?|?( ostype &, const char * ); 83 107 // ostype & ?|?( ostype &, const char16_t * ); 84 108 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous … … 87 111 // ostype & ?|?( ostype &, const wchar_t * ); 88 112 ostype & ?|?( ostype &, const void * ); 113 void & ?|?( ostype &, const void * ); 89 114 90 115 // manipulators 91 116 ostype & ?|?( ostype &, ostype & (*)( ostype & ) ); 92 ostype & endl( ostype & ); 117 void ?|?( ostype &, ostype & (*)( ostype & ) ); 118 ostype & nl( ostype & ); 119 ostype & nonl( ostype & ); 93 120 ostype & sep( ostype & ); 94 121 ostype & sepTuple( ostype & ); … … 97 124 ostype & sepDisable( ostype & ); 98 125 ostype & sepEnable( ostype & ); 126 ostype & nlOn( ostype & ); 127 ostype & nlOff( ostype & ); 99 128 } // distribution 100 129 101 130 // tuples 102 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) 103 ostype & ?|?( ostype & os, T arg, Params rest ); 131 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) { 132 ostype & ?|?( ostype & os, T arg, Params rest ); 133 void ?|?( ostype & os, T arg, Params rest ); 134 } // distribution 104 135 105 136 // writes the range [begin, end) to the given stream 106 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 107 void write( iterator_type begin, iterator_type end, ostype & os ); 108 109 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) 110 void write_reverse( iterator_type begin, iterator_type end, ostype & os ); 137 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) ) { 138 void write( iterator_type begin, iterator_type end, ostype & os ); 139 void write_reverse( iterator_type begin, iterator_type end, ostype & os ); 140 } // distribution 111 141 112 142 //--------------------------------------- … … 152 182 // manipulators 153 183 istype & ?|?( istype &, istype & (*)( istype & ) ); 154 istype & endl( istype & is );184 istype & nl( istype & is ); 155 185 } // distribution 156 186 … … 164 194 165 195 166 #include <time_t.hfa> // Duration (constructors) / Time (constructors) 167 168 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur ); 169 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time ); 170 196 #include <time_t.hfa> // Duration (constructors) / Time (constructors) 197 198 forall( dtype ostype | ostream( ostype ) ) { 199 ostype & ?|?( ostype & os, Duration dur ); 200 void ?|?( ostype & os, Duration dur ); 201 ostype & ?|?( ostype & os, Time time ); 202 void ?|?( ostype & os, Time time ); 203 } // distribution 171 204 172 205 // Local Variables: // -
libcfa/src/rational.cfa
r3d99498 r200fcb3 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 2 09:24:33201813 // Update Count : 16 212 // Last Modified On : Tue Dec 11 22:02:29 2018 13 // Update Count : 168 14 14 // 15 15 … … 35 35 static RationalImpl simplify( RationalImpl & n, RationalImpl & d ) { 36 36 if ( d == (RationalImpl){0} ) { 37 serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl;37 serr | "Invalid rational number construction: denominator cannot be equal to 0."; 38 38 exit( EXIT_FAILURE ); 39 39 } // exit … … 175 175 } // ?|? 176 176 177 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) 178 ostype & ?|?( ostype & os, Rational(RationalImpl ) r ) { 179 return os | r.numerator | '/' | r.denominator; 180 } // ?|? 177 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) { 178 ostype & ?|?( ostype & os, Rational(RationalImpl) r ) { 179 return os | r.numerator | '/' | r.denominator; 180 } // ?|? 181 182 void ?|?( ostype & os, Rational(RationalImpl) r ) { 183 (ostype)(os | r); if ( getANL( os ) ) nl( os ); 184 } // ?|? 185 } // distribution 181 186 } // distribution 182 187 -
libcfa/src/rational.hfa
r3d99498 r200fcb3 12 12 // Created On : Wed Apr 6 17:56:25 2016 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Sat Jun 2 09:10:01201815 // Update Count : 10 514 // Last Modified On : Tue Dec 4 23:07:46 2018 15 // Update Count : 106 16 16 // 17 17 … … 92 92 istype & ?|?( istype &, Rational(RationalImpl) & ); 93 93 94 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) 95 ostype & ?|?( ostype &, Rational(RationalImpl ) ); 94 forall( dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, RationalImpl ); } ) { 95 ostype & ?|?( ostype &, Rational(RationalImpl) ); 96 void ?|?( ostype &, Rational(RationalImpl) ); 97 } // distribution 96 98 } // distribution 97 99 -
libcfa/src/time.cfa
r3d99498 r200fcb3 10 10 // Created On : Tue Mar 27 13:33:14 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 6 22:26:00201813 // Update Count : 3712 // Last Modified On : Tue Dec 11 21:32:15 2018 13 // Update Count : 53 14 14 // 15 15 … … 31 31 32 32 33 forall( dtype ostype | ostream( ostype ) ) 34 ostype & ?|?( ostype & os, Duration dur ) with( dur ) { 35 os | tv / TIMEGRAN; // print seconds 36 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 37 if ( ns != 0 ) { // some ? 38 char buf[16]; 39 os | nanomsd( ns, buf ); // print nanoseconds 40 } // if 41 return os; 42 } // ?|? 33 forall( dtype ostype | ostream( ostype ) ) { 34 ostype & ?|?( ostype & os, Duration dur ) with( dur ) { 35 (ostype)(os | tv / TIMEGRAN); // print seconds 36 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 37 if ( ns != 0 ) { // some ? 38 char buf[16]; 39 (ostype)(os | nanomsd( ns, buf )); // print nanoseconds 40 } // if 41 return os; 42 } // ?|? 43 44 void ?|?( ostype & os, Duration dur ) with( dur ) { 45 (ostype)(os | dur); if ( getANL( os ) ) nl( os ); 46 } // ?|? 47 } // distribution 43 48 44 49 … … 137 142 } // strftime 138 143 139 forall( dtype ostype | ostream( ostype ) ) 140 ostype & ?|?( ostype & os, Time time ) with( time ) { 141 char buf[32]; // at least 26 142 time_t s = tv / TIMEGRAN; 143 ctime_r( &s, (char *)&buf ); // 26 characters: "Wed Jun 30 21:49:08 1993\n" 144 buf[24] = '\0'; // remove trailing '\n' 145 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 146 if ( ns == 0 ) { // none ? 147 os | buf; // print date/time/year 148 } else { 149 buf[19] = '\0'; // truncate to "Wed Jun 30 21:49:08" 150 os | buf; // print date/time 151 char buf2[16]; 152 nanomsd( ns, buf2 ); // compute nanoseconds 153 os | buf2 | ' ' | &buf[20]; // print nanoseconds and year 154 } // if 155 return os; 156 } // ?|? 144 forall( dtype ostype | ostream( ostype ) ) { 145 ostype & ?|?( ostype & os, Time time ) with( time ) { 146 char buf[32]; // at least 26 147 time_t s = tv / TIMEGRAN; 148 ctime_r( &s, (char *)&buf ); // 26 characters: "Wed Jun 30 21:49:08 1993\n" 149 buf[24] = '\0'; // remove trailing '\n' 150 long int ns = (tv < 0 ? -tv : tv) % TIMEGRAN; // compute nanoseconds 151 if ( ns == 0 ) { // none ? 152 (ostype)(os | buf); // print date/time/year 153 } else { 154 buf[19] = '\0'; // truncate to "Wed Jun 30 21:49:08" 155 char buf2[16]; 156 nanomsd( ns, buf2 ); // compute nanoseconds 157 (ostype)(os | buf | buf2 | ' ' | &buf[20]); // print date/time, nanoseconds and year 158 } // if 159 return os; 160 } // ?|? 161 162 void ?|?( ostype & os, Time time ) with( time ) { 163 (ostype)(os | time); if ( getANL( os ) ) nl( os ); 164 } // ?|? 165 } // distribution 157 166 158 167 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.