gda-util

gda-util — Utility functions

Synopsis

const gchar*        gda_type_to_string                  (GdaValueType type);
GdaValueType        gda_type_from_string                (const gchar *str);
GList*              gda_string_hash_to_list             (GHashTable *hash_table);
gchar*              gda_sql_replace_placeholders        (const gchar *sql,
                                                         GdaParameterList *params);
gchar*              gda_file_load                       (const gchar *filename);
gboolean            gda_file_save                       (const gchar *filename,
                                                         const gchar *buffer,
                                                         gint len);

Description

Details

gda_type_to_string ()

const gchar*        gda_type_to_string                  (GdaValueType type);

type :

Type to convert from.

Returns :

the string representing the given GdaValueType. This is not necessarily the same string used to describe the column type in a SQL statement. Use gda_connection_get_schema() with GDA_CONNECTION_SCHEMA_TYPES to get the actual types supported by the provider.

gda_type_from_string ()

GdaValueType        gda_type_from_string                (const gchar *str);

str :

the name of a GdaValueType, as returned by gda_type_to_string().

Returns :

the GdaValueType represented by the given str.

gda_string_hash_to_list ()

GList*              gda_string_hash_to_list             (GHashTable *hash_table);

Creates a new list of strings, which contains all keys of a given hash table. After using it, you should free this list by calling g_list_free.

hash_table :

a hash table.

Returns :

a new GList.

gda_sql_replace_placeholders ()

gchar*              gda_sql_replace_placeholders        (const gchar *sql,
                                                         GdaParameterList *params);

Replaces the placeholders (:name) in the given SQL command with the values from the GdaParameterList specified as the params argument.

sql :

a SQL command containing placeholders for values.

params :

a list of values for the placeholders.

Returns :

the SQL string with all placeholders replaced, or NULL on error. On success, the returned string must be freed by the caller when no longer needed.

gda_file_load ()

gchar*              gda_file_load                       (const gchar *filename);

Loads a file, specified by the given uri, and returns the file contents as a string.

It is the caller's responsibility to free the returned value.

filename :

path for the file to be loaded.

Returns :

the file contents as a newly-allocated string, or NULL if there is an error.

gda_file_save ()

gboolean            gda_file_save                       (const gchar *filename,
                                                         const gchar *buffer,
                                                         gint len);

Saves a chunk of data into a file.

filename :

path for the file to be saved.

buffer :

contents of the file.

len :

size of buffer.

Returns :

TRUE if successful, FALSE on error.