]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/source-file.hh
* lily/spanner.cc (find_broken_piece):
[lilypond.git] / lily / include / source-file.hh
1 /*
2   source-file.hh -- declare Source_file
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1999--2006 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #ifndef SOURCE_FILE_HH
10 #define SOURCE_FILE_HH
11
12 #include "flower-proto.hh"
13 #include "std-vector.hh"
14 #include "lily-proto.hh"
15 #include "smobs.hh"
16
17 #include <iostream>
18 using namespace std;
19
20 /**
21    class for reading and mapping a file.
22
23    duplicates a lot of Data_file and Text_stream.
24    should look at including Data_file's functionality:
25    get_line (), get_word () here.
26 */
27
28 class Source_file
29 {
30   vector<char const*> newline_locations_;
31   istream *istream_;
32   vector<char> characters_;
33   SCM str_port_;
34
35   void load_stdin ();
36   void init_port ();
37   void init ();
38   
39   DECLARE_SMOBS(Source_file, bla);
40 public:
41   Source_file (string fn);
42   Source_file (string, string);
43
44   char const *c_str () const;
45   virtual string quote_input (char const *pos_str0) const;
46   istream *get_istream ();
47   bool contains (char const *pos_str0) const;
48   int length () const;
49   virtual int get_line (char const *pos_str0) const;
50   void set_line (char const *pos_str0, int i);
51   string name_string () const;
52   string file_line_column_string (char const *str0) const;
53
54 public:
55   Slice line_slice (char const *pos_str0) const;
56   string line_string (char const *pos_str0) const;
57   void get_counts (char const *pos_str0, int *, int *, int *) const;
58   
59   SCM get_port () const;
60   string name_;
61
62 protected:
63   int line_offset_;
64 };
65
66 vector<char> gulp_file (string fn, int desired);
67
68 #endif /* SOURCE_FILE_HH */
69