- Timestamp:
- Aug 24, 2023, 11:39:08 AM (12 months ago)
- Branches:
- master
- Children:
- aa25216
- Parents:
- 5ad2c6c7
- Location:
- libcfa/src/containers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/containers/string.cfa
r5ad2c6c7 r88001dd 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 13 22:50:08202313 // Update Count : 712 // Last Modified On : Thu Aug 24 11:27:57 2023 13 // Update Count : 89 14 14 // 15 15 … … 118 118 } 119 119 120 void getline( ifstream & in, string & str, const char delimit = '\n' ) { 121 // .---------------, 122 // | | | | |...|0|0| check and guard 123 // `---------------' 124 enum { gwd = 256 + 2, wd = gwd - 1 }; // guarded and unguarded width 125 char cstr[gwd]; // read in chunks 126 bool cont = false;; 127 128 cstr[wd] = '\0'; // guard null terminate string 129 try { 130 in | getline( wdi( wd, cstr ), delimit ); // must have room for string terminator 131 if ( eof( in ) ) return; // do not change argument 132 } catch( cstring_length * ) { 133 cont = true; // continue not allowed 134 } finally { 135 str = cstr; // ok to initialize string 136 } // try 137 for ( ; cont; ) { // overflow read ? 138 cont = false; 139 try { 140 in | getline( wdi( wd, cstr ), delimit ); // must have room for string terminator 141 if ( eof( in ) ) return; 142 } catch( cstring_length * ) { 143 cont = true; // continue not allowed 144 } finally { 145 str += cstr; // build string chunk at a time 146 } // try 147 } // for 148 } 149 120 150 //////////////////////////////////////////////////////// 121 151 // Slicing -
libcfa/src/containers/string.hfa
r5ad2c6c7 r88001dd 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 13 22:46:46202313 // Update Count : 412 // Last Modified On : Wed Aug 23 11:16:14 2023 13 // Update Count : 6 14 14 // 15 15 … … 57 57 ifstream & ?|?(ifstream & in, string & s); 58 58 void ?|?( ifstream & in, string & this ); 59 void getline( ifstream & in, string & this, const char delimit = '\n' ); 59 60 60 61 // Concatenation
Note: See TracChangeset
for help on using the changeset viewer.