/*
- std-tring.cc -- implement external interface for Std_String
+ std-string.cc -- implement external interface for Std_String
source file of the GNU LilyPond music typesetter
*/
#include "std-string.hh"
-
-#if STD_STRING
+#include "string-convert.hh"
namespace std {
- Std_string
- to_std_string (char c, int n)
+
+ std::string
+ to_string (std::string s)
{
- /* FIXME, remove this function and use std::string interface for
- String? This interface is a bit clumsy, almost alway you want
- n=1. */
- return Std_string (n, c);
+ return s;
}
-}
-#define FIND_FAILED string::npos
-#define SIZE_T size_t
-#else /* !STD_STRING */
+ std::string
+ to_string (char c, int n)
+ {
+ return std::string (n, c);
+ }
-#define FIND_FAILED -1
-#define SIZE_T int
+ std::string
+ to_string (double f, char const *format)
+ {
+ return String_convert::double_string (f, format);
+ }
-#endif /* STD_STRING */
+ std::string
+ to_string (int i, char const *format)
+ {
+ return String_convert::int_string (i, format);
+ }
-Std_string &
-replace_all (Std_string &str, Std_string find, Std_string replace)
-{
- int len = find.length ();
- for (SIZE_T i = str.find (find); i != FIND_FAILED; i = str.find (find,
- i + len))
- str = str.replace (i, len, replace);
- return str;
-}
+ std::string
+ to_string (bool b)
+ {
+ return String_convert::bool_string (b);
+ }
+
+ std::string
+ to_string (long b)
+ {
+ return String_convert::long_string (b);
+ }
+
+ std::string
+ to_string (char const *format, ...)
+ {
+ va_list args;
+ va_start (args, format);
+ std::string str = String_convert::vform_string (format, args);
+ va_end (args);
+ return str;
+ }
+
+ std::string &
+ replace_all (std::string &str, std::string find, std::string 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;
+ }
+
+ std::string &
+ replace_all (std::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;
+ }
+ char *
+ string_copy (std::string s)
+ {
+ ssize len = s.length ();
+ char *dest = new char[len + 1];
+ //s.copy (dest, len + 1);
+ memcpy (dest, s.c_str (), len + 1);
+ return dest;
+ }
+
+ int
+ string_compare (std::string const &a, std::string const &b)
+ {
+ return a.compare (b);
+ }
+
+}