[glibmm] Glib::Keyfile: Use std::vector instead of Glib::ArrayHandle<>.



commit f70495f6196878a199d0c519f8bbfe8d9079c60b
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 17 10:33:00 2017 +0100

    Glib::Keyfile: Use std::vector instead of Glib::ArrayHandle<>.
    
    Using Glib::ArrayHandler<>::vector_to_array() and
    Glib::ArrayHandler<>::array_to_vector() instead, and only in the
    implementatoin instead of in the API.

 glib/src/keyfile.ccg |   52 +++++++++++++++++++++++++-------------------------
 glib/src/keyfile.hg  |   32 ++++++++++++++----------------
 2 files changed, 41 insertions(+), 43 deletions(-)
---
diff --git a/glib/src/keyfile.ccg b/glib/src/keyfile.ccg
index 65e2fb6..30a6ef7 100644
--- a/glib/src/keyfile.ccg
+++ b/glib/src/keyfile.ccg
@@ -95,14 +95,14 @@ KeyFile::load_from_data_dirs(const std::string& file, std::string& full_path, Ke
 }
 
 bool
-KeyFile::load_from_dirs(const std::string& file, const Glib::ArrayHandle<std::string>& search_dirs,
+KeyFile::load_from_dirs(const std::string& file, const std::vector<std::string>&  search_dirs,
   std::string& full_path, KeyFileFlags flags)
 {
   GError* gerror = nullptr;
   char* full_path_c = nullptr;
 
   const gboolean result =
-    g_key_file_load_from_dirs(gobj(), file.c_str(), const_cast<const gchar**>(search_dirs.data()),
+    g_key_file_load_from_dirs(gobj(), file.c_str(), const_cast<const 
gchar**>(Glib::ArrayHandler<std::string>::vector_to_array(search_dirs).data()),
       &full_path_c, static_cast<GKeyFileFlags>(unsigned(flags)), &gerror);
 
   if (gerror)
@@ -134,16 +134,16 @@ KeyFile::to_data()
   return Glib::convert_return_gchar_ptr_to_ustring(str);
 }
 
-Glib::ArrayHandle<Glib::ustring>
+std::vector<Glib::ustring>
 KeyFile::get_groups() const
 {
   gsize length = 0;
   char** const array = g_key_file_get_groups(const_cast<GKeyFile*>(gobj()), &length);
 
-  return Glib::ArrayHandle<Glib::ustring>(array, length, Glib::OWNERSHIP_DEEP);
+  return Glib::ArrayHandler<Glib::ustring>::array_to_vector(array, length, Glib::OWNERSHIP_DEEP);
 }
 
-Glib::ArrayHandle<Glib::ustring>
+std::vector<Glib::ustring>
 KeyFile::get_keys(const Glib::ustring& group_name) const
 {
   gsize length = 0;
@@ -155,7 +155,7 @@ KeyFile::get_keys(const Glib::ustring& group_name) const
   if (gerror)
     Glib::Error::throw_exception(gerror);
 
-  return Glib::ArrayHandle<Glib::ustring>(array, length, Glib::OWNERSHIP_DEEP);
+  return Glib::ArrayHandler<Glib::ustring>::array_to_vector(array, length, Glib::OWNERSHIP_DEEP);
 }
 
 Glib::ustring
@@ -247,7 +247,7 @@ KeyFile::set_double(const Glib::ustring& key, double value)
   if (err)                \
   Glib::Error::throw_exception(err)
 
-Glib::ArrayHandle<Glib::ustring>
+std::vector<Glib::ustring>
 KeyFile::get_string_list(
   const Glib::ustring& group_name, const Glib::ustring& key GLIBMM_ERROR_ARG) const
 {
@@ -259,10 +259,10 @@ KeyFile::get_string_list(
 
   GLIBMM_THROW(gerror);
 
-  return Glib::ArrayHandle<Glib::ustring>(array, length, Glib::OWNERSHIP_DEEP);
+  return Glib::ArrayHandler<Glib::ustring>::array_to_vector(array, length, Glib::OWNERSHIP_DEEP);
 }
 
-Glib::ArrayHandle<Glib::ustring>
+std::vector<Glib::ustring>
 KeyFile::get_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key,
   const Glib::ustring& locale GLIBMM_ERROR_ARG) const
 {
@@ -274,10 +274,10 @@ KeyFile::get_locale_string_list(const Glib::ustring& group_name, const Glib::ust
 
   GLIBMM_THROW(gerror);
 
-  return Glib::ArrayHandle<Glib::ustring>(array, length, Glib::OWNERSHIP_DEEP);
+  return Glib::ArrayHandler<Glib::ustring>::array_to_vector(array, length, Glib::OWNERSHIP_DEEP);
 }
 
-Glib::ArrayHandle<bool>
+std::vector<bool>
 KeyFile::get_boolean_list(
   const Glib::ustring& group_name, const Glib::ustring& key GLIBMM_ERROR_ARG) const
 {
@@ -289,10 +289,10 @@ KeyFile::get_boolean_list(
 
   GLIBMM_THROW(gerror);
 
-  return Glib::ArrayHandle<bool>(array, length, Glib::OWNERSHIP_SHALLOW);
+  return Glib::ArrayHandler<bool>::array_to_vector(array, length, Glib::OWNERSHIP_SHALLOW);
 }
 
-Glib::ArrayHandle<int>
+std::vector<int>
 KeyFile::get_integer_list(
   const Glib::ustring& group_name, const Glib::ustring& key GLIBMM_ERROR_ARG) const
 {
@@ -304,10 +304,10 @@ KeyFile::get_integer_list(
 
   GLIBMM_THROW(gerror);
 
-  return Glib::ArrayHandle<int>(array, length, Glib::OWNERSHIP_SHALLOW);
+  return Glib::ArrayHandler<int>::array_to_vector(array, length, Glib::OWNERSHIP_SHALLOW);
 }
 
-Glib::ArrayHandle<double>
+std::vector<double>
 KeyFile::get_double_list(
   const Glib::ustring& group_name, const Glib::ustring& key GLIBMM_ERROR_ARG) const
 {
@@ -318,47 +318,47 @@ KeyFile::get_double_list(
     const_cast<GKeyFile*>(gobj()), group_name.c_str(), key.c_str(), &length, &gerror);
   GLIBMM_THROW(gerror);
 
-  return Glib::ArrayHandle<double>(array, length, Glib::OWNERSHIP_SHALLOW);
+  return Glib::ArrayHandler<double>::array_to_vector(array, length, Glib::OWNERSHIP_SHALLOW);
 }
 
 void
 KeyFile::set_string_list(const Glib::ustring& group_name, const Glib::ustring& key,
-  const Glib::ArrayHandle<Glib::ustring>& list)
+  const std::vector<Glib::ustring>& list)
 {
   g_key_file_set_string_list(
-    gobj(), Glib::c_str_or_nullptr(group_name), key.c_str(), list.data(), list.size());
+    gobj(), Glib::c_str_or_nullptr(group_name), key.c_str(), 
Glib::ArrayHandler<Glib::ustring>::vector_to_array(list).data(), list.size());
 }
 
 void
 KeyFile::set_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key,
-  const Glib::ustring& locale, const Glib::ArrayHandle<Glib::ustring>& list)
+  const Glib::ustring& locale, const std::vector<Glib::ustring>& list)
 {
   g_key_file_set_locale_string_list(gobj(), Glib::c_str_or_nullptr(group_name), key.c_str(),
-    locale.c_str(), list.data(), list.size());
+    locale.c_str(), Glib::ArrayHandler<Glib::ustring>::vector_to_array(list).data(), list.size());
 }
 
 void
 KeyFile::set_integer_list(
-  const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<int>& list)
+  const Glib::ustring& group_name, const Glib::ustring& key, const std::vector<int>&  list)
 {
   g_key_file_set_integer_list(gobj(), Glib::c_str_or_nullptr(group_name), key.c_str(),
-    const_cast<int*>(list.data()), list.size());
+    const_cast<int*>(Glib::ArrayHandler<int>::vector_to_array(list).data()), list.size());
 }
 
 void
 KeyFile::set_double_list(
-  const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<double>& list)
+  const Glib::ustring& group_name, const Glib::ustring& key, const std::vector<double>&  list)
 {
   g_key_file_set_double_list(
-    gobj(), group_name.c_str(), key.c_str(), const_cast<double*>(list.data()), list.size());
+    gobj(), group_name.c_str(), key.c_str(), 
const_cast<double*>(Glib::ArrayHandler<double>::vector_to_array(list).data()), list.size());
 }
 
 void
 KeyFile::set_boolean_list(
-  const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<bool>& list)
+  const Glib::ustring& group_name, const Glib::ustring& key, const std::vector<bool>&  list)
 {
   g_key_file_set_boolean_list(gobj(), Glib::c_str_or_nullptr(group_name), key.c_str(),
-    const_cast<gboolean*>(list.data()), list.size());
+    const_cast<gboolean*>(Glib::ArrayHandler<bool>::vector_to_array(list).data()), list.size());
 }
 
 Glib::ustring
diff --git a/glib/src/keyfile.hg b/glib/src/keyfile.hg
index 41c2de2..8e69b0d 100644
--- a/glib/src/keyfile.hg
+++ b/glib/src/keyfile.hg
@@ -19,7 +19,6 @@ _DEFS(glibmm,glib)
 
 #include <glibmmconfig.h>
 #include <glibmm/ustring.h>
-#include <glibmm/arrayhandle.h>
 #include <glibmm/error.h>
 #include <glibmm/utility.h>
 #include <glib.h>
@@ -139,13 +138,12 @@ public:
   bool load_from_data(const Glib::ustring& data, KeyFileFlags flags = Glib::KEY_FILE_NONE);
   _IGNORE(g_key_file_load_from_data)
 
-#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())')
+#m4 _CONVERSION(`const std::vector<std::string>& ', `const gchar**', `const_cast<const gchar**>($3.data())')
 
   _IGNORE(g_key_file_load_from_dirs)
 
   _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);
+  bool load_from_dirs(const std::string& file, const std::vector<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
@@ -175,7 +173,7 @@ public:
   /** Gets a list of all groups in the KeyFile
    * @returns A list containing the names of the groups
    */
-  Glib::ArrayHandle<Glib::ustring> get_groups() const;
+  std::vector<Glib::ustring> get_groups() const;
   _IGNORE(g_key_file_get_groups)
 
   /** Gets a list of all keys from the group @a group_name.
@@ -183,7 +181,7 @@ public:
    * @returns A list containing the names of the keys in @a group_name
    * @throw Glib::KeyFileError
    */
-  Glib::ArrayHandle<Glib::ustring> get_keys(const Glib::ustring& group_name) const;
+  std::vector<Glib::ustring> get_keys(const Glib::ustring& group_name) const;
   _IGNORE(g_key_file_get_keys)
 
   _WRAP_METHOD(bool has_group(const Glib::ustring& group_name) const, g_key_file_has_group)
@@ -280,7 +278,7 @@ public:
    * @return A list containing the values requested
    * @throw Glib::KeyFileError
    */
-  Glib::ArrayHandle<Glib::ustring> get_string_list(const Glib::ustring& group_name, const Glib::ustring& 
key) const;
+  std::vector<Glib::ustring> get_string_list(const Glib::ustring& group_name, const Glib::ustring& key) 
const;
   _IGNORE(g_key_file_get_string_list)
 
   /** Returns the values associated with @a key under @a group_name
@@ -290,7 +288,7 @@ public:
    * @return A list containing the values requested
    * @throw Glib::KeyFileError
    */
-  Glib::ArrayHandle<Glib::ustring> get_locale_string_list(const Glib::ustring& group_name, const 
Glib::ustring& key) const;
+  std::vector<Glib::ustring> get_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& 
key) const;
 
   /** Returns the values associated with @a key under @a group_name
    * translated into @a locale, if available.
@@ -300,7 +298,7 @@ public:
    * @return A list containing the values requested
    * @throw Glib::KeyFileError
    */
-  Glib::ArrayHandle<Glib::ustring> get_locale_string_list(const Glib::ustring& group_name, const 
Glib::ustring& key, const Glib::ustring& locale) const;
+  std::vector<Glib::ustring> get_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& 
key, const Glib::ustring& locale) const;
   _IGNORE(g_key_file_get_locale_string_list)
 
   /** Returns the values associated with @a key under @a group_name
@@ -309,7 +307,7 @@ public:
    * @return A list of booleans
    * @throw Glib::KeyFileError
    */
-  Glib::ArrayHandle<bool> get_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
+  std::vector<bool> get_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
   _IGNORE(g_key_file_get_boolean_list)
 
   /** Returns the values associated with @a key under @a group_name
@@ -318,7 +316,7 @@ public:
    * @return A list of integers
    * @throw Glib::KeyFileError
    */
-  Glib::ArrayHandle<int> get_integer_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
+  std::vector<int> get_integer_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
   _IGNORE(g_key_file_get_integer_list)
 
   /** Returns the values associated with @a key under @a group_name
@@ -327,7 +325,7 @@ public:
    * @return A list of doubles
    * @throw Glib::KeyFileError
    */
-  Glib::ArrayHandle<double> get_double_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
+  std::vector<double> get_double_list(const Glib::ustring& group_name, const Glib::ustring& key) const;
   _IGNORE(g_key_file_get_double_list)
 
   /** Get comment from top of file
@@ -361,7 +359,7 @@ public:
    * @param key The name of a key
    * @param list A list holding objects of type Glib::ustring
    */
-  void set_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const 
Glib::ArrayHandle<Glib::ustring>& list);
+  void set_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const 
std::vector<Glib::ustring>&  list);
   _IGNORE(g_key_file_set_string_list)
 
   /** Sets a list of string values for the @a key under @a group_name and marks
@@ -372,7 +370,7 @@ public:
    * @param locale A locale
    * @param list A list holding objects of type Glib::ustring
    */
-  void set_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const 
Glib::ustring& locale, const Glib::ArrayHandle<Glib::ustring>& list);
+  void set_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key, const 
Glib::ustring& locale, const std::vector<Glib::ustring>&  list);
   _IGNORE(g_key_file_set_locale_string_list)
 
   /** Sets a list of booleans for the @a key under @a group_name.
@@ -381,7 +379,7 @@ public:
    * @param key The name of a key
    * @param list A list holding object of type bool
    */
-  void set_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key, const 
Glib::ArrayHandle<bool>& list);
+  void set_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key, const std::vector<bool>&  
list);
   _IGNORE(g_key_file_set_boolean_list)
 
   /** Sets a list of integers for the @a key under @a group_name.
@@ -390,7 +388,7 @@ public:
    * @param key The name of a key
    * @param list A list holding object of type int
    */
-  void set_integer_list(const Glib::ustring& group_name, const Glib::ustring& key, const 
Glib::ArrayHandle<int>& list);
+  void set_integer_list(const Glib::ustring& group_name, const Glib::ustring& key, const std::vector<int>&  
list);
   _IGNORE(g_key_file_set_integer_list)
 
   /** Sets a list of doubles for the @a key under @a group_name.
@@ -401,7 +399,7 @@ public:
    *
    * @newin{2,14}
    */
-  void set_double_list(const Glib::ustring& group_name, const Glib::ustring& key, const 
Glib::ArrayHandle<double>& list);
+  void set_double_list(const Glib::ustring& group_name, const Glib::ustring& key, const std::vector<double>& 
 list);
   _IGNORE(g_key_file_set_double_list)
 
 


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