1
0
Fork 0

[C] Made options functions internal

This commit is contained in:
seleznevae 2018-09-01 15:45:34 +03:00
parent 00083ee16a
commit 3b36d46d29
5 changed files with 104 additions and 66 deletions

View File

@ -352,6 +352,8 @@ struct fort_column_options {
};
extern fort_column_options_t g_column_options;
FT_INTERNAL
fort_column_options_t create_column_options(void);
#define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option))
@ -373,19 +375,27 @@ struct fort_cell_options {
};
typedef struct fort_cell_options fort_cell_options_t;
typedef vector_t fort_cell_opt_container_t;
fort_cell_opt_container_t *create_cell_opt_container(void);
void destroy_cell_opt_container(fort_cell_opt_container_t *cont);
const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col);
fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col);
fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value);
fort_status_t unset_cell_option(fort_cell_opt_container_t *cont, unsigned row, unsigned col, uint32_t option);
FT_INTERNAL
fort_cell_opt_container_t *create_cell_opt_container(void);
FT_INTERNAL
void destroy_cell_opt_container(fort_cell_opt_container_t *cont);
FT_INTERNAL
const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col);
FT_INTERNAL
fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col);
FT_INTERNAL
fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value);
FT_INTERNAL
int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t row, size_t column, uint32_t option);
FT_INTERNAL
fort_status_t set_default_cell_option(uint32_t option, int value);
/*****************************************************************************
@ -468,7 +478,11 @@ struct fort_entire_table_options {
};
typedef struct fort_entire_table_options fort_entire_table_options_t;
extern fort_entire_table_options_t g_entire_table_options;
FT_INTERNAL
fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value);
FT_INTERNAL
fort_status_t set_default_entire_table_option(uint32_t option, int value);
struct fort_table_options {
@ -478,15 +492,18 @@ struct fort_table_options {
};
extern fort_table_options_t g_table_options;
FT_INTERNAL
size_t max_border_elem_strlen(struct fort_table_options *);
FT_INTERNAL
fort_table_options_t *create_table_options(void);
FT_INTERNAL
fort_table_options_t *copy_table_options(const fort_table_options_t *option);
FT_INTERNAL
void destroy_table_options(fort_table_options_t *options);
#endif /* OPTIONS_H */
/********************************************************
@ -756,6 +773,8 @@ fort_column_options_t g_column_options = {
FT_ALIGNED_RIGHT, /* align */
};
FT_INTERNAL
fort_column_options_t create_column_options(void)
{
fort_column_options_t result;
@ -766,7 +785,7 @@ fort_column_options_t create_column_options(void)
//#define DEFAULT_CELL_OPTION {FT_ROW_UNSPEC, FT_COLUMN_UNSPEC, 0, 0, 0}
FT_INTERNAL
fort_cell_opt_container_t *create_cell_opt_container(void)
{
fort_cell_opt_container_t *ret = create_vector(sizeof(fort_cell_options_t), DEFAULT_VECTOR_CAPACITY);
@ -774,12 +793,15 @@ fort_cell_opt_container_t *create_cell_opt_container(void)
}
FT_INTERNAL
void destroy_cell_opt_container(fort_cell_opt_container_t *cont)
{
if (cont)
destroy_vector(cont);
}
FT_INTERNAL
const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col)
{
assert(cont);
@ -793,6 +815,8 @@ const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont,
return NULL;
}
FT_INTERNAL
fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col)
{
assert(cont);
@ -814,8 +838,7 @@ fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_contain
}
FT_INTERNAL
int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t row, size_t column, uint32_t option)
{
assert(options);
@ -880,6 +903,7 @@ fort_fail:
}
FT_INTERNAL
fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value)
{
fort_cell_options_t *opt = get_cell_opt_and_create_if_not_exists(cont, row, col);
@ -899,6 +923,8 @@ fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_
*/
}
FT_INTERNAL
fort_status_t set_default_cell_option(uint32_t option, int value)
{
return set_cell_option_impl(&g_default_cell_option, option, value);
@ -1231,17 +1257,23 @@ fort_fail:
return FT_EINVAL;
}
FT_INTERNAL
fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value)
{
assert(table_options);
return set_entire_table_option_internal(&table_options->entire_table_options, option, value);
}
FT_INTERNAL
fort_status_t set_default_entire_table_option(uint32_t option, int value)
{
return set_entire_table_option_internal(&g_entire_table_options, option, value);
}
FT_INTERNAL
size_t max_border_elem_strlen(struct fort_table_options *options)
{
assert(options);
@ -1278,6 +1310,7 @@ fort_table_options_t g_table_options = {
};
FT_INTERNAL
fort_table_options_t *create_table_options(void)
{
fort_table_options_t *options = (fort_table_options_t *)F_CALLOC(sizeof(fort_table_options_t), 1);
@ -1294,6 +1327,8 @@ fort_table_options_t *create_table_options(void)
return options;
}
FT_INTERNAL
fort_table_options_t *copy_table_options(const fort_table_options_t *option)
{
/* todo: normal implementation, do deep copy of col options */
@ -1316,6 +1351,7 @@ fort_table_options_t *copy_table_options(const fort_table_options_t *option)
}
FT_INTERNAL
void destroy_table_options(fort_table_options_t *options)
{
if (options == NULL)
@ -1663,12 +1699,6 @@ SOFTWARE.
/* #include "options.h" */ /* Commented by amalgamation script */
/*****************************************************************************
* LIBFORT
* ***************************************************************************/
ft_table_t *ft_create_table(void)
{
ft_table_t *result = (ft_table_t *)F_CALLOC(1, sizeof(ft_table_t));
@ -2149,15 +2179,6 @@ int ft_table_wwrite_ln(ft_table_t *table, size_t rows, size_t cols, const wchar_
/*****************************************************************************
* TABLE
* ***************************************************************************/
const char *ft_to_string(const ft_table_t *table)
{
typedef char char_type;
@ -2855,9 +2876,6 @@ fort_status_t vector_swap(vector_t *cur_vec, vector_t *mv_vec, size_t pos)
#include <assert.h>
#include <stddef.h>
#include <wchar.h>
/*****************************************************************************
* STRING BUFFER
* ***************************************************************************/
static ptrdiff_t str_iter_width(const char *beg, const char *end)
@ -2866,6 +2884,7 @@ static ptrdiff_t str_iter_width(const char *beg, const char *end)
return (end - beg);
}
static ptrdiff_t wcs_iter_width(const wchar_t *beg, const wchar_t *end)
{
assert(end >= beg);

View File

@ -41,12 +41,6 @@ SOFTWARE.
#include "options.h"
/*****************************************************************************
* LIBFORT
* ***************************************************************************/
ft_table_t *ft_create_table(void)
{
ft_table_t *result = (ft_table_t *)F_CALLOC(1, sizeof(ft_table_t));
@ -527,15 +521,6 @@ int ft_table_wwrite_ln(ft_table_t *table, size_t rows, size_t cols, const wchar_
/*****************************************************************************
* TABLE
* ***************************************************************************/
const char *ft_to_string(const ft_table_t *table)
{
typedef char char_type;

View File

@ -62,6 +62,8 @@ fort_column_options_t g_column_options = {
FT_ALIGNED_RIGHT, /* align */
};
FT_INTERNAL
fort_column_options_t create_column_options(void)
{
fort_column_options_t result;
@ -72,7 +74,7 @@ fort_column_options_t create_column_options(void)
//#define DEFAULT_CELL_OPTION {FT_ROW_UNSPEC, FT_COLUMN_UNSPEC, 0, 0, 0}
FT_INTERNAL
fort_cell_opt_container_t *create_cell_opt_container(void)
{
fort_cell_opt_container_t *ret = create_vector(sizeof(fort_cell_options_t), DEFAULT_VECTOR_CAPACITY);
@ -80,12 +82,15 @@ fort_cell_opt_container_t *create_cell_opt_container(void)
}
FT_INTERNAL
void destroy_cell_opt_container(fort_cell_opt_container_t *cont)
{
if (cont)
destroy_vector(cont);
}
FT_INTERNAL
const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col)
{
assert(cont);
@ -99,6 +104,8 @@ const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont,
return NULL;
}
FT_INTERNAL
fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col)
{
assert(cont);
@ -120,8 +127,7 @@ fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_contain
}
FT_INTERNAL
int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t row, size_t column, uint32_t option)
{
assert(options);
@ -186,6 +192,7 @@ fort_fail:
}
FT_INTERNAL
fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value)
{
fort_cell_options_t *opt = get_cell_opt_and_create_if_not_exists(cont, row, col);
@ -205,6 +212,8 @@ fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_
*/
}
FT_INTERNAL
fort_status_t set_default_cell_option(uint32_t option, int value)
{
return set_cell_option_impl(&g_default_cell_option, option, value);
@ -537,17 +546,23 @@ fort_fail:
return FT_EINVAL;
}
FT_INTERNAL
fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value)
{
assert(table_options);
return set_entire_table_option_internal(&table_options->entire_table_options, option, value);
}
FT_INTERNAL
fort_status_t set_default_entire_table_option(uint32_t option, int value)
{
return set_entire_table_option_internal(&g_entire_table_options, option, value);
}
FT_INTERNAL
size_t max_border_elem_strlen(struct fort_table_options *options)
{
assert(options);
@ -584,6 +599,7 @@ fort_table_options_t g_table_options = {
};
FT_INTERNAL
fort_table_options_t *create_table_options(void)
{
fort_table_options_t *options = (fort_table_options_t *)F_CALLOC(sizeof(fort_table_options_t), 1);
@ -600,6 +616,8 @@ fort_table_options_t *create_table_options(void)
return options;
}
FT_INTERNAL
fort_table_options_t *copy_table_options(const fort_table_options_t *option)
{
/* todo: normal implementation, do deep copy of col options */
@ -622,6 +640,7 @@ fort_table_options_t *copy_table_options(const fort_table_options_t *option)
}
FT_INTERNAL
void destroy_table_options(fort_table_options_t *options)
{
if (options == NULL)

View File

@ -11,6 +11,8 @@ struct fort_column_options {
};
extern fort_column_options_t g_column_options;
FT_INTERNAL
fort_column_options_t create_column_options(void);
#define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option))
@ -32,19 +34,27 @@ struct fort_cell_options {
};
typedef struct fort_cell_options fort_cell_options_t;
typedef vector_t fort_cell_opt_container_t;
fort_cell_opt_container_t *create_cell_opt_container(void);
void destroy_cell_opt_container(fort_cell_opt_container_t *cont);
const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col);
fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col);
fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value);
fort_status_t unset_cell_option(fort_cell_opt_container_t *cont, unsigned row, unsigned col, uint32_t option);
FT_INTERNAL
fort_cell_opt_container_t *create_cell_opt_container(void);
FT_INTERNAL
void destroy_cell_opt_container(fort_cell_opt_container_t *cont);
FT_INTERNAL
const fort_cell_options_t *cget_cell_opt(const fort_cell_opt_container_t *cont, size_t row, size_t col);
FT_INTERNAL
fort_cell_options_t *get_cell_opt_and_create_if_not_exists(fort_cell_opt_container_t *cont, size_t row, size_t col);
FT_INTERNAL
fort_status_t set_cell_option(fort_cell_opt_container_t *cont, size_t row, size_t col, uint32_t option, int value);
FT_INTERNAL
int get_cell_opt_value_hierarcial(const fort_table_options_t *options, size_t row, size_t column, uint32_t option);
FT_INTERNAL
fort_status_t set_default_cell_option(uint32_t option, int value);
/*****************************************************************************
@ -127,7 +137,11 @@ struct fort_entire_table_options {
};
typedef struct fort_entire_table_options fort_entire_table_options_t;
extern fort_entire_table_options_t g_entire_table_options;
FT_INTERNAL
fort_status_t set_entire_table_option(fort_table_options_t *table_options, uint32_t option, int value);
FT_INTERNAL
fort_status_t set_default_entire_table_option(uint32_t option, int value);
struct fort_table_options {
@ -137,13 +151,16 @@ struct fort_table_options {
};
extern fort_table_options_t g_table_options;
FT_INTERNAL
size_t max_border_elem_strlen(struct fort_table_options *);
FT_INTERNAL
fort_table_options_t *create_table_options(void);
FT_INTERNAL
fort_table_options_t *copy_table_options(const fort_table_options_t *option);
FT_INTERNAL
void destroy_table_options(fort_table_options_t *options);
#endif /* OPTIONS_H */

View File

@ -4,9 +4,6 @@
#include <assert.h>
#include <stddef.h>
#include <wchar.h>
/*****************************************************************************
* STRING BUFFER
* ***************************************************************************/
static ptrdiff_t str_iter_width(const char *beg, const char *end)
@ -15,6 +12,7 @@ static ptrdiff_t str_iter_width(const char *beg, const char *end)
return (end - beg);
}
static ptrdiff_t wcs_iter_width(const wchar_t *beg, const wchar_t *end)
{
assert(end >= beg);