Added the handling of errors with the functions to get a value in a

column
This commit is contained in:
Celine Mercier
2015-09-14 17:04:29 +02:00
parent 0e50fbf706
commit 5c3bc03bd2
12 changed files with 69 additions and 35 deletions

View File

@ -59,10 +59,11 @@ int obi_column_set_obibool_with_elt_idx(OBIDMS_column_p column, size_t line_nb,
obibool_t obi_column_get_obibool_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 OBIBool_NA;
}
return *(((obibool_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx);
}
@ -108,14 +109,14 @@ obibool_t obi_column_get_obibool_with_elt_name(OBIDMS_column_p column, size_t li
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nAn element name must be specified");
return -1;
return OBIBool_NA;
}
}
else
{
element_idx = obi_column_get_element_index_from_name(column, element_name);
if (element_idx == -1)
return -1;
return OBIBool_NA;
}
return obi_column_get_obibool_with_elt_idx(column, line_nb, element_idx);