Changeset 211def2 for libcfa/src/iostream.hfa
- Timestamp:
- Feb 7, 2024, 10:54:16 PM (3 months ago)
- Branches:
- master
- Children:
- 956299b
- Parents:
- a22d148
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.hfa
ra22d148 r211def2 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 28 11:56:29202413 // Update Count : 7 3312 // Last Modified On : Tue Feb 6 18:35:54 2024 13 // Update Count : 743 14 14 // 15 15 … … 370 370 // *********************************** exceptions *********************************** 371 371 372 ExceptionDecl( cstring_length ); 373 ExceptionDecl( missing_data ); 372 ExceptionDecl( missing_data ); // read finds no appropriate data 373 ExceptionDecl( cstring_length ); // character string size exceeded 374 ExceptionDecl( data_range ); // value too large for numerical type 374 375 375 376 // *********************************** manipulators *********************************** … … 406 407 char * s; 407 408 inline _Istream_str_base; 408 }; // _Istream_C str409 }; // _Istream_Cwidth 409 410 410 411 // Restrict nesting of input manipulators to those combinations that make sense. 412 413 struct _Istream_Cquoted { 414 _Istream_Cwidth cstr; 415 }; // _Istream_Cquoted 411 416 412 417 struct _Istream_Cstr { … … 414 419 }; // _Istream_Cstr 415 420 416 struct _Istream_Cquoted {417 _Istream_Cwidth cstr;418 }; // _Istream_Cquoted419 420 421 static inline { 421 422 // 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); 422 423 _Istream_Cwidth wdi( unsigned int wd, char s[] ) { 423 if ( wd <= 1 ) throw (cstring_length){ &cstring_length_vt }; // minimum 1 character and null terminator424 if ( wd <= 1 ) throwResume ExceptionInst( cstring_length ); // minimum 1 character and null terminator 424 425 return (_Istream_Cwidth)@{ .s : s, { {.scanset : 0p}, .wd : wd, {.all : 0} } }; 425 426 } 426 427 _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 subset428 if ( wd <= 1 || wd <= rwd ) throwResume ExceptionInst( cstring_length ); // minimum 1 character, null terminator, plus subset 428 429 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; 429 433 } 430 434 _Istream_Cquoted quoted( char & ch, const char Ldelimiter = '\'', const char Rdelimiter = '\0' ) { … … 435 439 return (_Istream_Cquoted &)f; 436 440 } 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 }440 441 _Istream_Cstr & incl( const char scanset[], _Istream_Cwidth & f ) { f.scanset = scanset; f.flags.inex = false; return (_Istream_Cstr &)f; } 441 442 _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_C width)@{ .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} } } }; } 443 444 _Istream_Cstr & ignore( _Istream_Cwidth & f ) { f.flags.ignore = true; return (_Istream_Cstr &)f; } 444 445 _Istream_Cquoted & ignore( _Istream_Cquoted & f ) { f.cstr.flags.ignore = true; return (_Istream_Cquoted &)f; } … … 450 451 istype & ?|?( istype & is, _Istream_Cquoted f ); 451 452 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; } 455 454 } // distribution 456 455
Note: See TracChangeset
for help on using the changeset viewer.