source: src/libcfa/iostream @ ea8b2f7

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change on this file since ea8b2f7 was 3ce0d440, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

more push/pop updates

  • Property mode set to 100644
File size: 6.2 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           : Peter A. Buhr
10// Created On       : Wed May 27 17:56:53 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sat Jun  2 08:07:55 2018
13// Update Count     : 153
14//
15
16#pragma once
17
18#include "iterator"
19
20trait ostream( dtype ostype ) {
21        // private
22        _Bool sepPrt( ostype & );                                                       // return separator state (on/off)
23        void sepReset( ostype & );                                                      // set separator state to default state
24        void sepReset( ostype &, _Bool );                                       // set separator and default state
25        const char * sepGetCur( ostype & );                                     // get current separator string
26        void sepSetCur( ostype &, const char * );                       // set current separator string
27        _Bool getNL( ostype & );                                                        // check newline
28        void setNL( ostype &, _Bool );                                          // saw newline
29        // public
30        void sepOn( ostype & );                                                         // turn separator state on
31        void sepOff( ostype & );                                                        // turn separator state off
32        _Bool sepDisable( ostype & );                                           // set default state to off, and return previous state
33        _Bool sepEnable( ostype & );                                            // set default state to on, and return previous state
34
35        const char * sepGet( ostype & );                                        // get separator string
36        void sepSet( ostype &, const char * );                          // set separator to string (15 character maximum)
37        const char * sepGetTuple( ostype & );                           // get tuple separator string
38        void sepSetTuple( ostype &, const char * );                     // set tuple separator to string (15 character maximum)
39
40        int fail( ostype & );
41        int flush( ostype & );
42        void open( ostype & os, const char * name, const char * mode );
43        void close( ostype & os );
44        ostype & write( ostype &, const char *, unsigned long int );
45        int fmt( ostype &, const char fmt[], ... );
46}; // ostream
47
48// trait writeable( otype T ) {
49//      forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, T );
50// }; // writeable
51
52trait writeable( otype T, dtype ostype | ostream( ostype ) ) {
53        ostype & ?|?( ostype &, T );
54}; // writeable
55
56// implement writable for intrinsic types
57
58forall( dtype ostype | ostream( ostype ) ) {
59        ostype & ?|?( ostype &, _Bool );
60
61        ostype & ?|?( ostype &, char );
62        ostype & ?|?( ostype &, signed char );
63        ostype & ?|?( ostype &, unsigned char );
64
65        ostype & ?|?( ostype &, short int );
66        ostype & ?|?( ostype &, unsigned short int );
67        ostype & ?|?( ostype &, int );
68        ostype & ?|?( ostype &, unsigned int );
69        ostype & ?|?( ostype &, long int );
70        ostype & ?|?( ostype &, long long int );
71        ostype & ?|?( ostype &, unsigned long int );
72        ostype & ?|?( ostype &, unsigned long long int );
73
74        ostype & ?|?( ostype &, float ); // FIX ME: should not be required
75        ostype & ?|?( ostype &, double );
76        ostype & ?|?( ostype &, long double );
77
78        ostype & ?|?( ostype &, float _Complex );
79        ostype & ?|?( ostype &, double _Complex );
80        ostype & ?|?( ostype &, long double _Complex );
81
82        ostype & ?|?( ostype &, const char * );
83        // ostype & ?|?( ostype &, const char16_t * );
84#if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
85        // ostype & ?|?( ostype &, const char32_t * );
86#endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 )
87        // ostype & ?|?( ostype &, const wchar_t * );
88        ostype & ?|?( ostype &, const void * );
89
90        // manipulators
91        ostype & ?|?( ostype &, ostype & (*)( ostype & ) );
92        ostype & endl( ostype & );
93        ostype & sep( ostype & );
94        ostype & sepTuple( ostype & );
95        ostype & sepOn( ostype & );
96        ostype & sepOff( ostype & );
97        ostype & sepDisable( ostype & );
98        ostype & sepEnable( ostype & );
99} // distribution
100
101// tuples
102forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } )
103ostype & ?|?( ostype & os, T arg, Params rest );
104
105// writes the range [begin, end) to the given stream
106forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
107void write( iterator_type begin, iterator_type end, ostype & os );
108
109forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
110void write_reverse( iterator_type begin, iterator_type end, ostype & os );
111
112//---------------------------------------
113
114trait istream( dtype istype ) {
115        int fail( istype & );
116        int eof( istype & );
117        void open( istype & is, const char * name );
118        void close( istype & is );
119        istype & read( istype &, char *, unsigned long int );
120        istype & ungetc( istype &, char );
121        int fmt( istype &, const char fmt[], ... );
122}; // istream
123
124trait readable( otype T ) {
125        forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, T );
126}; // readable
127
128forall( dtype istype | istream( istype ) ) {
129        istype & ?|?( istype &, _Bool & );
130
131        istype & ?|?( istype &, char & );
132        istype & ?|?( istype &, signed char & );
133        istype & ?|?( istype &, unsigned char & );
134
135        istype & ?|?( istype &, short int & );
136        istype & ?|?( istype &, unsigned short int & );
137        istype & ?|?( istype &, int & );
138        istype & ?|?( istype &, unsigned int & );
139        istype & ?|?( istype &, long int & );
140        istype & ?|?( istype &, long long int & );
141        istype & ?|?( istype &, unsigned long int & );
142        istype & ?|?( istype &, unsigned long long int & );
143
144        istype & ?|?( istype &, float & );
145        istype & ?|?( istype &, double & );
146        istype & ?|?( istype &, long double & );
147
148        istype & ?|?( istype &, float _Complex & );
149        istype & ?|?( istype &, double _Complex & );
150        istype & ?|?( istype &, long double _Complex & );
151
152        // manipulators
153        istype & ?|?( istype &, istype & (*)( istype & ) );
154        istype & endl( istype & is );
155} // distribution
156
157struct _Istream_cstrUC { char * s; };
158_Istream_cstrUC cstr( char * );
159forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrUC );
160
161struct _Istream_cstrC { char * s; int size; };
162_Istream_cstrC cstr( char *, int size );
163forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrC );
164
165
166#include <time_t.h>                                                                             // Duration (constructors) / Time (constructors)
167
168forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );
169forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
170
171
172// Local Variables: //
173// mode: c //
174// tab-width: 4 //
175// End: //
Note: See TracBrowser for help on using the repository browser.