changeset 8809:fde4101fa183

[gaim-migrate @ 9571] Added the GaimValue changes from my status rewrite tree to here. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 25 Apr 2004 22:31:50 +0000
parents bbd8cdaf0ad5
children a7affa2e2986
files src/value.c src/value.h
diffstat 2 files changed, 107 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/value.c	Sun Apr 25 22:02:06 2004 +0000
+++ b/src/value.c	Sun Apr 25 22:31:50 2004 +0000
@@ -97,6 +97,104 @@
 	g_free(value);
 }
 
+GaimValue *
+gaim_value_dup(const GaimValue *value)
+{
+	GaimValue *new_value;
+	GaimType type;
+
+	g_return_val_if_fail(value != NULL, NULL);
+
+	type = gaim_value_get_type(value);
+
+	if (type == GAIM_TYPE_SUBTYPE)
+	{
+		new_value = gaim_value_new(GAIM_TYPE_SUBTYPE,
+								   gaim_value_get_subtype(value));
+	}
+	else if (type == GAIM_TYPE_BOXED)
+	{
+		new_value = gaim_value_new(GAIM_TYPE_BOXED,
+								   gaim_value_get_specific_type(value));
+	}
+	else
+		new_value = gaim_value_new(type);
+
+	new_value->flags = value->flags;
+
+	switch (type)
+	{
+		case GAIM_TYPE_CHAR:
+			gaim_value_set_char(new_value, gaim_value_get_char(value));
+			break;
+
+		case GAIM_TYPE_UCHAR:
+			gaim_value_set_uchar(new_value, gaim_value_get_uchar(value));
+			break;
+
+		case GAIM_TYPE_BOOLEAN:
+			gaim_value_set_boolean(new_value, gaim_value_get_boolean(value));
+			break;
+
+		case GAIM_TYPE_SHORT:
+			gaim_value_set_short(new_value, gaim_value_get_short(value));
+			break;
+
+		case GAIM_TYPE_USHORT:
+			gaim_value_set_ushort(new_value, gaim_value_get_ushort(value));
+			break;
+
+		case GAIM_TYPE_INT:
+			gaim_value_set_int(new_value, gaim_value_get_int(value));
+			break;
+
+		case GAIM_TYPE_UINT:
+			gaim_value_set_uint(new_value, gaim_value_get_uint(value));
+			break;
+
+		case GAIM_TYPE_LONG:
+			gaim_value_set_long(new_value, gaim_value_get_long(value));
+			break;
+
+		case GAIM_TYPE_ULONG:
+			gaim_value_set_ulong(new_value, gaim_value_get_ulong(value));
+			break;
+
+		case GAIM_TYPE_INT64:
+			gaim_value_set_int64(new_value, gaim_value_get_int64(value));
+			break;
+
+		case GAIM_TYPE_UINT64:
+			gaim_value_set_uint64(new_value, gaim_value_get_uint64(value));
+			break;
+
+		case GAIM_TYPE_STRING:
+			gaim_value_set_string(new_value, gaim_value_get_string(value));
+			break;
+
+		case GAIM_TYPE_OBJECT:
+			gaim_value_set_object(new_value, gaim_value_get_object(value));
+			break;
+
+		case GAIM_TYPE_POINTER:
+			gaim_value_set_pointer(new_value, gaim_value_get_pointer(value));
+			break;
+
+		case GAIM_TYPE_ENUM:
+			gaim_value_set_enum(new_value, gaim_value_get_enum(value));
+			break;
+
+		case GAIM_TYPE_BOXED:
+			gaim_value_set_boxed(new_value, gaim_value_get_boxed(value));
+			break;
+
+		default:
+			break;
+	}
+
+	return new_value;
+}
+
 GaimType
 gaim_value_get_type(const GaimValue *value)
 {
--- a/src/value.h	Sun Apr 25 22:02:06 2004 +0000
+++ b/src/value.h	Sun Apr 25 22:31:50 2004 +0000
@@ -163,6 +163,15 @@
 void gaim_value_destroy(GaimValue *value);
 
 /**
+ * Duplicated a GaimValue.
+ *
+ * @param value The value to duplicate.
+ *
+ * @return The duplicate value.
+ */
+GaimValue *gaim_value_dup(const GaimValue *value);
+
+/**
  * Returns a value's type.
  *
  * @return The value's type.