[C] Rename ft_delete_range to ft_erase_range

This commit is contained in:
seleznevae
2020-01-19 22:06:25 +03:00
parent 4e922a7eca
commit 1ed13718d5
13 changed files with 200 additions and 38 deletions

View File

@@ -2152,7 +2152,7 @@ f_row_t *split_row(f_row_t *row, size_t pos);
// Delete range [left; right] of cells (both ends included)
FT_INTERNAL
int ft_row_delete_range(f_row_t *row, size_t left, size_t right);
int ft_row_erase_range(f_row_t *row, size_t left, size_t right);
FT_INTERNAL
f_row_t *create_row_from_string(const char *str);
@@ -2813,9 +2813,9 @@ size_t ft_row_count(const ft_table_t *table)
return vector_size(table->rows);
}
int ft_delete_range(ft_table_t *table,
size_t top_left_row, size_t top_left_col,
size_t bottom_right_row, size_t bottom_right_col)
int ft_erase_range(ft_table_t *table,
size_t top_left_row, size_t top_left_col,
size_t bottom_right_row, size_t bottom_right_col)
{
assert(table && table->rows);
int status = FT_SUCCESS;
@@ -2839,7 +2839,7 @@ int ft_delete_range(ft_table_t *table,
size_t i = top_left_row;
while (i < rows_n && i <= bottom_right_row) {
row = VECTOR_AT(table->rows, i, f_row_t *);
status = ft_row_delete_range(row, top_left_col, bottom_right_col);
status = ft_row_erase_range(row, top_left_col, bottom_right_col);
if (FT_IS_ERROR(status))
return status;
++i;
@@ -5329,7 +5329,7 @@ f_row_t *split_row(f_row_t *row, size_t pos)
}
FT_INTERNAL
int ft_row_delete_range(f_row_t *row, size_t left, size_t right)
int ft_row_erase_range(f_row_t *row, size_t left, size_t right)
{
assert(row);
size_t cols_n = vector_size(row->cells);

View File

@@ -341,7 +341,7 @@ int ft_is_empty(const ft_table_t *table);
size_t ft_row_count(const ft_table_t *table);
/**
* Delete range of cells.
* Erase range of cells.
*
* Range of cells is determined by 2 points (top-left and bottom-right) (both
* ends are included).
@@ -360,9 +360,9 @@ size_t ft_row_count(const ft_table_t *table);
* - 0 - Operation was successfully implemented
* - (<0): In case of error
*/
int ft_delete_range(ft_table_t *table,
size_t top_left_row, size_t top_left_col,
size_t bottom_right_row, size_t bottom_right_col);
int ft_erase_range(ft_table_t *table,
size_t top_left_row, size_t top_left_col,
size_t bottom_right_row, size_t bottom_right_col);
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)

View File

@@ -990,6 +990,15 @@ public:
{
return table_cell(ps_row_idx_, coll_idx, *ps_table_);
}
void erase()
{
if (FT_IS_ERROR(ft_erase_range(ps_table_->table_,
property_owner_t::ps_row_idx_, 0,
property_owner_t::ps_row_idx_, (UINT_MAX - 2)))) {
throw std::runtime_error("Failed to erase row");
}
}
};
/**
@@ -997,11 +1006,45 @@ public:
*/
class table_column: public property_owner_t
{
using property_owner_t::ps_coll_idx_;
using property_owner_t::ps_table_;
public:
table_column(std::size_t col_idx, table &tbl)
: property_owner_t(FT_ANY_ROW, col_idx, &tbl) {}
void erase()
{
if (FT_IS_ERROR(ft_erase_range(ps_table_->table_,
0, ps_coll_idx_,
(UINT_MAX - 2), ps_coll_idx_))) {
throw std::runtime_error("Failed to erase column");
}
}
};
/**
* Table column.
*/
class cell_range: public property_owner_t
{
using property_owner_t::ps_coll_idx_;
using property_owner_t::ps_row_idx_;
using property_owner_t::ps_table_;
public:
table_column(std::size_t col_idx, table &tbl)
: property_owner_t(FT_ANY_ROW, col_idx, &tbl) {}
void erase()
{
if (FT_IS_ERROR(ft_erase_range(ps_table_->table_,
0, ps_coll_idx_,
(UINT_MAX - 2), ps_coll_idx_))) {
throw std::runtime_error("Failed to erase column");
}
}
};
class default_properties: public property_owner_t
{
public: