lilypond-0.1.16
[lilypond.git] / flower / data-file.cc
blob251380d3c806f5a11a16a0696253019e181ccccb
1 #include <fstream.h>
2 #include <ctype.h>
4 #include "data-file.hh"
6 void
7 Data_file::gobble_white()
9 char c;
11 while ((c=data_get()) == ' ' ||c == '\t')
12 if (eof())
13 break;
15 data_unget (c);
18 String
19 Data_file::get_word()
20 {// should handle escape seq's
21 String s;
23 while (1)
25 char c = data_get();
27 if (isspace (c) || eof())
29 data_unget (c);
30 break;
34 if (c == '\"')
36 rawmode= true;
38 while ((c = data_get()) != '\"')
39 if (eof())
40 error ("EOF in a string");
41 else
42 s += c;
45 rawmode= false;
47 else
48 s += c;
51 return s;
54 /** get a char
55 Only class member who uses text_file::get
57 char
58 Data_file::data_get() {
59 char c = get();
60 if (!rawmode && c == '#') // gobble comment
62 while ((c = get()) != '\n' && !eof ())
64 return '\n';
67 return c;
70 /// read line, gobble '\n'
71 String Data_file::get_line()
73 char c;
74 String s;
76 while ((c = data_get()) != '\n' && !eof ())
77 s += c;
78 return s;
81 /// gobble stuff before first entry on a line.
82 void
83 Data_file::gobble_leading_white()
85 // eat blank lines.
86 while (!eof())
88 char c = data_get();
89 if (!isspace (c))
91 data_unget (c);
92 break;