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.h --
|
---|
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 : Mon Nov 23 14:15:25 2015
|
---|
13 | // Update Count : 17
|
---|
14 | //
|
---|
15 |
|
---|
16 | #ifndef IOSTREAM_H
|
---|
17 | #define IOSTREAM_H
|
---|
18 |
|
---|
19 | #include "iterator.h"
|
---|
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 *, double );
|
---|
37 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char * );
|
---|
38 | forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const void * );
|
---|
39 |
|
---|
40 | forall( dtype ostype, dtype retostype | ostream( ostype ) | ostream( retostype ) ) retostype * ?|?( ostype *os, retostype * (* manip)(ostype*) );
|
---|
41 | forall( dtype ostype | ostream( ostype ) ) ostype * endl( ostype * );
|
---|
42 |
|
---|
43 | // writes the range [begin, end) to the given stream
|
---|
44 | forall( type elt_type | writeable( elt_type ),
|
---|
45 | type iterator_type | iterator( iterator_type, elt_type ),
|
---|
46 | dtype os_type | ostream( os_type ) )
|
---|
47 | void write( iterator_type begin, iterator_type end, os_type *os );
|
---|
48 |
|
---|
49 | forall( type elt_type | writeable( elt_type ),
|
---|
50 | type iterator_type | iterator( iterator_type, elt_type ),
|
---|
51 | dtype os_type | ostream( os_type ) )
|
---|
52 | void write_reverse( iterator_type begin, iterator_type end, os_type *os );
|
---|
53 |
|
---|
54 | //******************************************************************************
|
---|
55 |
|
---|
56 | context istream( dtype istype ) {
|
---|
57 | istype *read( istype *, char *, streamsize_type );
|
---|
58 | istype *unread( istype *, char );
|
---|
59 | int fail( istype * );
|
---|
60 | int eof( istype * );
|
---|
61 | };
|
---|
62 |
|
---|
63 | context readable( type T ) {
|
---|
64 | forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, T );
|
---|
65 | };
|
---|
66 |
|
---|
67 | forall( dtype istype | istream( istype ) )
|
---|
68 | istype * ?|?( istype *, char * );
|
---|
69 |
|
---|
70 | forall( dtype istype | istream( istype ) )
|
---|
71 | istype * ?|?( istype *, int * );
|
---|
72 |
|
---|
73 | #endif // IOSTREAM_H
|
---|
74 |
|
---|
75 | // Local Variables: //
|
---|
76 | // tab-width: 4 //
|
---|
77 | // compile-command: "cfa iostream.c" //
|
---|
78 | // End: //
|
---|