comparison src/ls-oct-ascii.cc @ 5103:e2ed74b9bfa0 after-gnuplot-split

[project @ 2004-12-28 02:43:01 by jwe]
author jwe
date Tue, 28 Dec 2004 02:43:01 +0000
parents 5a92c3177fc6
children 23b37da9fd5b
comparison
equal deleted inserted replaced
5102:b04b30d30c66 5103:e2ed74b9bfa0
297 } 297 }
298 } 298 }
299 return status; 299 return status;
300 } 300 }
301 301
302 // Match one of the elements in KEYWORDS on stream IS, placing the
303 // matched keyword in KW and the associated value in VALUE,
304 // returning TRUE if successful and FALSE otherwise.
305 //
306 // Input should look something like:
307 //
308 // [%#][ \t]*keyword[ \t]*int-value.*\n
309
310 bool
311 extract_keyword (std::istream& is, const string_vector& keywords,
312 std::string& kw, int& value, const bool next_only)
313 {
314 bool status = false;
315 kw = "";
316 value = 0;
317
318 char c;
319 while (is.get (c))
320 {
321 if (c == '%' || c == '#')
322 {
323 OSSTREAM buf;
324
325 while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#'))
326 ; // Skip whitespace and comment characters.
327
328 if (isalpha (c))
329 buf << c;
330
331 while (is.get (c) && isalpha (c))
332 buf << c;
333
334 buf << OSSTREAM_ENDS;
335 std::string tmp = OSSTREAM_STR (buf);
336 OSSTREAM_FREEZE (buf);
337
338 for (int i = 0; i < keywords.length (); i++)
339 {
340 int match = (tmp == keywords[i]);
341
342 if (match)
343 {
344 kw = keywords[i];
345
346 while (is.get (c) && (c == ' ' || c == '\t' || c == ':'))
347 ; // Skip whitespace and the colon.
348
349 is.putback (c);
350 if (c != '\n')
351 is >> value;
352 if (is)
353 status = true;
354 while (is.get (c) && c != '\n')
355 ; // Skip to beginning of next line;
356 return status;
357 }
358 }
359
360 if (next_only)
361 break;
362 }
363 }
364 return status;
365 }
366
367 // Extract one value (scalar, matrix, string, etc.) from stream IS and 302 // Extract one value (scalar, matrix, string, etc.) from stream IS and
368 // place it in TC, returning the name of the variable. If the value 303 // place it in TC, returning the name of the variable. If the value
369 // is tagged as global in the file, return TRUE in GLOBAL. 304 // is tagged as global in the file, return TRUE in GLOBAL.
370 // 305 //
371 // Each type supplies its own function to load the data, and so this 306 // Each type supplies its own function to load the data, and so this