]> git.donarmstrong.com Git - lilypond.git/blob - lib/input.cc
release: 0.0.47
[lilypond.git] / lib / input.cc
1 /*
2   input.cc -- implement Input
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "proto.hh"
9 #include "input.hh"
10 #include "string.hh"
11 #include "source.hh"
12 #include "source-file.hh"
13
14 Input::Input(Source_file*s, char const *cl)
15 {
16     source_file_l_=s;
17     defined_ch_C_=cl;
18 }
19
20 Input::Input()
21 {
22     source_file_l_ = 0;
23     defined_ch_C_ = 0;
24 }
25
26 Input::Input(Input const &s)
27 {
28     source_file_l_ = s.source_file_l_;
29     defined_ch_C_ = s.defined_ch_C_;
30 }
31
32 void
33 Input::set_spot(Input const &i)
34 {
35     *this  = i;
36 }
37
38 void
39 Input::message(String message_str)const
40 {
41     String str = "";
42     
43     if ( source_file_l_ ) {
44         str += source_file_l_->file_line_no_str(defined_ch_C_) + String(": ");
45     }
46     
47     str += message_str;
48     if ( source_file_l_ ) {
49         str += ":\n";
50         str += source_file_l_->error_str( defined_ch_C_);
51     }
52     cerr << str << endl;
53 }
54
55 void
56 Input::warning( String message_str)const
57 {
58     message( "warning: " + message_str);
59 }
60 void
61 Input::error(String s)const
62 {
63     message("error: "+ s);
64     exit (1);
65 }
66
67 String
68 Input::location_str()const
69 {
70     if (source_file_l_) 
71         return source_file_l_->file_line_no_str(defined_ch_C_);
72     else
73         return "(location unknown)";
74 }