Managing values

Values returned by functions of managing data are GdaValue objects. GdaValue class has many functions to access data, so we show the most important ones of them:

There are many functions to know what is the type of a value and to manage values, that can be seen in GdaValue class.

We will return to the examples about last section to notice some important details:

        void
        show_table2 (GdaDataModel * dm)
        {
          gint row_id;
          gint column_id;
          GdaValue *value;
          GdaRow *row;
          gchar *string;
        
(1)          for (column_id = 0; column_id < gda_data_model_get_n_columns (dm);
               column_id++)
            g_print("%s\t",gda_data_model_get_column_title (dm, column_id));
          g_print("\n");
        
(2)          for (row_id = 0; row_id < gda_data_model_get_n_rows (dm); row_id++)
            {
              row = (GdaRow *) gda_data_model_get_row (dm, row_id);
(3)              for (column_id = 0; column_id < gda_data_model_get_n_columns (dm);
                   column_id++)
                {
                  value = gda_row_get_value (row, column_id);
(4)                  string=gda_value_stringify (value);
                  g_print ("%s\t", string);
                  gda_value_free(value);
                  g_free(string);
                }
              g_print ("\n");
            }
        }
        
(1)
Loop for writing column names.
(2)
Outer loop obtaining rows using gda_data_model_get_row ()
(3)
Inner loop obtaining the value using gda_row_get_value () . Notice that gda_row_get_value () doesn't return a const GdaValue, so we have to free it.
(4)
We have the difference here. As you can see above, gda_value_stringify () does not return a const gchar *, so you have to free it. First way is quite attractive but it is not good.