libfort/src/table.h

52 lines
1.4 KiB
C
Raw Normal View History

2018-01-17 19:22:57 +01:00
#ifndef TABLE_H
#define TABLE_H
#include "fort_impl.h"
2018-02-04 14:21:04 +01:00
2018-05-05 21:34:45 +02:00
struct ft_table;
typedef struct ft_table ft_table_t;
struct ft_table
2018-01-17 19:22:57 +01:00
{
vector_t *rows;
fort_table_options_t *options;
string_buffer_t *conv_buffer;
size_t cur_row;
size_t cur_col;
2018-02-04 14:21:04 +01:00
vector_t *separators;
2018-01-17 19:22:57 +01:00
};
2018-03-14 19:30:27 +01:00
static FT_INLINE
2018-02-04 14:21:04 +01:00
separator_t *create_separator(int enabled)
{
separator_t *res = (separator_t *)F_CALLOC(1, sizeof(separator_t));
2018-02-04 14:21:04 +01:00
if (res == NULL)
return NULL;
res->enabled = enabled;
return res;
}
2018-03-14 19:30:27 +01:00
static FT_INLINE
2018-02-04 14:21:04 +01:00
void destroy_separator(separator_t *sep)
{
F_FREE(sep);
}
2018-01-17 19:22:57 +01:00
2018-05-05 21:34:45 +02:00
fort_status_t get_table_sizes(const ft_table_t *table, size_t *rows, size_t *cols);
fort_row_t *get_row_implementation(ft_table_t *table, size_t row, enum PolicyOnNull policy);
fort_row_t *get_row(ft_table_t *table, size_t row);
const fort_row_t *get_row_c(const ft_table_t *table, size_t row);
fort_row_t *get_row_and_create_if_not_exists(ft_table_t *table, size_t row);
2018-01-17 19:22:57 +01:00
2018-05-05 21:34:45 +02:00
string_buffer_t * get_cur_str_buffer_and_create_if_not_exists(ft_table_t * table);
2018-01-17 19:22:57 +01:00
2018-05-05 21:34:45 +02:00
fort_status_t table_rows_and_cols_geometry(const ft_table_t *table,
2018-01-17 19:22:57 +01:00
size_t **col_width_arr_p, size_t *col_width_arr_sz,
size_t **row_height_arr_p, size_t *row_height_arr_sz);
2018-05-05 21:34:45 +02:00
fort_status_t table_geometry(const ft_table_t *table, size_t *height, size_t *width);
2018-01-17 19:22:57 +01:00
2018-03-09 10:44:16 +01:00
#endif /* TABLE_H */