Ignore:
Timestamp:
Aug 30, 2023, 11:20:14 AM (10 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
55b060d
Parents:
7e1dbd7
Message:

second attempt at input manipulators for strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.hfa

    r7e1dbd7 r38de914  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug 25 14:55:06 2023
    13 // Update Count     : 535
     12// Last Modified On : Tue Aug 29 19:15:06 2023
     13// Update Count     : 542
    1414//
    1515
     
    406406// *********************************** manipulators ***********************************
    407407
    408 struct _Istream_Cstr {
    409         char * s;
     408struct _Istream_str_base {
    410409        union {
    411410                const char * scanset;
     
    422421                } flags;
    423422        };
     423}; // _Istream_str_base
     424
     425struct _Istream_Cstr {
     426        char * s;
     427        inline _Istream_str_base;
    424428}; // _Istream_Cstr
    425429
    426430static inline {
    427431        // width must include room for null terminator
    428         _Istream_Cstr wdi( unsigned int wd, char s[] ) { return (_Istream_Cstr)@{ s, {0p}, wd, {.all : 0} }; }
     432        _Istream_Cstr wdi( unsigned int wd, char s[] ) { return (_Istream_Cstr)@{ s, { {0p}, wd, {.all : 0} } }; }
    429433        // read width does not include null terminator
    430434        _Istream_Cstr wdi( unsigned int wd, unsigned int rwd, char s[] ) {
    431435                if ( wd <= rwd ) throw (cstring_length){ &cstring_length_vt };
    432                 return (_Istream_Cstr)@{ s, {0p}, rwd, {.flags.rwd : true} };
     436                return (_Istream_Cstr)@{ s, { {0p}, rwd, {.flags.rwd : true} } };
    433437        }
    434         _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr)@{ 0p, {scanset}, -1, {.all : 0} }; }
    435         _Istream_Cstr skip( unsigned int wd ) { return (_Istream_Cstr)@{ 0p, {0p}, wd, {.all : 0} }; }
     438        _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr)@{ 0p, { {scanset}, -1, {.all : 0} } }; }
     439        _Istream_Cstr skip( unsigned int wd ) { return (_Istream_Cstr)@{ 0p, { {0p}, wd, {.all : 0} } }; }
    436440        _Istream_Cstr & getline( _Istream_Cstr & fmt, const char delimit = '\n' ) {
    437441                fmt.delimit[0] = delimit; fmt.delimit[1] = '\0'; fmt.flags.delimit = true; fmt.flags.inex = true; return fmt; }
    438442        _Istream_Cstr & incl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }
    439443        _Istream_Cstr & excl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }
    440         _Istream_Cstr ignore( char s[] ) { return (_Istream_Cstr)@{ s, {0p}, -1, {.flags.ignore : true} }; }
     444        _Istream_Cstr ignore( char s[] ) { return (_Istream_Cstr)@{ s, { {0p}, -1, {.flags.ignore : true} } }; }
    441445        _Istream_Cstr & ignore( _Istream_Cstr & fmt ) { fmt.flags.ignore = true; return fmt; }
    442446} // distribution
    443447forall( istype & | basic_istream( istype ) ) {
     448        void readstr( istype & is, _Istream_str_base f, char fmtstr[], char cstr[] );
    444449        istype & ?|?( istype & is, _Istream_Cstr f );
    445450        ISTYPE_VOID( _Istream_Cstr );
Note: See TracChangeset for help on using the changeset viewer.