[A] Add function ft_row_count
This commit is contained in:
11
lib/fort.c
11
lib/fort.c
@@ -2797,10 +2797,13 @@ void ft_set_cur_cell(ft_table_t *table, size_t row, size_t col)
|
||||
int ft_is_empty(const ft_table_t *table)
|
||||
{
|
||||
assert(table);
|
||||
if (table->rows == NULL || (vector_size(table->rows) == 0))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
return ft_row_count(table) == 0;
|
||||
}
|
||||
|
||||
size_t ft_row_count(const ft_table_t *table)
|
||||
{
|
||||
assert(table && table->rows);
|
||||
return vector_size(table->rows);
|
||||
}
|
||||
|
||||
static int ft_row_printf_impl_(ft_table_t *table, size_t row, const struct f_string_view *fmt, va_list *va)
|
||||
|
10
lib/fort.h
10
lib/fort.h
@@ -330,6 +330,16 @@ void ft_set_cur_cell(ft_table_t *table, size_t row, size_t col);
|
||||
*/
|
||||
int ft_is_empty(const ft_table_t *table);
|
||||
|
||||
/**
|
||||
* Get number of rows in the table.
|
||||
*
|
||||
* @param table
|
||||
* Pointer to formatted table.
|
||||
* @return
|
||||
* Number of rows in the table.
|
||||
*/
|
||||
size_t ft_row_count(const ft_table_t *table);
|
||||
|
||||
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)
|
||||
|
||||
/**
|
||||
|
12
lib/fort.hpp
12
lib/fort.hpp
@@ -1069,6 +1069,18 @@ public:
|
||||
return ft_is_empty(table_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of rows in the table.
|
||||
*
|
||||
* @return
|
||||
* Number of rows in the table.
|
||||
*/
|
||||
std::size_t
|
||||
row_count() const noexcept
|
||||
{
|
||||
return ft_row_count(table_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current cell.
|
||||
*
|
||||
|
Reference in New Issue
Block a user