Example #1
0
/**
 * gda_data_handler_get_descr:
 * @dh: an object which implements the #GdaDataHandler interface
 *
 * Get a short description of the GdaDataHandler
 *
 * Returns: (transfer none): the description
 */
const gchar *
gda_data_handler_get_descr (GdaDataHandler *dh)
{
	g_return_val_if_fail (dh && GDA_IS_DATA_HANDLER (dh), NULL);

	if (GDA_DATA_HANDLER_GET_IFACE (dh)->get_descr)
		return (GDA_DATA_HANDLER_GET_IFACE (dh)->get_descr) (dh);
	
	return NULL;
}
Example #2
0
/**
 * gda_data_handler_get_sane_init_value:
 * @dh: an object which implements the #GdaDataHandler interface
 * @type: a #GType
 *
 * Creates a new GValue which holds a sane initial value to be used if no value is specifically
 * provided. For example for a simple string, this would return a new value containing the "" string.
 *
 * Returns: (allow-none) (transfer full): the new #GValue, or %NULL if no such value can be created.
 */
GValue *
gda_data_handler_get_sane_init_value (GdaDataHandler *dh, GType type)
{
	g_return_val_if_fail (dh && GDA_IS_DATA_HANDLER (dh), NULL);
	g_return_val_if_fail (_accepts_g_type (dh, type), NULL);

	if (GDA_DATA_HANDLER_GET_IFACE (dh)->get_sane_init_value)
		return (GDA_DATA_HANDLER_GET_IFACE (dh)->get_sane_init_value) (dh, type);
	
	return NULL;
}
Example #3
0
/**
 * gda_data_handler_get_value_from_sql:
 * @dh: an object which implements the #GdaDataHandler interface
 * @sql: (allow-none) (transfer none): an SQL string, or %NULL
 * @type: a GType
 *
 * Creates a new GValue which represents the SQL value given as argument. This is
 * the opposite of the function gda_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 GValue is of type GDA_TYPE_NULL;
 * if the @sql string does not correspond to a valid SQL string for the requested type, then
 * the %NULL is returned.
 *
 * Returns: (transfer full): the new #GValue or %NULL on error
 */
GValue *
gda_data_handler_get_value_from_sql (GdaDataHandler *dh, const gchar *sql, GType type)
{
	g_return_val_if_fail (dh && GDA_IS_DATA_HANDLER (dh), NULL);
	g_return_val_if_fail (_accepts_g_type (dh, type), NULL);

	if (!sql)
		return gda_value_new_null ();

	if (GDA_DATA_HANDLER_GET_IFACE (dh)->get_value_from_sql)
		return (GDA_DATA_HANDLER_GET_IFACE (dh)->get_value_from_sql) (dh, sql, type);
	
	return NULL;
}
Example #4
0
/**
 * gda_data_handler_get_str_from_value:
 * @dh: an object which implements the #GdaDataHandler interface
 * @value: (allow-none): the value to be converted to a string, or %NULL
 *
 * Creates a new string which is a "user friendly" representation of the given value
 * (in the user's locale, specially for the dates). If the value is 
 * NULL or is of type GDA_TYPE_NULL, the returned string is a copy of "" (empty string).
 *
 * Note: the returned value will be in the current locale representation.
 *
 * Returns: (transfer full): the new string, or %NULL if an error occurred
 */
gchar *
gda_data_handler_get_str_from_value (GdaDataHandler *dh, const GValue *value)
{
	g_return_val_if_fail (dh && GDA_IS_DATA_HANDLER (dh), NULL);

	if (! value || gda_value_is_null (value))
		return g_strdup ("");

	g_return_val_if_fail (_accepts_g_type (dh, G_VALUE_TYPE (value)), NULL);

	/* Calling the real function with value != NULL and not of type GDA_TYPE_NULL */
	if (GDA_DATA_HANDLER_GET_IFACE (dh)->get_str_from_value)
		return (GDA_DATA_HANDLER_GET_IFACE (dh)->get_str_from_value) (dh, value);
	
	return NULL;
}
void
gda_server_provider_handler_declare (GdaServerProvider *prov, GdaDataHandler *dh,
				     GdaConnection *cnc, 
				     GType g_type, const gchar *dbms_type)
{
	GdaServerProviderHandlerInfo *info;
	g_return_if_fail (GDA_IS_SERVER_PROVIDER (prov));
	g_return_if_fail (GDA_IS_DATA_HANDLER (dh));
	
	info = g_new (GdaServerProviderHandlerInfo, 1);
	info->cnc = cnc;
	info->g_type = g_type;
	info->dbms_type = dbms_type ? g_strdup (dbms_type) : NULL;

	g_hash_table_insert (prov->priv->data_handlers, info, dh);
	g_object_ref (dh);
}
Example #6
0
/**
 * gdaui_entry_string_new:
 * @dh: the data handler to be used by the new widget
 * @type: the requested data type (compatible with @dh)
 * @options: (nullable): some options formatting the new entry, or %NULL
 *
 * Creates a new data entry widget. Known options are: MAX_SIZE, MULTILINE, and HIDDEN
 *
 * Returns: (transfer full): the new widget
 */
GtkWidget *
gdaui_entry_string_new (GdaDataHandler *dh, GType type, const gchar *options)
{
	GObject *obj;
	GdauiEntryString *mgstr;

	g_return_val_if_fail (GDA_IS_DATA_HANDLER (dh), NULL);
	g_return_val_if_fail (gda_data_handler_accepts_g_type (dh, type), NULL);
	g_return_val_if_fail (type == G_TYPE_STRING, NULL);

	obj = g_object_new (GDAUI_TYPE_ENTRY_STRING, "handler", dh, NULL);
	mgstr = GDAUI_ENTRY_STRING (obj);
	gdaui_data_entry_set_value_type (GDAUI_DATA_ENTRY (mgstr), type);

	g_object_set (obj, "options", options, NULL);

	return GTK_WIDGET (obj);
}
Example #7
0
/**
 * gda_data_handler_get_value_from_str:
 * @dh: an object which implements the #GdaDataHandler interface
 * @str: (allow-none) (transfer none): a string or %NULL
 * @type: a GType
 *
 * Creates a new GValue which represents the @str value given as argument. This is
 * the opposite of the function gda_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 GValue is of type GDA_TYPE_NULL;
 * if the @str string does not correspond to a valid string for the requested type, then
 * %NULL is returned.
 *
 * Note: the @str string must be in the current locale representation
 *
 * Returns: (transfer full): the new #GValue or %NULL on error
 */
GValue *
gda_data_handler_get_value_from_str (GdaDataHandler *dh, const gchar *str, GType type)
{
	g_return_val_if_fail (dh && GDA_IS_DATA_HANDLER (dh), NULL);
	g_return_val_if_fail (_accepts_g_type (dh, type), NULL);

	if (!str)
		return gda_value_new_null ();

	if (GDA_DATA_HANDLER_GET_IFACE (dh)->get_value_from_str)
		return (GDA_DATA_HANDLER_GET_IFACE (dh)->get_value_from_str) (dh, str, type);
	else {
		/* if the get_value_from_str() method is not implemented, then we try the
		   get_value_from_sql() method */
		if (GDA_DATA_HANDLER_GET_IFACE (dh)->get_value_from_sql)
			return (GDA_DATA_HANDLER_GET_IFACE (dh)->get_value_from_sql) (dh, str, type);
	}
	
	return NULL;
}
Example #8
0
/**
 * gda_data_handler_accepts_g_type:
 * @dh: an object which implements the #GdaDataHandler interface
 * @type: a #GType
 *
 * Checks wether the GdaDataHandler is able to handle the gda type given as argument.
 *
 * Returns: %TRUE if the gda type can be handled
 */
gboolean
gda_data_handler_accepts_g_type (GdaDataHandler *dh, GType type)
{
	g_return_val_if_fail (GDA_IS_DATA_HANDLER (dh), FALSE);
	return _accepts_g_type (dh, type);
}