[glibmm] Properly wrap g_key_file_load_from_dirs().



commit a4d4aab826a9c080921d54492855c36a1c6aad77
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Sun Jul 22 15:44:40 2012 +0200

    Properly wrap g_key_file_load_from_dirs().
    
    * glib/src/keyfile.hg:
    * glib/src/keyfile.ccg: The just deprecated wrapper was
    incorrectly passing an array wrapper for full_path parameter when
    it should pass a std::string&, because full_path is an output
    parameter. Added handwritten wrapper passing proper parameter.

 ChangeLog            |   10 ++++++++++
 glib/src/keyfile.ccg |   27 +++++++++++++++++++++++++++
 glib/src/keyfile.hg  |    8 ++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f2413dd..51b802f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2012-07-22  Krzesimir Nowak  <qdlacz gmail com>
 
+	Properly wrap g_key_file_load_from_dirs().
+
+	* glib/src/keyfile.hg:
+	* glib/src/keyfile.ccg: The just deprecated wrapper was
+	incorrectly passing an array wrapper for full_path parameter when
+	it should pass a std::string&, because full_path is an output
+	parameter. Added handwritten wrapper passing proper parameter.
+
+2012-07-22  Krzesimir Nowak  <qdlacz gmail com>
+
 	Wrap g_variant_type_peek_string() by hand.
 
 	* glib/src/gvarianttype.hg:
diff --git a/glib/src/keyfile.ccg b/glib/src/keyfile.ccg
index 27c6d3e..5a6c65e 100644
--- a/glib/src/keyfile.ccg
+++ b/glib/src/keyfile.ccg
@@ -74,6 +74,33 @@ bool KeyFile::load_from_data_dirs(const std::string& file, std::string& full_pat
   return (result != 0);
 }
 
+bool KeyFile::load_from_dirs(const std::string& file, const Glib::ArrayHandle<std::string>& search_dirs, std::string& full_path, KeyFileFlags flags)
+{
+  GError* gerror = 0;
+  char* full_path_c = 0;
+
+  const gboolean result = g_key_file_load_from_dirs(
+      gobj(), file.c_str(), const_cast<const gchar**>(search_dirs.data()),
+      &full_path_c, static_cast<GKeyFileFlags>(unsigned(flags)),
+      &gerror);
+
+  if(gerror)
+  {
+    if (full_path_c)
+    {
+      g_free(full_path_c);
+    }
+    Glib::Error::throw_exception(gerror);
+  }
+
+  if(full_path_c)
+    full_path = Glib::ScopedPtr<char>(full_path_c).get();
+  else
+    full_path.erase();
+
+  return (result != 0);
+}
+
 Glib::ustring KeyFile::to_data()
 {
   GError* gerror = 0;
diff --git a/glib/src/keyfile.hg b/glib/src/keyfile.hg
index ac3122b..415dd49 100644
--- a/glib/src/keyfile.hg
+++ b/glib/src/keyfile.hg
@@ -135,8 +135,16 @@ public:
 
 #m4 _CONVERSION(`const Glib::ArrayHandle<std::string>&', `const gchar**', `const_cast<const gchar**>($3.data())')
 #m4 _CONVERSION(`Glib::ArrayHandle<std::string>&', `gchar**', `const_cast<gchar**>($3.data())')
+
+_DEPRECATE_IFDEF_START
+
   _WRAP_METHOD(bool load_from_dirs(const std::string& file, const Glib::ArrayHandle<std::string>& search_dirs, Glib::ArrayHandle<std::string>& full_path, KeyFileFlags flags = Glib::KEY_FILE_NONE), g_key_file_load_from_dirs, errthrow)
 
+_DEPRECATE_IFDEF_END
+
+  _WRAP_METHOD_DOCS_ONLY(g_key_file_load_from_dirs)
+  bool load_from_dirs(const std::string& file, const Glib::ArrayHandle<std::string>& search_dirs, std::string& full_path, KeyFileFlags flags = Glib::KEY_FILE_NONE);
+
   /** Looks for a KeyFile named @a file in the paths returned from
    * g_get_user_data_dir() and g_get_system_data_dirs() and loads them
    * into the keyfile object, placing the full path to the file in



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