Refactored and relocated the set and get functions of all column types,
both within and out of the context of a view
This commit is contained in:
@ -1418,7 +1418,53 @@ index_t obi_column_get_element_index_from_name(OBIDMS_column_p column, const cha
|
||||
}
|
||||
|
||||
|
||||
char* obi_column_format_date(time_t date)
|
||||
int obi_column_prepare_to_set_value(OBIDMS_column_p column, index_t line_nb)
|
||||
{
|
||||
// Check if the column is read-only
|
||||
if (!(column->writable))
|
||||
{
|
||||
obi_set_errno(OBICOL_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError trying to set a value in a read-only column");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check that the line number is not greater than the maximum allowed
|
||||
if (line_nb >= MAXIMUM_LINE_COUNT)
|
||||
{
|
||||
obi_set_errno(OBICOL_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError trying to set a value at a line number greater than the maximum allowed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check if the file needs to be enlarged
|
||||
while ((line_nb+1) > (column->header)->line_count)
|
||||
{
|
||||
// Enlarge the file
|
||||
if (obi_enlarge_column(column) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Update lines used
|
||||
if ((line_nb+1) > (column->header)->lines_used)
|
||||
(column->header)->lines_used = line_nb+1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int obi_column_prepare_to_get_value(OBIDMS_column_p column, index_t line_nb)
|
||||
{
|
||||
if ((line_nb+1) > ((column->header)->line_count))
|
||||
{
|
||||
obi_set_errno(OBICOL_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError trying to get a value that is beyond the current number of lines used in the column");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char* obi_column_format_date(time_t date) // TODO put in utils.c
|
||||
{
|
||||
char* formatted_time;
|
||||
struct tm* tmp;
|
||||
|
Reference in New Issue
Block a user