if (col >= 0)
{
value = gdaex_data_model_get_value_stringify_at (data_model, row, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
if (col >= 0)
{
value = gdaex_data_model_get_value_gdatimestamp_at (data_model, row, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
value = NULL;
}
- return gda_timestamp_copy ((gpointer)value);
+ return (GdaTimestamp *)gda_timestamp_copy ((gpointer)value);
}
/**
if (col >= 0)
{
value = gdaex_data_model_get_value_gdate_at (data_model, row, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
if (col >= 0)
{
value = gdaex_data_model_get_value_gdatetime_at (data_model, row, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
if (col >= 0)
{
value = gdaex_data_model_get_value_tm_at (data_model, row, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
error = NULL;
v = gda_data_model_get_value_at (data_model, col, row, &error);
- if (error == NULL)
+ if (v != NULL && error == NULL)
{
if (!gda_value_is_null (v))
{
}
else
{
- g_warning ("Error on retrieving field's value: %s\n",
+ g_warning ("Error on retrieving field's value: «%s».\n%s\n",
+ gda_data_model_get_column_name (data_model, col),
error->message != NULL ? error->message : "no details");
ret = NULL;
}
error = NULL;
v = gda_data_model_get_value_at (data_model, col, row, &error);
- if (error != NULL)
- {
- g_warning ("Error on retrieving field's value: %s\n",
- error->message != NULL ? error->message : "no details");
- }
- else
+ if (v != NULL && error == NULL)
{
if (gda_value_isa (v, G_TYPE_INT))
{
ret = strtol (gda_value_stringify (v), NULL, 10);
}
}
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\n%s\n",
+ gda_data_model_get_column_name (data_model, col),
+ error->message != NULL ? error->message : "no details");
+ }
return ret;
}
error = NULL;
v = gda_data_model_get_value_at (data_model, col, row, &error);
- if (error != NULL)
- {
- g_warning ("Error on retrieving field's value: %s\n",
- error->message != NULL ? error->message : "no details");
- }
- else
+ if (v != NULL && error == NULL)
{
if (gda_value_isa (v, G_TYPE_FLOAT))
{
ret = g_strtod (gda_value_stringify (v), NULL);
}
}
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\n%s\n",
+ gda_data_model_get_column_name (data_model, col),
+ error->message != NULL ? error->message : "no details");
+ }
return ret;
}
error = NULL;
v = gda_data_model_get_value_at (data_model, col, row, &error);
- if (error != NULL)
- {
- g_warning ("Error on retrieving field's value: %s\n",
- error->message != NULL ? error->message : "no details");
- }
- else
+ if (v != NULL && error == NULL)
{
if (gda_value_isa (v, G_TYPE_DOUBLE))
{
ret = g_strtod (gda_value_stringify (v), NULL);
}
}
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\n%s\n",
+ gda_data_model_get_column_name (data_model, col),
+ error->message != NULL ? error->message : "no details");
+ }
return ret;
}
error = NULL;
v = gda_data_model_get_value_at (data_model, col, row, &error);
- if (error != NULL)
- {
- g_warning ("Error on retrieving field's value: %s\n",
- error->message != NULL ? error->message : "no details");
- }
- else
+ if (v != NULL && error == NULL)
{
if (gda_value_isa (v, G_TYPE_BOOLEAN))
{
}
else
{
- gchar *vstr = g_strstrip (gda_value_stringify (v));
+ gchar *vstr = g_strstrip (g_strdup (gda_value_stringify (v)));
if (strcasecmp (vstr, "true") == 0 ||
strcasecmp (vstr, "t") == 0 ||
strcasecmp (vstr, "yes") == 0 ||
{
ret = FALSE;
}
+ g_free (vstr);
}
}
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\n%s\n",
+ gda_data_model_get_column_name (data_model, col),
+ error->message != NULL ? error->message : "no details");
+ }
return ret;
}
error = NULL;
v = gda_data_model_get_value_at (data_model, col, row, &error);
- if (v == NULL || error != NULL)
+ if (v != NULL && error == NULL)
{
- g_warning ("Error on retrieving field's value: %s\n",
- error->message != NULL ? error->message : "no details");
- }
- else if (!gda_value_is_null (v))
- {
- if (gda_value_isa (v, GDA_TYPE_TIMESTAMP))
- {
- gdatimestamp = (GdaTimestamp *)gda_value_get_timestamp (v);
- }
- else if (gda_value_isa (v, G_TYPE_DATE_TIME))
+ if (!gda_value_is_null (v))
{
- GDateTime *gdatetime;
+ if (gda_value_isa (v, GDA_TYPE_TIMESTAMP))
+ {
+ gdatimestamp = (GdaTimestamp *)gda_value_get_timestamp (v);
+ }
+ else if (gda_value_isa (v, G_TYPE_DATE_TIME))
+ {
+ GDateTime *gdatetime;
- gdatetime = gdaex_data_model_get_value_gdatetime_at (data_model, row, col);
- gdatimestamp = g_malloc0 (sizeof (GdaTimestamp));
- gdatimestamp->year = g_date_time_get_year (gdatetime);
- gdatimestamp->month = g_date_time_get_month (gdatetime);
- gdatimestamp->day = g_date_time_get_day_of_month (gdatetime);
- gdatimestamp->hour = g_date_time_get_hour (gdatetime);
- gdatimestamp->minute = g_date_time_get_minute (gdatetime);
- gdatimestamp->second = g_date_time_get_second (gdatetime);
- }
- else if (gda_value_isa (v, G_TYPE_DATE))
- {
- GDate *date;
+ gdatetime = gdaex_data_model_get_value_gdatetime_at (data_model, row, col);
+ gdatimestamp = g_malloc0 (sizeof (GdaTimestamp));
+ gdatimestamp->year = g_date_time_get_year (gdatetime);
+ gdatimestamp->month = g_date_time_get_month (gdatetime);
+ gdatimestamp->day = g_date_time_get_day_of_month (gdatetime);
+ gdatimestamp->hour = g_date_time_get_hour (gdatetime);
+ gdatimestamp->minute = g_date_time_get_minute (gdatetime);
+ gdatimestamp->second = g_date_time_get_second (gdatetime);
+ }
+ else if (gda_value_isa (v, G_TYPE_DATE))
+ {
+ GDate *date;
- date = gdaex_data_model_get_value_gdate_at (data_model, row, col);
+ date = gdaex_data_model_get_value_gdate_at (data_model, row, col);
- if (date != NULL)
- {
- gdatimestamp = g_malloc0 (sizeof (GdaTimestamp));
- if (g_date_valid (date))
+ if (date != NULL)
{
- gdatimestamp->year = g_date_get_year (date);
- gdatimestamp->month = g_date_get_month (date);
- gdatimestamp->day = g_date_get_day (date);
- }
- else
- {
- gdatimestamp->year = date->year;
- gdatimestamp->month = date->month;
- gdatimestamp->day = date->day;
+ gdatimestamp = g_new0 (GdaTimestamp, 1);
+ if (g_date_valid (date))
+ {
+ gdatimestamp->year = g_date_get_year (date);
+ gdatimestamp->month = g_date_get_month (date);
+ gdatimestamp->day = g_date_get_day (date);
+ }
+ else
+ {
+ gdatimestamp->year = date->year;
+ gdatimestamp->month = date->month;
+ gdatimestamp->day = date->day;
+ }
+ g_date_free (date);
}
}
- }
- else if (gda_value_isa (v, GDA_TYPE_TIME))
- {
- const GdaTime *time;
+ else if (gda_value_isa (v, GDA_TYPE_TIME))
+ {
+ const GdaTime *time;
- time = gda_value_get_time (v);
+ time = gda_value_get_time (v);
- if (time != NULL)
+ if (time != NULL)
+ {
+ gdatimestamp = g_new0 (GdaTimestamp, 1);
+ gdatimestamp->hour = time->hour;
+ gdatimestamp->minute = time->minute;
+ gdatimestamp->second = time->second;
+ }
+ }
+ else
{
- gdatimestamp = g_malloc0 (sizeof (GdaTimestamp));
- gdatimestamp->hour = time->hour;
- gdatimestamp->minute = time->minute;
- gdatimestamp->second = time->second;
+ g_warning ("Error on retrieving field's value: «%s».\nUnknown GValue type.",
+ gda_data_model_get_column_name (data_model, col));
}
}
- else
- {
- g_warning ("Error on retrieving field's value: unknown GValue type.");
- }
+ }
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\n%s\n",
+ gda_data_model_get_column_name (data_model, col),
+ error->message != NULL ? error->message : "no details");
}
return (GdaTimestamp *)gda_timestamp_copy ((gpointer)gdatimestamp);
error = NULL;
v = gda_data_model_get_value_at (data_model, col, row, &error);
- if (v == NULL || error != NULL)
+ if (v != NULL && error == NULL)
{
- g_warning ("Error on retrieving field's value: %s\n",
- error->message != NULL ? error->message : "no details");
- }
- else if (!gda_value_is_null (v))
- {
- if (gda_value_isa (v, GDA_TYPE_TIMESTAMP))
- {
- gdatimestamp = gdaex_data_model_get_value_gdatimestamp_at (data_model, row, col);
- ret = g_date_new_dmy ((GDateYear)gdatimestamp->year,
- (GDateMonth)gdatimestamp->month,
- (GDateDay)gdatimestamp->day);
- }
- else if (gda_value_isa (v, G_TYPE_DATE_TIME))
- {
- gdatetime = gdaex_data_model_get_value_gdatetime_at (data_model, row, col);
- ret = g_date_new_dmy ((GDateYear)g_date_time_get_year ((GDateTime *)gdatetime),
- (GDateMonth)g_date_time_get_month ((GDateTime *)gdatetime),
- (GDateDay)g_date_time_get_day_of_month ((GDateTime *)gdatetime));
- }
- else if (gda_value_isa (v, G_TYPE_DATE))
- {
- ret = (GDate *)g_value_get_boxed (v);
- }
- else
+ if (!gda_value_is_null (v))
{
- g_warning ("Error on retrieving field's value: unknown GValue type.");
+ if (gda_value_isa (v, GDA_TYPE_TIMESTAMP))
+ {
+ gdatimestamp = gdaex_data_model_get_value_gdatimestamp_at (data_model, row, col);
+ ret = g_date_new_dmy ((GDateYear)gdatimestamp->year,
+ (GDateMonth)gdatimestamp->month,
+ (GDateDay)gdatimestamp->day);
+ }
+ else if (gda_value_isa (v, G_TYPE_DATE_TIME))
+ {
+ gdatetime = gdaex_data_model_get_value_gdatetime_at (data_model, row, col);
+ ret = g_date_new_dmy ((GDateYear)g_date_time_get_year ((GDateTime *)gdatetime),
+ (GDateMonth)g_date_time_get_month ((GDateTime *)gdatetime),
+ (GDateDay)g_date_time_get_day_of_month ((GDateTime *)gdatetime));
+ }
+ else if (gda_value_isa (v, G_TYPE_DATE))
+ {
+ ret = (GDate *)g_value_get_boxed (v);
+ }
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\nUnknown GValue type.",
+ gda_data_model_get_column_name (data_model, col));
+ }
}
}
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\n%s\n",
+ gda_data_model_get_column_name (data_model, col),
+ error->message != NULL ? error->message : "no details");
+ }
return ret;
}
error = NULL;
v = gda_data_model_get_value_at (data_model, col, row, &error);
- if (v == NULL || error != NULL)
- {
- g_warning ("Error on retrieving field's value: %s\n",
- error->message != NULL ? error->message : "no details");
- }
- else if (!gda_value_is_null (v))
+ if (v != NULL && error == NULL)
{
- if (gda_value_isa (v, GDA_TYPE_TIMESTAMP))
- {
- gdatimestamp = gdaex_data_model_get_value_gdatimestamp_at (data_model, row, col);
- ret = g_date_time_new_local ((gint)gdatimestamp->year,
- (gint)gdatimestamp->month,
- (gint)gdatimestamp->day,
- (gint)gdatimestamp->hour,
- (gint)gdatimestamp->minute,
- (gdouble)gdatimestamp->second);
- }
- else if (gda_value_isa (v, G_TYPE_DATE))
- {
- gdate = gdaex_data_model_get_value_gdate_at (data_model, row, col);
- ret = g_date_time_new_local ((gint)g_date_get_year (gdate),
- (gint)g_date_get_month (gdate),
- (gint)g_date_get_day (gdate),
- 0,
- 0,
- 0.0);
- }
- else if (gda_value_isa (v, G_TYPE_DATE_TIME))
- {
- ret = (GDateTime *)g_value_get_boxed (v);
- }
- else
+ if (!gda_value_is_null (v))
{
- g_warning ("Error on retrieving field's value: unknown GValue type.");
+ if (gda_value_isa (v, GDA_TYPE_TIMESTAMP))
+ {
+ gdatimestamp = gdaex_data_model_get_value_gdatimestamp_at (data_model, row, col);
+ ret = g_date_time_new_local ((gint)gdatimestamp->year,
+ (gint)gdatimestamp->month,
+ (gint)gdatimestamp->day,
+ (gint)gdatimestamp->hour,
+ (gint)gdatimestamp->minute,
+ (gdouble)gdatimestamp->second);
+ }
+ else if (gda_value_isa (v, G_TYPE_DATE))
+ {
+ gdate = gdaex_data_model_get_value_gdate_at (data_model, row, col);
+ ret = g_date_time_new_local ((gint)g_date_get_year (gdate),
+ (gint)g_date_get_month (gdate),
+ (gint)g_date_get_day (gdate),
+ 0,
+ 0,
+ 0.0);
+ }
+ else if (gda_value_isa (v, G_TYPE_DATE_TIME))
+ {
+ ret = (GDateTime *)g_value_get_boxed (v);
+ }
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\nUnknown GValue type.",
+ gda_data_model_get_column_name (data_model, col));
+ }
}
}
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\n%s\n",
+ gda_data_model_get_column_name (data_model, col),
+ error->message != NULL ? error->message : "no details");
+ }
return ret;
}
error = NULL;
v = gda_data_model_get_value_at (data_model, col, row, &error);
- if (v == NULL || error != NULL)
+ if (v != NULL && error == NULL)
{
- g_warning ("Error on retrieving field's value: %s\n",
- error->message != NULL ? error->message : "no details");
- }
- else if (!gda_value_is_null (v))
- {
- GdaTimestamp *gdatimestamp;
-
- gdatimestamp = gdaex_data_model_get_value_gdatimestamp_at (data_model, row, col);
-
- if (gdatimestamp != NULL)
+ if (!gda_value_is_null (v))
{
- ret = g_malloc0 (sizeof (struct tm));
+ GdaTimestamp *gdatimestamp;
- ret->tm_year = gdatimestamp->year - 1900;
- ret->tm_mon = gdatimestamp->month - 1;
- ret->tm_mday = gdatimestamp->day;
- ret->tm_hour = gdatimestamp->hour;
- ret->tm_min = gdatimestamp->minute;
- ret->tm_sec = gdatimestamp->second;
+ gdatimestamp = gdaex_data_model_get_value_gdatimestamp_at (data_model, row, col);
+
+ if (gdatimestamp != NULL)
+ {
+ ret = g_new0 (struct tm, 1);
+
+ ret->tm_year = gdatimestamp->year - 1900;
+ ret->tm_mon = gdatimestamp->month - 1;
+ ret->tm_mday = gdatimestamp->day;
+ ret->tm_hour = gdatimestamp->hour;
+ ret->tm_min = gdatimestamp->minute;
+ ret->tm_sec = gdatimestamp->second;
+ }
}
}
+ else
+ {
+ g_warning ("Error on retrieving field's value: «%s».\n%s\n",
+ gda_data_model_get_column_name (data_model, col),
+ error->message != NULL ? error->message : "no details");
+ }
return ret;
}
*/
gchar
*gdaex_data_model_iter_get_field_value_stringify_at (GdaDataModelIter *iter,
- const gchar *field_name)
+ const gchar *field_name)
{
GdaDataModel *data_model;
gchar *value;
if (col >= 0)
{
value = gdaex_data_model_iter_get_value_stringify_at (iter, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
if (col >= 0)
{
value = gdaex_data_model_iter_get_value_gdatimestamp_at (iter, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
value = NULL;
}
- return gda_timestamp_copy ((gpointer)value);
+ return (GdaTimestamp *)gda_timestamp_copy ((gpointer)value);
}
/**
if (col >= 0)
{
value = gdaex_data_model_iter_get_value_gdate_at (iter, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
if (col >= 0)
{
value = gdaex_data_model_iter_get_value_gdatetime_at (iter, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
if (col >= 0)
{
value = gdaex_data_model_iter_get_value_tm_at (iter, col);
- if (value == NULL)
- {
- g_warning ("Error retrieving «%s»'s value.", field_name);
- }
}
else
{
v = gda_data_model_iter_get_value_at (iter, col);
if (v == NULL)
{
- g_warning ("Error on retrieving field's value at column %d.", col);
+ GdaDataModel *data_model;
+
+ g_object_get (G_OBJECT (iter), "data-model", &data_model, NULL);
+
+ g_warning ("Error on retrieving field's value: «%s».",
+ gda_data_model_get_column_name (data_model, col));
}
else
{
v = gda_data_model_iter_get_value_at (iter, col);
if (v == NULL)
{
- g_warning ("Error on retrieving field's value at column %d.", col);
+ GdaDataModel *data_model;
+
+ g_object_get (G_OBJECT (iter), "data-model", &data_model, NULL);
+
+ g_warning ("Error on retrieving field's value: «%s».",
+ gda_data_model_get_column_name (data_model, col));
}
else
{
v = gda_data_model_iter_get_value_at (iter, col);
if (v == NULL)
{
- g_warning ("Error on retrieving field's value at column %d.", col);
+ GdaDataModel *data_model;
+
+ g_object_get (G_OBJECT (iter), "data-model", &data_model, NULL);
+
+ g_warning ("Error on retrieving field's value: «%s».",
+ gda_data_model_get_column_name (data_model, col));
}
else
{
v = gda_data_model_iter_get_value_at (iter, col);
if (v == NULL)
{
- g_warning ("Error on retrieving field's value at column %d.", col);
+ GdaDataModel *data_model;
+
+ g_object_get (G_OBJECT (iter), "data-model", &data_model, NULL);
+
+ g_warning ("Error on retrieving field's value: «%s».",
+ gda_data_model_get_column_name (data_model, col));
}
else
{
v = gda_data_model_iter_get_value_at (iter, col);
if (v == NULL)
{
- g_warning ("Error on retrieving field's value at column %d.", col);
+ GdaDataModel *data_model;
+
+ g_object_get (G_OBJECT (iter), "data-model", &data_model, NULL);
+
+ g_warning ("Error on retrieving field's value: «%s».",
+ gda_data_model_get_column_name (data_model, col));
}
else
{
}
else
{
- gchar *vstr = g_strstrip (gda_value_stringify (v));
+ gchar *vstr = g_strstrip (g_strdup (gda_value_stringify (v)));
if (strcasecmp (vstr, "true") == 0 ||
strcasecmp (vstr, "t") == 0 ||
strcasecmp (vstr, "yes") == 0 ||
{
ret = FALSE;
}
+ g_free (vstr);
}
}
v = gda_data_model_iter_get_value_at (iter, col);
if (v == NULL)
{
- g_warning ("Error on retrieving field's value at column %d.", col);
+ GdaDataModel *data_model;
+
+ g_object_get (G_OBJECT (iter), "data-model", &data_model, NULL);
+
+ g_warning ("Error on retrieving field's value: «%s».",
+ gda_data_model_get_column_name (data_model, col));
}
else if (!gda_value_is_null (v))
{
if (date != NULL)
{
- gdatimestamp = g_malloc0 (sizeof (GdaTimestamp));
+ gdatimestamp = g_new0 (GdaTimestamp, 1);
if (g_date_valid (date))
{
gdatimestamp->year = g_date_get_year (date);
gdatimestamp->month = date->month;
gdatimestamp->day = date->day;
}
+ g_date_free (date);
}
}
else if (gda_value_isa (v, GDA_TYPE_TIME))
if (time != NULL)
{
- gdatimestamp = g_malloc0 (sizeof (GdaTimestamp));
+ gdatimestamp = g_new0 (GdaTimestamp,1 );
gdatimestamp->hour = time->hour;
gdatimestamp->minute = time->minute;
gdatimestamp->second = time->second;
v = gda_data_model_iter_get_value_at (iter, col);
if (v == NULL)
{
- g_warning ("Error on retrieving field's value at column %d.", col);
+ GdaDataModel *data_model;
+
+ g_object_get (G_OBJECT (iter), "data-model", &data_model, NULL);
+
+ g_warning ("Error on retrieving field's value: «%s».",
+ gda_data_model_get_column_name (data_model, col));
}
else if (!gda_value_is_null (v))
{
v = gda_data_model_iter_get_value_at (iter, col);
if (v == NULL)
{
- g_warning ("Error on retrieving field's value at column %d.", col);
+ GdaDataModel *data_model;
+
+ g_object_get (G_OBJECT (iter), "data-model", &data_model, NULL);
+
+ g_warning ("Error on retrieving field's value: «%s».",
+ gda_data_model_get_column_name (data_model, col));
}
else if (!gda_value_is_null (v))
{
v = gda_data_model_iter_get_value_at (iter, col);
if (v == NULL)
{
- g_warning ("Error on retrieving field's value at column %d.", col);
+ GdaDataModel *data_model;
+
+ g_object_get (G_OBJECT (iter), "data-model", &data_model, NULL);
+
+ g_warning ("Error on retrieving field's value: «%s».",
+ gda_data_model_get_column_name (data_model, col));
}
else if (!gda_value_is_null (v))
{
if (gdatimestamp != NULL)
{
- ret = g_malloc0 (sizeof (struct tm));
+ ret = g_new0 (struct tm, 1);
ret->tm_year = gdatimestamp->year - 1900;
ret->tm_mon = gdatimestamp->month - 1;