source: libcfa/src/iostream.hfa @ fe8c31e

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since fe8c31e was 8dcb832, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

remove mutual-exclusion acquire for streams, add EINTR restarts for C stream functions

  • Property mode set to 100644
File size: 20.8 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.hfa --
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 : Wed Oct  6 18:54:59 2021
13// Update Count     : 404
14//
15
16#pragma once
17
18#include "iterator.hfa"
19
20
21// *********************************** ostream ***********************************
22
23
24trait basic_ostream( ostype & ) {
25        // private
26        bool sepPrt$( ostype & );                                                       // get separator state (on/off)
27        void sepReset$( ostype & );                                                     // set separator state to default state
28        void sepReset$( ostype &, bool );                                       // set separator and default state
29        const char * sepGetCur$( ostype & );                            // get current separator string
30        void sepSetCur$( ostype &, const char [] );                     // set current separator string
31        bool getNL$( ostype & );                                                        // check newline
32        void setNL$( ostype &, bool );                                          // saw newline
33        bool getANL$( ostype & );                                                       // get auto newline (on/off)
34        bool getPrt$( ostype & );                                                       // get fmt called in output cascade
35        void setPrt$( ostype &, bool );                                         // set fmt called in output cascade
36        // public
37        void sepOn( ostype & );                                                         // turn separator state on
38        void sepOff( ostype & );                                                        // turn separator state off
39        bool sepDisable( ostype & );                                            // set default state to off, and return previous state
40        bool sepEnable( ostype & );                                                     // set default state to on, and return previous state
41        void nlOn( ostype & );                                                          // turn auto-newline state on
42        void nlOff( ostype & );                                                         // turn auto-newline state off
43
44        const char * sepGet( ostype & );                                        // get separator string
45        void sepSet( ostype &, const char [] );                         // set separator to string (15 character maximum)
46        const char * sepGetTuple( ostype & );                           // get tuple separator string
47        void sepSetTuple( ostype &, const char [] );            // set tuple separator to string (15 character maximum)
48
49        void ends( ostype & );                                                          // end of output statement
50        int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
51}; // basic_ostream
52       
53trait ostream( ostype & | basic_ostream( ostype ) ) {
54        bool fail( ostype & );                                                          // operation failed?
55        void clear( ostype & );
56        int flush( ostype & );
57        void open( ostype &, const char name[], const char mode[] );
58        void close( ostype & );
59        ostype & write( ostype &, const char [], size_t );
60}; // ostream
61
62// trait writeable( T ) {
63//      forall( ostype & | ostream( ostype ) ) ostype & ?|?( ostype &, T );
64// }; // writeable
65
66trait writeable( T, ostype & | ostream( ostype ) ) {
67        ostype & ?|?( ostype &, T );
68}; // writeable
69
70// implement writable for intrinsic types
71
72forall( ostype & | basic_ostream( ostype ) ) {
73        ostype & ?|?( ostype &, bool );
74        void ?|?( ostype &, bool );
75
76        ostype & ?|?( ostype &, char );
77        void ?|?( ostype &, char );
78        ostype & ?|?( ostype &, signed char );
79        void ?|?( ostype &, signed char );
80        ostype & ?|?( ostype &, unsigned char );
81        void ?|?( ostype &, unsigned char );
82
83        ostype & ?|?( ostype &, short int );
84        void ?|?( ostype &, short int );
85        ostype & ?|?( ostype &, unsigned short int );
86        void ?|?( ostype &, unsigned short int );
87        ostype & ?|?( ostype &, int );
88        void ?|?( ostype &, int );
89        ostype & ?|?( ostype &, unsigned int );
90        void ?|?( ostype &, unsigned int );
91        ostype & ?|?( ostype &, long int );
92        void ?|?( ostype &, long int );
93        ostype & ?|?( ostype &, long long int );
94        void ?|?( ostype &, long long int );
95        ostype & ?|?( ostype &, unsigned long int );
96        void ?|?( ostype &, unsigned long int );
97        ostype & ?|?( ostype &, unsigned long long int );
98        void ?|?( ostype &, unsigned long long int );
99        #if defined( __SIZEOF_INT128__ )
100        ostype & ?|?( ostype &, int128 );
101        void ?|?( ostype &, int128 );
102        ostype & ?|?( ostype &, unsigned int128 );
103        void ?|?( ostype &, unsigned int128 );
104        #endif // __SIZEOF_INT128__
105
106        ostype & ?|?( ostype &, float );
107        void ?|?( ostype &, float );
108        ostype & ?|?( ostype &, double );
109        void ?|?( ostype &, double );
110        ostype & ?|?( ostype &, long double );
111        void ?|?( ostype &, long double );
112
113        ostype & ?|?( ostype &, float _Complex );
114        void ?|?( ostype &, float _Complex );
115        ostype & ?|?( ostype &, double _Complex );
116        void ?|?( ostype &, double _Complex );
117        ostype & ?|?( ostype &, long double _Complex );
118        void ?|?( ostype &, long double _Complex );
119
120        ostype & ?|?( ostype &, const char [] );
121        void ?|?( ostype &, const char [] );
122        // ostype & ?|?( ostype &, const char16_t * );
123        #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
124        // ostype & ?|?( ostype &, const char32_t * );
125        #endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 )
126        // ostype & ?|?( ostype &, const wchar_t * );
127        ostype & ?|?( ostype &, const void * );
128        void ?|?( ostype &, const void * );
129
130        // manipulators
131        ostype & ?|?( ostype &, ostype & (*)( ostype & ) );
132        void ?|?( ostype &, ostype & (*)( ostype & ) );
133        ostype & nl( ostype & );
134        ostype & nonl( ostype & );
135        ostype & sep( ostype & );
136        ostype & sepTuple( ostype & );
137        ostype & sepOn( ostype & );
138        ostype & sepOff( ostype & );
139        ostype & sepDisable( ostype & );
140        ostype & sepEnable( ostype & );
141        ostype & nlOn( ostype & );
142        ostype & nlOff( ostype & );
143} // distribution
144
145// tuples
146forall( ostype &, T, Params... | writeable( T, ostype ) | { ostype & ?|?( ostype &, Params ); } ) {
147        ostype & ?|?( ostype & os, T arg, Params rest );
148        void ?|?( ostype & os, T arg, Params rest );
149} // distribution
150
151// writes the range [begin, end) to the given stream
152forall( ostype &, elt_type | writeable( elt_type, ostype ), iterator_type | iterator( iterator_type, elt_type ) ) {
153        void write( iterator_type begin, iterator_type end, ostype & os );
154        void write_reverse( iterator_type begin, iterator_type end, ostype & os );
155} // distribution
156
157// *********************************** manipulators ***********************************
158
159forall( T )
160struct _Ostream_Manip {
161        T val;                                                                                          // polymorphic base-type
162        int wd, pc;                                                                                     // width, precision: signed for computations
163        char base;                                                                                      // numeric base / floating-point style
164        union {
165                unsigned char all;
166                struct {
167                        unsigned char eng:1;                                            // engineering notation
168                        unsigned char neg:1;                                            // val is negative
169                        unsigned char pc:1;                                                     // precision specified
170                        unsigned char left:1;                                           // left justify
171                        unsigned char nobsdp:1;                                         // base prefix / decimal point
172                        unsigned char sign:1;                                           // plus / minus sign
173                        unsigned char pad0:1;                                           // zero pad
174                } flags;
175        };
176}; // _Ostream_Manip
177
178// *********************************** integral ***********************************
179
180// See 6.7.9. 19) The initialization shall occur in initializer list order, each initializer provided for a particular
181// subobject overriding any previously listed initializer for the same subobject; ***all subobjects that are not
182// initialized explicitly shall be initialized implicitly the same as objects that have static storage duration.***
183
184#define IntegralFMTDecl( T, CODE ) \
185static inline { \
186        _Ostream_Manip(T) bin( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'b', { .all : 0 } }; } \
187        _Ostream_Manip(T) oct( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'o', { .all : 0 } }; } \
188        _Ostream_Manip(T) hex( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'x', { .all : 0 } }; } \
189        _Ostream_Manip(T) wd( unsigned int w, T val ) { return (_Ostream_Manip(T))@{ val, w, 0, CODE, { .all : 0 } }; } \
190        _Ostream_Manip(T) wd( unsigned int w, unsigned int pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, CODE, { .flags.pc : true } }; } \
191        _Ostream_Manip(T) & wd( unsigned int w, _Ostream_Manip(T) & fmt ) { fmt.wd = w; return fmt; } \
192        _Ostream_Manip(T) & wd( unsigned int w, unsigned int pc, _Ostream_Manip(T) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \
193        _Ostream_Manip(T) & left( _Ostream_Manip(T) & fmt ) { fmt.flags.left = true; return fmt; } \
194        _Ostream_Manip(T) & upcase( _Ostream_Manip(T) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; } \
195        _Ostream_Manip(T) & nobase( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \
196        _Ostream_Manip(T) & pad0( _Ostream_Manip(T) & fmt ) { fmt.flags.pad0 = true; return fmt; } \
197        _Ostream_Manip(T) sign( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, CODE, { .flags.sign : true } }; } \
198        _Ostream_Manip(T) & sign( _Ostream_Manip(T) & fmt ) { fmt.flags.sign = true; return fmt; } \
199} /* distribution */ \
200forall( ostype & | basic_ostream( ostype ) ) { \
201        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \
202        void ?|?( ostype & os, _Ostream_Manip(T) f ); \
203} // ?|?
204
205IntegralFMTDecl( signed char, 'd' )
206IntegralFMTDecl( unsigned char, 'u' )
207IntegralFMTDecl( signed short int, 'd' )
208IntegralFMTDecl( unsigned short int, 'u' )
209IntegralFMTDecl( signed int, 'd' )
210IntegralFMTDecl( unsigned int, 'u' )
211IntegralFMTDecl( signed long int, 'd' )
212IntegralFMTDecl( unsigned long int, 'u' )
213IntegralFMTDecl( signed long long int, 'd' )
214IntegralFMTDecl( unsigned long long int, 'u' )
215#if defined( __SIZEOF_INT128__ )
216IntegralFMTDecl( int128, 'd' )
217IntegralFMTDecl( unsigned int128, 'u' )
218#endif // __SIZEOF_INT128__
219
220// *********************************** floating point ***********************************
221
222// Default suffix for values with no fraction is "."
223#define FloatingPointFMTDecl( T ) \
224static inline { \
225        _Ostream_Manip(T) hex( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'a', { .all : 0 } }; } \
226        _Ostream_Manip(T) sci( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'e', { .all : 0 } }; } \
227        _Ostream_Manip(T) eng( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.eng : true } }; } \
228        _Ostream_Manip(T) wd( unsigned int w, T val ) { return (_Ostream_Manip(T))@{ val, w, 0, 'g', { .all : 0 } }; } \
229        _Ostream_Manip(T) wd( unsigned int w, unsigned int pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'f', { .flags.pc : true } }; } \
230        _Ostream_Manip(T) ws( unsigned int w, unsigned int pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'g', { .flags.pc : true } }; } \
231        _Ostream_Manip(T) & wd( unsigned int w, _Ostream_Manip(T) & fmt ) { if ( fmt.flags.eng ) fmt.base = 'f'; fmt.wd = w; return fmt; } \
232        _Ostream_Manip(T) & wd( unsigned int w, unsigned int pc, _Ostream_Manip(T) & fmt ) { if ( fmt.flags.eng ) fmt.base = 'f'; fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \
233        _Ostream_Manip(T) & ws( unsigned int w, unsigned int pc, _Ostream_Manip(T) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \
234        _Ostream_Manip(T) & left( _Ostream_Manip(T) & fmt ) { fmt.flags.left = true; return fmt; } \
235        _Ostream_Manip(T) upcase( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'G', { .all : 0 } }; } \
236        _Ostream_Manip(T) & upcase( _Ostream_Manip(T) & fmt ) { fmt.base -= 32; /* upper case */ return fmt; } \
237        _Ostream_Manip(T) & pad0( _Ostream_Manip(T) & fmt ) { fmt.flags.pad0 = true; return fmt; } \
238        _Ostream_Manip(T) sign( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.sign : true } }; } \
239        _Ostream_Manip(T) & sign( _Ostream_Manip(T) & fmt ) { fmt.flags.sign = true; return fmt; } \
240        _Ostream_Manip(T) nodp( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.nobsdp : true } }; } \
241        _Ostream_Manip(T) & nodp( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \
242        _Ostream_Manip(T) unit( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.nobsdp : true } }; } \
243        _Ostream_Manip(T) & unit( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \
244} /* distribution */ \
245forall( ostype & | basic_ostream( ostype ) ) { \
246        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \
247        void ?|?( ostype & os, _Ostream_Manip(T) f ); \
248} // ?|?
249
250FloatingPointFMTDecl( double )
251FloatingPointFMTDecl( long double )
252
253// *********************************** character ***********************************
254
255static inline {
256        _Ostream_Manip(char) bin( char c ) { return (_Ostream_Manip(char))@{ c, 1, 0, 'b', { .all : 0 } }; }
257        _Ostream_Manip(char) oct( char c ) { return (_Ostream_Manip(char))@{ c, 1, 0, 'o', { .all : 0 } }; }
258        _Ostream_Manip(char) hex( char c ) { return (_Ostream_Manip(char))@{ c, 1, 0, 'x', { .all : 0 } }; }
259        _Ostream_Manip(char) wd( unsigned int w, char c ) { return (_Ostream_Manip(char))@{ c, w, 0, 'c', { .all : 0 } }; }
260        _Ostream_Manip(char) & wd( unsigned int w, _Ostream_Manip(char) & fmt ) { fmt.wd = w; return fmt; }
261        _Ostream_Manip(char) & left( _Ostream_Manip(char) & fmt ) { fmt.flags.left = true; return fmt; }
262        _Ostream_Manip(char) & upcase( _Ostream_Manip(char) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; }
263        _Ostream_Manip(char) & nobase( _Ostream_Manip(char) & fmt ) { fmt.flags.nobsdp = true; return fmt; }
264} // distribution
265forall( ostype & | basic_ostream( ostype ) ) {
266        ostype & ?|?( ostype & os, _Ostream_Manip(char) f );
267        void ?|?( ostype & os, _Ostream_Manip(char) f );
268} // ?|?
269
270// *********************************** C string ***********************************
271
272static inline {
273        _Ostream_Manip(const char *) bin( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; }
274        _Ostream_Manip(const char *) oct( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; }
275        _Ostream_Manip(const char *) hex( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; }
276        _Ostream_Manip(const char *) wd( unsigned int w, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; }
277        _Ostream_Manip(const char *) wd( unsigned int w, unsigned int pc, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, w, pc, 's', { .flags.pc : true } }; }
278        _Ostream_Manip(const char *) & wd( unsigned int w, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; return fmt; }
279        _Ostream_Manip(const char *) & wd( unsigned int w, unsigned int pc, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; }
280        _Ostream_Manip(const char *) & left( _Ostream_Manip(const char *) & fmt ) { fmt.flags.left = true; return fmt; }
281        _Ostream_Manip(const char *) & nobase( _Ostream_Manip(const char *) & fmt ) { fmt.flags.nobsdp = true; return fmt; }
282} // distribution
283forall( ostype & | basic_ostream( ostype ) ) {
284        ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f );
285        void ?|?( ostype & os, _Ostream_Manip(const char *) f );
286} // ?|?
287
288
289// *********************************** istream ***********************************
290
291
292trait basic_istream( istype & ) {
293        bool getANL( istype & );                                                        // get scan newline (on/off)
294        void nlOn( istype & );                                                          // read newline
295        void nlOff( istype & );                                                         // scan newline
296
297        void ends( istype & os );                                                       // end of output statement
298        int fmt( istype &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
299        istype & ungetc( istype &, char );
300        bool eof( istype & );
301}; // basic_istream
302
303trait istream( istype & | basic_istream( istype ) ) {
304        bool fail( istype & );
305        void clear( istype & );
306        void open( istype & is, const char name[] );
307        void close( istype & is );
308        istype & read( istype &, char [], size_t );
309}; // istream
310
311trait readable( T ) {
312        forall( istype & | istream( istype ) ) istype & ?|?( istype &, T );
313}; // readable
314
315forall( istype & | basic_istream( istype ) ) {
316        istype & ?|?( istype &, bool & );
317        void ?|?( istype &, bool & );
318
319        istype & ?|?( istype &, char & );
320        void ?|?( istype &, char & );
321        istype & ?|?( istype &, signed char & );
322        void ?|?( istype &, signed char & );
323        istype & ?|?( istype &, unsigned char & );
324        void ?|?( istype &, unsigned char & );
325
326        istype & ?|?( istype &, short int & );
327        void ?|?( istype &, short int & );
328        istype & ?|?( istype &, unsigned short int & );
329        void ?|?( istype &, unsigned short int & );
330        istype & ?|?( istype &, int & );
331        void ?|?( istype &, int & );
332        istype & ?|?( istype &, unsigned int & );
333        void ?|?( istype &, unsigned int & );
334        istype & ?|?( istype &, long int & );
335        void ?|?( istype &, long int & );
336        istype & ?|?( istype &, unsigned long int & );
337        void ?|?( istype &, unsigned long int & );
338        istype & ?|?( istype &, long long int & );
339        void ?|?( istype &, long long int & );
340        istype & ?|?( istype &, unsigned long long int & );
341        void ?|?( istype &, unsigned long long int & );
342        #if defined( __SIZEOF_INT128__ )
343        istype & ?|?( istype &, int128 & );
344        void ?|?( istype &, int128 & );
345        istype & ?|?( istype &, unsigned int128 & );
346        void ?|?( istype &, unsigned int128 & );
347        #endif // __SIZEOF_INT128__
348
349        istype & ?|?( istype &, float & );
350        void ?|?( istype &, float & );
351        istype & ?|?( istype &, double & );
352        void ?|?( istype &, double & );
353        istype & ?|?( istype &, long double & );
354        void ?|?( istype &, long double & );
355
356        istype & ?|?( istype &, float _Complex & );
357        void ?|?( istype &, float _Complex & );
358        istype & ?|?( istype &, double _Complex & );
359        void ?|?( istype &, double _Complex & );
360        istype & ?|?( istype &, long double _Complex & );
361        void ?|?( istype &, long double _Complex & );
362
363//      istype & ?|?( istype &, const char [] );
364        istype & ?|?( istype &, char [] );
365        void ?|?( istype &, char [] );
366
367        // manipulators
368        istype & ?|?( istype &, istype & (*)( istype & ) );
369        void ?|?( istype &, istype & (*)( istype & ) );
370        istype & nl( istype & is );
371        istype & nlOn( istype & );
372        istype & nlOff( istype & );
373} // distribution
374
375// *********************************** manipulators ***********************************
376
377struct _Istream_Cstr {
378        char * s;
379        const char * scanset;
380        int wd;                                                                                         // width
381        union {
382                unsigned char all;
383                struct {
384                        unsigned char ignore:1;                                         // do not change input argument
385                        unsigned char inex:1;                                           // include/exclude characters in scanset
386                } flags;
387        };
388}; // _Istream_Cstr
389
390static inline {
391        _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; }
392        _Istream_Cstr skip( unsigned int n ) { return (_Istream_Cstr){ 0p, 0p, n, { .all : 0 } }; }
393        _Istream_Cstr incl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; }
394        _Istream_Cstr & incl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }
395        _Istream_Cstr excl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; }
396        _Istream_Cstr & excl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }
397        _Istream_Cstr ignore( char s[] ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; }
398        _Istream_Cstr & ignore( _Istream_Cstr & fmt ) { fmt.flags.ignore = true; return fmt; }
399        _Istream_Cstr wdi( unsigned int w, char s[] ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; }
400        _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; }
401} // distribution
402forall( istype & | basic_istream( istype ) ) {
403        istype & ?|?( istype & is, _Istream_Cstr f );
404        void ?|?( istype & is, _Istream_Cstr f );
405}
406
407struct _Istream_Char {
408        bool ignore;                                                                            // do not change input argument
409}; // _Istream_Char
410
411static inline {
412        _Istream_Char ignore( const char ) { return (_Istream_Char)@{ true }; }
413        _Istream_Char & ignore( _Istream_Char & fmt ) { fmt.ignore = true; return fmt; }
414} // distribution
415forall( istype & | basic_istream( istype ) ) {
416        istype & ?|?( istype & is, _Istream_Char f );
417        void ?|?( istype & is, _Istream_Char f );
418}
419
420forall( T & | sized( T ) )
421struct _Istream_Manip {
422        T & val;                                                                                        // polymorphic base-type
423        int wd;                                                                                         // width
424        bool ignore;                                                                            // do not change input argument
425}; // _Istream_Manip
426
427#define InputFMTDecl( T ) \
428static inline { \
429        _Istream_Manip(T) ignore( const T & val ) { return (_Istream_Manip(T))@{ (T &)val, -1, true }; } \
430        _Istream_Manip(T) & ignore( _Istream_Manip(T) & fmt ) { fmt.ignore = true; return fmt; } \
431        _Istream_Manip(T) wdi( unsigned int w, T & val ) { return (_Istream_Manip(T))@{ val, w, false }; } \
432        _Istream_Manip(T) & wdi( unsigned int w, _Istream_Manip(T) & fmt ) { fmt.wd = w; return fmt; } \
433} /* distribution */ \
434forall( istype & | basic_istream( istype ) ) { \
435        istype & ?|?( istype & is, _Istream_Manip(T) f ); \
436        void ?|?( istype & is, _Istream_Manip(T) f ); \
437} // ?|?
438
439InputFMTDecl( signed char )
440InputFMTDecl( unsigned char )
441InputFMTDecl( signed short int )
442InputFMTDecl( unsigned short int )
443InputFMTDecl( signed int )
444InputFMTDecl( unsigned int )
445InputFMTDecl( signed long int )
446InputFMTDecl( unsigned long int )
447InputFMTDecl( signed long long int )
448InputFMTDecl( unsigned long long int )
449
450InputFMTDecl( float )
451InputFMTDecl( double )
452InputFMTDecl( long double )
453
454InputFMTDecl( float _Complex )
455InputFMTDecl( double _Complex )
456InputFMTDecl( long double _Complex )
457
458
459// *********************************** time ***********************************
460
461
462#include <time_t.hfa>                                                                   // Duration (constructors) / Time (constructors)
463
464forall( ostype & | ostream( ostype ) ) {
465        ostype & ?|?( ostype & os, Duration dur );
466        void ?|?( ostype & os, Duration dur );
467        ostype & ?|?( ostype & os, Time time );
468        void ?|?( ostype & os, Time time );
469} // distribution
470
471// Local Variables: //
472// tab-width: 4 //
473// End: //
Note: See TracBrowser for help on using the repository browser.