Changeset 2286 in Sophya for trunk/SophyaLib/TArray/utilarr.cc
- Timestamp:
- Dec 5, 2002, 12:15:55 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/utilarr.cc
r2149 r2286 195 195 /*! 196 196 \param str : string to be decoded 197 \param nbad : number of unmatched quotes or parenthesis 197 \param nbad : number of unmatched quotes or parenthesis (returned value) 198 \param sep : word separator in string. Each word is decoded as a MuTyV value. 198 199 \return the number of added elements. 199 200 */ 200 sa_size_t EnumeratedSequence::Append(string const & str, int& nbad )201 sa_size_t EnumeratedSequence::Append(string const & str, int& nbad, const char* sep) 201 202 { 202 203 nbad = 0; … … 204 205 size_t l = str.length(); 205 206 if (l < 1) return(0); 206 if ((str[0] == '#') || (str[0] == '*')) return(0);207 // if ((str[0] == '#') || (str[0] == '*')) return(0); 207 208 size_t q = 0; 208 size_t p = str.find_first_not_of(" \t"); 209 size_t p = 0; 210 /* 211 size_t p = str.find_first_not_of(sep); 209 212 if ((str[p] == '+') || (str[p] == '-')) { 210 213 if (p == l-1) return(0); … … 212 215 } 213 216 else if (!isdigit(str[p]) && (str[p] != '\'') && (str[p] != '(') ) return(0); 214 217 */ 215 218 while(q < l) { 216 p = str.find_first_not_of( " \t",q);219 p = str.find_first_not_of(sep,q); 217 220 if (p >= l) break; 218 221 if (str[p] == '\'') { // Decodage d'un string … … 236 239 } 237 240 else { 238 q = str.find_first_of( " \t",p);241 q = str.find_first_of(sep,p); 239 242 if (!isdigit(str[p]) && !(str[p] == '+') && !(str[p] == '-') ) { // une chaine 240 continue;243 vecv_.push_back(MuTyV(str.substr(p,q-p))); 241 244 } 242 245 else { // C'est un nombre … … 260 263 \param nr : Number of non empty (or comment) lines in stream (return value) 261 264 \param nc : Number of columns (= ntot/nlines) (return value) 265 \param clm : Lines starting with clm character are treated as comment lines 266 \param sep : word separator in lines 262 267 \return Number of decoded elements 263 268 */ 264 sa_size_t EnumeratedSequence::FillFromFile(istream& is, 265 sa_size_t& nr, sa_size_t& nc)269 sa_size_t EnumeratedSequence::FillFromFile(istream& is, sa_size_t& nr, sa_size_t& nc, 270 char clm, const char* sep) 266 271 { 267 272 nr = 0; … … 278 283 line += buff; 279 284 if (is.good()) { 280 nel = Append(line, nbad); 281 // cout << " Decoding line = " << line << " Nel= " << nel << endl; 282 if (nel > 0) { 283 nr++; n += nel; 284 } 285 nbadtot += nbad; 285 if ((line.length() > 0) && (line[0]!=clm)) { 286 nel = Append(line, nbad); 287 if (nel > 0) { 288 nr++; n += nel; 289 } 290 nbadtot += nbad; 291 } 292 cout << " Decoding line = " << line << " Nel= " << nel << endl; 286 293 line = ""; 287 294 } 288 295 } 289 if ( line.length() > 0) {296 if ((line.length() > 0) && (line[0]!=clm)) { 290 297 nel = Append(line, nbad); 291 //cout << " Decoding Eline = " << line << " Nel= " << nel << endl;298 cout << " Decoding Eline = " << line << " Nel= " << nel << endl; 292 299 if (nel > 0) { 293 300 nr++; n += nel;
Note:
See TracChangeset
for help on using the changeset viewer.