source: libcfa/src/iostream.hfa @ c41c2dbe

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since c41c2dbe was 6c5d92f, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

for private variables and functions, move prefix $ to suffix $

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