[gnome-db] GValue from string: CVS - Observation and Proposal



There are a problem with the implementation, I think, know if you want to transform a value from a string you'll need to use gda_value_set_from_string and that's correct, but:

What happen if I want to use the GValue API to transform that value (a string) to other; may be could be more clear to register the transformation functions (the code already exist in the function set_from_string).

Then the programer can use a code where he don't need to take care about the type of the value he transforms from.

if ( g_value_transformable (G_VALUE_TYPE(source), G_VALUE_TYPE(destination)) {

      g_value_transform( source, destination );

     UseTheValue(destination); // This function coulde take care about how to use the type of the value passed as argument
}
else Error();



In the case of use the actual API you allways need to know that the actual value is a string:

if ( G_VALUE_TYPE(source) == G_TYPE_STRING ) {

      gda_value_set_from_string( destination, g_value_get_string( source ), G_TYPE_INT);

      UseTheValue(destination);
}
else {
   if ( g_value_transformable (G_VALUE_TYPE(source), G_VALUE_TYPE(destination)) {

        g_value_transform( source, destination );

        UseTheValue(destination); // This function coulde take care about how to use the type of the value passed as argument
   }
   else Error();
}


--
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]