lilypond-0.1.16
[lilypond.git] / lib / input.cc
blob3ef073cb39620a3fadeb018d4c5b1803379c818d
1 /*
2 input.cc -- implement Input
4 source file of the LilyPond music typesetter
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"
14 Input::Input(Source_file*s, char const *cl)
16 source_file_l_=s;
17 defined_ch_C_=cl;
20 Input::Input()
22 source_file_l_ = 0;
23 defined_ch_C_ = 0;
26 Input::Input(Input const &s)
28 source_file_l_ = s.source_file_l_;
29 defined_ch_C_ = s.defined_ch_C_;
32 void
33 Input::set_spot(Input const &i)
35 *this = i;
38 void
39 Input::message(String message_str) const
41 String str = "";
43 if (source_file_l_)
45 str += location_str() + String(": ");
48 str += message_str;
49 if (source_file_l_)
51 str += ":\n";
52 str += source_file_l_->error_str(defined_ch_C_);
54 cerr << str << endl;
57 void
58 Input::warning(String message_str) const
60 message("warning: " + message_str);
62 void
63 Input::error(String s) const
65 message("error: "+ s);
68 String
69 Input::location_str() const
71 if (source_file_l_)
72 return source_file_l_->file_line_no_str(defined_ch_C_);
73 else
74 return "(location unknown)";