lilypond-1.3.100
[lilypond.git] / flower / data-file.cc
blob7faabf383a6dadfa8df29597485d8a1529950b80
1 /*
2 data-file.cc -- implement Data_file
4 source file of the Flower Library
6 (c) '95, '96, '97 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 DEPRECATED
11 #include <fstream.h>
12 #include <ctype.h>
13 #include <stdlib.h>
15 #include "international.hh"
16 #include "data-file.hh"
18 void
19 Data_file::gobble_white()
21 char c;
23 while ((c=data_get()) == ' ' ||c == '\t')
24 if (eof_b())
25 return;
27 data_unget (c);
30 String
31 Data_file::get_word()
32 {// should handle escape seq's
33 String s;
35 while (1)
37 char c = data_get();
39 if (eof_b ())
40 break;
42 if (isspace (c))
44 data_unget (c);
45 break;
49 if (c == '\"')
51 rawmode= true;
53 while ((c = data_get()) != '\"')
54 if (eof_b ())
55 error (_ ("EOF in a string"));
56 else
57 s += to_str (c);
60 rawmode= false;
62 else
63 s += to_str (c);
66 return s;
69 char
70 Data_file::data_get()
72 char c = get();
73 if (!rawmode && c == '#') // gobble comment
75 while (!eof_b () && (c = get()) != '\n')
77 return '\n';
80 return c;
83 String
84 Data_file::get_line()
86 char c;
87 String s;
89 while (!eof_b () && (c = data_get()) != '\n')
90 s += to_str (c);
91 return s;
94 void
95 Data_file::gobble_leading_white()
97 // eat blank lines.
98 while (!eof_b ())
100 char c = data_get();
101 if (!isspace (c))
103 data_unget (c);
104 break;
109 Data_file::Data_file (String s)
110 : Text_stream (s)
112 //*mlog << "(" << s << flush;
113 rawmode= false;
116 void
117 Data_file::warning (String s)
119 message (_ ("warning: ") + s);
122 void
123 Data_file::error (String s)
125 message (s);
126 exit (1);
129 String
130 Data_file::gulp ()
132 String s;
134 while (!eof_b ())
136 s += to_str (data_get ());
138 return s;
142 Data_file::~Data_file ()