]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/string.cc
* flower/include/std-string.hh: Oops, bugfix for --disable-std-string.
[lilypond.git] / flower / string.cc
index 622ef5917e1c5954a3f77bcb3d2eabec8356e9a3..7b4620906a595ac07eaf430ec193344788c83989 100644 (file)
@@ -21,6 +21,8 @@ using namespace std;
 #include "libc-extension.hh"
 #include "string-convert.hh"
 
+/* std::string conversion helpers */
+
 #if STD_STRING
 
 #include "std-string.hh"
@@ -29,22 +31,29 @@ String::String (Std_string const &s)
 {
   *this = String (s.c_str ());
 }
+
+String::operator Std_string () const
+{
+  return Std_string (this->c_str ());
+}
+
 #endif
 
+/* std::string interface */
 
 String::String (String const &s, int pos, int n)
 {
   if (n == -1)
-    n = s.size () - pos;
+    n = s.length () - pos;
   if (pos == 0)
     *this = s.left_string (n);
   else
-    *this = s.right_string (s.size () - pos).left_string (n);
+    *this = s.right_string (s.length () - pos).left_string (n);
 }
 
-String::operator Std_string () const
+String::String (int n, char c)
 {
-  return Std_string (this->c_str ());
+  *this = String_convert::char_string (c, n);
 }
 
 char const *
@@ -60,15 +69,21 @@ String::empty () const
 }
 
 int
-String::size () const
+String::find (char c) const
 {
-  return length ();
+  return index (c);
 }
 
 int
-String::find (char c) const
-{
-  return index (c);
+String::find (String &s, int pos) const
+{
+  if (!pos)
+    return index (s);
+  String f = right_string (length () - pos);
+  int n = f.index (s);
+  if (n != -1)
+    return pos + n;
+  return -1;
 }
 
 int
@@ -77,7 +92,15 @@ String::rfind (char c) const
   return index_last (c);
 }
 
+String
+String::replace (int pos, int n, String str)
+{
+  return String (*this, 0, pos) + str + String (*this, pos + n);
+}
+
+
 
+/* String */
 
 #ifdef STRING_DEBUG
 void *mymemmove (void *dest, void const *src, size_t n);