## GnomeDbDataHandler

GnomeDbDataHandler — Interface which provides data handling capabilities

## Synopsis

                GnomeDbDataHandler;
    GType       gnome_db_data_handler_get_type  (void);
    GnomeDbDataEntry* gnome_db_data_handler_get_entry_from_value
                                                (GnomeDbDataHandler *dh,
                                                 const GdaValue *value,
                                                 GdaValueType type);
    GtkCellRenderer* gnome_db_data_handler_get_cell_renderer
                                                (GnomeDbDataHandler *dh,
                                                 GdaValueType type);
    gchar*      gnome_db_data_handler_get_sql_from_value
                                                (GnomeDbDataHandler *dh,
                                                 const GdaValue *value);
    gchar*      gnome_db_data_handler_get_str_from_value
                                                (GnomeDbDataHandler *dh,
                                                 const GdaValue *value);
    GdaValue*   gnome_db_data_handler_get_value_from_sql
                                                (GnomeDbDataHandler *dh,
                                                 const gchar *sql,
                                                 GdaValueType type);
    GdaValue*   gnome_db_data_handler_get_value_from_str
                                                (GnomeDbDataHandler *dh,
                                                 const gchar *str,
                                                 GdaValueType type);
    GdaValue*   gnome_db_data_handler_get_sane_init_value
                                                (GnomeDbDataHandler *dh,
                                                 GdaValueType type);
    guint       gnome_db_data_handler_get_nb_gda_types
                                                (GnomeDbDataHandler *dh);
    GdaValueType gnome_db_data_handler_get_gda_type_index
                                                (GnomeDbDataHandler *dh,
                                                 guint index);
    gboolean    gnome_db_data_handler_accepts_gda_type
                                                (GnomeDbDataHandler *dh,
                                                 GdaValueType type);
    const gchar* gnome_db_data_handler_get_descr
                                                (GnomeDbDataHandler *dh);
    const gchar* gnome_db_data_handler_get_descr_detail
                                                (GnomeDbDataHandler *dh);
    const gchar* gnome_db_data_handler_get_version
                                                (GnomeDbDataHandler *dh);
    gboolean    gnome_db_data_handler_is_plugin (GnomeDbDataHandler *dh);
    const gchar* gnome_db_data_handler_get_plugin_name
                                                (GnomeDbDataHandler *dh);
    const gchar* gnome_db_data_handler_get_plugin_file
                                                (GnomeDbDataHandler *dh);
    gchar*      gnome_db_data_handler_get_key   (GnomeDbDataHandler *dh);

## Object Hierarchy

      GInterface
       +----GnomeDbDataHandler

## Known Implementations

GnomeDbDataHandler is implemented by GnomeDbHandlerNone, GnomeDbHandlerCidr, GnomeDbHandlerTime, GnomeDbHandlerText, GnomeDbHandlerString, GnomeDbHandlerNumerical, GnomeDbHandlerBoolean and GnomeDbHandlerPassmd5.

## Description

Because data types vary a lot from a DBMS to another, the GnomeDbDataHandler interface helps designing modules which can handle very specific pieces of data through plugins. Each object which imlements the GnomeDbDataHandler interface is expected to handle a subset of the possible libgda defined data types.

The GnomeDbDataHandler object can convert a GdaValue to and from both SQL and 'STR'. The SQL representation of a value is the actual string which would be used in an SQL statement (for example a string's SQL representation is surrounded by quotes such as 'that\'s a string'). The 'STR' representation is a user friendly representation of a value (and the previous example would simply be: that's a string).

Only one object which implements this interface is needed for any given data type, and it mainly contains some methods to manage values (as GdaValue structures). The GnomeDbDataEntry interface is complementary to this one since it it implemented by widgets where the user can enter or modify some data.

For a given data type, the GnomeDbServer (found in the correspoding GnomeDbDict object) will provide a reference to a valid GnomeDbDataHandler to handle values of that data type.

Libmergeant provides some default GnomeDbDataHandler objects for the most common data types (strings with a GnomeDbHandlerString, booleans with a GnomeDbHandlerBoolean, etc) and some other as plugins.

## Details

### GnomeDbDataHandler

    typedef struct _GnomeDbDataHandler GnomeDbDataHandler;

### gnome_db_data_handler_get_type ()

    GType       gnome_db_data_handler_get_type  (void);

Returns : |

### gnome_db_data_handler_get_entry_from_value ()

    GnomeDbDataEntry* gnome_db_data_handler_get_entry_from_value
                                                (GnomeDbDataHandler *dh,
                                                 const GdaValue *value,
                                                 GdaValueType type);

Create a new GnomeDbDataEntry widget to edit the given value. If the value is NULL or of type GDA_VALUE_TYPE_NULL, then the type argument is used and determines the real requested type (it is otherwise ignored).

Also, if the value is NULL or of type GDA_VALUE_TYPE_NULL, then the initial edited value in the widget will be the sane initial value provided by the GnomeDbDataHandler object.

`dh` : | an object which implements the GnomeDbDataHandler interface
`value` : | the original value to display or `NULL`
`type` : | the requested data type (if `value` is not `NULL` or of type NULL, then this parameter is ignored)
Returns : | the new widget

### gnome_db_data_handler_get_cell_renderer ()

    GtkCellRenderer* gnome_db_data_handler_get_cell_renderer
                                                (GnomeDbDataHandler *dh,
                                                 GdaValueType type);

Creates a new GtkCellRenderer object to handle `type` of data.

`dh` : | an object which implements the GnomeDbDataHandler interface
`type` : | the requested data type
Returns : | the new cell renderer

### gnome_db_data_handler_get_sql_from_value ()

    gchar*      gnome_db_data_handler_get_sql_from_value
                                                (GnomeDbDataHandler *dh,
                                                 const GdaValue *value);

Creates a new string which is an SQL representation of the given value. If the value is NULL or is of type GDA_VALUE_TYPE_NULL, the returned string is NULL.

`dh` : | an object which implements the GnomeDbDataHandler interface
`value` : | the value to be converted to a string
Returns : | the new string.

### gnome_db_data_handler_get_str_from_value ()

    gchar*      gnome_db_data_handler_get_str_from_value
                                                (GnomeDbDataHandler *dh,
                                                 const GdaValue *value);

Creates a new string which is a "user friendly" representation of the given value (usually it will be in the users's locale, specially for the dates). If the value is NULL or is of type GDA_VALUE_TYPE_NULL, the returned string is a copy of "" (empty string).

`dh` : | an object which implements the GnomeDbDataHandler interface
`value` : | the value to be converted to a string
Returns : | the new string.

### gnome_db_data_handler_get_value_from_sql ()

    GdaValue*   gnome_db_data_handler_get_value_from_sql
                                                (GnomeDbDataHandler *dh,
                                                 const gchar *sql,
                                                 GdaValueType type);

Creates a new GdaValue which represents the SQL value given as argument. This is the opposite of the function `gnome_db_data_handler_get_sql_from_value()`. The type argument is used to determine the real data type requested for the returned value.

If the sql string is NULL, then the returned GdaValue is of type GDA_VALUE_TYPE_NULL; if the sql string does not correspond to a valid SQL string for the requested type, then NULL is returned.

`dh` : | an object which implements the GnomeDbDataHandler interface
`sql` : |
`type` : |
Returns : | the new GdaValue or NULL on error

### gnome_db_data_handler_get_value_from_str ()

    GdaValue*   gnome_db_data_handler_get_value_from_str
                                                (GnomeDbDataHandler *dh,
                                                 const gchar *str,
                                                 GdaValueType type);

Creates a new GdaValue which represents the STR value given as argument. This is the opposite of the function `gnome_db_data_handler_get_str_from_value()`. The type argument is used to determine the real data type requested for the returned value.

If the str string is NULL, then the returned GdaValue is of type GDA_VALUE_TYPE_NULL; if the str string does not correspond to a valid STR string for the requested type, then NULL is returned.

`dh` : | an object which implements the GnomeDbDataHandler interface
`str` : |
`type` : |
Returns : | the new GdaValue or NULL on error

### gnome_db_data_handler_get_sane_init_value ()

    GdaValue*   gnome_db_data_handler_get_sane_init_value
                                                (GnomeDbDataHandler *dh,
                                                 GdaValueType type);

Creates a new GdaValue which holds a sane initial value to be used if no value is specifically provided. For example for a simple string, this would return gda_value_new_string ("").

`dh` : | an object which implements the GnomeDbDataHandler interface
`type` : |
Returns : | the new GdaValue.

### gnome_db_data_handler_get_nb_gda_types ()

    guint       gnome_db_data_handler_get_nb_gda_types
                                                (GnomeDbDataHandler *dh);

Get the number of GdaValueType types the GnomeDbDataHandler can handle correctly

`dh` : | an object which implements the GnomeDbDataHandler interface
Returns : | the number.

### gnome_db_data_handler_get_gda_type_index ()

    GdaValueType gnome_db_data_handler_get_gda_type_index
                                                (GnomeDbDataHandler *dh,
                                                 guint index);

Get the GdaValueType handled by the GnomeDbDataHandler, at the given position (starting at zero).

`dh` : | an object which implements the GnomeDbDataHandler interface
`index` : |
Returns : | the GdaValueType

### gnome_db_data_handler_accepts_gda_type ()

    gboolean    gnome_db_data_handler_accepts_gda_type
                                                (GnomeDbDataHandler *dh,
                                                 GdaValueType type);

Checks wether the GnomeDbDataHandler is able to handle the gda type given as argument.

`dh` : | an object which implements the GnomeDbDataHandler interface
`type` : |
Returns : | TRUE if the gda type can be handled

### gnome_db_data_handler_get_descr ()

    const gchar* gnome_db_data_handler_get_descr
                                                (GnomeDbDataHandler *dh);

Get a short description of the GnomeDbDataHandler

`dh` : | an object which implements the GnomeDbDataHandler interface
Returns : | the description

### gnome_db_data_handler_get_descr_detail ()

    const gchar* gnome_db_data_handler_get_descr_detail
                                                (GnomeDbDataHandler *dh);

Get a detailled description of the GnomeDbDataHandler

`dh` : | an object which implements the GnomeDbDataHandler interface
Returns : | the description

### gnome_db_data_handler_get_version ()

    const gchar* gnome_db_data_handler_get_version
                                                (GnomeDbDataHandler *dh);

Get the GnomeDbDataHandler's version

`dh` : | an object which implements the GnomeDbDataHandler interface
Returns : | the version

### gnome_db_data_handler_is_plugin ()

    gboolean    gnome_db_data_handler_is_plugin (GnomeDbDataHandler *dh);

Get wether the GnomeDbDataHandler is a plugin or not

`dh` : | an object which implements the GnomeDbDataHandler interface
Returns : | TRUE if the GnomeDbDataHandler is a plugin

### gnome_db_data_handler_get_plugin_name ()

    const gchar* gnome_db_data_handler_get_plugin_name
                                                (GnomeDbDataHandler *dh);

Get the name of the GnomeDbDataHandler if it is a plugin

`dh` : | an object which implements the GnomeDbDataHandler interface
Returns : | the name of the GnomeDbDataHandler if it is a plugin or NULL

### gnome_db_data_handler_get_plugin_file ()

    const gchar* gnome_db_data_handler_get_plugin_file
                                                (GnomeDbDataHandler *dh);

Get the file name (.so on Unix) of the GnomeDbDataHandler if it is a plugin

`dh` : | an object which implements the GnomeDbDataHandler interface
Returns : | the file name of the GnomeDbDataHandler if it is a plugin or NULL

### gnome_db_data_handler_get_key ()

    gchar*      gnome_db_data_handler_get_key   (GnomeDbDataHandler *dh);

Get a unique identifier for the GnomeDbDataHandler

`dh` : | an object which implements the GnomeDbDataHandler interface
Returns : | the identifier

## See Also

The GnomeDbServerDataType class an the GnomeDbDataEntry interface.