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