source: src/examples/it_out.c @ 09a9a8b

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 09a9a8b was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

licencing: seventh groups of files

  • Property mode set to 100644
File size: 1.9 KB
Line 
1# 1 "iterator.c"
2# 1 "<built-in>"
3# 1 "<command line>"
4# 1 "iterator.c"
5# 1 "iterator.h" 1
6
7
8
9# 1 "iostream.h" 1
10
11
12
13typedef unsigned long streamsize_type;
14
15
16
17context ostream( dtype os_type )
18{
19
20    os_type *write( os_type *, const char *, streamsize_type );
21
22
23    int fail( os_type * );
24};
25
26
27
28
29context writeable( type T )
30{
31    forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, T );
32};
33
34
35
36forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, char );
37forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, int );
38forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, const char * );
39
40
41
42
43context istream( dtype is_type )
44{
45
46    is_type *read( is_type *, char *, streamsize_type );
47
48
49    is_type *unread( is_type *, char );
50
51
52    int fail( is_type * );
53
54
55    int eof( is_type * );
56};
57
58
59
60
61context readable( type T )
62{
63    forall( dtype is_type | istream( is_type ) ) is_type * ?<<?( is_type *, T );
64};
65
66
67
68forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, char* );
69forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, int* );
70# 5 "iterator.h" 2
71
72
73context iterator( type iterator_type, type elt_type )
74{
75
76    iterator_type ?++( iterator_type* );
77    iterator_type ++?( iterator_type* );
78
79
80    int ?==?( iterator_type, iterator_type );
81    int ?!=?( iterator_type, iterator_type );
82
83
84    lvalue elt_type *?( iterator_type );
85};
86
87
88
89forall( type elt_type | writeable( elt_type ),
90        type iterator_type | iterator( iterator_type, elt_type ),
91        dtype os_type | ostream( os_type ) )
92void write_all( iterator_type begin, iterator_type end, os_type *os );
93# 2 "iterator.c" 2
94
95forall( type elt_type | writeable( elt_type ),
96        type iterator_type | iterator( iterator_type, elt_type ),
97        dtype os_type | ostream( os_type ) )
98void
99write_all( elt_type begin, iterator_type end, os_type *os )
100{
101    os << begin;
102}
Note: See TracBrowser for help on using the repository browser.