lilypond-1.4.3
[lilypond.git] / flower / datafile.cc
blobe5940b4c40648d69a36a897c0aa44cb6bd369abf
1 #include <fstream.h>
2 #include <ctype.h>
4 #include "datafile.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()) {
87 char c = data_get();
88 if (!isspace(c)) {
89 data_unget(c);
90 break;