X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Fstd-string.cc;h=223c8f1fd0eda9b78fba2cb34006f371d06b590f;hb=712e575fb12d02d58e04553a3474afb9f6d2391b;hp=1221609c6c0ce4bc2e76a140d4fcbb1ed35f3d11;hpb=e7c33f14dc0ae7b43b21db16fd0ce48934049a57;p=lilypond.git diff --git a/flower/std-string.cc b/flower/std-string.cc index 1221609c6c..223c8f1fd0 100644 --- a/flower/std-string.cc +++ b/flower/std-string.cc @@ -1,9 +1,20 @@ /* - std-string.cc -- implement external interface for Std_String + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2006--2009 Jan Nieuwenhuizen - (c) 2006--2007 Jan Nieuwenhuizen + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "std-string.hh" @@ -57,6 +68,12 @@ to_string (unsigned u) return String_convert::unsigned_string (u); } +string +to_string (I64 b, char const *format) +{ + return String_convert::i64_string (b, format); +} + string to_string (char const *format, ...) { @@ -71,20 +88,21 @@ to_string (char const *format, ...) TODO: this O(n^2) in #occurences of find, due to repeated copying. */ string & -replace_all (string &str, string find, string replace) +replace_all (string *str, string const &find, string const &replace) { ssize len = find.length (); - for (ssize i = str.find (find); i != NPOS; i = str.find (find, i + len)) - str = str.replace (i, len, replace); - return str; + ssize replen = replace.length (); + for (ssize i = str->find (find); i != NPOS; i = str->find (find, i + replen)) + *str = str->replace (i, len, replace); + return *str; } string & -replace_all (string &str, char find, char replace) +replace_all (string *str, char find, char replace) { - for (ssize i = str.find (find); i != NPOS; i = str.find (find, i + 1)) - str[i] = replace; - return str; + for (ssize i = str->find (find); i != NPOS; i = str->find (find, i + 1)) + (*str)[i] = replace; + return *str; } char *