]> git.donarmstrong.com Git - lilypond.git/blob - src/inputfile.cc
partial: 0.0.38.jcn
[lilypond.git] / src / inputfile.cc
1 /*
2   inputfile.cc -- implement Input_file
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl> Jan Nieuwenhuizen <jan@digicash.com>
7 */
8
9 #include <iostream.h>
10 #include <strstream.h>
11 #include "proto.hh"
12 #include "plist.hh"
13 #include "inputfile.hh"
14 #include "debug.hh"
15 #include "sourcefile.hh"
16 #include "binary-source-file.hh"
17 #include "source.hh"
18
19 Input_file::Input_file(String s)
20 {
21         name = s;
22         line = 1;
23         String pf(s);
24         if ( pf == "" ) {
25                 is = &cin;
26                 defined_ch_c_l_ = 0;
27                 sourcefile_l_ = 0;
28         }
29         else {
30                 Source_file* sourcefile_p = 0;
31                 // ugh, very dirty, need to go away
32                 if ( ( pf.right_str( 3 ).lower_str() == "mid" ) || ( pf.right_str( 4 ).lower_str() == "midi" ) )
33                     sourcefile_p = new Binary_source_file( pf );
34                 else
35                     sourcefile_p = new Source_file( pf );
36                 source_l_g->add( sourcefile_p );
37                 sourcefile_l_ = sourcefile_p;
38                 is = sourcefile_l_->istream_l();
39                 defined_ch_c_l_ = sourcefile_l_->ch_c_l();
40         }
41         cout << "[" << pf << flush;
42 }
43
44 Input_file::~Input_file()
45 {
46         cout << "]" << flush;  
47 }