2 binary-source-file.cc -- implement Binary_source_file
4 source file of the LilyPond music typesetter
6 (c) 1997 Jan Nieuwenhuizen
10 #include <limits.h> // INT_MAX
16 #include "source-file.hh"
17 #include "binary-source-file.hh"
18 #include "string-convert.hh"
20 Binary_source_file::Binary_source_file( String& filename_str )
21 : Source_file( filename_str )
25 Binary_source_file::~Binary_source_file()
30 Binary_source_file::error_str( char const* pos_ch_c_l )
33 if ( !in_b( pos_ch_c_l ) )
36 char const* begin_ch_c_l = pos_ch_c_l - 8 >? ch_C();
37 char const* end_ch_c_l = pos_ch_c_l + 7 <? ch_C() + length_off();
39 String pre_str( (Byte const*)begin_ch_c_l, pos_ch_c_l - begin_ch_c_l );
40 pre_str = String_convert::bin2hex_str( pre_str );
41 for ( int i = 2; i < pre_str.length_i(); i += 3 )
42 pre_str = pre_str.left_str( i ) + " " + pre_str.mid_str( i, INT_MAX );
43 String post_str( (Byte const*)pos_ch_c_l, end_ch_c_l - pos_ch_c_l );
44 post_str = String_convert::bin2hex_str( post_str );
45 for ( int i = 2; i < post_str.length_i(); i += 3 )
46 post_str = post_str.left_str( i ) + " " + post_str.mid_str( i, INT_MAX );
50 + String( ' ', pre_str.length_i() + 1 )
56 Binary_source_file::line_i( char const* pos_ch_c_l )
58 if ( !in_b( pos_ch_c_l ) )
61 return pos_ch_c_l - ch_C();