]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/source-file.hh
*** empty log message ***
[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--2005 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #ifndef SOURCE_FILE_HH
10 #define SOURCE_FILE_HH
11
12 #include <iostream>
13
14 #include "string.hh"
15 #include "protected-scm.hh"
16 #include "parray.hh"
17
18 /**
19    class for reading and mapping a file.
20
21    duplicates a lot of Data_file and Text_stream.
22    should look at including Data_file's functionality:
23    get_line (), get_word () here.
24 */
25
26 class Source_file
27 {
28 public:
29   Source_file (String fn);
30   Source_file (String, String);
31
32   virtual ~Source_file ();
33
34   char const *to_str0 () const;
35   virtual String quote_input (char const *pos_str0) const;
36   std::istream *get_istream ();
37   bool contains (char const *pos_str0) const;
38   int length () const;
39   virtual int get_line (char const *pos_str0) const;
40   String name_string () const;
41   String file_line_column_string (char const *str0) const;
42
43   // return start + n
44   char const *seek_str0 (int n);
45
46   int tell () const;
47   // return here + n bytes
48   char const *forward_str0 (int n);
49   char const *pos_str0 () { return pos_str0_; }
50   String get_string (int n);
51   void set_pos (char const *pos_str0);
52 public:
53   Slice line_slice (char const *pos_str0) const;
54   String line_string (char const *pos_str0) const;
55   void get_counts (char const *pos_str0, int*, int*, int*) const;
56
57   /*
58     JUNKME.
59
60     This thing doubles as a file-storage/file-iterator object.
61   */
62   char const *pos_str0_;
63
64   SCM get_port () const;
65   String name_;
66
67 private:
68   Link_array<char> newline_locations_;
69   std::istream *istream_;
70   char *contents_str0_;
71   int length_;
72   void load_stdin ();
73   void init_port ();
74
75   Protected_scm str_port_;
76 };
77
78 char *gulp_file (String fn, int *len);
79
80 #endif /* SOURCE_FILE_HH */
81