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