source: trunk/gsdl/lib/cfgread.cpp@ 100

Last change on this file since 100 was 100, checked in by rjmcnab, 25 years ago

Added standard header to source files.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.3 KB
Line 
1/**********************************************************************
2 *
3 * cfgread.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: cfgread.cpp 100 1999-01-08 02:33:16Z rjmcnab $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
14 Revision 1.2 1999/01/08 02:33:13 rjmcnab
15
16 Added standard header to source files.
17
18 */
19
20static char *RCSID = "$Id: cfgread.cpp 100 1999-01-08 02:33:16Z rjmcnab $";
21
22
23#include "cfgread.h"
24
25
26// returns 0 on success, -1 on failure
27int read_cfg_line (ifstream &filein, text_tarray &values) {
28 values.erase(values.begin(), values.end());
29
30 if (!filein.good()) return -1;
31
32 text_t curvalue;
33 char c;
34
35 int firstchar = 1;
36 filein.get(c);
37 while (!filein.eof()) {
38 if (c == '#' && firstchar) {
39 // found a comment, ignore the rest of the line
40 while (!filein.eof() && c != '\n') {
41 filein.get(c);
42 }
43
44 } else if (firstchar && (c == '\n' || c == ' ' || c == '\t')) {
45 // found initial white space, ignore it
46
47 } else if (c == '\n') {
48 // found the end of an entry
49 break;
50
51 } else if (c == '\t') {
52 // found a record separator
53 values.push_back(curvalue);
54 curvalue.clear();
55
56 } else {
57 curvalue.push_back(c);
58 firstchar = 0;
59 }
60
61 filein.get(c);
62 }
63
64 values.push_back(curvalue);
65
66 return 0;
67}
Note: See TracBrowser for help on using the repository browser.