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/collections/string_res.hfa

    ra22d148 r211def2  
    1010// Created On       : Fri Sep 03 11:00:00 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan  4 11:28:06 2024
    13 // Update Count     : 27
     12// Last Modified On : Wed Feb  7 21:24:40 2024
     13// Update Count     : 59
    1414//
    1515
     
    123123void ?|?(ofstream & out, const string_res & s);
    124124ifstream & ?|?(ifstream & in, string_res & s);
    125 void ?|?( ifstream & in, string_res & s );
     125
     126struct _Istream_Rwidth {
     127        string_res * s;
     128        inline _Istream_str_base;
     129}; // _Istream_Rwidth
     130
     131struct _Istream_Rquoted {
     132        // string_res * s;
     133        // inline _Istream_str_base;
     134        _Istream_Rwidth rstr;
     135}; // _Istream_Rquoted
    126136
    127137struct _Istream_Rstr {
    128138        string_res * s;
    129139        inline _Istream_str_base;
     140//      _Istream_Rwidth rstr;
    130141}; // _Istream_Rstr
    131142
    132143static inline {
    133144        // read width does not include null terminator
    134         _Istream_Rstr wdi( unsigned int rwd, string_res & s ) { return (_Istream_Rstr)@{ &s, {{0p}, rwd, {.flags.rwd : true}} }; }
     145        _Istream_Rwidth wdi( unsigned int rwd, string_res & s ) { return (_Istream_Rwidth)@{ .s : &s, { {.scanset : 0p}, .wd : rwd, {.flags.rwd : true} } }; }
    135146        _Istream_Rstr getline( string_res & s, const char delimiter = '\n' ) {
    136                 return (_Istream_Rstr)@{ &s, {{.delimiters : { delimiter, '\0' } }, -1, {.flags.delimiter : true, .flags.inex : true}} };
    137         }
    138         _Istream_Rstr & getline( _Istream_Rstr & fmt, const char delimiter = '\n' ) {
    139                 fmt.delimiters[0] = delimiter; fmt.delimiters[1] = '\0'; fmt.flags.delimiter = true; fmt.flags.inex = true; return fmt;
    140         }
    141         _Istream_Rstr incl( const char scanset[], string_res & s ) { return (_Istream_Rstr)@{ &s, {{scanset}, -1, {.flags.inex : false}} }; }
    142         _Istream_Rstr & incl( const char scanset[], _Istream_Rstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }
    143         _Istream_Rstr excl( const char scanset[], string_res & s ) { return (_Istream_Rstr)@{ &s, {{scanset}, -1, {.flags.inex : true}} }; }
    144         _Istream_Rstr & excl( const char scanset[], _Istream_Rstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }
    145         _Istream_Rstr ignore( string_res & s ) { return (_Istream_Rstr)@{ &s, {{0p}, -1, {.flags.ignore : true}} }; }
    146         _Istream_Rstr & ignore( _Istream_Rstr & fmt ) { fmt.flags.ignore = true; return fmt; }
     147//              return (_Istream_Rstr)@{ { .s : &s, { {.delimiters : { delimiter, '\0' } }, .wd : -1, {.flags.delimiter : true} } } };
     148                return (_Istream_Rstr)@{ .s : &s, { {.delimiters : { delimiter, '\0' } }, .wd : -1, {.flags.delimiter : true} } };
     149        }
     150        _Istream_Rstr & getline( _Istream_Rwidth & f, const char delimiter = '\n' ) {
     151                f.delimiters[0] = delimiter; f.delimiters[1] = '\0'; f.flags.delimiter = true; return (_Istream_Rstr &)f;
     152        }
     153        _Istream_Rquoted quoted( string_res & s, const char Ldelimiter = '\"', const char Rdelimiter = '\0' ) {
     154                return (_Istream_Rquoted)@{ { .s : &s, { {.delimiters : { Ldelimiter, Rdelimiter, '\0' }}, .wd : -1, {.flags.rwd : true} } } };
     155        }
     156        _Istream_Rquoted & quoted( _Istream_Rwidth & f, const char Ldelimiter = '"', const char Rdelimiter = '\0' ) {
     157                f.delimiters[0] = Ldelimiter;  f.delimiters[1] = Rdelimiter;  f.delimiters[2] = '\0';
     158                return (_Istream_Rquoted &)f;
     159        }
     160        _Istream_Rstr incl( const char scanset[], string_res & s ) { return (_Istream_Rstr)@{ .s : &s, { {.scanset : scanset}, .wd : -1, {.flags.inex : false} } }; }
     161        _Istream_Rstr & incl( const char scanset[], _Istream_Rwidth & f ) { f.scanset = scanset; f.flags.inex = false; return (_Istream_Rstr &)f; }
     162        _Istream_Rstr excl( const char scanset[], string_res & s ) { return (_Istream_Rstr)@{ .s : &s, { {.scanset : scanset}, .wd : -1, {.flags.inex : true} } }; }
     163        _Istream_Rstr & excl( const char scanset[], _Istream_Rwidth & f ) { f.scanset = scanset; f.flags.inex = true; return (_Istream_Rstr &)f; }
     164        _Istream_Rstr ignore( string_res & s ) { return (_Istream_Rstr)@{ .s : &s, { {.scanset : 0p}, .wd : -1, {.flags.ignore : true} } }; }
     165        _Istream_Rstr & ignore( _Istream_Rwidth & f ) { f.flags.ignore = true; return (_Istream_Rstr &)f; }
     166        _Istream_Rquoted & ignore( _Istream_Rquoted & f ) { f.rstr.flags.ignore = true; return (_Istream_Rquoted &)f; }
     167        _Istream_Rstr & ignore( _Istream_Rstr & f ) { f.flags.ignore = true; return (_Istream_Rstr &)f; }
    147168} // distribution
     169ifstream & ?|?( ifstream & is, _Istream_Rquoted f );
    148170ifstream & ?|?( ifstream & is, _Istream_Rstr f );
    149 void ?|?( ifstream & is, _Istream_Rstr t );
     171static inline ifstream & ?|?( ifstream & is, _Istream_Rwidth f ) { return is | *(_Istream_Rstr *)&f; }
    150172
    151173// Concatenation
Note: See TracChangeset for help on using the changeset viewer.