]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/source-file.hh
* lily/source-file.cc (init_port): add an SCM port to the
[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
12 /**
13   class for reading and mapping a file. 
14
15   duplicates a lot of Data_file and Text_stream.
16   should look at including Data_file's functionality:
17   get_line (), get_word () here.
18 */
19
20 class Source_file
21 {
22 public:
23   Source_file (String fn);
24   Source_file (String, String );
25
26   virtual ~Source_file ();
27
28   char const* to_str0 () const;
29   virtual String error_string (char const* pos_str0 ) const;
30   std::istream * get_istream ();
31   bool in_b (char const* pos_str0 ) const;
32   int length () const;
33   virtual int get_line (char const* pos_str0 ) const;
34   String name_string () const;
35   String file_line_column_string (char const* str0 ) const;
36
37   // return start + n
38   char const* seek_str0 (int n);
39
40   int tell () const;
41   // return here + n bytes
42   char const* forward_str0 (int n);
43   char const* pos_str0 () { return pos_str0_; }
44   String get_string (int n);
45   void set_pos (char const * pos_str0);
46 public:
47   Slice line_slice (char const* pos_str0) const;
48   String line_string (char const* pos_str0) const;
49   int get_column (char const* pos_str0) const;
50   int get_char (char const* pos_str0) const;
51
52   /*
53     DOCUMENT-ME
54    */
55   char const* pos_str0_;
56
57   SCM get_port()const { return str_port_; }
58 private:
59   String name_string_;
60   std::istream* istream_;
61   char  * contents_str0_;
62   int length_;
63   void load_stdin ();
64   void init_port ();
65   
66   Protected_scm str_port_;
67   
68 };
69
70 char * gulp_file (String fn, int *len);
71
72 #endif // SOURCE_FILE_HH //
73