Ignore:
Timestamp:
Jan 7, 2021, 2:55:57 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
58fe85a
Parents:
bdfc032 (diff), 44e37ef (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into dkobets-vector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.hfa

    rbdfc032 reef8dfb  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 12 12:08:38 2019
    13 // Update Count     : 334
     12// Last Modified On : Tue Aug 11 22:16:14 2020
     13// Update Count     : 350
    1414//
    1515
     
    1919
    2020
    21 //*********************************** ostream ***********************************
     21// *********************************** ostream ***********************************
    2222
    2323
    2424trait ostream( dtype ostype ) {
    2525        // 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
     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
    3636        // public
    3737        void sepOn( ostype & );                                                         // turn separator state on
     
    4343
    4444        const char * sepGet( ostype & );                                        // get separator string
    45         void sepSet( ostype &, const char * );                          // set separator to string (15 character maximum)
     45        void sepSet( ostype &, const char [] );                         // set separator to string (15 character maximum)
    4646        const char * sepGetTuple( ostype & );                           // get tuple separator string
    47         void sepSetTuple( ostype &, const char * );                     // set tuple separator to string (15 character maximum)
     47        void sepSetTuple( ostype &, const char [] );            // set tuple separator to string (15 character maximum)
    4848
    4949        void ends( ostype & os );                                                       // end of output statement
    5050        int fail( ostype & );
    5151        int flush( ostype & );
    52         void open( ostype & os, const char * name, const char * mode );
     52        void open( ostype & os, const char name[], const char mode[] );
    5353        void close( ostype & os );
    54         ostype & write( ostype &, const char *, size_t );
     54        ostype & write( ostype &, const char [], size_t );
    5555        int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    5656}; // ostream
     
    6767
    6868forall( dtype ostype | ostream( ostype ) ) {
    69         ostype & ?|?( ostype &, zero_t );
    70         void ?|?( ostype &, zero_t );
    71         ostype & ?|?( ostype &, one_t );
    72         void ?|?( ostype &, one_t );
    73 
    7469        ostype & ?|?( ostype &, bool );
    7570        void ?|?( ostype &, bool );
     
    9893        ostype & ?|?( ostype &, unsigned long long int );
    9994        void ?|?( ostype &, unsigned long long int );
     95#if defined( __SIZEOF_INT128__ )
     96        ostype & ?|?( ostype &, int128 );
     97        void ?|?( ostype &, int128 );
     98        ostype & ?|?( ostype &, unsigned int128 );
     99        void ?|?( ostype &, unsigned int128 );
     100#endif // __SIZEOF_INT128__
    100101
    101102        ostype & ?|?( ostype &, float );
     
    113114        void ?|?( ostype &, long double _Complex );
    114115
    115         ostype & ?|?( ostype &, const char * );
    116         void ?|?( ostype &, const char * );
     116        ostype & ?|?( ostype &, const char [] );
     117        void ?|?( ostype &, const char [] );
    117118        // ostype & ?|?( ostype &, const char16_t * );
    118119#if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous
     
    150151} // distribution
    151152
    152 //*********************************** manipulators ***********************************
     153// *********************************** manipulators ***********************************
    153154
    154155forall( otype T )
     
    160161                unsigned char all;
    161162                struct {
     163                        unsigned char neg:1;                                            // val is negative
    162164                        unsigned char pc:1;                                                     // precision specified
    163165                        unsigned char left:1;                                           // left justify
     
    169171}; // _Ostream_Manip
    170172
    171 //*********************************** integral ***********************************
     173// *********************************** integral ***********************************
    172174
    173175// See 6.7.9. 19) The initialization shall occur in initializer list order, each initializer provided for a particular
     
    206208IntegralFMTDecl( signed long long int, 'd' )
    207209IntegralFMTDecl( unsigned long long int, 'u' )
    208 
    209 //*********************************** floating point ***********************************
     210#if defined( __SIZEOF_INT128__ )
     211IntegralFMTDecl( int128, 'd' )
     212IntegralFMTDecl( unsigned int128, 'u' )
     213#endif // __SIZEOF_INT128__
     214
     215// *********************************** floating point ***********************************
    210216
    211217// Default suffix for values with no fraction is "."
     
    236242FloatingPointFMTDecl( long double )
    237243
    238 //*********************************** character ***********************************
     244// *********************************** character ***********************************
    239245
    240246static inline {
     
    253259} // ?|?
    254260
    255 //*********************************** C string ***********************************
     261// *********************************** C string ***********************************
    256262
    257263static inline {
    258         _Ostream_Manip(const char *) bin( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; }
    259         _Ostream_Manip(const char *) oct( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; }
    260         _Ostream_Manip(const char *) hex( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; }
    261         _Ostream_Manip(const char *) wd( unsigned int w, const char * s ) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; }
    262         _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 } }; }
     264        _Ostream_Manip(const char *) bin( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; }
     265        _Ostream_Manip(const char *) oct( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; }
     266        _Ostream_Manip(const char *) hex( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; }
     267        _Ostream_Manip(const char *) wd( unsigned int w, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; }
     268        _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 } }; }
    263269        _Ostream_Manip(const char *) & wd( unsigned int w, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; return fmt; }
    264270        _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; }
     
    272278
    273279
    274 //*********************************** istream ***********************************
     280// *********************************** istream ***********************************
    275281
    276282
     
    281287        int fail( istype & );
    282288        int eof( istype & );
    283         void open( istype & is, const char * name );
     289        void open( istype & is, const char name[] );
    284290        void close( istype & is );
    285291        istype & read( istype &, char *, size_t );
     
    304310        istype & ?|?( istype &, unsigned int & );
    305311        istype & ?|?( istype &, long int & );
     312        istype & ?|?( istype &, unsigned long int & );
    306313        istype & ?|?( istype &, long long int & );
    307         istype & ?|?( istype &, unsigned long int & );
    308314        istype & ?|?( istype &, unsigned long long int & );
     315#if defined( __SIZEOF_INT128__ )
     316        istype & ?|?( istype &, int128 & );
     317        istype & ?|?( istype &, unsigned int128 & );
     318#endif // __SIZEOF_INT128__
    309319
    310320        istype & ?|?( istype &, float & );
     
    316326        istype & ?|?( istype &, long double _Complex & );
    317327
    318 //      istype & ?|?( istype &, const char * );
     328//      istype & ?|?( istype &, const char [] );
    319329        istype & ?|?( istype &, char * );
    320330
     
    326336} // distribution
    327337
    328 //*********************************** manipulators ***********************************
     338// *********************************** manipulators ***********************************
    329339
    330340struct _Istream_Cstr {
     
    343353static inline {
    344354        _Istream_Cstr skip( unsigned int n ) { return (_Istream_Cstr){ 0p, 0p, n, { .all : 0 } }; }
    345         _Istream_Cstr skip( const char * scanset ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; }
    346         _Istream_Cstr incl( const char * scanset, char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; }
    347         _Istream_Cstr & incl( const char * scanset, _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }
    348         _Istream_Cstr excl( const char * scanset, char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; }
    349         _Istream_Cstr & excl( const char * scanset, _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }
    350         _Istream_Cstr ignore( const char * s ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; }
     355        _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; }
     356        _Istream_Cstr incl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; }
     357        _Istream_Cstr & incl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }
     358        _Istream_Cstr excl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; }
     359        _Istream_Cstr & excl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }
     360        _Istream_Cstr ignore( char s[] ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; }
    351361        _Istream_Cstr & ignore( _Istream_Cstr & fmt ) { fmt.flags.ignore = true; return fmt; }
    352         _Istream_Cstr wdi( unsigned int w, char * s ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; }
     362        _Istream_Cstr wdi( unsigned int w, char s[] ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; }
    353363        _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; }
    354364} // distribution
     
    360370
    361371static inline {
    362         _Istream_Char ignore( const char c ) { return (_Istream_Char)@{ true }; }
     372        _Istream_Char ignore( const char ) { return (_Istream_Char)@{ true }; }
    363373        _Istream_Char & ignore( _Istream_Char & fmt ) { fmt.ignore = true; return fmt; }
    364374} // distribution
    365375forall( dtype istype | istream( istype ) ) istype & ?|?( istype & is, _Istream_Char f );
    366376
    367 forall( otype T )
     377forall( dtype T | sized( T ) )
    368378struct _Istream_Manip {
    369379        T & val;                                                                                        // polymorphic base-type
     
    403413
    404414
    405 //*********************************** time ***********************************
     415// *********************************** time ***********************************
    406416
    407417
Note: See TracChangeset for help on using the changeset viewer.