[C] Made row functions internal

This commit is contained in:
seleznevae 2018-08-31 20:09:10 +03:00
parent db5783cdcc
commit 65a85fa510
3 changed files with 106 additions and 34 deletions

View File

@ -533,48 +533,68 @@ string_buffer_t *cell_get_string_buffer(fort_cell_t *cell);
#include <wchar.h> #include <wchar.h>
#endif #endif
FT_INTERNAL
fort_row_t *create_row(void); fort_row_t *create_row(void);
FT_INTERNAL
void destroy_row(fort_row_t *row); void destroy_row(fort_row_t *row);
FT_INTERNAL
fort_row_t *create_row_from_string(const char *str); fort_row_t *create_row_from_string(const char *str);
FT_INTERNAL
fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args); fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args);
FT_INTERNAL
size_t columns_in_row(const fort_row_t *row); size_t columns_in_row(const fort_row_t *row);
fort_cell_t *get_cell_implementation(fort_row_t *row, size_t col, enum PolicyOnNull policy); FT_INTERNAL
fort_cell_t *get_cell(fort_row_t *row, size_t col); fort_cell_t *get_cell(fort_row_t *row, size_t col);
FT_INTERNAL
const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col); const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col);
FT_INTERNAL
fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col); fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col);
FT_INTERNAL
fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos); fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos);
FT_INTERNAL
size_t group_cell_number(const fort_row_t *row, size_t master_cell_col); size_t group_cell_number(const fort_row_t *row, size_t master_cell_col);
FT_INTERNAL
int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz); int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz);
FT_INTERNAL
fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span); fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span);
FT_INTERNAL
int print_row_separator(char *buffer, size_t buffer_sz, int print_row_separator(char *buffer, size_t buffer_sz,
const size_t *col_width_arr, size_t cols, const size_t *col_width_arr, size_t cols,
const fort_row_t *upper_row, const fort_row_t *lower_row, const fort_row_t *upper_row, const fort_row_t *lower_row,
enum HorSeparatorPos separatorPos, const separator_t *sep, enum HorSeparatorPos separatorPos, const separator_t *sep,
const context_t *context); const context_t *context);
FT_INTERNAL
int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz,
size_t row_height, const context_t *context); size_t row_height, const context_t *context);
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
fort_row_t *create_row_from_wstring(const wchar_t *str); fort_row_t *create_row_from_wstring(const wchar_t *str);
FT_INTERNAL
fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args); fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args);
FT_INTERNAL
int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, int wprint_row_separator(wchar_t *buffer, size_t buffer_sz,
const size_t *col_width_arr, size_t cols, const size_t *col_width_arr, size_t cols,
const fort_row_t *upper_row, const fort_row_t *lower_row, const fort_row_t *upper_row, const fort_row_t *lower_row,
enum HorSeparatorPos separatorPos, const separator_t *sep, enum HorSeparatorPos separatorPos, const separator_t *sep,
const context_t *context); const context_t *context);
FT_INTERNAL
int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz,
size_t row_height, const context_t *context); size_t row_height, const context_t *context);
#endif #endif
@ -3551,7 +3571,7 @@ struct fort_row {
}; };
FT_INTERNAL
fort_row_t *create_row(void) fort_row_t *create_row(void)
{ {
fort_row_t *row = (fort_row_t *)F_CALLOC(sizeof(fort_row_t), 1); fort_row_t *row = (fort_row_t *)F_CALLOC(sizeof(fort_row_t), 1);
@ -3570,6 +3590,7 @@ fort_row_t *create_row(void)
return row; return row;
} }
FT_INTERNAL
void destroy_row(fort_row_t *row) void destroy_row(fort_row_t *row)
{ {
size_t i = 0; size_t i = 0;
@ -3589,9 +3610,7 @@ void destroy_row(fort_row_t *row)
} }
FT_INTERNAL
size_t columns_in_row(const fort_row_t *row) size_t columns_in_row(const fort_row_t *row)
{ {
if (row == NULL || row->cells == NULL) if (row == NULL || row->cells == NULL)
@ -3601,6 +3620,7 @@ size_t columns_in_row(const fort_row_t *row)
} }
static
fort_cell_t *get_cell_implementation(fort_row_t *row, size_t col, enum PolicyOnNull policy) fort_cell_t *get_cell_implementation(fort_row_t *row, size_t col, enum PolicyOnNull policy)
{ {
if (row == NULL || row->cells == NULL) { if (row == NULL || row->cells == NULL) {
@ -3631,21 +3651,28 @@ fort_cell_t *get_cell_implementation(fort_row_t *row, size_t col, enum PolicyOnN
} }
FT_INTERNAL
fort_cell_t *get_cell(fort_row_t *row, size_t col) fort_cell_t *get_cell(fort_row_t *row, size_t col)
{ {
return get_cell_implementation(row, col, DoNotCreate); return get_cell_implementation(row, col, DoNotCreate);
} }
FT_INTERNAL
const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col) const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col)
{ {
return get_cell((fort_row_t *)row, col); return get_cell((fort_row_t *)row, col);
} }
FT_INTERNAL
fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col) fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col)
{ {
return get_cell_implementation(row, col, Create); return get_cell_implementation(row, col, Create);
} }
FT_INTERNAL
fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos) fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos)
{ {
assert(cur_row); assert(cur_row);
@ -3662,6 +3689,8 @@ fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos)
return vector_swap(cur_row->cells, ins_row->cells, pos); return vector_swap(cur_row->cells, ins_row->cells, pos);
} }
FT_INTERNAL
size_t group_cell_number(const fort_row_t *row, size_t master_cell_col) size_t group_cell_number(const fort_row_t *row, size_t master_cell_col)
{ {
assert(row); assert(row);
@ -3685,6 +3714,8 @@ size_t group_cell_number(const fort_row_t *row, size_t master_cell_col)
return slave_col - master_cell_col; return slave_col - master_cell_col;
} }
FT_INTERNAL
int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz) int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz)
{ {
assert(row); assert(row);
@ -3701,6 +3732,8 @@ int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types
return FT_SUCCESS; return FT_SUCCESS;
} }
FT_INTERNAL
fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span) fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span)
{ {
assert(row); assert(row);
@ -3730,8 +3763,7 @@ fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_
} }
FT_INTERNAL
int print_row_separator(char *buffer, size_t buffer_sz, int print_row_separator(char *buffer, size_t buffer_sz,
const size_t *col_width_arr, size_t cols, const size_t *col_width_arr, size_t cols,
const fort_row_t *upper_row, const fort_row_t *lower_row, const fort_row_t *upper_row, const fort_row_t *lower_row,
@ -3904,7 +3936,7 @@ clear:
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, int wprint_row_separator(wchar_t *buffer, size_t buffer_sz,
const size_t *col_width_arr, size_t cols, const size_t *col_width_arr, size_t cols,
const fort_row_t *upper_row, const fort_row_t *lower_row, const fort_row_t *upper_row, const fort_row_t *lower_row,
@ -4077,6 +4109,7 @@ clear:
#endif #endif
FT_INTERNAL
fort_row_t *create_row_from_string(const char *str) fort_row_t *create_row_from_string(const char *str)
{ {
typedef char char_type; typedef char char_type;
@ -4165,6 +4198,7 @@ clear:
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
fort_row_t *create_row_from_wstring(const wchar_t *str) fort_row_t *create_row_from_wstring(const wchar_t *str)
{ {
typedef wchar_t char_type; typedef wchar_t char_type;
@ -4251,7 +4285,7 @@ clear:
} }
#endif #endif
FT_INTERNAL
fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args) fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args)
{ {
#define VSNPRINTF vsnprintf #define VSNPRINTF vsnprintf
@ -4335,6 +4369,7 @@ clear:
} }
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args) fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args)
{ {
#define VSNPRINTF vswprintf #define VSNPRINTF vswprintf
@ -4419,6 +4454,7 @@ clear:
#endif #endif
FT_INTERNAL
int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz,
size_t row_height, const context_t *context) size_t row_height, const context_t *context)
{ {
@ -4508,7 +4544,7 @@ clear:
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz,
size_t row_height, const context_t *context) size_t row_height, const context_t *context)
{ {

View File

@ -11,7 +11,7 @@ struct fort_row {
}; };
FT_INTERNAL
fort_row_t *create_row(void) fort_row_t *create_row(void)
{ {
fort_row_t *row = (fort_row_t *)F_CALLOC(sizeof(fort_row_t), 1); fort_row_t *row = (fort_row_t *)F_CALLOC(sizeof(fort_row_t), 1);
@ -30,6 +30,7 @@ fort_row_t *create_row(void)
return row; return row;
} }
FT_INTERNAL
void destroy_row(fort_row_t *row) void destroy_row(fort_row_t *row)
{ {
size_t i = 0; size_t i = 0;
@ -49,9 +50,7 @@ void destroy_row(fort_row_t *row)
} }
FT_INTERNAL
size_t columns_in_row(const fort_row_t *row) size_t columns_in_row(const fort_row_t *row)
{ {
if (row == NULL || row->cells == NULL) if (row == NULL || row->cells == NULL)
@ -61,6 +60,7 @@ size_t columns_in_row(const fort_row_t *row)
} }
static
fort_cell_t *get_cell_implementation(fort_row_t *row, size_t col, enum PolicyOnNull policy) fort_cell_t *get_cell_implementation(fort_row_t *row, size_t col, enum PolicyOnNull policy)
{ {
if (row == NULL || row->cells == NULL) { if (row == NULL || row->cells == NULL) {
@ -91,21 +91,28 @@ fort_cell_t *get_cell_implementation(fort_row_t *row, size_t col, enum PolicyOnN
} }
FT_INTERNAL
fort_cell_t *get_cell(fort_row_t *row, size_t col) fort_cell_t *get_cell(fort_row_t *row, size_t col)
{ {
return get_cell_implementation(row, col, DoNotCreate); return get_cell_implementation(row, col, DoNotCreate);
} }
FT_INTERNAL
const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col) const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col)
{ {
return get_cell((fort_row_t *)row, col); return get_cell((fort_row_t *)row, col);
} }
FT_INTERNAL
fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col) fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col)
{ {
return get_cell_implementation(row, col, Create); return get_cell_implementation(row, col, Create);
} }
FT_INTERNAL
fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos) fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos)
{ {
assert(cur_row); assert(cur_row);
@ -122,6 +129,8 @@ fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos)
return vector_swap(cur_row->cells, ins_row->cells, pos); return vector_swap(cur_row->cells, ins_row->cells, pos);
} }
FT_INTERNAL
size_t group_cell_number(const fort_row_t *row, size_t master_cell_col) size_t group_cell_number(const fort_row_t *row, size_t master_cell_col)
{ {
assert(row); assert(row);
@ -145,6 +154,8 @@ size_t group_cell_number(const fort_row_t *row, size_t master_cell_col)
return slave_col - master_cell_col; return slave_col - master_cell_col;
} }
FT_INTERNAL
int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz) int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz)
{ {
assert(row); assert(row);
@ -161,6 +172,8 @@ int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types
return FT_SUCCESS; return FT_SUCCESS;
} }
FT_INTERNAL
fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span) fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span)
{ {
assert(row); assert(row);
@ -190,8 +203,7 @@ fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_
} }
FT_INTERNAL
int print_row_separator(char *buffer, size_t buffer_sz, int print_row_separator(char *buffer, size_t buffer_sz,
const size_t *col_width_arr, size_t cols, const size_t *col_width_arr, size_t cols,
const fort_row_t *upper_row, const fort_row_t *lower_row, const fort_row_t *upper_row, const fort_row_t *lower_row,
@ -364,7 +376,7 @@ clear:
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, int wprint_row_separator(wchar_t *buffer, size_t buffer_sz,
const size_t *col_width_arr, size_t cols, const size_t *col_width_arr, size_t cols,
const fort_row_t *upper_row, const fort_row_t *lower_row, const fort_row_t *upper_row, const fort_row_t *lower_row,
@ -537,6 +549,7 @@ clear:
#endif #endif
FT_INTERNAL
fort_row_t *create_row_from_string(const char *str) fort_row_t *create_row_from_string(const char *str)
{ {
typedef char char_type; typedef char char_type;
@ -625,6 +638,7 @@ clear:
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
fort_row_t *create_row_from_wstring(const wchar_t *str) fort_row_t *create_row_from_wstring(const wchar_t *str)
{ {
typedef wchar_t char_type; typedef wchar_t char_type;
@ -711,7 +725,7 @@ clear:
} }
#endif #endif
FT_INTERNAL
fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args) fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args)
{ {
#define VSNPRINTF vsnprintf #define VSNPRINTF vsnprintf
@ -795,6 +809,7 @@ clear:
} }
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args) fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args)
{ {
#define VSNPRINTF vswprintf #define VSNPRINTF vswprintf
@ -879,6 +894,7 @@ clear:
#endif #endif
FT_INTERNAL
int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz,
size_t row_height, const context_t *context) size_t row_height, const context_t *context)
{ {
@ -968,7 +984,7 @@ clear:
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz,
size_t row_height, const context_t *context) size_t row_height, const context_t *context)
{ {

View File

@ -9,48 +9,68 @@
#include <wchar.h> #include <wchar.h>
#endif #endif
FT_INTERNAL
fort_row_t *create_row(void); fort_row_t *create_row(void);
FT_INTERNAL
void destroy_row(fort_row_t *row); void destroy_row(fort_row_t *row);
FT_INTERNAL
fort_row_t *create_row_from_string(const char *str); fort_row_t *create_row_from_string(const char *str);
FT_INTERNAL
fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args); fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args);
FT_INTERNAL
size_t columns_in_row(const fort_row_t *row); size_t columns_in_row(const fort_row_t *row);
fort_cell_t *get_cell_implementation(fort_row_t *row, size_t col, enum PolicyOnNull policy); FT_INTERNAL
fort_cell_t *get_cell(fort_row_t *row, size_t col); fort_cell_t *get_cell(fort_row_t *row, size_t col);
FT_INTERNAL
const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col); const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col);
FT_INTERNAL
fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col); fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col);
FT_INTERNAL
fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos); fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos);
FT_INTERNAL
size_t group_cell_number(const fort_row_t *row, size_t master_cell_col); size_t group_cell_number(const fort_row_t *row, size_t master_cell_col);
FT_INTERNAL
int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz); int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz);
FT_INTERNAL
fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span); fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span);
FT_INTERNAL
int print_row_separator(char *buffer, size_t buffer_sz, int print_row_separator(char *buffer, size_t buffer_sz,
const size_t *col_width_arr, size_t cols, const size_t *col_width_arr, size_t cols,
const fort_row_t *upper_row, const fort_row_t *lower_row, const fort_row_t *upper_row, const fort_row_t *lower_row,
enum HorSeparatorPos separatorPos, const separator_t *sep, enum HorSeparatorPos separatorPos, const separator_t *sep,
const context_t *context); const context_t *context);
FT_INTERNAL
int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz,
size_t row_height, const context_t *context); size_t row_height, const context_t *context);
#ifdef FT_HAVE_WCHAR #ifdef FT_HAVE_WCHAR
FT_INTERNAL
fort_row_t *create_row_from_wstring(const wchar_t *str); fort_row_t *create_row_from_wstring(const wchar_t *str);
FT_INTERNAL
fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args); fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args);
FT_INTERNAL
int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, int wprint_row_separator(wchar_t *buffer, size_t buffer_sz,
const size_t *col_width_arr, size_t cols, const size_t *col_width_arr, size_t cols,
const fort_row_t *upper_row, const fort_row_t *lower_row, const fort_row_t *upper_row, const fort_row_t *lower_row,
enum HorSeparatorPos separatorPos, const separator_t *sep, enum HorSeparatorPos separatorPos, const separator_t *sep,
const context_t *context); const context_t *context);
FT_INTERNAL
int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz,
size_t row_height, const context_t *context); size_t row_height, const context_t *context);
#endif #endif