summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2006-05-09 12:57:26 +0000
committerMurray Cumming <murrayc@src.gnome.org>2006-05-09 12:57:26 +0000
commit10d607afe1ade71a232f05b2d398693a4a26b964 (patch)
tree5ea3ee9e5901aa0476f08f1fd7c3ad5f57805773
parent1a48ce21ba8b95703d2da32a35d5b3a687f978af (diff)
downloadglibmm-10d607afe1ade71a232f05b2d398693a4a26b964.tar.gz
Added init(const GValue*), so that we can copy GValue instances of any
2006-05-09 Murray Cumming <murrayc@murrayc.com> * glib/glibmm/value.cc: * glib/glibmm/value.h: Added init(const GValue*), so that we can copy GValue instances of any type at runtime. Needed by libgdamm, which returns const GValue* instances.
-rw-r--r--ChangeLog6
-rw-r--r--glib/glibmm/value.cc8
-rw-r--r--glib/glibmm/value.h12
3 files changed, 26 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c0f068e..b2722d9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-09 Murray Cumming <murrayc@murrayc.com>
+
+ * glib/glibmm/value.cc:
+ * glib/glibmm/value.h: Added init(const GValue*), so that we can copy GValue instances
+ of any type at runtime. Needed by libgdamm, which returns const GValue* instances.
+
This is the HEAD branch, for API additions. See also the glibmm-2-10 branch.
2.10.1:
diff --git a/glib/glibmm/value.cc b/glib/glibmm/value.cc
index adb3e902..12ba6fc9 100644
--- a/glib/glibmm/value.cc
+++ b/glib/glibmm/value.cc
@@ -39,6 +39,14 @@ void ValueBase::init(GType type)
g_value_init(&gobject_, type);
}
+void ValueBase::init(const GValue* value)
+{
+ g_value_init(&gobject_, G_VALUE_TYPE(value));
+
+ if(value)
+ g_value_copy(value, &gobject_);
+}
+
ValueBase::ValueBase(const ValueBase& other)
{
GLIBMM_INITIALIZE_STRUCT(gobject_, GValue);
diff --git a/glib/glibmm/value.h b/glib/glibmm/value.h
index 94203a32..a891418c 100644
--- a/glib/glibmm/value.h
+++ b/glib/glibmm/value.h
@@ -69,9 +69,21 @@ public:
*
* init() is not implemented as constructor, to avoid the necessity
* to implement a forward constructor in each derived class.
+ *
+ * @param type The type that the Value should hold.
*/
void init(GType type);
+ /** Setup the GValue storing the type and value of the specified @a value.
+ * Note that init() should never be called twice.
+ *
+ * init() is not implemented as constructor, to avoid the necessity
+ * to implement a forward constructor in each derived class.
+ *
+ * @param value The existing GValue.
+ */
+ void init(const GValue* value);
+
/** Reset contents to the default value of its type.
*/
void reset();