| [86bd7c1f] | 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 | //
|
|---|
| [d3b7937] | 7 | // iostream --
|
|---|
| [86bd7c1f] | 8 | //
|
|---|
| 9 | // Author : Richard C. Bilson
|
|---|
| 10 | // Created On : Wed May 27 17:56:53 2015
|
|---|
| 11 | // Last Modified By : Peter A. Buhr
|
|---|
| [6ba0659] | 12 | // Last Modified On : Wed Feb 17 14:04:24 2016
|
|---|
| 13 | // Update Count : 32
|
|---|
| [86bd7c1f] | 14 | //
|
|---|
| 15 |
|
|---|
| [51b73452] | 16 | #ifndef IOSTREAM_H
|
|---|
| 17 | #define IOSTREAM_H
|
|---|
| 18 |
|
|---|
| [d3b7937] | 19 | #include "iterator"
|
|---|
| [e56cfdb0] | 20 |
|
|---|
| [51b73452] | 21 | typedef unsigned long streamsize_type;
|
|---|
| 22 |
|
|---|
| [134b86a] | 23 | context ostream( dtype ostype ) {
|
|---|
| [86bd7c1f] | 24 | int fail( ostype * );
|
|---|
| [6ba0659] | 25 | int flush( ostype * );
|
|---|
| 26 | ostype * write( ostype *, const char *, streamsize_type );
|
|---|
| [51b73452] | 27 | };
|
|---|
| [134b86a] | 28 | context writeable( type T ) {
|
|---|
| [cf16f94] | 29 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T );
|
|---|
| [51b73452] | 30 | };
|
|---|
| 31 |
|
|---|
| 32 | // implement writable for some intrinsic types
|
|---|
| 33 |
|
|---|
| [cf16f94] | 34 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, char );
|
|---|
| 35 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, int );
|
|---|
| [784deab] | 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 );
|
|---|
| [d3b7937] | 41 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, float ); // FIX ME: should not be required
|
|---|
| [cf16f94] | 42 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, double );
|
|---|
| [784deab] | 43 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, long double );
|
|---|
| [d3b7937] | 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 );
|
|---|
| [cf16f94] | 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 * );
|
|---|
| [e56cfdb0] | 52 |
|
|---|
| 53 | // writes the range [begin, end) to the given stream
|
|---|
| [6ba0659] | 54 | forall( type elt_type | writeable( elt_type ), type iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) )
|
|---|
| [e56cfdb0] | 55 | void write( iterator_type begin, iterator_type end, os_type *os );
|
|---|
| 56 |
|
|---|
| [6ba0659] | 57 | forall( type elt_type | writeable( elt_type ), type iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) )
|
|---|
| [e56cfdb0] | 58 | void write_reverse( iterator_type begin, iterator_type end, os_type *os );
|
|---|
| [51b73452] | 59 |
|
|---|
| [6ba0659] | 60 | //---------------------------------------
|
|---|
| [51b73452] | 61 |
|
|---|
| [134b86a] | 62 | context istream( dtype istype ) {
|
|---|
| [86bd7c1f] | 63 | int fail( istype * );
|
|---|
| 64 | int eof( istype * );
|
|---|
| [6ba0659] | 65 | istype * get( istype *, int * );
|
|---|
| 66 | istype * read( istype *, char *, streamsize_type );
|
|---|
| 67 | istype * ungetc( istype *, char );
|
|---|
| [51b73452] | 68 | };
|
|---|
| 69 |
|
|---|
| [134b86a] | 70 | context readable( type T ) {
|
|---|
| [cf16f94] | 71 | forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, T );
|
|---|
| [51b73452] | 72 | };
|
|---|
| 73 |
|
|---|
| 74 | forall( dtype istype | istream( istype ) )
|
|---|
| [cf16f94] | 75 | istype * ?|?( istype *, char * );
|
|---|
| [51b73452] | 76 |
|
|---|
| 77 | forall( dtype istype | istream( istype ) )
|
|---|
| [cf16f94] | 78 | istype * ?|?( istype *, int * );
|
|---|
| [51b73452] | 79 |
|
|---|
| [134b86a] | 80 | #endif // IOSTREAM_H
|
|---|
| [86bd7c1f] | 81 |
|
|---|
| 82 | // Local Variables: //
|
|---|
| [d3b7937] | 83 | // mode: c //
|
|---|
| [86bd7c1f] | 84 | // tab-width: 4 //
|
|---|
| 85 | // End: //
|
|---|