The set_from_string() allows to transform an int to a string, it
should be used by the
gda_value_new_from_string() function, I'll correct this ASAP.
What about to register the functions to transform the types used by GDA in the GLib's GType system, to simplify the code implementation?
I tested the following transformation, with out register any function and it works! using the following code for each type:
integer = g_new0(GValue, 1);
g_value_init(integer, G_TYPE_INT); // Substitude to any type
g_value_set_int(integer, -255); // Use the correct g_value_set_* function
g_value_transform(integer, string); // This is the transformation itself
g_string_printf(txt, "Integer to String: int = %s\n", g_value_get_string(string)); // printing the string
I tested to string the following types using GLib 2.8.3 in Ubuntu 5.10: INT, UINT, INT64, BOOLEAN
and from String: FLOAT, DOUBLE
Thanks Daniel, I agree that the transformations work OK from any type to a string, but not the other way around. If you look at that source code link you provided you will see that there is only the function "value_transform_string_string()". There are no transformations from string to int for instance. Meaning that I have to check all the types and write that logic myself now. Don't understand why these transformation functions (string->other) do not exist for GValue types.
I found that GLib resgister a lot of transformation functions, for string to type and int's to other types of int's, bools, etc.
You can find then in the function g_value_transforms_init:
http://cvs.gnome.org/viewcvs/glib/gobject/gvaluetransform.c?rev=1.13&view=markup
Attachment:
signature.asc
Description: This is a digitally signed message part