]> git.donarmstrong.com Git - lilypond.git/blob - lib/input.cc
release: 0.1.11
[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       {
45         str += location_str() + String(": ");
46       }
47     
48     str += message_str;
49     if (source_file_l_) 
50       {
51         str += ":\n";
52         str += source_file_l_->error_str(defined_ch_C_);
53       }
54     cerr << str << endl;
55 }
56
57 void
58 Input::warning(String message_str) const
59 {
60     message("warning: " + message_str);
61 }
62 void
63 Input::error(String s) const
64 {
65     message("error: "+ s);
66 }
67
68 String
69 Input::location_str() const
70 {
71     if (source_file_l_) 
72         return source_file_l_->file_line_no_str(defined_ch_C_);
73     else
74         return "(location unknown)";
75 }