Commit 65880db4 by Celine Mercier

Made function to update the line count of a view private

parent 767d9c78
......@@ -79,6 +79,26 @@ int create_obiview_file(int dms_file_descriptor);
/**
* @brief Internal function to update the line count in the context of a view.
*
* All columns of the view are enlarged to contain at least the new line count.
*
* @warning The view must be writable.
*
* @param view A pointer on the view.
* @param line_count The new line count.
*
* @returns A value indicating the success of the operation.
* @retval 0 if the operation was successfully completed.
* @retval -1 if an error occurred.
*
* @since February 2016
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int update_lines(Obiview_p view, index_t line_count);
/**
* Internal function preparing to set a value in a column, in the context of a view.
*
* The function checks that the view is not read-only, clones the column or all columns if needed,
......@@ -249,6 +269,26 @@ int create_obiview_file(int dms_file_descriptor)
}
int update_lines(Obiview_p view, index_t line_count)
{
int i;
for (i=0; i<(view->column_count); i++)
{
while (line_count > (((view->columns)[i])->header)->line_count)
{
// Enlarge the column
if (obi_enlarge_column((view->columns)[i]) < 0)
return -1;
}
}
view->line_count = line_count;
return 0;
}
int prepare_to_set_value_in_column(Obiview_p view, OBIDMS_column_p* column_pp, index_t* line_nb_p)
{
// Check that the view is not read-only
......@@ -277,7 +317,7 @@ int prepare_to_set_value_in_column(Obiview_p view, OBIDMS_column_p* column_pp, i
if (((*line_nb_p)+1) > view->line_count)
{
if (obi_view_update_lines(view, ((*line_nb_p)+1)) < 0)
if (update_lines(view, ((*line_nb_p)+1)) < 0)
return -1;
}
......@@ -936,26 +976,6 @@ int obi_select_lines(Obiview_p view, index_t* line_nbs)
}
int obi_view_update_lines(Obiview_p view, index_t line_count)
{
int i;
for (i=0; i<(view->column_count); i++)
{
while (line_count > (((view->columns)[i])->header)->line_count)
{
// Enlarge the column
if (obi_enlarge_column((view->columns)[i]) < 0)
return -1;
}
}
view->line_count = line_count;
return 0;
}
int obi_save_view(Obiview_p view)
{
int i;
......
......@@ -440,26 +440,6 @@ int obi_select_lines(Obiview_p view, index_t* line_nbs);
/**
* @brief Update the line count in the context of a view.
*
* All columns of the view are enlarged to contain at least the new line count.
*
* @warning The view must be writable.
*
* @param view A pointer on the view.
* @param line_count The new line count.
*
* @returns A value indicating the success of the operation.
* @retval 0 if the operation was successfully completed.
* @retval -1 if an error occurred.
*
* @since February 2016
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int obi_view_update_lines(Obiview_p view, index_t line_count);
/**
* @brief Saves a view, writing it in the view file.
*
* The view is written at the end of the view file, following the latest written view.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment