[beast/devel: 22/35] BSE: bsestorage: use Rapicorn::string_format() for warnings and errors



commit 9ab0807a5755b478aef07f70f72d61134f469d5c
Author: Tim Janik <timj gnu org>
Date:   Mon May 13 03:09:31 2013 +0200

    BSE: bsestorage: use Rapicorn::string_format() for warnings and errors

 bse/bsestorage.cc |   34 +++++-----------------------------
 bse/bsestorage.hh |   15 ++++++---------
 2 files changed, 11 insertions(+), 38 deletions(-)
---
diff --git a/bse/bsestorage.cc b/bse/bsestorage.cc
index 80aa2b0..80cb945 100644
--- a/bse/bsestorage.cc
+++ b/bse/bsestorage.cc
@@ -983,57 +983,33 @@ bse_storage_parse_item_link (BseStorage           *self,
 }
 
 void
-bse_storage_warn (BseStorage  *self,
-                  const gchar *format,
-                  ...)
+bse_storage_warn_str (BseStorage *self, const std::string &string)
 {
-  va_list args;
-  gchar *string;
   g_return_if_fail (BSE_IS_STORAGE (self));
-  va_start (args, format);
-  string = g_strdup_vprintf (format, args);
-  va_end (args);
   if (self->rstore)
     sfi_rstore_warn (self->rstore, string);
   else
-    g_printerr ("BseStorage: while storing: %s", string);
-  g_free (string);
+    g_printerr ("BseStorage: while storing: %s", string.c_str());
 }
 
 GTokenType
-bse_storage_warn_skip (BseStorage  *self,
-                       const gchar *format,
-                       ...)
+bse_storage_skip (BseStorage *self, const std::string &string)
 {
-  va_list args;
-  gchar *string;
   GTokenType token;
   g_return_val_if_fail (BSE_IS_STORAGE (self), G_TOKEN_ERROR);
   g_return_val_if_fail (self->rstore != NULL, G_TOKEN_ERROR);
-  va_start (args, format);
-  string = g_strdup_vprintf (format, args);
-  va_end (args);
   token = sfi_rstore_warn_skip (self->rstore, string);
-  g_free (string);
   return token;
 }
 
 void
-bse_storage_error (BseStorage  *self,
-                   const gchar *format,
-                   ...)
+bse_storage_error_str (BseStorage *self, const std::string &string)
 {
-  va_list args;
-  gchar *string;
   g_return_if_fail (BSE_IS_STORAGE (self));
-  va_start (args, format);
-  string = g_strdup_vprintf (format, args);
-  va_end (args);
   if (self->rstore)
     sfi_rstore_error (self->rstore, string);
   else
-    g_printerr ("BseStorage: ERROR: while storing: %s\n", string);
-  g_free (string);
+    g_printerr ("BseStorage: ERROR: while storing: %s\n", string.c_str());
 }
 
 static void
diff --git a/bse/bsestorage.hh b/bse/bsestorage.hh
index 1a2ec95..676fae0 100644
--- a/bse/bsestorage.hh
+++ b/bse/bsestorage.hh
@@ -125,15 +125,12 @@ BseErrorType bse_storage_flush_fd               (BseStorage             *self,
 
 
 /* --- reading --- */
-void         bse_storage_error                  (BseStorage             *self,
-                                                 const gchar            *format,
-                                                 ...) G_GNUC_PRINTF (2,3);
-void         bse_storage_warn                   (BseStorage             *self,
-                                                 const gchar            *format,
-                                                 ...) G_GNUC_PRINTF (2,3);
-GTokenType   bse_storage_warn_skip              (BseStorage             *self,
-                                                 const gchar            *format,
-                                                 ...) G_GNUC_PRINTF (2,3);
+#define      bse_storage_error(s, ...)          bse_storage_error_str (s, Rapicorn::string_format 
(__VA_ARGS__).c_str())
+void         bse_storage_error_str              (BseStorage *self, const std::string &string);
+#define      bse_storage_warn(s, ...)           bse_storage_warn_str (s, Rapicorn::string_format 
(__VA_ARGS__).c_str())
+void         bse_storage_warn_str               (BseStorage *self, const std::string &string);
+#define      bse_storage_warn_skip(s, ...)      bse_storage_skip (s, Rapicorn::string_format 
(__VA_ARGS__).c_str())
+GTokenType   bse_storage_skip                   (BseStorage *self, const std::string &string);
 GTokenType   bse_storage_parse_param_value      (BseStorage             *self,
                                                  GValue                 *value,
                                                  GParamSpec             *pspec);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]