lilypond-1.4.1
[lilypond.git] / flower / data-file.cc
blob9f4c16b115fb6dea2693a352955b9a8751f9ba8b
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 <ctype.h>
12 #include <stdlib.h>
14 #include "international.hh"
15 #include "data-file.hh"
17 void
18 Data_file::gobble_white ()
20 char c;
22 while ((c=data_get ()) == ' ' ||c == '\t')
23 if (eof_b ())
24 return;
26 data_unget (c);
29 String
30 Data_file::get_word ()
31 {// should handle escape seq's
32 String s;
34 while (1)
36 char c = data_get ();
38 if (eof_b ())
39 break;
41 if (isspace (c))
43 data_unget (c);
44 break;
48 if (c == '\"')
50 rawmode= true;
52 while ((c = data_get ()) != '\"')
53 if (eof_b ())
54 error (_ ("EOF in a string"));
55 else
56 s += to_str (c);
59 rawmode= false;
61 else
62 s += to_str (c);
65 return s;
68 char
69 Data_file::data_get ()
71 char c = get ();
72 if (!rawmode && c == '#') // gobble comment
74 while (!eof_b () && (c = get ()) != '\n')
76 return '\n';
79 return c;
82 String
83 Data_file::get_line ()
85 char c;
86 String s;
88 while (!eof_b () && (c = data_get ()) != '\n')
89 s += to_str (c);
90 return s;
93 void
94 Data_file::gobble_leading_white ()
96 // eat blank lines.
97 while (!eof_b ())
99 char c = data_get ();
100 if (!isspace (c))
102 data_unget (c);
103 break;
108 Data_file::Data_file (String s)
109 : Text_stream (s)
111 //*mlog << " (" << s << flush;
112 rawmode= false;
115 void
116 Data_file::warning (String s)
118 message (_ ("warning: ") + s);
121 void
122 Data_file::error (String s)
124 message (s);
125 exit (1);
128 String
129 Data_file::gulp ()
131 String s;
133 while (!eof_b ())
135 s += to_str (data_get ());
137 return s;
141 Data_file::~Data_file ()