## GdaDataModel columns GdaDataModel columns — Management of GdaDataModel column attributes |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

                        GdaColumn;
    GdaColumn *         gda_column_new                      (void);
    GdaColumn *         gda_column_copy                     (GdaColumn *column);
    const gchar *       gda_column_get_name                 (GdaColumn *column);
    const gchar *       gda_column_get_description          (GdaColumn *column);
    const gchar *       gda_column_get_dbms_type            (GdaColumn *column);
    GType               gda_column_get_g_type               (GdaColumn *column);
    gboolean            gda_column_get_allow_null           (GdaColumn *column);
    gboolean            gda_column_get_auto_increment       (GdaColumn *column);
    gint                gda_column_get_position             (GdaColumn *column);
    const GValue *      gda_column_get_default_value        (GdaColumn *column);
    const GValue *      gda_column_get_attribute            (GdaColumn *column,
                                                             const gchar *attribute);
    void                gda_column_set_attribute            (GdaColumn *column,
                                                             const gchar *attribute,
                                                             const GValue *value,
                                                             GDestroyNotify destroy);
    #define             gda_column_set_attribute_static     (holder,
                                                             attribute,
                                                             value)

## Object Hierarchy

      GObject
       +----GdaColumn

## Properties

      "id"                       gchar*                : Read / Write

## Signals

      "g-type-changed"                                 : Run Last
      "name-changed"                                   : Run Last

## Description

The GdaColumn object represents a GdaDataModel's column and handle all its properties.

## Details

### GdaColumn

    typedef struct _GdaColumn GdaColumn;

### gda_column_new ()

    GdaColumn *         gda_column_new                      (void);

Returns : | a newly allocated GdaColumn object.

### gda_column_copy ()

    GdaColumn *         gda_column_copy                     (GdaColumn *column);

Creates a new GdaColumn object from an existing one.

`column` : | column to get a copy from.
Returns : | a newly allocated GdaColumn with a copy of the data in `column`. [transfer full]

### gda_column_get_name ()

    const gchar *       gda_column_get_name                 (GdaColumn *column);

`column` : | a GdaColumn.
Returns : | the name of `column`.

### gda_column_get_description ()

    const gchar *       gda_column_get_description          (GdaColumn *column);

`column` : | a GdaColumn.
Returns : | the column's description, in any

### gda_column_get_dbms_type ()

    const gchar *       gda_column_get_dbms_type            (GdaColumn *column);

`column` : | a GdaColumn.
Returns : | the database type of `column`.

### gda_column_get_g_type ()

    GType               gda_column_get_g_type               (GdaColumn *column);

`column` : | a GdaColumn.
Returns : | the type of `column`.

### gda_column_get_allow_null ()

    gboolean            gda_column_get_allow_null           (GdaColumn *column);

Gets the 'allow null' flag of the given column.

`column` : | a GdaColumn.
Returns : | whether the given column allows null values or not (`TRUE` or `FALSE`).

### gda_column_get_auto_increment ()

    gboolean            gda_column_get_auto_increment       (GdaColumn *column);

`column` : | a GdaColumn.
Returns : | whether the given column is an auto incremented one (`TRUE` or `FALSE`).

### gda_column_get_position ()

    gint                gda_column_get_position             (GdaColumn *column);

`column` : | a GdaColumn.
Returns : | the position of the column refer to in the containing data model.

### gda_column_get_default_value ()

    const GValue *      gda_column_get_default_value        (GdaColumn *column);

`column` : | a GdaColumn.
Returns : | `column`'s default value, as a GValue object, or `NULL` if column does not have a default value. [allow-none]

### gda_column_get_attribute ()

    const GValue *      gda_column_get_attribute            (GdaColumn *column,
                                                             const gchar *attribute);

Get the value associated to a named attribute.

Attributes can have any name, but Libgda proposes some default names, see this section.

`column` : | a GdaColumn
`attribute` : | attribute name as a string
Returns : | a read-only GValue, or `NULL` if not attribute named `attribute` has been set for `column`

### gda_column_set_attribute ()

    void                gda_column_set_attribute            (GdaColumn *column,
                                                             const gchar *attribute,
                                                             const GValue *value,
                                                             GDestroyNotify destroy);

Set the value associated to a named attribute. The `attribute` string is 'stolen' by this method, and the memory it uses will be freed using the `destroy` function when no longer needed (if `destroy` is `NULL`, then the string will not be freed at all).

Attributes can have any name, but Libgda proposes some default names, see this section.

If there is already an attribute named `attribute` set, then its value is replaced with the new value (`value` is copied), except if `value` is `NULL`, in which case the attribute is removed.

For example one would use it as:

`gda_column_set_attribute (holder, g_strdup (my_attribute), g_free, my_value); gda_column_set_attribute (holder, GDA_ATTRIBUTE_NAME, NULL, my_value);`

Note: this method does not modify in any way the contents of the data model for which `column` is a column (nor does it modify the table definition of the tables used by a SELECT statement is the model was created from a SELECT statement).

`column` : | a GdaColumn
`attribute` : | attribute name as a static string
`value` : | a GValue, or `NULL`. [allow-none]
`destroy` : | a function to be called when `attribute` is not needed anymore, or `NULL`. [allow-none]

### gda_column_set_attribute_static()

    #define gda_column_set_attribute_static(holder,attribute,value) gda_column_set_attribute((holder),(attribute),(value),NULL)

This function is similar to `gda_column_set_attribute()` but for static strings

`holder` : | a GdaHolder
`attribute` : | attribute's name
`value` : | the value to set the attribute to, or `NULL`. [allow-none]

## Property Details

### The `"id"` property

      "id"                       gchar*                : Read / Write

Column's Id (warning: the column's ID is not guaranteed to be unique in a GdaDataModel).

Default value: NULL

## Signal Details

### The `"g-type-changed"` signal

    void                user_function                      (GdaColumn *column,
                                                            GType     *old_type,
                                                            GType     *new_type,
                                                            gpointer   user_data)      : Run Last

Gets emitted whenever `column`'s type has been changed

`column` : | the GdaColumn object
`old_type` : | the column's previous type
`new_type` : | the column's new type
`user_data` : | user data set when the signal handler was connected.

### The `"name-changed"` signal

    void                user_function                      (GdaColumn *column,
                                                            gchar     *old_name,
                                                            gpointer   user_data)      : Run Last

Gets emitted whenever `column`'s name has been changed

`column` : | the GdaColumn object
`old_name` : | the column's previous name
`user_data` : | user data set when the signal handler was connected.

## See Also

GdaDataModel