]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/source-file.hh
* The grand 2005-2006 replace.
[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 <iostream>
13 using namespace std;
14
15 #include "string.hh"
16 #include "protected-scm.hh"
17 #include "parray.hh"
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 public:
30   Source_file (String fn);
31   Source_file (String, String);
32
33   virtual ~Source_file ();
34
35   char const *to_str0 () const;
36   virtual String quote_input (char const *pos_str0) const;
37   istream *get_istream ();
38   bool contains (char const *pos_str0) const;
39   int length () const;
40   virtual int get_line (char const *pos_str0) const;
41   String name_string () const;
42   String file_line_column_string (char const *str0) const;
43
44   // return start + n
45   char const *seek_str0 (int n);
46
47   int tell () const;
48   // return here + n bytes
49   char const *forward_str0 (int n);
50   char const *pos_str0 () { return pos_str0_; }
51   String get_string (int n);
52   void set_pos (char const *pos_str0);
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   /*
59     JUNKME.
60
61     This thing doubles as a file-storage/file-iterator object.
62   */
63   char const *pos_str0_;
64
65   SCM get_port () const;
66   String name_;
67
68 private:
69   Link_array<char> newline_locations_;
70   istream *istream_;
71   char *contents_str0_;
72   int length_;
73   void load_stdin ();
74   void init_port ();
75
76   Protected_scm str_port_;
77 };
78
79 char *gulp_file (String fn, int *len);
80
81 #endif /* SOURCE_FILE_HH */
82