source: src/libcfa/iostream @ 1be845b

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since 1be845b was 9428d52, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

more fixes for 32-bit build problem

  • Property mode set to 100644
File size: 6.1 KB
RevLine 
[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//
[bb82c03]7// iostream --
[86bd7c1f]8//
[90c3b1c]9// Author           : Peter A. Buhr
[86bd7c1f]10// Created On       : Wed May 27 17:56:53 2015
11// Last Modified By : Peter A. Buhr
[9428d52]12// Last Modified On : Sun Jul  1 12:12:22 2018
13// Update Count     : 155
[86bd7c1f]14//
15
[53a6c2a]16#pragma once
[51b7345]17
[d3b7937]18#include "iterator"
[e56cfdb0]19
[4040425]20trait ostream( dtype ostype ) {
[9ebd778]21        // private
[09687aa]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
[9ebd778]29        // public
[09687aa]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 );
[7c919446]44        ostype & write( ostype &, const char *, size_t );
[09687aa]45        int fmt( ostype &, const char fmt[], ... );
[86f384b]46}; // ostream
[90c3b1c]47
[e1780a2]48// trait writeable( otype T ) {
[09687aa]49//      forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype &, T );
[e1780a2]50// }; // writeable
51
52trait writeable( otype T, dtype ostype | ostream( ostype ) ) {
[09687aa]53        ostype & ?|?( ostype &, T );
[86f384b]54}; // writeable
[51b7345]55
[4e06c1e]56// implement writable for intrinsic types
[51b7345]57
[3ce0d440]58forall( dtype ostype | ostream( ostype ) ) {
59        ostype & ?|?( ostype &, _Bool );
[1e6e08de]60
[3ce0d440]61        ostype & ?|?( ostype &, char );
62        ostype & ?|?( ostype &, signed char );
63        ostype & ?|?( ostype &, unsigned char );
[09687aa]64
[3ce0d440]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 );
[09687aa]73
[3ce0d440]74        ostype & ?|?( ostype &, float ); // FIX ME: should not be required
75        ostype & ?|?( ostype &, double );
76        ostype & ?|?( ostype &, long double );
[09687aa]77
[3ce0d440]78        ostype & ?|?( ostype &, float _Complex );
79        ostype & ?|?( ostype &, double _Complex );
80        ostype & ?|?( ostype &, long double _Complex );
[09687aa]81
[3ce0d440]82        ostype & ?|?( ostype &, const char * );
83        // ostype & ?|?( ostype &, const char16_t * );
[0db817e]84#if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
[3ce0d440]85        // ostype & ?|?( ostype &, const char32_t * );
[0db817e]86#endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 )
[3ce0d440]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
[cf16f94]100
[c443d1d]101// tuples
[09687aa]102forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } )
103ostype & ?|?( ostype & os, T arg, Params rest );
[c443d1d]104
[e56cfdb0]105// writes the range [begin, end) to the given stream
[e1780a2]106forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
[09687aa]107void write( iterator_type begin, iterator_type end, ostype & os );
[e56cfdb0]108
[e1780a2]109forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )
[09687aa]110void write_reverse( iterator_type begin, iterator_type end, ostype & os );
[51b7345]111
[6ba0659]112//---------------------------------------
[51b7345]113
[4040425]114trait istream( dtype istype ) {
[09687aa]115        int fail( istype & );
116        int eof( istype & );
117        void open( istype & is, const char * name );
118        void close( istype & is );
[9428d52]119        istype & read( istype &, char *, size_t );
[09687aa]120        istype & ungetc( istype &, char );
121        int fmt( istype &, const char fmt[], ... );
[86f384b]122}; // istream
[51b7345]123
[4040425]124trait readable( otype T ) {
[09687aa]125        forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, T );
[86f384b]126}; // readable
[51b7345]127
[3ce0d440]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
[44574f2]156
[53ba273]157struct _Istream_cstrUC { char * s; };
158_Istream_cstrUC cstr( char * );
[09687aa]159forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrUC );
[51b7345]160
[53ba273]161struct _Istream_cstrC { char * s; int size; };
162_Istream_cstrC cstr( char *, int size );
[09687aa]163forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrC );
[51b7345]164
[10a97adb]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
[86bd7c1f]172// Local Variables: //
[d3b7937]173// mode: c //
[86bd7c1f]174// tab-width: 4 //
175// End: //
Note: See TracBrowser for help on using the repository browser.