source: libcfa/src/iostream.hfa@ 45c9441

ADT ast-experimental enum forall-pointer-decay pthread-emulation qualifiedEnum
Last change on this file since 45c9441 was 00e9be9, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

add stream function clear, change eof to return bool

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