lilypond-0.1.37
[lilypond.git] / flower / data-file.cc
blob5a273c5dbb6b33b5f022b289a05f3a26d8266169
1 /*
2 data-file.cc -- implement Data_file
4 source file of the Flower Library
6 (c) '95, '96, '97 Han-Wen Nienhuys <hanwen@stack.nl>
8 */
9 #include <fstream.h>
10 #include <ctype.h>
12 #include "international.hh"
13 #include "data-file.hh"
15 void
16 Data_file::gobble_white()
18 char c;
20 while ((c=data_get()) == ' ' ||c == '\t')
21 if (eof())
22 break;
24 data_unget (c);
27 String
28 Data_file::get_word()
29 {// should handle escape seq's
30 String s;
32 while (1)
34 char c = data_get();
36 if (isspace (c) || eof())
38 data_unget (c);
39 break;
43 if (c == '\"')
45 rawmode= true;
47 while ((c = data_get()) != '\"')
48 if (eof())
49 error (_("EOF in a string"));
50 else
51 s += c;
54 rawmode= false;
56 else
57 s += c;
60 return s;
63 /** get a char
64 Only class member who uses text_file::get
66 char
67 Data_file::data_get() {
68 char c = get();
69 if (!rawmode && c == '#') // gobble comment
71 while ((c = get()) != '\n' && !eof ())
73 return '\n';
76 return c;
79 /// read line, gobble '\n'
80 String Data_file::get_line()
82 char c;
83 String s;
85 while ((c = data_get()) != '\n' && !eof ())
86 s += c;
87 return s;
90 /// gobble stuff before first entry on a line.
91 void
92 Data_file::gobble_leading_white()
94 // eat blank lines.
95 while (!eof())
97 char c = data_get();
98 if (!isspace (c))
100 data_unget (c);
101 break;