]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/binary-source-file.cc
* flower/include/std-string.hh:
[lilypond.git] / lily / binary-source-file.cc
index 9f69b5ec986b86dfa880684c77e121b77f87a137..90d4a4ac02a10ee3a61501d32cd53694e2dd4fb7 100644 (file)
@@ -3,21 +3,17 @@
 
   source file of the LilyPond music typesetter
 
-  (c) 1997--2004 Jan Nieuwenhuizen
+  (c) 1997--2006 Jan Nieuwenhuizen
 */
 
+#include <climits>             // INT_MAX
+using namespace std;
 
-#include <limits.h>            // INT_MAX
-#include <assert.h>
-
-#include "flower-proto.hh"
-#include "string.hh"
-#include "source-file.hh"
 #include "binary-source-file.hh"
 #include "string-convert.hh"
 
-Binary_source_file::Binary_source_file (String& filename_string)
-  : Source_file (filename_string)
+Binary_source_file::Binary_source_file (string &file_name_string)
+  : Source_file (file_name_string)
 {
 }
 
@@ -25,48 +21,49 @@ Binary_source_file::~Binary_source_file ()
 {
 }
 
-String
-Binary_source_file::error_string (char const* pos_str0) const
+string
+Binary_source_file::quote_input (char const *pos_str0) const
 {
   assert (this);
-  if (!in_b (pos_str0))
+  if (!contains (pos_str0))
     return "";
 
-  char const* begin_str0 = pos_str0 - 8 >? to_str0 ();
-  char const* end_str0 = pos_str0 + 7 <? to_str0 () + length ();
+  char const *begin_str0 = max (pos_str0 - 8, c_str ());
+  char const *end_str0 = min (pos_str0 + 7, c_str () + length ());
 
-  String pre_string ((Byte const*)begin_str0, pos_str0 - begin_str0);
+  string pre_string (begin_str0, pos_str0 - begin_str0);
   pre_string = String_convert::bin2hex (pre_string);
-  for (int i = 2; i < pre_string.length (); i += 3)
-    pre_string = pre_string.left_string (i) + " " + pre_string.cut_string (i, INT_MAX);
-  String post_string ((Byte const*)pos_str0, end_str0 - pos_str0);
+  for (ssize i = 2; i < pre_string.length (); i += 3)
+    pre_string = pre_string.substr (0, i)
+      + " " + pre_string.substr (i, NPOS);
+  string post_string (pos_str0, end_str0 - pos_str0);
   post_string = String_convert::bin2hex (post_string);
-  for (int i = 2; i < post_string.length (); i += 3)
-    post_string = post_string.left_string (i) + " " + post_string.cut_string (i, INT_MAX);
+  for (ssize i = 2; i < post_string.length (); i += 3)
+    post_string = post_string.substr (0, i)
+      + " " + post_string.substr (i, NPOS);
 
-  String str = pre_string
+  string str = pre_string
     + to_string ('\n')
-    + to_string (' ', pre_string.length () + 1) 
+    + to_string (' ', pre_string.length () + 1)
     + post_string;
   return str;
 }
 
 int
-Binary_source_file::get_line (char constpos_str0) const
+Binary_source_file::get_line (char const *pos_str0) const
 {
-  if (!in_b (pos_str0))
+  if (!contains (pos_str0))
     return 0;
 
-  return pos_str0 - to_str0 ();
+  return pos_str0 - c_str ();
 }
 
 U8
 Binary_source_file::get_U8 ()
 {
-  return * (U8*)forward_str0 (1);
+  return *(U8 *)forward_str0 (1);
 }
 
-
 U16
 Binary_source_file::get_U16 ()
 {
@@ -80,13 +77,13 @@ Binary_source_file::get_U16 ()
 
 /*
   naming is wrong. This is a UNIX-endian-32 (as opposed to xinu or ixun)
- */
+*/
 
 U32
 Binary_source_file::get_U32 ()
 {
   U32 b;
-  
+
   b = get_U8 () << 24;
   b |= get_U8 () << 16;
   b |= get_U8 () << 8;
@@ -95,4 +92,3 @@ Binary_source_file::get_U32 ()
   return b;
 }
 
-