Changeset 85d8153 for libcfa


Ignore:
Timestamp:
Apr 24, 2021, 11:27:45 AM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b431515
Parents:
e638266
Message:

divide ostream trait into basic_ostream and ostream where the former is used by strstream

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    re638266 r85d8153  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 20 19:09:41 2021
    13 // Update Count     : 1325
     12// Last Modified On : Sat Apr 24 10:03:54 2021
     13// Update Count     : 1329
    1414//
    1515
     
    3636
    3737
    38 forall( ostype & | ostream( ostype ) ) {
     38forall( ostype & | basic_ostream( ostype ) ) {
    3939        ostype & ?|?( ostype & os, bool b ) {
    4040                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
     
    294294
    295295                // last character IS spacing or opening punctuation => turn off separator for next item
    296                 size_t len = strlen( s );
     296                int len = strlen( s );
    297297                ch = s[len - 1];                                                                // must make unsigned
     298                fmt( os, "%s", s );                                                             // fmt resets seperator, but reset it again
    298299                if ( sepPrt$( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    299300                        sepOn( os );
     
    302303                } // if
    303304                if ( ch == '\n' ) setNL$( os, true );                   // check *AFTER* sepPrt$ call above as it resets NL flag
    304                 return write( os, s, len );
     305                return os;
     306//              return write( os, s, len );
    305307        } // ?|?
    306308        void ?|?( ostype & os, const char s[] ) {
     
    397399                return os;
    398400        } // nlOff
    399 
     401} // distribution
     402
     403forall( ostype & | ostream( ostype ) ) {
    400404        ostype & acquire( ostype & os ) {
    401405                acquire( os );                                                                  // call void returning
     
    445449// Default prefix for non-decimal prints is 0b, 0, 0x.
    446450#define IntegralFMTImpl( T, IFMTNP, IFMTP ) \
    447 forall( ostype & | ostream( ostype ) ) { \
     451forall( ostype & | basic_ostream( ostype ) ) { \
    448452        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    449453                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); \
     
    539543#if defined( __SIZEOF_INT128__ )
    540544// Default prefix for non-decimal prints is 0b, 0, 0x.
    541 forall( ostype & | ostream( ostype ) )
     545forall( ostype & | basic_ostream( ostype ) )
    542546static inline void base_128( ostype & os, unsigned int128 val, unsigned int128 power, _Ostream_Manip(uint64_t) & f, unsigned int maxdig, unsigned int bits, unsigned int cnt = 0 ) {
    543547        int wd = 1;                                                                                     // f.wd is never 0 because 0 implies left-pad
     
    604608
    605609#define IntegralFMTImpl128( T ) \
    606 forall( ostype & | ostream( ostype ) ) { \
     610forall( ostype & | basic_ostream( ostype ) ) { \
    607611        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    608612                _Ostream_Manip(uint64_t) fmt; \
     
    677681
    678682#define FloatingPointFMTImpl( T, DFMTNP, DFMTP ) \
    679 forall( ostype & | ostream( ostype ) ) { \
     683forall( ostype & | basic_ostream( ostype ) ) { \
    680684        static void eng( T &value, int & pc, int & exp10 ) { \
    681685                exp10 = lrint( floor( log10( abs( value ) ) ) ); /* round to desired precision */ \
     
    723727// *********************************** character ***********************************
    724728
    725 forall( ostype & | ostream( ostype ) ) {
     729forall( ostype & | basic_ostream( ostype ) ) {
    726730        ostype & ?|?( ostype & os, _Ostream_Manip(char) f ) {
    727731                if ( f.base != 'c' ) {                                                  // bespoke binary/octal/hex format
     
    756760// *********************************** C string ***********************************
    757761
    758 forall( ostype & | ostream( ostype ) ) {
     762forall( ostype & | basic_ostream( ostype ) ) {
    759763        ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f ) {
    760764                if ( ! f.val ) return os;                                               // null pointer ?
  • libcfa/src/iostream.hfa

    re638266 r85d8153  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 20 19:09:44 2021
    13 // Update Count     : 385
     12// Last Modified On : Sat Apr 24 09:28:56 2021
     13// Update Count     : 393
    1414//
    1515
     
    2222
    2323
    24 trait ostream( ostype & ) {
     24trait basic_ostream( ostype & ) {
    2525        // private
    2626        bool sepPrt$( ostype & );                                                       // get separator state (on/off)
     
    4747        void sepSetTuple( ostype &, const char [] );            // set tuple separator to string (15 character maximum)
    4848
    49         void ends( ostype & os );                                                       // end of output statement
    50         int fail( ostype & );
     49        void ends( ostype & );                                                          // end of output statement
     50        int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    5151        int flush( ostype & );
    52         void open( ostype & os, const char name[], const char mode[] );
    53         void close( ostype & os );
     52}; // basic_ostream
     53       
     54trait ostream( ostype & | basic_ostream( ostype ) ) {
     55        bool fail( ostype & );                                                          // operation failed?
     56        void open( ostype &, const char name[], const char mode[] );
     57        void close( ostype & );
    5458        ostype & write( ostype &, const char [], size_t );
    55         int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    56         void acquire( ostype & );
     59        void acquire( ostype & );                                                       // concurrent access
    5760}; // ostream
    5861
     
    6770// implement writable for intrinsic types
    6871
    69 forall( ostype & | ostream( ostype ) ) {
     72forall( ostype & | basic_ostream( ostype ) ) {
    7073        ostype & ?|?( ostype &, bool );
    7174        void ?|?( ostype &, bool );
     
    138141        ostype & nlOn( ostype & );
    139142        ostype & nlOff( ostype & );
     143} // distribution
     144
     145forall( ostype & | ostream( ostype ) ) {
    140146        ostype & acquire( ostype & );
    141147} // distribution
     
    196202        _Ostream_Manip(T) & sign( _Ostream_Manip(T) & fmt ) { fmt.flags.sign = true; return fmt; } \
    197203} /* distribution */ \
    198 forall( ostype & | ostream( ostype ) ) { \
     204forall( ostype & | basic_ostream( ostype ) ) { \
    199205        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \
    200206        void ?|?( ostype & os, _Ostream_Manip(T) f ); \
     
    241247        _Ostream_Manip(T) & unit( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \
    242248} /* distribution */ \
    243 forall( ostype & | ostream( ostype ) ) { \
     249forall( ostype & | basic_ostream( ostype ) ) { \
    244250        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \
    245251        void ?|?( ostype & os, _Ostream_Manip(T) f ); \
     
    261267        _Ostream_Manip(char) & nobase( _Ostream_Manip(char) & fmt ) { fmt.flags.nobsdp = true; return fmt; }
    262268} // distribution
    263 forall( ostype & | ostream( ostype ) ) {
     269forall( ostype & | basic_ostream( ostype ) ) {
    264270        ostype & ?|?( ostype & os, _Ostream_Manip(char) f );
    265271        void ?|?( ostype & os, _Ostream_Manip(char) f );
     
    279285        _Ostream_Manip(const char *) & nobase( _Ostream_Manip(const char *) & fmt ) { fmt.flags.nobsdp = true; return fmt; }
    280286} // distribution
    281 forall( ostype & | ostream( ostype ) ) {
     287forall( ostype & | basic_ostream( ostype ) ) {
    282288        ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f );
    283289        void ?|?( ostype & os, _Ostream_Manip(const char *) f );
     
    294300
    295301        void ends( istype & os );                                                       // end of output statement
    296         int fail( istype & );
     302        bool fail( istype & );
    297303        int eof( istype & );
    298304        void open( istype & is, const char name[] );
Note: See TracChangeset for help on using the changeset viewer.