![]() |
![]() |
![]() |
GNOME Data Access 4.0 manual | ![]() |
---|---|---|---|---|
GdaHolder; GdaHolder* gda_holder_new (GType type); #define gda_holder_new_string (id,str) #define gda_holder_new_boolean (id,abool) #define gda_holder_new_int (id,anint) GdaHolder* gda_holder_new_inline (GType type, const gchar *id, ...); GdaHolder* gda_holder_copy (GdaHolder *orig); GType gda_holder_get_g_type (GdaHolder *holder); const gchar* gda_holder_get_id (GdaHolder *holder); const GValue* gda_holder_get_value (GdaHolder *holder); gchar* gda_holder_get_value_str (GdaHolder *holder, GdaDataHandler *dh); gboolean gda_holder_set_value (GdaHolder *holder, const GValue *value, GError **error); gboolean gda_holder_set_value_str (GdaHolder *holder, GdaDataHandler *dh, const gchar *value, GError **error); gboolean gda_holder_take_value (GdaHolder *holder, GValue *value, GError **error); const GValue* gda_holder_get_default_value (GdaHolder *holder); void gda_holder_set_default_value (GdaHolder *holder, const GValue *value); gboolean gda_holder_set_value_to_default (GdaHolder *holder); gboolean gda_holder_value_is_default (GdaHolder *holder); void gda_holder_force_invalid (GdaHolder *holder); gboolean gda_holder_is_valid (GdaHolder *holder); void gda_holder_set_not_null (GdaHolder *holder, gboolean not_null); gboolean gda_holder_get_not_null (GdaHolder *holder); gboolean gda_holder_set_source_model (GdaHolder *holder, GdaDataModel *model, gint col, GError **error); GdaDataModel* gda_holder_get_source_model (GdaHolder *holder, gint *col); gboolean gda_holder_set_bind (GdaHolder *holder, GdaHolder *bind_to, GError **error); GdaHolder* gda_holder_get_bind (GdaHolder *holder);
"description" gchar* : Read / Write "full-bind" GdaHolder* : Read / Write "g-type" gulong : Read / Write / Construct Only "id" gchar* : Read / Write "name" gchar* : Read / Write "not-null" gboolean : Read / Write "plugin" gchar* : Read / Write "simple-bind" GdaHolder* : Read / Write "source-column" gint : Read / Write "source-model" GdaDataModel* : Read / Write
The GdaHolder is a container for a single GValue value. It also specifies various attributes of the contained value (default value, ...)
GdaHolder* gda_holder_new (GType type);
Creates a new holder of type type
|
the GType requested |
Returns : |
a new GdaHolder object |
#define gda_holder_new_string(id,str) gda_holder_new_inline (G_TYPE_STRING, (id), (str))
|
|
|
#define gda_holder_new_boolean(id,abool) gda_holder_new_inline (G_TYPE_BOOLEAN, (id), (abool))
|
|
|
#define gda_holder_new_int(id,anint) gda_holder_new_inline (G_TYPE_INT, (id), (anint))
|
|
|
GdaHolder* gda_holder_new_inline (GType type, const gchar *id, ...);
Creates a new GdaHolder object named name
, of type type
, and containing the value passed
as the last argument.
Note that this function is a utility function and that anly a limited set of types are supported. Trying to use an unsupported type will result in a warning, and the returned value holder holding a safe default value.
|
a valid GLib type |
|
the id of the holder to create, or NULL
|
|
value to set |
Returns : |
a new GdaHolder object |
GType gda_holder_get_g_type (GdaHolder *holder);
Get holder
's type
|
a GdaHolder object |
Returns : |
the data type |
const gchar* gda_holder_get_id (GdaHolder *holder);
Get the ID of holder
. The ID can be set using holder
's "id" property
|
a GdaHolder object |
Returns : |
the ID (don't modify the string). |
const GValue* gda_holder_get_value (GdaHolder *holder);
Get the value held into the holder. If holder
is set to use its default value
and that default value is not of the same type as holder
, then NULL
is returned.
If holder
is set to NULL, then the returned value is a GDA_TYPE_NULL GValue.
|
a GdaHolder object |
Returns : |
the value, or NULL
|
gchar* gda_holder_get_value_str (GdaHolder *holder, GdaDataHandler *dh);
Same functionality as gda_holder_get_value()
except that it returns the value as a string
(the conversion is done using dh
if not NULL
, or the default data handler otherwise).
|
a GdaHolder object |
|
a GdaDataHandler to use, or NULL
|
Returns : |
the value, or NULL
|
gboolean gda_holder_set_value (GdaHolder *holder, const GValue *value, GError **error);
Sets the value within the holder. If holder
is an alias for another
holder, then the value is also set for that other holder.
On success, the action of any call to gda_holder_force_invalid()
is cancelled
as soon as this method is called (even if holder
's value does not actually change)
If the value is not different from the one already contained within holder
,
then holder
is not changed and no signal is emitted.
Note1: the value
argument is treated the same way if it is NULL
or if it is a GDA_TYPE_NULL value
Note2: if holder
can't accept the value
value, then this method returns FALSE, and holder
will be left
in an invalid state.
Note3: before the change is accepted by holder
, the "validate-change" signal will be emitted (the value
of which can prevent the change from happening) which can be connected to to have a greater control
of which values holder
can have, or implement some business rules.
|
a GdaHolder object |
|
a value to set the holder to, or NULL
|
|
a place to store errors, or NULL
|
Returns : |
TRUE if value has been set |
gboolean gda_holder_set_value_str (GdaHolder *holder, GdaDataHandler *dh, const gchar *value, GError **error);
Same functionality as gda_holder_set_value()
except that it uses a string representation
of the value to set, which will be converted into a GValue first (using default data handler if
dh
is NULL
).
Note1: if value
is NULL
or is the "NULL" string, then holder
's value is set to NULL
.
Note2: if holder
can't accept the value
value, then this method returns FALSE, and holder
will be left
in an invalid state.
|
a GdaHolder object |
|
a GdaDataHandler to use, or NULL
|
|
a value to set the holder to, as a string |
|
a place to store errors, or NULL
|
Returns : |
TRUE if value has been set |
gboolean gda_holder_take_value (GdaHolder *holder, GValue *value, GError **error);
Sets the value within the holder. If holder
is an alias for another
holder, then the value is also set for that other holder.
On success, the action of any call to gda_holder_force_invalid()
is cancelled
as soon as this method is called (even if holder
's value does not actually change).
If the value is not different from the one already contained within holder
,
then holder
is not chaged and no signal is emitted.
Note1: if holder
can't accept the value
value, then this method returns FALSE, and holder
will be left
in an invalid state.
Note2: before the change is accepted by holder
, the "validate-change" signal will be emitted (the value
of which can prevent the change from happening) which can be connected to to have a greater control
of which values holder
can have, or implement some business rules.
|
a GdaHolder object |
|
a value to set the holder to |
|
a place to store errors, or NULL
|
Returns : |
TRUE if value has been set |
const GValue* gda_holder_get_default_value (GdaHolder *holder);
Get the default value held into the holder. WARNING: the default value does not need to be of
the same type as the one required by holder
.
|
a GdaHolder object |
Returns : |
the default value |
void gda_holder_set_default_value (GdaHolder *holder, const GValue *value);
Sets the default value within the holder. If value
is NULL
then holder
won't have a
default value anymore. To set a default value to NULL
, then pass a GValue created using
gda_value_new_null()
.
NOTE: the default value does not need to be of the same type as the one required by holder
.
|
a GdaHolder object |
|
a value to set the holder's default value, or NULL
|
gboolean gda_holder_set_value_to_default (GdaHolder *holder);
Set holder
's value to its default value.
|
a GdaHolder object |
Returns : |
TRUE if holder has got a default value
|
gboolean gda_holder_value_is_default (GdaHolder *holder);
Tells if holder
's current value is the default one.
|
a GdaHolder object |
Returns : |
TRUE if holder holder 's current value is the default one
|
void gda_holder_force_invalid (GdaHolder *holder);
Forces a holder to be invalid; to set it valid again, a new value must be assigned
to it using gda_holder_set_value()
or gda_holder_take_value()
.
holder
's value is set to NULL
.
|
a GdaHolder object |
gboolean gda_holder_is_valid (GdaHolder *holder);
Get the validity of holder
(that is, of the value held by holder
)
|
a GdaHolder object |
Returns : |
TRUE if holder 's value can safely be used
|
void gda_holder_set_not_null (GdaHolder *holder, gboolean not_null);
Sets if the holder can have a NULL value. If not_null
is TRUE, then that won't be allowed
|
a GdaHolder object |
|
gboolean gda_holder_get_not_null (GdaHolder *holder);
Get wether the holder can be NULL or not
|
a GdaHolder object |
Returns : |
TRUE if the holder cannot be NULL |
gboolean gda_holder_set_source_model (GdaHolder *holder, GdaDataModel *model, gint col, GError **error);
Sets a limit on the possible values for the holder
holder: the value must be among the values
contained in the col
column of the model
data model.
|
a GdaHolder object |
|
a GdaDataModel object or NULL |
|
the reference column in model
|
|
location to store error, or NULL
|
Returns : |
TRUE if no error occurred |
GdaDataModel* gda_holder_get_source_model (GdaHolder *holder, gint *col);
Tells if holder
has its values sourceed by a GdaDataModel, and optionnaly
allows to fetch the resteictions.
|
a GdaHolder |
|
a place to store the column in the model sourceing the holder, or NULL
|
Returns : |
a pointer to the GdaDataModel source for holder
|
gboolean gda_holder_set_bind (GdaHolder *holder, GdaHolder *bind_to, GError **error);
Sets holder
to change when bind_to
changes (and does not make bind_to
change when holder
changes).
If bind_to
is NULL
, then holder
will not be bound anymore.
"source-column"
property"source-column" gint : Read / Write
Allowed values: >= 0
Default value: 0
"changed"
signalvoid user_function (GdaHolder *gdaholder, gpointer user_data) : Run First
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"source-changed"
signalvoid user_function (GdaHolder *gdaholder, gpointer user_data) : Run First
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"validate-change"
signalgpointer user_function (GdaHolder *gdaholder, gpointer arg1, gpointer user_data) : Run Last
|
the object which received the signal. |
|
|
|
user data set when the signal handler was connected. |
Returns : |