Re: [gnome-db] gda_value_new_from string()





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


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





--
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (entrámite, pero para los cuates: LIBRE)

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