]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/text-db.hh
lpb and l2d fixes
[lilypond.git] / flower / include / text-db.hh
1 #ifndef TEXTDB_HH
2 #define TEXTDB_HH
3
4 #include "data-file.hh"
5
6 /**a "const" Array. Contents can't be changed. do "#" comments, read quote enclosed  fields */
7
8 class Text_record : Array<String>  
9 {
10     int line_no;
11     String filename;
12     
13 public:
14     Text_record () { } // needed because of other ctor
15
16     /// report an error in this line.
17     void message (String s);
18       String operator[] (int j) {
19         return Array<String>::operator[] (j);
20     }
21
22     Text_record (Array<String> s, String fn, int j) : Array<String> (s) { 
23         filename = fn; line_no = j; 
24     }
25     Array<String>::size;           
26 };
27
28 /** abstraction for a datafile.
29     add a subrec/fieldsep/record separator
30     */
31
32 class Text_db : private Data_file
33 {
34     void gobble_leading_white ();
35 public:
36     /// get a line with records
37     Text_record    get_record ();
38
39     Text_db (String fn):Data_file (fn) { }
40     Data_file::error;
41     bool eof_b ();
42
43     /// get next line.
44     Text_record operator++ (int) {
45         return get_record ();
46     }
47     /// are we done yet?
48     operator bool () {
49         return !eof_b ();
50     }
51 };
52
53 #endif