]> git.donarmstrong.com Git - lilypond.git/blob - lily/input-scheme.cc
Issue 4550 (1/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / input-scheme.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "std-string.hh"
21 #include "input.hh"
22
23 using std::string;
24
25 LY_DEFINE (ly_input_warning, "ly:input-warning", 2, 0, 1, (SCM sip, SCM msg, SCM rest),
26            "Print @var{msg} as a GNU compliant warning message, pointing"
27            " to the location in @var{sip}.  @var{msg} is interpreted"
28            " similar to @code{format}'s argument, using @var{rest}.")
29 {
30   Input *ip = unsmob<Input> (sip);
31
32   LY_ASSERT_SMOB (Input, sip, 1);
33   LY_ASSERT_TYPE (scm_is_string, msg, 2);
34
35   msg = scm_simple_format (SCM_BOOL_F, msg, rest);
36
37   string m = ly_scm2string (msg);
38   ip->warning (m);
39
40   return SCM_UNSPECIFIED;
41 }
42
43 LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM rest),
44            "Print @var{msg} as a GNU compliant error message, pointing"
45            " to the location in @var{sip}.  @var{msg} is interpreted"
46            " similar to @code{format}'s argument, using @var{rest}.")
47 {
48   Input *ip = unsmob<Input> (sip);
49
50   LY_ASSERT_SMOB (Input, sip, 1);
51   LY_ASSERT_TYPE (scm_is_string, msg, 2);
52
53   msg = scm_simple_format (SCM_BOOL_F, msg, rest);
54
55   string m = ly_scm2string (msg);
56   ip->message (m);
57
58   return SCM_UNSPECIFIED;
59 }
60
61 LY_DEFINE (ly_input_file_line_char_column,
62            "ly:input-file-line-char-column",
63            1, 0, 0, (SCM sip),
64            "Return input location in @var{sip} as"
65            " @code{(file-name line char column)}.")
66 {
67   LY_ASSERT_SMOB (Input, sip, 1);
68   Input *ip = unsmob<Input> (sip);
69
70   int l, ch, col, offset = 0;
71   ip->get_counts (&l, &ch, &col, &offset);
72   return scm_list_4 (ly_string2scm (ip->file_string ()),
73                      scm_from_int (l),
74                      scm_from_int (ch),
75                      scm_from_int (col));
76 }
77
78 LY_DEFINE (ly_input_both_locations,
79            "ly:input-both-locations",
80            1, 0, 0, (SCM sip),
81            "Return input location in @var{sip} as"
82            " @code{(file-name first-line first-column last-line last-column)}.")
83 {
84
85   LY_ASSERT_SMOB (Input, sip, 1);
86   Input *ip = unsmob<Input> (sip);
87
88   return scm_list_5 (ly_string2scm (ip->file_string ()),
89                      scm_from_int (ip->line_number ()),
90                      scm_from_int (ip->column_number ()),
91                      scm_from_int (ip->end_line_number ()),
92                      scm_from_int (ip->end_column_number ()));
93 }