C API: Added a function to set an entire column to a specified (atomic)
value.
This commit is contained in:
@ -1750,6 +1750,62 @@ int obi_enlarge_column(OBIDMS_column_p column)
|
||||
}
|
||||
|
||||
|
||||
void obi_set_column_to_value(OBIDMS_column_p column,
|
||||
index_t first_line_nb,
|
||||
index_t nb_lines,
|
||||
void* value_p)
|
||||
{
|
||||
index_t i, start, end, nb_elements;
|
||||
|
||||
nb_elements = nb_lines*((column->header)->nb_elements_per_line);
|
||||
start = first_line_nb*((column->header)->nb_elements_per_line);
|
||||
end = start + nb_elements;
|
||||
|
||||
switch ((column->header)->stored_data_type) {
|
||||
|
||||
case OBI_VOID: break;
|
||||
|
||||
case OBI_INT: for (i=start;i<end;i++)
|
||||
{
|
||||
obiint_t value = *((obiint_t*)value_p);
|
||||
*(((obiint_t*) (column->data)) + i) = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case OBI_FLOAT: for (i=start;i<end;i++)
|
||||
{
|
||||
obifloat_t value = *((obifloat_t*)value_p);
|
||||
*(((obifloat_t*) (column->data)) + i) = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case OBI_BOOL: for (i=start;i<end;i++)
|
||||
{
|
||||
obibool_t value = *((obibool_t*)value_p);
|
||||
*(((obibool_t*) (column->data)) + i) = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case OBI_CHAR: for (i=start;i<end;i++)
|
||||
{
|
||||
obichar_t value = *((obichar_t*)value_p);
|
||||
*(((obichar_t*) (column->data)) + i) = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case OBI_IDX: for (i=start;i<end;i++)
|
||||
{
|
||||
index_t value = *((index_t*)value_p);
|
||||
*(((index_t*) (column->data)) + i) = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case OBI_SEQ: break;
|
||||
case OBI_STR: break;
|
||||
case OBI_QUAL: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void obi_ini_to_NA_values(OBIDMS_column_p column,
|
||||
index_t first_line_nb,
|
||||
@ -1761,7 +1817,8 @@ void obi_ini_to_NA_values(OBIDMS_column_p column,
|
||||
start = first_line_nb*((column->header)->nb_elements_per_line);
|
||||
end = start + nb_elements;
|
||||
|
||||
switch ((column->header)->stored_data_type) {
|
||||
switch ((column->header)->stored_data_type)
|
||||
{
|
||||
case OBI_VOID: // TODO;
|
||||
break;
|
||||
|
||||
@ -1794,24 +1851,9 @@ void obi_ini_to_NA_values(OBIDMS_column_p column,
|
||||
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
|
||||
}
|
||||
break;
|
||||
|
||||
case OBI_QUAL: for (i=start;i<end;i++) // case not used since OBI_QUAL is only a returned_data_type
|
||||
{
|
||||
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
|
||||
}
|
||||
break;
|
||||
|
||||
case OBI_STR: for (i=start;i<end;i++) // case not used since OBI_QUAL is only a returned_data_type
|
||||
{
|
||||
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
|
||||
}
|
||||
break;
|
||||
|
||||
case OBI_SEQ: for (i=start;i<end;i++) // case not used since OBI_QUAL is only a returned_data_type
|
||||
{
|
||||
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
|
||||
}
|
||||
break;
|
||||
case OBI_SEQ: break;
|
||||
case OBI_STR: break;
|
||||
case OBI_QUAL: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,6 +372,26 @@ int obi_truncate_column(OBIDMS_column_p column);
|
||||
int obi_enlarge_column(OBIDMS_column_p column);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @brief Sets the data in a column to the specified value.
|
||||
*
|
||||
* @warning The specified value should be the atomic value effectively stored in the column (i.e. it can not be a character string for example).
|
||||
*
|
||||
* @param column A pointer on an OBIDMS column.
|
||||
* @param start The first line number of the block that should be set.
|
||||
* @param nb_lines The number of lines that should be set.
|
||||
* @param value_p A pointer on the value to which the column should be set.
|
||||
*
|
||||
* @since May 2018
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
void obi_set_column_to_value(OBIDMS_column_p column,
|
||||
index_t first_line_nb,
|
||||
index_t nb_lines,
|
||||
void* value_p);
|
||||
|
||||
|
||||
/*
|
||||
* @brief Sets the data in a column to the NA value of the data OBIType.
|
||||
*
|
||||
|
Reference in New Issue
Block a user