Added the handling of errors with the functions to get a value in a
column
This commit is contained in:
@ -59,10 +59,11 @@ int obi_column_set_obiidx_with_elt_idx(OBIDMS_column_p column, size_t line_nb, s
|
||||
|
||||
obiidx_t obi_column_get_obiidx_with_elt_idx(OBIDMS_column_p column, size_t line_nb, size_t element_idx)
|
||||
{
|
||||
if ((line_nb+1) > (column->header)->line_count)
|
||||
if ((line_nb+1) > (column->header)->lines_used)
|
||||
{
|
||||
obidebug(1, "\nError trying to get a value that is beyond the current line count");
|
||||
return -1; // TODO return NA value?
|
||||
obi_set_errno(OBICOL_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nError trying to get a value that is beyond the current number of lines used");
|
||||
return OBIIdx_NA;
|
||||
}
|
||||
return *(((obiidx_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx);
|
||||
}
|
||||
@ -108,14 +109,14 @@ obiidx_t obi_column_get_obiidx_with_elt_name(OBIDMS_column_p column, size_t line
|
||||
{
|
||||
obi_set_errno(OBICOL_UNKNOWN_ERROR);
|
||||
obidebug(1, "\nAn element name must be specified");
|
||||
return -1;
|
||||
return OBIIdx_NA;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
element_idx = obi_column_get_element_index_from_name(column, element_name);
|
||||
if (element_idx == -1)
|
||||
return -1;
|
||||
return OBIIdx_NA;
|
||||
}
|
||||
|
||||
return obi_column_get_obiidx_with_elt_idx(column, line_nb, element_idx);
|
||||
|
Reference in New Issue
Block a user