[glibmm] Wrap g_variant_type_peek_string() by hand.



commit a38c7969eea2fb6364df1325f3ea719fae903960
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Sun Jul 22 11:59:26 2012 +0200

    Wrap g_variant_type_peek_string() by hand.
    
    * glib/src/gvarianttype.hg:
    * glib/src/gvarianttype.ccg: The wrapped function does not return
    a C string (it is not NULL terminated), so std::string(str, size)
    constructor needs to be used. I wonder how glibmm_variant test
    passed through all distchecks so far...

 ChangeLog                |   10 ++++++++++
 glib/src/varianttype.ccg |    5 +++++
 glib/src/varianttype.hg  |    4 +++-
 3 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 63bbebd..f2413dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-07-22  Krzesimir Nowak  <qdlacz gmail com>
+
+	Wrap g_variant_type_peek_string() by hand.
+
+	* glib/src/gvarianttype.hg:
+	* glib/src/gvarianttype.ccg: The wrapped function does not return
+	a C string (it is not NULL terminated), so std::string(str, size)
+	constructor needs to be used. I wonder how glibmm_variant test
+	passed through all distchecks so far...
+
 2012-07-16  Murray Cumming  <murrayc murrayc com>
 
 	Show get_type() in the API documentation.
diff --git a/glib/src/varianttype.ccg b/glib/src/varianttype.ccg
index 62a46a7..c60031e 100644
--- a/glib/src/varianttype.ccg
+++ b/glib/src/varianttype.ccg
@@ -101,4 +101,9 @@ const VariantType VARIANT_TYPE_BYTESTRING(G_VARIANT_TYPE_BYTESTRING);
 
 const VariantType VARIANT_TYPE_BYTESTRING_ARRAY(G_VARIANT_TYPE_STRING_ARRAY);
 
+std::string VariantType::get_string() const
+{
+  return std::string(g_variant_type_peek_string(gobj()), g_variant_type_get_string_length(gobj()));
+}
+
 }
diff --git a/glib/src/varianttype.hg b/glib/src/varianttype.hg
index feb2fb9..8fc2c32 100644
--- a/glib/src/varianttype.hg
+++ b/glib/src/varianttype.hg
@@ -120,7 +120,9 @@ public:
 
   //TODO: Use something instead of gsize?
   _WRAP_METHOD(gsize _get_string_length() const, g_variant_type_get_string_length)
-  _WRAP_METHOD(std::string get_string() const, g_variant_type_peek_string)
+  dnl wrapped by hand, because g_variant_type_peek_string does not return a C string.
+  _WRAP_METHOD_DOCS_ONLY(g_variant_type_peek_string)
+  std::string get_string() const;
   _IGNORE(g_variant_type_dup_string)
 
   _WRAP_METHOD(bool is_definite() const, g_variant_type_is_definite)



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