]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/source-file.hh
* configure.in: Test for and accept lmodern if EC fonts not found.
[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--2004 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 error_string (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   int get_column (char const* pos_str0) const;
56   int get_char (char const* pos_str0) 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 { return str_port_; }
66   String name_;
67
68 private:
69   Link_array<char> newline_locations_; 
70   std::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