[A] Added new border styles
This commit is contained in:
		@@ -4,11 +4,31 @@
 | 
			
		||||
#include <locale.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static FTABLE *create_basic_table()
 | 
			
		||||
{
 | 
			
		||||
    FTABLE *table = ft_create_table();
 | 
			
		||||
    ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
 | 
			
		||||
    ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
 | 
			
		||||
 | 
			
		||||
    ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
 | 
			
		||||
    FT_NWRITE_LN(table, "Rank", "Title", "Year", "Rating");
 | 
			
		||||
 | 
			
		||||
    FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
 | 
			
		||||
    FT_NWRITE_LN(table, "2", "12 Angry Men", "1957", "8.8");
 | 
			
		||||
    FT_NWRITE_LN(table, "3", "It's a Wonderful Life", "1946", "8.6");
 | 
			
		||||
    ft_add_separator(table);
 | 
			
		||||
    FT_NWRITE_LN(table, "4", "2001: A Space Odyssey", "1968", "8.5");
 | 
			
		||||
    FT_NWRITE_LN(table, "5", "Blade Runner", "1982", "8.1");
 | 
			
		||||
    return table;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int main()
 | 
			
		||||
{
 | 
			
		||||
    FTABLE *table = NULL;
 | 
			
		||||
 | 
			
		||||
#ifdef FORT_HAVE_WCHAR
 | 
			
		||||
#ifdef FT_HAVE_WCHAR
 | 
			
		||||
    setlocale(LC_CTYPE, "");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -132,65 +152,28 @@ int main()
 | 
			
		||||
    /*----------------  Different styles  --------------------*/
 | 
			
		||||
 | 
			
		||||
    ft_set_default_borders(FT_BASIC_STYLE);
 | 
			
		||||
 | 
			
		||||
    table = ft_create_table();
 | 
			
		||||
    ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
 | 
			
		||||
    ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
 | 
			
		||||
 | 
			
		||||
    ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
 | 
			
		||||
    FT_NWRITE_LN(table, "Rank", "Title", "Year", "Rating");
 | 
			
		||||
 | 
			
		||||
    FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
 | 
			
		||||
    FT_NWRITE_LN(table, "2", "12 Angry Men", "1957", "8.8");
 | 
			
		||||
    FT_NWRITE_LN(table, "3", "2001: A Space Odyssey", "1968", "8.5");
 | 
			
		||||
    FT_NWRITE_LN(table, "4", "Blade Runner", "1982", "8.1");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    printf("Table:\n");
 | 
			
		||||
    printf("%s\n", ft_to_string(table));
 | 
			
		||||
    table = create_basic_table();
 | 
			
		||||
    printf("Table:\n%s\n", ft_to_string(table));
 | 
			
		||||
    ft_destroy_table(table);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /* ------------- */
 | 
			
		||||
 | 
			
		||||
    ft_set_default_borders(FT_SIMPLE_STYLE);
 | 
			
		||||
 | 
			
		||||
    table = ft_create_table();
 | 
			
		||||
    ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
 | 
			
		||||
    ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
 | 
			
		||||
 | 
			
		||||
    ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
 | 
			
		||||
    FT_NWRITE_LN(table, "Rank", "Title", "Year", "Rating");
 | 
			
		||||
 | 
			
		||||
    FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
 | 
			
		||||
    FT_NWRITE_LN(table, "2", "12 Angry Men", "1957", "8.8");
 | 
			
		||||
    FT_NWRITE_LN(table, "3", "2001: A Space Odyssey", "1968", "8.5");
 | 
			
		||||
    FT_NWRITE_LN(table, "4", "Blade Runner", "1982", "8.1");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    printf("Table:\n");
 | 
			
		||||
    printf("%s\n", ft_to_string(table));
 | 
			
		||||
    table = create_basic_table();
 | 
			
		||||
    printf("Table:\n%s\n", ft_to_string(table));
 | 
			
		||||
    ft_destroy_table(table);
 | 
			
		||||
 | 
			
		||||
    /* ------------- */
 | 
			
		||||
    ft_set_default_borders(FT_PLAIN_STYLE);
 | 
			
		||||
    table = create_basic_table();
 | 
			
		||||
    printf("Table:\n%s\n", ft_to_string(table));
 | 
			
		||||
    ft_destroy_table(table);
 | 
			
		||||
 | 
			
		||||
    ft_set_default_borders(FT_DOT_STYLE);
 | 
			
		||||
    table = create_basic_table();
 | 
			
		||||
    printf("Table:\n%s\n", ft_to_string(table));
 | 
			
		||||
    ft_destroy_table(table);
 | 
			
		||||
 | 
			
		||||
    table = ft_create_table();
 | 
			
		||||
    ft_set_cell_option(table, FT_ANY_ROW, 0, FT_OPT_TEXT_ALIGN, CenterAligned);
 | 
			
		||||
    ft_set_cell_option(table, FT_ANY_ROW, 1, FT_OPT_TEXT_ALIGN, LeftAligned);
 | 
			
		||||
 | 
			
		||||
    ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
 | 
			
		||||
    FT_NWRITE_LN(table, "Rank", "Title", "Year", "Rating");
 | 
			
		||||
 | 
			
		||||
    FT_NWRITE_LN(table, "1", "The Shawshank Redemption", "1994", "9.5");
 | 
			
		||||
    FT_NWRITE_LN(table, "2", "12 Angry Men", "1957", "8.8");
 | 
			
		||||
    FT_NWRITE_LN(table, "3", "2001: A Space Odyssey", "1968", "8.5");
 | 
			
		||||
    FT_NWRITE_LN(table, "4", "Blade Runner", "1982", "8.1");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    printf("Table:\n");
 | 
			
		||||
    printf("%s\n", ft_to_string(table));
 | 
			
		||||
    ft_set_default_borders(FT_EMPTY_STYLE);
 | 
			
		||||
    table = create_basic_table();
 | 
			
		||||
    printf("Table:\n%s\n", ft_to_string(table));
 | 
			
		||||
    ft_destroy_table(table);
 | 
			
		||||
 | 
			
		||||
    table = NULL;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										193
									
								
								include/fort.h
									
									
									
									
									
								
							
							
						
						
									
										193
									
								
								include/fort.h
									
									
									
									
									
								
							@@ -37,13 +37,13 @@ SOFTWARE.
 | 
			
		||||
 * Determine compiler
 | 
			
		||||
 */
 | 
			
		||||
#if defined(__clang__)
 | 
			
		||||
#define FORT_CLANG_COMPILER
 | 
			
		||||
#define FT_CLANG_COMPILER
 | 
			
		||||
#elif defined(__GNUC__)
 | 
			
		||||
#define FORT_GCC_COMPILER
 | 
			
		||||
#define FT_GCC_COMPILER
 | 
			
		||||
#elif defined(_MSC_VER)
 | 
			
		||||
#define FORT_MICROSOFT_COMPILER
 | 
			
		||||
#define FT_MICROSOFT_COMPILER
 | 
			
		||||
#else
 | 
			
		||||
#define FORT_UNDEFINED_COMPILER
 | 
			
		||||
#define FT_UNDEFINED_COMPILER
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -52,59 +52,59 @@ SOFTWARE.
 | 
			
		||||
 * Declare restrict
 | 
			
		||||
 */
 | 
			
		||||
#if defined(__cplusplus)
 | 
			
		||||
#if defined(FORT_CLANG_COMPILER)
 | 
			
		||||
#define FORT_RESTRICT __restrict__
 | 
			
		||||
#if defined(FT_CLANG_COMPILER)
 | 
			
		||||
#define FT_RESTRICT __restrict__
 | 
			
		||||
#else
 | 
			
		||||
#define FORT_RESTRICT __restrict
 | 
			
		||||
#endif /* if defined(FORT_CLANG_COMPILER) */
 | 
			
		||||
#define FT_RESTRICT __restrict
 | 
			
		||||
#endif /* if defined(FT_CLANG_COMPILER) */
 | 
			
		||||
#else
 | 
			
		||||
#if __STDC_VERSION__ < 199901L
 | 
			
		||||
#define FORT_RESTRICT
 | 
			
		||||
#define FT_RESTRICT
 | 
			
		||||
#else
 | 
			
		||||
#define FORT_RESTRICT restrict
 | 
			
		||||
#define FT_RESTRICT restrict
 | 
			
		||||
#endif /* __STDC_VERSION__ < 199901L */
 | 
			
		||||
#endif /* if defined(__cplusplus) */
 | 
			
		||||
 | 
			
		||||
/* #define FORT_RESTRICT*/
 | 
			
		||||
/* #define FT_RESTRICT*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Declare restrict
 | 
			
		||||
 */
 | 
			
		||||
#if defined(__cplusplus)
 | 
			
		||||
#define FORT_INLINE inline
 | 
			
		||||
#define FT_INLINE inline
 | 
			
		||||
#else
 | 
			
		||||
#define FORT_INLINE __inline
 | 
			
		||||
#define FT_INLINE __inline
 | 
			
		||||
#endif /* if defined(__cplusplus) */
 | 
			
		||||
 | 
			
		||||
/* #define FORT_RESTRICT*/
 | 
			
		||||
/* #define FT_RESTRICT*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Attribute format for argument checking
 | 
			
		||||
 */
 | 
			
		||||
#if defined(FORT_CLANG_COMPILER) || defined(FORT_GCC_COMPILER)
 | 
			
		||||
#define FORT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check) \
 | 
			
		||||
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)
 | 
			
		||||
#define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check) \
 | 
			
		||||
    __attribute__ ((format (printf, string_index, first_to_check)))
 | 
			
		||||
#else
 | 
			
		||||
#define FORT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check)
 | 
			
		||||
#endif /* defined(FORT_CLANG_COMPILER) || defined(FORT_GCC_COMPILER) */
 | 
			
		||||
#define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check)
 | 
			
		||||
#endif /* defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  C++ needs to know that types and declarations are C, not C++.
 | 
			
		||||
 */
 | 
			
		||||
#ifdef	__cplusplus
 | 
			
		||||
# define FORT_BEGIN_DECLS	extern "C" {
 | 
			
		||||
# define FORT_END_DECLS	}
 | 
			
		||||
# define FT_BEGIN_DECLS	extern "C" {
 | 
			
		||||
# define FT_END_DECLS	}
 | 
			
		||||
#else
 | 
			
		||||
# define FORT_BEGIN_DECLS
 | 
			
		||||
# define FORT_END_DECLS
 | 
			
		||||
# define FT_BEGIN_DECLS
 | 
			
		||||
# define FT_END_DECLS
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef FORT_EXTERN
 | 
			
		||||
#define FORT_EXTERN extern
 | 
			
		||||
#ifndef FT_EXTERN
 | 
			
		||||
#define FT_EXTERN extern
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -115,7 +115,7 @@ SOFTWARE.
 | 
			
		||||
/*
 | 
			
		||||
 *  Wchar support
 | 
			
		||||
 */
 | 
			
		||||
#define FORT_HAVE_WCHAR
 | 
			
		||||
#define FT_HAVE_WCHAR
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Helper macros
 | 
			
		||||
@@ -127,13 +127,13 @@ SOFTWARE.
 | 
			
		||||
    STR_2_CAT_(arg1, arg2)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static FORT_INLINE int fort_check_if_string_helper(const char*str)
 | 
			
		||||
static FT_INLINE int ft_check_if_string_helper(const char*str)
 | 
			
		||||
{
 | 
			
		||||
    (void)str;
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static FORT_INLINE int fort_check_if_wstring_helper(const wchar_t*str)
 | 
			
		||||
static FT_INLINE int ft_check_if_wstring_helper(const wchar_t*str)
 | 
			
		||||
{
 | 
			
		||||
    (void)str;
 | 
			
		||||
    return 0;
 | 
			
		||||
@@ -156,70 +156,70 @@ static FORT_INLINE int fort_check_if_wstring_helper(const wchar_t*str)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_32(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_31(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_31(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_30(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_30(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_29(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_29(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_28(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_28(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_27(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_27(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_26(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_26(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_25(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_25(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_24(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_24(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_23(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_23(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_22(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_22(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_21(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_21(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_20(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_20(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_19(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_19(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_18(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_18(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_17(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_17(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_16(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_16(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_15(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_15(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_14(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_14(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_13(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_13(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_12(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_12(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_11(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_11(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_10(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_10(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_9(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_9(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_8(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_8(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_7(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_7(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_6(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_6(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_5(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_5(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_4(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_4(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_3(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_3(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_2(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_2(checker,arg,...) (checker(arg),CHECK_IF_ARG_IS_STRING_1(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_ARG_IS_STRING_1(checker,arg) (checker(arg))
 | 
			
		||||
#define CHECK_IF_STRING_32(checker,arg,...) (checker(arg),CHECK_IF_STRING_31(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_31(checker,arg,...) (checker(arg),CHECK_IF_STRING_30(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_30(checker,arg,...) (checker(arg),CHECK_IF_STRING_29(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_29(checker,arg,...) (checker(arg),CHECK_IF_STRING_28(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_28(checker,arg,...) (checker(arg),CHECK_IF_STRING_27(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_27(checker,arg,...) (checker(arg),CHECK_IF_STRING_26(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_26(checker,arg,...) (checker(arg),CHECK_IF_STRING_25(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_25(checker,arg,...) (checker(arg),CHECK_IF_STRING_24(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_24(checker,arg,...) (checker(arg),CHECK_IF_STRING_23(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_23(checker,arg,...) (checker(arg),CHECK_IF_STRING_22(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_22(checker,arg,...) (checker(arg),CHECK_IF_STRING_21(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_21(checker,arg,...) (checker(arg),CHECK_IF_STRING_20(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_20(checker,arg,...) (checker(arg),CHECK_IF_STRING_19(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_19(checker,arg,...) (checker(arg),CHECK_IF_STRING_18(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_18(checker,arg,...) (checker(arg),CHECK_IF_STRING_17(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_17(checker,arg,...) (checker(arg),CHECK_IF_STRING_16(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_16(checker,arg,...) (checker(arg),CHECK_IF_STRING_15(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_15(checker,arg,...) (checker(arg),CHECK_IF_STRING_14(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_14(checker,arg,...) (checker(arg),CHECK_IF_STRING_13(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_13(checker,arg,...) (checker(arg),CHECK_IF_STRING_12(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_12(checker,arg,...) (checker(arg),CHECK_IF_STRING_11(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_11(checker,arg,...) (checker(arg),CHECK_IF_STRING_10(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_10(checker,arg,...) (checker(arg),CHECK_IF_STRING_9(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_9(checker,arg,...) (checker(arg),CHECK_IF_STRING_8(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_8(checker,arg,...) (checker(arg),CHECK_IF_STRING_7(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_7(checker,arg,...) (checker(arg),CHECK_IF_STRING_6(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_6(checker,arg,...) (checker(arg),CHECK_IF_STRING_5(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_5(checker,arg,...) (checker(arg),CHECK_IF_STRING_4(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_4(checker,arg,...) (checker(arg),CHECK_IF_STRING_3(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_3(checker,arg,...) (checker(arg),CHECK_IF_STRING_2(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_2(checker,arg,...) (checker(arg),CHECK_IF_STRING_1(checker,__VA_ARGS__))
 | 
			
		||||
#define CHECK_IF_STRING_1(checker,arg) (checker(arg))
 | 
			
		||||
 | 
			
		||||
#define CHECK_IF_ARGS_ARE_STRINGS__(checker,func, ...) func(checker,__VA_ARGS__)
 | 
			
		||||
#define CHECK_IF_ARGS_ARE_STRINGS_(checker,basis, n, ...) CHECK_IF_ARGS_ARE_STRINGS__(checker,STR_2_CAT_(basis, n), __VA_ARGS__)
 | 
			
		||||
#define CHECK_IF_ARGS_ARE_STRINGS(...) CHECK_IF_ARGS_ARE_STRINGS_(fort_check_if_string_helper,CHECK_IF_ARG_IS_STRING_,PP_NARG(__VA_ARGS__), __VA_ARGS__)
 | 
			
		||||
#ifdef FORT_HAVE_WCHAR
 | 
			
		||||
#define CHECK_IF_ARGS_ARE_WSTRINGS(...) CHECK_IF_ARGS_ARE_STRINGS_(fort_check_if_wstring_helper,CHECK_IF_ARG_IS_STRING_,PP_NARG(__VA_ARGS__), __VA_ARGS__)
 | 
			
		||||
#define CHECK_IF_ARGS_ARE_STRINGS(...) CHECK_IF_ARGS_ARE_STRINGS_(ft_check_if_string_helper,CHECK_IF_STRING_,PP_NARG(__VA_ARGS__), __VA_ARGS__)
 | 
			
		||||
#ifdef FT_HAVE_WCHAR
 | 
			
		||||
#define CHECK_IF_ARGS_ARE_WSTRINGS(...) CHECK_IF_ARGS_ARE_STRINGS_(ft_check_if_wstring_helper,CHECK_IF_STRING_,PP_NARG(__VA_ARGS__), __VA_ARGS__)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * libfort structures and functions declarations
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
FORT_BEGIN_DECLS
 | 
			
		||||
FT_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
struct fort_table;
 | 
			
		||||
typedef struct fort_table FTABLE;
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN FTABLE * ft_create_table(void);
 | 
			
		||||
FORT_EXTERN void ft_destroy_table(FTABLE *FORT_RESTRICT table);
 | 
			
		||||
FT_EXTERN FTABLE * ft_create_table(void);
 | 
			
		||||
FT_EXTERN void ft_destroy_table(FTABLE *FT_RESTRICT table);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN void ft_ln(FTABLE *FORT_RESTRICT table);
 | 
			
		||||
FT_EXTERN void ft_ln(FTABLE *FT_RESTRICT table);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(FORT_CLANG_COMPILER) || defined(FORT_GCC_COMPILER)
 | 
			
		||||
FORT_EXTERN int ft_printf(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...) FORT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
 | 
			
		||||
FORT_EXTERN int ft_printf_ln(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...) FORT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
 | 
			
		||||
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)
 | 
			
		||||
FT_EXTERN int ft_printf(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
 | 
			
		||||
FT_EXTERN int ft_printf_ln(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_printf_impl(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...) FORT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
 | 
			
		||||
FORT_EXTERN int ft_printf_ln_impl(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...) FORT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
 | 
			
		||||
FT_EXTERN int ft_printf_impl(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
 | 
			
		||||
FT_EXTERN int ft_printf_ln_impl(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3);
 | 
			
		||||
 | 
			
		||||
#define ft_printf(table, ...) \
 | 
			
		||||
    (( 0 ? fprintf(stderr, __VA_ARGS__) : 1), ft_printf_impl(table, __VA_ARGS__))
 | 
			
		||||
@@ -229,55 +229,55 @@ FORT_EXTERN int ft_printf_ln_impl(FTABLE *FORT_RESTRICT table, const char* FORT_
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_write(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_content);
 | 
			
		||||
FORT_EXTERN int ft_write_ln(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_content);
 | 
			
		||||
FT_EXTERN int ft_write(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT cell_content);
 | 
			
		||||
FT_EXTERN int ft_write_ln(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT cell_content);
 | 
			
		||||
 | 
			
		||||
#define FT_NWRITE(table, ...)\
 | 
			
		||||
    (0 ? CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) : ft_nwrite(table, PP_NARG(__VA_ARGS__), __VA_ARGS__))
 | 
			
		||||
#define FT_NWRITE_LN(table, ...)\
 | 
			
		||||
    (0 ? CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) : ft_nwrite_ln(table, PP_NARG(__VA_ARGS__), __VA_ARGS__))
 | 
			
		||||
FORT_EXTERN int ft_nwrite(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRICT cell_content, ...);
 | 
			
		||||
FORT_EXTERN int ft_nwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRICT cell_content, ...);
 | 
			
		||||
FT_EXTERN int ft_nwrite(FTABLE *FT_RESTRICT table, size_t n, const char* FT_RESTRICT cell_content, ...);
 | 
			
		||||
FT_EXTERN int ft_nwrite_ln(FTABLE *FT_RESTRICT table, size_t n, const char* FT_RESTRICT cell_content, ...);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef FORT_HAVE_WCHAR
 | 
			
		||||
FORT_EXTERN int ft_wwrite(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_content);
 | 
			
		||||
FORT_EXTERN int ft_wwrite_ln(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_content);
 | 
			
		||||
#ifdef FT_HAVE_WCHAR
 | 
			
		||||
FT_EXTERN int ft_wwrite(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content);
 | 
			
		||||
FT_EXTERN int ft_wwrite_ln(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content);
 | 
			
		||||
 | 
			
		||||
#define FT_NWWRITE(table, ...)\
 | 
			
		||||
    (0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite(table, PP_NARG(__VA_ARGS__), __VA_ARGS__))
 | 
			
		||||
#define FT_NWWRITE_LN(table, ...)\
 | 
			
		||||
    (0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite_ln(table, PP_NARG(__VA_ARGS__), __VA_ARGS__))
 | 
			
		||||
FORT_EXTERN int ft_nwwrite(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RESTRICT cell_content, ...);
 | 
			
		||||
FORT_EXTERN int ft_nwwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RESTRICT cell_content, ...);
 | 
			
		||||
FT_EXTERN int ft_nwwrite(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...);
 | 
			
		||||
FT_EXTERN int ft_nwwrite_ln(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_row_write(FTABLE *FORT_RESTRICT table, size_t cols, const char* FORT_RESTRICT row_cells[]);
 | 
			
		||||
FORT_EXTERN int ft_row_write_ln(FTABLE *FORT_RESTRICT table, size_t cols, const char* FORT_RESTRICT row_cells[]);
 | 
			
		||||
FT_EXTERN int ft_row_write(FTABLE *FT_RESTRICT table, size_t cols, const char* FT_RESTRICT row_cells[]);
 | 
			
		||||
FT_EXTERN int ft_row_write_ln(FTABLE *FT_RESTRICT table, size_t cols, const char* FT_RESTRICT row_cells[]);
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_s_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* FORT_RESTRICT table_cells[rows][cols]);
 | 
			
		||||
FORT_EXTERN int ft_s_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* FORT_RESTRICT table_cells[rows][cols]);
 | 
			
		||||
FT_EXTERN int ft_s_table_write(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* FT_RESTRICT table_cells[rows][cols]);
 | 
			
		||||
FT_EXTERN int ft_s_table_write_ln(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* FT_RESTRICT table_cells[rows][cols]);
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* * FORT_RESTRICT table_cells[rows]);
 | 
			
		||||
FORT_EXTERN int ft_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* * FORT_RESTRICT table_cells[rows]);
 | 
			
		||||
FT_EXTERN int ft_table_write(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* * FT_RESTRICT table_cells[rows]);
 | 
			
		||||
FT_EXTERN int ft_table_write_ln(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* * FT_RESTRICT table_cells[rows]);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_add_separator(FTABLE *FORT_RESTRICT table);
 | 
			
		||||
FT_EXTERN int ft_add_separator(FTABLE *FT_RESTRICT table);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN const char* ft_to_string(const FTABLE *FORT_RESTRICT table);
 | 
			
		||||
FORT_EXTERN const wchar_t* ft_to_wstring(const FTABLE *FORT_RESTRICT table);
 | 
			
		||||
/*FORT_EXTERN ssize_t ft_n_to_string(const FTABLE *FORT_RESTRICT table, char *FORT_RESTRICT dst, size_t dst_len);*/
 | 
			
		||||
FT_EXTERN const char* ft_to_string(const FTABLE *FT_RESTRICT table);
 | 
			
		||||
FT_EXTERN const wchar_t* ft_to_wstring(const FTABLE *FT_RESTRICT table);
 | 
			
		||||
/*FT_EXTERN ssize_t ft_n_to_string(const FTABLE *FT_RESTRICT table, char *FT_RESTRICT dst, size_t dst_len);*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -296,21 +296,24 @@ struct ft_border_style
 | 
			
		||||
{
 | 
			
		||||
    struct ft_border_chars border_chs;
 | 
			
		||||
    struct ft_border_chars header_border_chs;
 | 
			
		||||
    char hor_separator_char;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* List of built-in table border styles */
 | 
			
		||||
extern struct ft_border_style * FT_BASIC_STYLE;
 | 
			
		||||
extern struct ft_border_style * FT_SIMPLE_STYLE;
 | 
			
		||||
extern struct ft_border_style * FT_PLAIN_STYLE;
 | 
			
		||||
extern struct ft_border_style * FT_DOT_STYLE;
 | 
			
		||||
extern struct ft_border_style * FT_EMPTY_STYLE;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_set_default_borders(struct ft_border_style *style);
 | 
			
		||||
FORT_EXTERN int ft_set_table_borders(FTABLE * FORT_RESTRICT table, struct ft_border_style *style);
 | 
			
		||||
FT_EXTERN int ft_set_default_borders(struct ft_border_style *style);
 | 
			
		||||
FT_EXTERN int ft_set_table_borders(FTABLE * FT_RESTRICT table, struct ft_border_style *style);
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_set_default_cell_option(uint32_t option, int value);
 | 
			
		||||
FORT_EXTERN int ft_set_cell_option(FTABLE * FORT_RESTRICT table, unsigned row, unsigned col, uint32_t option, int value);
 | 
			
		||||
FT_EXTERN int ft_set_default_cell_option(uint32_t option, int value);
 | 
			
		||||
FT_EXTERN int ft_set_cell_option(FTABLE * FT_RESTRICT table, unsigned row, unsigned col, uint32_t option, int value);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FORT_END_DECLS
 | 
			
		||||
FT_END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* LIBFORT_H */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										56
									
								
								src/fort.c
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								src/fort.c
									
									
									
									
									
								
							@@ -72,7 +72,7 @@ FTABLE * ft_create_table(void)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void ft_destroy_table(FTABLE *FORT_RESTRICT table)
 | 
			
		||||
void ft_destroy_table(FTABLE *FT_RESTRICT table)
 | 
			
		||||
{
 | 
			
		||||
    size_t i = 0;
 | 
			
		||||
 | 
			
		||||
@@ -98,7 +98,7 @@ void ft_destroy_table(FTABLE *FORT_RESTRICT table)
 | 
			
		||||
    F_FREE(table);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ft_ln(FTABLE *FORT_RESTRICT table)
 | 
			
		||||
void ft_ln(FTABLE *FT_RESTRICT table)
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    table->cur_col = 0;
 | 
			
		||||
@@ -106,7 +106,7 @@ void ft_ln(FTABLE *FORT_RESTRICT table)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int ft_row_printf_impl(FTABLE *FORT_RESTRICT table, size_t row, const char* FORT_RESTRICT fmt, va_list *va)
 | 
			
		||||
static int ft_row_printf_impl(FTABLE *FT_RESTRICT table, size_t row, const char* FT_RESTRICT fmt, va_list *va)
 | 
			
		||||
{
 | 
			
		||||
    size_t i = 0;
 | 
			
		||||
 | 
			
		||||
@@ -151,7 +151,7 @@ clear:
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(FORT_CLANG_COMPILER) || defined(FORT_GCC_COMPILER)
 | 
			
		||||
#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER)
 | 
			
		||||
#define FT_PRINTF ft_printf
 | 
			
		||||
#define FT_PRINTF_LN ft_printf_ln
 | 
			
		||||
#else
 | 
			
		||||
@@ -161,7 +161,7 @@ clear:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int FT_PRINTF(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...)
 | 
			
		||||
int FT_PRINTF(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    va_list va;
 | 
			
		||||
@@ -171,7 +171,7 @@ int FT_PRINTF(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...)
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int FT_PRINTF_LN(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...)
 | 
			
		||||
int FT_PRINTF_LN(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT fmt, ...)
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    va_list va;
 | 
			
		||||
@@ -190,7 +190,7 @@ int FT_PRINTF_LN(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT fmt, ...
 | 
			
		||||
#undef FT_HDR_PRINTF_LN
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int ft_write(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_content)
 | 
			
		||||
int ft_write(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT cell_content)
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    string_buffer_t *str_buffer = get_cur_str_buffer_and_create_if_not_exists(table);
 | 
			
		||||
@@ -204,7 +204,7 @@ int ft_write(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_content
 | 
			
		||||
    return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ft_write_ln(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_content)
 | 
			
		||||
int ft_write_ln(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT cell_content)
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    int status = ft_write(table, cell_content);
 | 
			
		||||
@@ -214,7 +214,7 @@ int ft_write_ln(FTABLE *FORT_RESTRICT table, const char* FORT_RESTRICT cell_cont
 | 
			
		||||
    return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ft_wwrite(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_content)
 | 
			
		||||
int ft_wwrite(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content)
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    string_buffer_t *str_buffer = get_cur_str_buffer_and_create_if_not_exists(table);
 | 
			
		||||
@@ -228,7 +228,7 @@ int ft_wwrite(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_con
 | 
			
		||||
    return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ft_wwrite_ln(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_content)
 | 
			
		||||
int ft_wwrite_ln(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content)
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    int status = ft_wwrite(table, cell_content);
 | 
			
		||||
@@ -239,7 +239,7 @@ int ft_wwrite_ln(FTABLE *FORT_RESTRICT table, const wchar_t* FORT_RESTRICT cell_
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int ft_nwrite(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRICT cell_content, ...)
 | 
			
		||||
int ft_nwrite(FTABLE *FT_RESTRICT table, size_t n, const char* FT_RESTRICT cell_content, ...)
 | 
			
		||||
{
 | 
			
		||||
    size_t i = 0;
 | 
			
		||||
    assert(table);
 | 
			
		||||
@@ -260,7 +260,7 @@ int ft_nwrite(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRICT c
 | 
			
		||||
    return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ft_nwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRICT cell_content, ...)
 | 
			
		||||
int ft_nwrite_ln(FTABLE *FT_RESTRICT table, size_t n, const char* FT_RESTRICT cell_content, ...)
 | 
			
		||||
{
 | 
			
		||||
    size_t i = 0;
 | 
			
		||||
    assert(table);
 | 
			
		||||
@@ -286,7 +286,7 @@ int ft_nwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const char* FORT_RESTRIC
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int ft_nwwrite(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RESTRICT cell_content, ...)
 | 
			
		||||
int ft_nwwrite(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...)
 | 
			
		||||
{
 | 
			
		||||
    size_t i = 0;
 | 
			
		||||
    assert(table);
 | 
			
		||||
@@ -307,7 +307,7 @@ int ft_nwwrite(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RESTRI
 | 
			
		||||
    return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ft_nwwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RESTRICT cell_content, ...)
 | 
			
		||||
int ft_nwwrite_ln(FTABLE *FT_RESTRICT table, size_t n, const wchar_t* FT_RESTRICT cell_content, ...)
 | 
			
		||||
{
 | 
			
		||||
    size_t i = 0;
 | 
			
		||||
    assert(table);
 | 
			
		||||
@@ -333,7 +333,7 @@ int ft_nwwrite_ln(FTABLE *FORT_RESTRICT table, size_t n, const wchar_t* FORT_RES
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_row_write(FTABLE *FORT_RESTRICT table, size_t cols, const char* FORT_RESTRICT cells[])
 | 
			
		||||
FT_EXTERN int ft_row_write(FTABLE *FT_RESTRICT table, size_t cols, const char* FT_RESTRICT cells[])
 | 
			
		||||
{
 | 
			
		||||
    size_t i = 0;
 | 
			
		||||
    assert(table);
 | 
			
		||||
@@ -347,7 +347,7 @@ FORT_EXTERN int ft_row_write(FTABLE *FORT_RESTRICT table, size_t cols, const cha
 | 
			
		||||
    return F_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
FORT_EXTERN int ft_row_write_ln(FTABLE *FORT_RESTRICT table, size_t cols, const char* FORT_RESTRICT cells[])
 | 
			
		||||
FT_EXTERN int ft_row_write_ln(FTABLE *FT_RESTRICT table, size_t cols, const char* FT_RESTRICT cells[])
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    int status = ft_row_write(table, cols, cells);
 | 
			
		||||
@@ -360,7 +360,7 @@ FORT_EXTERN int ft_row_write_ln(FTABLE *FORT_RESTRICT table, size_t cols, const
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int ft_s_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* FORT_RESTRICT table_cells[rows][cols])
 | 
			
		||||
int ft_s_table_write(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* FT_RESTRICT table_cells[rows][cols])
 | 
			
		||||
{
 | 
			
		||||
    size_t i = 0;
 | 
			
		||||
    assert(table);
 | 
			
		||||
@@ -376,7 +376,7 @@ int ft_s_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, cons
 | 
			
		||||
    return F_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ft_s_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* FORT_RESTRICT table_cells[rows][cols])
 | 
			
		||||
int ft_s_table_write_ln(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* FT_RESTRICT table_cells[rows][cols])
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    int status = ft_s_table_write(table, rows, cols, table_cells);
 | 
			
		||||
@@ -387,7 +387,7 @@ int ft_s_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, c
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int ft_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* * FORT_RESTRICT table_cells[rows])
 | 
			
		||||
int ft_table_write(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* * FT_RESTRICT table_cells[rows])
 | 
			
		||||
{
 | 
			
		||||
    size_t i = 0;
 | 
			
		||||
    assert(table);
 | 
			
		||||
@@ -403,7 +403,7 @@ int ft_table_write(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const
 | 
			
		||||
    return F_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ft_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, const char* * FORT_RESTRICT table_cells[rows])
 | 
			
		||||
int ft_table_write_ln(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* * FT_RESTRICT table_cells[rows])
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
    int status = ft_table_write(table, rows, cols, table_cells);
 | 
			
		||||
@@ -427,7 +427,7 @@ int ft_table_write_ln(FTABLE *FORT_RESTRICT table, size_t rows, size_t cols, con
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const char* ft_to_string(const FTABLE *FORT_RESTRICT table)
 | 
			
		||||
const char* ft_to_string(const FTABLE *FT_RESTRICT table)
 | 
			
		||||
{
 | 
			
		||||
#define CHECK_RESULT_AND_MOVE_DEV(statement) \
 | 
			
		||||
    k = statement; \
 | 
			
		||||
@@ -521,7 +521,7 @@ clear:
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const wchar_t* ft_to_wstring(const FTABLE *FORT_RESTRICT table)
 | 
			
		||||
const wchar_t* ft_to_wstring(const FTABLE *FT_RESTRICT table)
 | 
			
		||||
{
 | 
			
		||||
#define CHECK_RESULT_AND_MOVE_DEV(statement) \
 | 
			
		||||
    k = statement; \
 | 
			
		||||
@@ -668,7 +668,9 @@ int ft_add_separator(FTABLE *table)
 | 
			
		||||
 | 
			
		||||
struct ft_border_style * FT_BASIC_STYLE = (struct ft_border_style *)&FORT_BASIC_STYLE;
 | 
			
		||||
struct ft_border_style * FT_SIMPLE_STYLE = (struct ft_border_style *)&FORT_SIMPLE_STYLE;
 | 
			
		||||
struct ft_border_style * FT_PLAIN_STYLE =  (struct ft_border_style *)&FORT_PLAIN_STYLE;
 | 
			
		||||
struct ft_border_style * FT_DOT_STYLE = (struct ft_border_style *)&FORT_DOT_STYLE;
 | 
			
		||||
struct ft_border_style * FT_EMPTY_STYLE  = (struct ft_border_style *)&FORT_EMPTY_STYLE;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -676,7 +678,9 @@ static void set_border_options_for_options(fort_table_options_t *options, struct
 | 
			
		||||
{
 | 
			
		||||
    if ((struct fort_border_style *)style == &FORT_BASIC_STYLE
 | 
			
		||||
        || (struct fort_border_style *)style == &FORT_SIMPLE_STYLE
 | 
			
		||||
        || (struct fort_border_style *)style == &FORT_DOT_STYLE)
 | 
			
		||||
        || (struct fort_border_style *)style == &FORT_DOT_STYLE
 | 
			
		||||
        || (struct fort_border_style *)style == &FORT_PLAIN_STYLE
 | 
			
		||||
        || (struct fort_border_style *)style == &FORT_EMPTY_STYLE)
 | 
			
		||||
    {
 | 
			
		||||
        memcpy(&(options->border_style), (struct fort_border_style *)style, sizeof(struct fort_border_style));
 | 
			
		||||
        return;
 | 
			
		||||
@@ -687,6 +691,7 @@ static void set_border_options_for_options(fort_table_options_t *options, struct
 | 
			
		||||
 | 
			
		||||
#define BOR_CHARS options->border_style.border_chars
 | 
			
		||||
#define H_BOR_CHARS options->border_style.header_border_chars
 | 
			
		||||
#define SEP_CHARS options->border_style.separator_chars
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
    BOR_CHARS[TL_bip] = BOR_CHARS[TT_bip] = BOR_CHARS[TV_bip] = BOR_CHARS[TR_bip] = border_chs->top_border_ch;
 | 
			
		||||
@@ -729,8 +734,13 @@ static void set_border_options_for_options(fort_table_options_t *options, struct
 | 
			
		||||
        H_BOR_CHARS[LH_bip] = H_BOR_CHARS[RH_bip] = '\0';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SEP_CHARS[LH_sip] = SEP_CHARS[RH_sip] = SEP_CHARS[II_sip] = header_border_chs->out_intersect_ch;
 | 
			
		||||
    SEP_CHARS[IH_sip] = style->hor_separator_char;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#undef BOR_CHARS
 | 
			
		||||
#undef H_BOR_CHARS
 | 
			
		||||
#undef SEP_CHARS
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,8 +13,9 @@ struct fort_cell_options g_default_cell_option =
 | 
			
		||||
    FT_ANY_COLUMN, /* cell_col */
 | 
			
		||||
 | 
			
		||||
    /* options */
 | 
			
		||||
    FT_OPT_MIN_WIDTH  | FT_OPT_TEXT_ALIGN | FT_OPT_TOP_PADDING | FT_OPT_BOTTOM_PADDING
 | 
			
		||||
    | FT_OPT_LEFT_PADDING | FT_OPT_RIGHT_PADDING | FT_OPT_EMPTY_STR_HEIGHT ,
 | 
			
		||||
    FT_OPT_MIN_WIDTH  | FT_OPT_TEXT_ALIGN | FT_OPT_TOP_PADDING
 | 
			
		||||
    | FT_OPT_BOTTOM_PADDING | FT_OPT_LEFT_PADDING | FT_OPT_RIGHT_PADDING
 | 
			
		||||
    | FT_OPT_EMPTY_STR_HEIGHT ,
 | 
			
		||||
 | 
			
		||||
    0,             /* col_min_width */
 | 
			
		||||
    RightAligned,  /* align */
 | 
			
		||||
@@ -224,7 +225,7 @@ fort_status_t set_default_cell_option(uint32_t option, int value)
 | 
			
		||||
    },                            \
 | 
			
		||||
    /* separator_chars */         \
 | 
			
		||||
    {                             \
 | 
			
		||||
    '+', '=', '+', '+',           \
 | 
			
		||||
    '+', '-', '+', '+',           \
 | 
			
		||||
    },                            \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -245,7 +246,28 @@ fort_status_t set_default_cell_option(uint32_t option, int value)
 | 
			
		||||
    },                            \
 | 
			
		||||
    /* separator_chars */         \
 | 
			
		||||
    {                             \
 | 
			
		||||
    ' ', '=', ' ', ' ',           \
 | 
			
		||||
    ' ', '-', ' ', ' ',           \
 | 
			
		||||
    },                            \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define PLAIN_STYLE  {            \
 | 
			
		||||
    /* border_chars */            \
 | 
			
		||||
    {                             \
 | 
			
		||||
     ' ', ' ', ' ', ' ',          \
 | 
			
		||||
     ' ', ' ', ' ',               \
 | 
			
		||||
     '\0', '\0', '\0', '\0',      \
 | 
			
		||||
     ' ', ' ', ' ', ' '           \
 | 
			
		||||
    },                            \
 | 
			
		||||
    /* header_border_chars */     \
 | 
			
		||||
    {                             \
 | 
			
		||||
    ' ', '-', '-', ' ',           \
 | 
			
		||||
    ' ', ' ', ' ',                \
 | 
			
		||||
    ' ', '-', '-', ' ',           \
 | 
			
		||||
    ' ', '-', '-', ' '            \
 | 
			
		||||
    },                            \
 | 
			
		||||
    /* separator_chars */         \
 | 
			
		||||
    {                             \
 | 
			
		||||
    ' ', '-', '-', ' ',           \
 | 
			
		||||
    },                            \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -266,13 +288,36 @@ fort_status_t set_default_cell_option(uint32_t option, int value)
 | 
			
		||||
    },                            \
 | 
			
		||||
    /* separator_chars */         \
 | 
			
		||||
    {                             \
 | 
			
		||||
    '+', '=', '+', '+',           \
 | 
			
		||||
    ':', '.', ':', ':',           \
 | 
			
		||||
    },                            \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define EMPTY_STYLE  {              \
 | 
			
		||||
    /* border_chars */            \
 | 
			
		||||
    {                             \
 | 
			
		||||
     ' ', ' ', ' ', ' ',          \
 | 
			
		||||
     ' ', ' ', ' ',               \
 | 
			
		||||
     '\0', '\0', '\0', '\0',      \
 | 
			
		||||
     ' ', ' ', ' ', ' '           \
 | 
			
		||||
    },                            \
 | 
			
		||||
    /* header_border_chars */     \
 | 
			
		||||
    {                             \
 | 
			
		||||
    ' ', ' ', ' ', ' ',           \
 | 
			
		||||
    ' ', ' ', ' ',                \
 | 
			
		||||
    '\0', '\0', '\0', '\0',      \
 | 
			
		||||
    ' ', ' ', ' ', ' '            \
 | 
			
		||||
    },                            \
 | 
			
		||||
    /* separator_chars */         \
 | 
			
		||||
    {                             \
 | 
			
		||||
    ' ', ' ', ' ', ' ',           \
 | 
			
		||||
    },                            \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct fort_border_style FORT_BASIC_STYLE = BASIC_STYLE;
 | 
			
		||||
struct fort_border_style FORT_SIMPLE_STYLE = SIMPLE_STYLE;
 | 
			
		||||
struct fort_border_style FORT_PLAIN_STYLE = PLAIN_STYLE;
 | 
			
		||||
struct fort_border_style FORT_DOT_STYLE = DOT_STYLE;
 | 
			
		||||
struct fort_border_style FORT_EMPTY_STYLE = EMPTY_STYLE;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -147,7 +147,10 @@ struct fort_border_style
 | 
			
		||||
};
 | 
			
		||||
extern struct fort_border_style FORT_BASIC_STYLE;
 | 
			
		||||
extern struct fort_border_style FORT_SIMPLE_STYLE;
 | 
			
		||||
extern struct fort_border_style FORT_PLAIN_STYLE;
 | 
			
		||||
extern struct fort_border_style FORT_DOT_STYLE;
 | 
			
		||||
extern struct fort_border_style FORT_EMPTY_STYLE;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
struct fort_table_options
 | 
			
		||||
 
 | 
			
		||||
@@ -403,7 +403,7 @@ clear:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
fort_row_t* create_row_from_fmt_string(const char* FORT_RESTRICT fmt, va_list *va_args)
 | 
			
		||||
fort_row_t* create_row_from_fmt_string(const char* FT_RESTRICT fmt, va_list *va_args)
 | 
			
		||||
{
 | 
			
		||||
    string_buffer_t *buffer = create_string_buffer(DEFAULT_STR_BUF_SIZE, CharBuf);
 | 
			
		||||
    if (buffer == NULL)
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ enum RowType
 | 
			
		||||
fort_row_t * create_row();
 | 
			
		||||
void destroy_row(fort_row_t *row);
 | 
			
		||||
fort_row_t * create_row_from_string(const char *str);
 | 
			
		||||
fort_row_t* create_row_from_fmt_string(const char* FORT_RESTRICT fmt, va_list *va_args);
 | 
			
		||||
fort_row_t* create_row_from_fmt_string(const char* FT_RESTRICT fmt, va_list *va_args);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int columns_in_row(const fort_row_t *row);
 | 
			
		||||
@@ -48,7 +48,7 @@ int wprint_row_separator(wchar_t *buffer, size_t buffer_sz,
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
fort_row_t* create_row_from_string(const char *str);
 | 
			
		||||
fort_row_t* create_row_from_fmt_string(const char* FORT_RESTRICT fmt, va_list *va_args);
 | 
			
		||||
fort_row_t* create_row_from_fmt_string(const char* FT_RESTRICT fmt, va_list *va_args);
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ fort_row_t *get_row_and_create_if_not_exists(fort_table_t *table, size_t row)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
string_buffer_t * get_cur_str_buffer_and_create_if_not_exists(FTABLE *FORT_RESTRICT table)
 | 
			
		||||
string_buffer_t * get_cur_str_buffer_and_create_if_not_exists(FTABLE *FT_RESTRICT table)
 | 
			
		||||
{
 | 
			
		||||
    assert(table);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ struct fort_table
 | 
			
		||||
    vector_t *separators;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static FORT_INLINE
 | 
			
		||||
static FT_INLINE
 | 
			
		||||
separator_t *create_separator(int enabled)
 | 
			
		||||
{
 | 
			
		||||
    separator_t *res = F_CALLOC(1, sizeof(separator_t));
 | 
			
		||||
@@ -26,7 +26,7 @@ separator_t *create_separator(int enabled)
 | 
			
		||||
    return res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static FORT_INLINE
 | 
			
		||||
static FT_INLINE
 | 
			
		||||
void destroy_separator(separator_t *sep)
 | 
			
		||||
{
 | 
			
		||||
    F_FREE(sep);
 | 
			
		||||
@@ -40,7 +40,7 @@ fort_row_t *get_row(fort_table_t *table, size_t row);
 | 
			
		||||
const fort_row_t *get_row_c(const fort_table_t *table, size_t row);
 | 
			
		||||
fort_row_t *get_row_and_create_if_not_exists(fort_table_t *table, size_t row);
 | 
			
		||||
 | 
			
		||||
string_buffer_t * get_cur_str_buffer_and_create_if_not_exists(FTABLE *FORT_RESTRICT table);
 | 
			
		||||
string_buffer_t * get_cur_str_buffer_and_create_if_not_exists(FTABLE *FT_RESTRICT table);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
//#define FORT_EXTERN static
 | 
			
		||||
//#define FT_EXTERN static
 | 
			
		||||
#include "tests.h"
 | 
			
		||||
#include "fort.h"
 | 
			
		||||
#include <string.h>
 | 
			
		||||
@@ -37,6 +37,8 @@ int set_test_options_for_table(FTABLE *table)
 | 
			
		||||
    brdr_style.header_border_chs.side_border_ch = '|';
 | 
			
		||||
    brdr_style.header_border_chs.out_intersect_ch = '+';
 | 
			
		||||
    brdr_style.header_border_chs.in_intersect_ch = '+';
 | 
			
		||||
 | 
			
		||||
    brdr_style.hor_separator_char = '=';
 | 
			
		||||
    return ft_set_table_borders(table, &brdr_style);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -70,6 +72,9 @@ int set_test_options_as_default()
 | 
			
		||||
    brdr_style.header_border_chs.side_border_ch = '|';
 | 
			
		||||
    brdr_style.header_border_chs.out_intersect_ch = '+';
 | 
			
		||||
    brdr_style.header_border_chs.in_intersect_ch = '+';
 | 
			
		||||
 | 
			
		||||
    brdr_style.hor_separator_char = '=';
 | 
			
		||||
 | 
			
		||||
    return ft_set_default_borders(&brdr_style);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -403,7 +408,7 @@ void test_table_options(void **state)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    WHEN("Separator testing") {
 | 
			
		||||
        table = create_test_int_table(0);
 | 
			
		||||
        table = create_test_int_table(1);
 | 
			
		||||
        ft_add_separator(table);
 | 
			
		||||
 | 
			
		||||
        ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_OPT_ROW_TYPE, Header);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user