source: src/libcfa/iostream @ 9d7b3ea

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 9d7b3ea was 6ba0659, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

major rewrite of I/O library and update example programs to use new I/O

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