2 binary-source-file.cc -- implement Binary_source_file
4 source file of the LilyPond music typesetter
6 (c) 1997--2005 Jan Nieuwenhuizen
9 #include <climits> // INT_MAX
11 #include "binary-source-file.hh"
12 #include "string-convert.hh"
14 Binary_source_file::Binary_source_file (String &file_name_string)
15 : Source_file (file_name_string)
19 Binary_source_file::~Binary_source_file ()
24 Binary_source_file::error_string (char const *pos_str0) const
27 if (!contains (pos_str0))
30 char const *begin_str0 = max (pos_str0 - 8, to_str0 ());
31 char const *end_str0 = min (pos_str0 + 7, to_str0 () + length ());
33 String pre_string ((Byte const *)begin_str0, pos_str0 - begin_str0);
34 pre_string = String_convert::bin2hex (pre_string);
35 for (int i = 2; i < pre_string.length (); i += 3)
36 pre_string = pre_string.left_string (i)
37 + " " + pre_string.cut_string (i, INT_MAX);
38 String post_string ((Byte const *)pos_str0, end_str0 - pos_str0);
39 post_string = String_convert::bin2hex (post_string);
40 for (int i = 2; i < post_string.length (); i += 3)
41 post_string = post_string.left_string (i)
42 + " " + post_string.cut_string (i, INT_MAX);
44 String str = pre_string
46 + to_string (' ', pre_string.length () + 1)
52 Binary_source_file::get_line (char const* pos_str0) const
54 if (!contains (pos_str0))
57 return pos_str0 - to_str0 ();
61 Binary_source_file::get_U8 ()
63 return * (U8*)forward_str0 (1);
68 Binary_source_file::get_U16 ()
79 naming is wrong. This is a UNIX-endian-32 (as opposed to xinu or ixun)
83 Binary_source_file::get_U32 ()