Ignore:
Timestamp:
Feb 7, 2024, 10:54:16 PM (3 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
956299b
Parents:
a22d148
Message:

omnibus I/O changes to get quoted manipulator to work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.hfa

    ra22d148 r211def2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jan 28 11:56:29 2024
    13 // Update Count     : 733
     12// Last Modified On : Tue Feb  6 18:35:54 2024
     13// Update Count     : 743
    1414//
    1515
     
    370370// *********************************** exceptions ***********************************
    371371
    372 ExceptionDecl( cstring_length );
    373 ExceptionDecl( missing_data );
     372ExceptionDecl( missing_data );                                                  // read finds no appropriate data
     373ExceptionDecl( cstring_length );                                                // character string size exceeded
     374ExceptionDecl( data_range );                                                    // value too large for numerical type
    374375
    375376// *********************************** manipulators ***********************************
     
    406407        char * s;
    407408        inline _Istream_str_base;
    408 }; // _Istream_Cstr
     409}; // _Istream_Cwidth
    409410
    410411// Restrict nesting of input manipulators to those combinations that make sense.
     412
     413struct _Istream_Cquoted {
     414        _Istream_Cwidth cstr;
     415}; // _Istream_Cquoted
    411416
    412417struct _Istream_Cstr {
     
    414419}; // _Istream_Cstr
    415420
    416 struct _Istream_Cquoted {
    417         _Istream_Cwidth cstr;
    418 }; // _Istream_Cquoted
    419 
    420421static inline {
    421422        // width must include room for null terminator, (gcc) scanf does not allow a 0 width => wd > 1 (1 char and null) and rd > 0 (1 char);
    422423        _Istream_Cwidth wdi( unsigned int wd, char s[] ) {
    423                 if ( wd <= 1 ) throw (cstring_length){ &cstring_length_vt }; // minimum 1 character and null terminator
     424                if ( wd <= 1 ) throwResume ExceptionInst( cstring_length ); // minimum 1 character and null terminator
    424425                return (_Istream_Cwidth)@{ .s : s, { {.scanset : 0p}, .wd : wd, {.all : 0} } };
    425426        }
    426427        _Istream_Cwidth wdi( unsigned int wd, unsigned int rwd, char s[] ) {
    427                 if ( wd <= 1 || wd <= rwd ) throw (cstring_length){ &cstring_length_vt }; // minimum 1 character, null terminator, plus subset
     428                if ( wd <= 1 || wd <= rwd ) throwResume ExceptionInst( cstring_length ); // minimum 1 character, null terminator, plus subset
    428429                return (_Istream_Cwidth)@{ .s : s, { {.scanset : 0p}, .wd : rwd, {.flags.rwd : true} } };
     430        }
     431        _Istream_Cstr & getline( _Istream_Cwidth & f, const char delimiter = '\n' ) {
     432                f.delimiters[0] = delimiter; f.delimiters[1] = '\0'; f.flags.delimiter = true; return (_Istream_Cstr &)f;
    429433        }
    430434        _Istream_Cquoted quoted( char & ch, const char Ldelimiter = '\'', const char Rdelimiter = '\0' ) {
     
    435439                return (_Istream_Cquoted &)f;
    436440        }
    437         _Istream_Cstr & getline( _Istream_Cwidth & f, const char delimiter = '\n' ) {
    438                 f.delimiters[0] = delimiter; f.delimiters[1] = '\0'; f.flags.delimiter = true; return (_Istream_Cstr &)f;
    439         }
    440441        _Istream_Cstr & incl( const char scanset[], _Istream_Cwidth & f ) { f.scanset = scanset; f.flags.inex = false; return (_Istream_Cstr &)f; }
    441442        _Istream_Cstr & excl( const char scanset[], _Istream_Cwidth & f ) { f.scanset = scanset; f.flags.inex = true; return (_Istream_Cstr &)f; }
    442         _Istream_Cstr ignore( const char s[] ) { return (_Istream_Cwidth)@{ .s : (char *)s, { {.scanset : 0p}, .wd : -1, {.flags.ignore : true} } }; }
     443        _Istream_Cstr ignore( const char s[] ) { return (_Istream_Cstr)@{ { .s : (char *)s, { {.scanset : 0p}, .wd : -1, {.flags.ignore : true} } } }; }
    443444        _Istream_Cstr & ignore( _Istream_Cwidth & f ) { f.flags.ignore = true; return (_Istream_Cstr &)f; }
    444445        _Istream_Cquoted & ignore( _Istream_Cquoted & f ) { f.cstr.flags.ignore = true; return (_Istream_Cquoted &)f; }
     
    450451        istype & ?|?( istype & is, _Istream_Cquoted f );
    451452        istype & ?|?( istype & is, _Istream_Cstr f );
    452         static inline {
    453                 istype & ?|?( istype & is, _Istream_Cwidth f ) { return is | *(_Istream_Cstr *)&f; }
    454         } // distribution
     453        static inline istype & ?|?( istype & is, _Istream_Cwidth f ) { return is | *(_Istream_Cstr *)&f; }
    455454} // distribution
    456455
Note: See TracChangeset for help on using the changeset viewer.