| 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 | // iostream --
|
|---|
| 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 : Fri Jan 29 15:50:36 2016
|
|---|
| 13 | // Update Count : 29
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | #ifndef IOSTREAM_H
|
|---|
| 17 | #define IOSTREAM_H
|
|---|
| 18 |
|
|---|
| 19 | #include "iterator"
|
|---|
| 20 |
|
|---|
| 21 | typedef unsigned long streamsize_type;
|
|---|
| 22 |
|
|---|
| 23 | context ostream( dtype ostype ) {
|
|---|
| 24 | ostype *write( ostype *, const char *, streamsize_type );
|
|---|
| 25 | int fail( ostype * );
|
|---|
| 26 | };
|
|---|
| 27 |
|
|---|
| 28 | context writeable( type T ) {
|
|---|
| 29 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T );
|
|---|
| 30 | };
|
|---|
| 31 |
|
|---|
| 32 | // implement writable for some intrinsic types
|
|---|
| 33 |
|
|---|
| 34 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, char );
|
|---|
| 35 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, int );
|
|---|
| 36 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned int );
|
|---|
| 37 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long int );
|
|---|
| 38 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long long int );
|
|---|
| 39 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned long int );
|
|---|
| 40 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, unsigned long long int );
|
|---|
| 41 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, float ); // FIX ME: should not be required
|
|---|
| 42 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, double );
|
|---|
| 43 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long double );
|
|---|
| 44 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, float _Complex );
|
|---|
| 45 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, double _Complex );
|
|---|
| 46 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long double _Complex );
|
|---|
| 47 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char * );
|
|---|
| 48 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const void * );
|
|---|
| 49 |
|
|---|
| 50 | forall( dtype ostype, dtype retostype | ostream( ostype ) | ostream( retostype ) ) retostype * ?|?( ostype *os, retostype * (* manip)(ostype*) );
|
|---|
| 51 | forall( dtype ostype | ostream( ostype ) ) ostype * endl( ostype * );
|
|---|
| 52 |
|
|---|
| 53 | // writes the range [begin, end) to the given stream
|
|---|
| 54 | forall( type elt_type | writeable( elt_type ),
|
|---|
| 55 | type iterator_type | iterator( iterator_type, elt_type ),
|
|---|
| 56 | dtype os_type | ostream( os_type ) )
|
|---|
| 57 | void write( iterator_type begin, iterator_type end, os_type *os );
|
|---|
| 58 |
|
|---|
| 59 | forall( type elt_type | writeable( elt_type ),
|
|---|
| 60 | type iterator_type | iterator( iterator_type, elt_type ),
|
|---|
| 61 | dtype os_type | ostream( os_type ) )
|
|---|
| 62 | void write_reverse( iterator_type begin, iterator_type end, os_type *os );
|
|---|
| 63 |
|
|---|
| 64 | //******************************************************************************
|
|---|
| 65 |
|
|---|
| 66 | context istream( dtype istype ) {
|
|---|
| 67 | istype *read( istype *, char *, streamsize_type );
|
|---|
| 68 | istype *unread( istype *, char );
|
|---|
| 69 | int fail( istype * );
|
|---|
| 70 | int eof( istype * );
|
|---|
| 71 | };
|
|---|
| 72 |
|
|---|
| 73 | context readable( type T ) {
|
|---|
| 74 | forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, T );
|
|---|
| 75 | };
|
|---|
| 76 |
|
|---|
| 77 | forall( dtype istype | istream( istype ) )
|
|---|
| 78 | istype * ?|?( istype *, char * );
|
|---|
| 79 |
|
|---|
| 80 | forall( dtype istype | istream( istype ) )
|
|---|
| 81 | istype * ?|?( istype *, int * );
|
|---|
| 82 |
|
|---|
| 83 | #endif // IOSTREAM_H
|
|---|
| 84 |
|
|---|
| 85 | // Local Variables: //
|
|---|
| 86 | // mode: c //
|
|---|
| 87 | // tab-width: 4 //
|
|---|
| 88 | // End: //
|
|---|