| 1 | //
 | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
| 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
| 6 | //
 | 
|---|
| 7 | // it_out.c -- 
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // Author           : Richard C. Bilson
 | 
|---|
| 10 | // Created On       : Wed May 27 17:56:53 2015
 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr
 | 
|---|
| 12 | // Last Modified On : Tue Mar  8 22:14:39 2016
 | 
|---|
| 13 | // Update Count     : 8
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | typedef unsigned long streamsize_type;
 | 
|---|
| 17 | 
 | 
|---|
| 18 | trait ostream( dtype os_type ) {
 | 
|---|
| 19 |         os_type *write( os_type *, const char *, streamsize_type );
 | 
|---|
| 20 |         int fail( os_type * );
 | 
|---|
| 21 | };
 | 
|---|
| 22 | 
 | 
|---|
| 23 | trait writeable( otype T ) {
 | 
|---|
| 24 |         forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, T );
 | 
|---|
| 25 | };
 | 
|---|
| 26 | 
 | 
|---|
| 27 | forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, char );
 | 
|---|
| 28 | forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, int );
 | 
|---|
| 29 | forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, const char * );
 | 
|---|
| 30 | 
 | 
|---|
| 31 | trait istream( dtype is_type ) {
 | 
|---|
| 32 |         is_type *read( is_type *, char *, streamsize_type );
 | 
|---|
| 33 |         is_type *unread( is_type *, char );
 | 
|---|
| 34 |         int fail( is_type * );
 | 
|---|
| 35 |         int eof( is_type * );
 | 
|---|
| 36 | };
 | 
|---|
| 37 | 
 | 
|---|
| 38 | trait readable( otype T ) {
 | 
|---|
| 39 |         forall( dtype is_type | istream( is_type ) ) is_type * ?<<?( is_type *, T );
 | 
|---|
| 40 | };
 | 
|---|
| 41 | 
 | 
|---|
| 42 | forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, char* );
 | 
|---|
| 43 | forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, int* );
 | 
|---|
| 44 | 
 | 
|---|
| 45 | trait iterator( otype iterator_type, otype elt_type ) {
 | 
|---|
| 46 |         iterator_type ?++( iterator_type* );
 | 
|---|
| 47 |         iterator_type ++?( iterator_type* );
 | 
|---|
| 48 |         int ?==?( iterator_type, iterator_type );
 | 
|---|
| 49 |         int ?!=?( iterator_type, iterator_type );
 | 
|---|
| 50 | 
 | 
|---|
| 51 |         lvalue elt_type *?( iterator_type );
 | 
|---|
| 52 | };
 | 
|---|
| 53 | 
 | 
|---|
| 54 | forall( otype elt_type | writeable( elt_type ),
 | 
|---|
| 55 |                 otype iterator_type | iterator( iterator_type, elt_type ),
 | 
|---|
| 56 |                 dtype os_type | ostream( os_type ) )
 | 
|---|
| 57 | void write_all( iterator_type begin, iterator_type end, os_type *os );
 | 
|---|
| 58 | 
 | 
|---|
| 59 | forall( otype elt_type | writeable( elt_type ),
 | 
|---|
| 60 |                 otype iterator_type | iterator( iterator_type, elt_type ),
 | 
|---|
| 61 |                 dtype os_type | ostream( os_type ) )
 | 
|---|
| 62 | void write_all( elt_type begin, iterator_type end, os_type *os ) {
 | 
|---|
| 63 |         os << begin;
 | 
|---|
| 64 | }
 | 
|---|
| 65 | 
 | 
|---|
| 66 | // Local Variables: //
 | 
|---|
| 67 | // tab-width: 4 //
 | 
|---|
| 68 | // compile-command: "cfa it_out.c" //
 | 
|---|
| 69 | // End: //
 | 
|---|