[glibmm] Wrap function g_listenv()



commit 9a996e4ead1b7b74bcf9ed85e41b7006195fe531
Author: Alex Vallée <alex alexvallee com>
Date:   Wed Apr 21 21:56:51 2010 -0500

    Wrap function g_listenv()

 ChangeLog                |    7 +++++++
 glib/glibmm/miscutils.cc |   10 ++++++++++
 glib/glibmm/miscutils.h  |   14 ++++++++++++++
 3 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 43365eb..75e61af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-17 Alex Vallée <alex alexvallee com>
+
+	Wrap function g_listenv().
+
+	* glib/glibmm/miscutils.[h|cc]: Add wrap function Glib::listenv(). Fixes
+	bug #578355.
+
 2010-04-21  Jonathon Jongsma  <jonathon jongsma collabora co uk>
 
 	* .gitignore:
diff --git a/glib/glibmm/miscutils.cc b/glib/glibmm/miscutils.cc
index 5654800..2da6ac9 100644
--- a/glib/glibmm/miscutils.cc
+++ b/glib/glibmm/miscutils.cc
@@ -71,6 +71,16 @@ void unsetenv(const std::string& variable)
   g_unsetenv(variable.c_str());
 }
 
+Glib::ArrayHandle<std::string> listenv()
+{
+  char **value = g_listenv();
+  char **end = value;
+  while(*end){
+    ++end;
+  }
+  return Glib::ArrayHandle<std::string>(value, end-value, Glib::OWNERSHIP_DEEP);
+}
+
 std::string get_user_name()
 {
   return convert_const_gchar_ptr_to_stdstring(g_get_user_name());
diff --git a/glib/glibmm/miscutils.h b/glib/glibmm/miscutils.h
index a8cf0f1..8b1ad5d 100644
--- a/glib/glibmm/miscutils.h
+++ b/glib/glibmm/miscutils.h
@@ -125,6 +125,20 @@ bool setenv(const std::string& variable, const std::string& value, bool overwrit
  **/
 void unsetenv(const std::string& variable);
 
+/** Gets the names of all variables set in the environment.
+ *
+ * Programs that want to be portable to Windows should typically use this
+ * function and getenv() instead of using the environ array from the C library
+ * directly. On Windows, the strings in the environ array are in system
+ * codepage encoding, while in most of the typical use cases for environment
+ * variables in GLib-using programs you want the UTF-8 encoding that this
+ * function and getenv() provide.
+ *
+ * @return Array of environment names (The generic ArrayHandle will be
+ * implicitly converted to any STL compatible container type).
+ */
+Glib::ArrayHandle<std::string> listenv();
+
 /** Gets the user name of the current user.
  * @return The name of the current user.
  */



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