[C] Renames options to properties

This commit is contained in:
seleznevae
2018-11-03 23:50:30 +03:00
parent 01da9c3f68
commit ece19c8bcb
27 changed files with 798 additions and 801 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -672,17 +672,17 @@ int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style);
/**
* @name Cell options identifiers.
* @name Cell properties identifiers.
* @{
*/
#define FT_COPT_MIN_WIDTH (0x01U << 0) /**< Minimum width */
#define FT_COPT_TEXT_ALIGN (0x01U << 1) /**< Text alignment */
#define FT_COPT_TOP_PADDING (0x01U << 2) /**< Top padding for cell content */
#define FT_COPT_BOTTOM_PADDING (0x01U << 3) /**< Bottom padding for cell content */
#define FT_COPT_LEFT_PADDING (0x01U << 4) /**< Left padding for cell content */
#define FT_COPT_RIGHT_PADDING (0x01U << 5) /**< Right padding for cell content */
#define FT_COPT_EMPTY_STR_HEIGHT (0x01U << 6) /**< Height of empty cell */
#define FT_COPT_ROW_TYPE (0x01U << 7) /**< Row type */
#define FT_CPROP_MIN_WIDTH (0x01U << 0) /**< Minimum width */
#define FT_CPROP_TEXT_ALIGN (0x01U << 1) /**< Text alignment */
#define FT_CPROP_TOP_PADDING (0x01U << 2) /**< Top padding for cell content */
#define FT_CPROP_BOTTOM_PADDING (0x01U << 3) /**< Bottom padding for cell content */
#define FT_CPROP_LEFT_PADDING (0x01U << 4) /**< Left padding for cell content */
#define FT_CPROP_RIGHT_PADDING (0x01U << 5) /**< Right padding for cell content */
#define FT_CPROP_EMPTY_STR_HEIGHT (0x01U << 6) /**< Height of empty cell */
#define FT_CPROP_ROW_TYPE (0x01U << 7) /**< Row type */
/** @} */
@@ -705,20 +705,20 @@ enum ft_row_type {
};
/**
* Set default cell option for all new formatted tables.
* Set default cell property for all new formatted tables.
*
* @param option
* Cell option identifier.
* @param property
* Cell property identifier.
* @param value
* Cell option value.
* Cell property value.
* @return
* - 0: Success; default cell option was changed.
* - 0: Success; default cell property was changed.
* - (<0): In case of error
*/
int ft_set_default_cell_option(uint32_t option, int value);
int ft_set_default_cell_prop(uint32_t property, int value);
/**
* Set option for the specified cell of the table.
* Set property for the specified cell of the table.
*
* @param table
* A pointer to the ft_table_t structure.
@@ -726,56 +726,56 @@ int ft_set_default_cell_option(uint32_t option, int value);
* Cell row.
* @param col
* Cell column.
* @param option
* Cell option identifier.
* @param property
* Cell property identifier.
* @param value
* Cell option value.
* Cell property value.
* @return
* - 0: Success; cell option was changed.
* - 0: Success; cell property was changed.
* - (<0): In case of error
*/
int ft_set_cell_option(ft_table_t *table, size_t row, size_t col, uint32_t option, int value);
int ft_set_cell_prop(ft_table_t *table, size_t row, size_t col, uint32_t property, int value);
/**
* @name Table options identifiers.
* @name Table properties identifiers.
* @{
*/
#define FT_TOPT_LEFT_MARGIN (0x01U << 0)
#define FT_TOPT_TOP_MARGIN (0x01U << 1)
#define FT_TOPT_RIGHT_MARGIN (0x01U << 2)
#define FT_TOPT_BOTTOM_MARGIN (0x01U << 3)
#define FT_TPROP_LEFT_MARGIN (0x01U << 0)
#define FT_TPROP_TOP_MARGIN (0x01U << 1)
#define FT_TPROP_RIGHT_MARGIN (0x01U << 2)
#define FT_TPROP_BOTTOM_MARGIN (0x01U << 3)
/** @} */
/**
* Set default table option.
* Set default table property.
*
* @param option
* Table option identifier.
* @param property
* Table property identifier.
* @param value
* Table option value.
* Table property value.
* @return
* - 0: Success; default table option was changed.
* - 0: Success; default table property was changed.
* - (<0): In case of error
*/
int ft_set_default_tbl_option(uint32_t option, int value);
int ft_set_default_tbl_prop(uint32_t property, int value);
/**
* Set table option.
* Set table property.
*
* @param table
* A pointer to the ft_table_t structure.
* @param option
* Table option identifier.
* @param property
* Table property identifier.
* @param value
* Table option value.
* Table property value.
* @return
* - 0: Success; default table option was changed.
* - 0: Success; default table property was changed.
* - (<0): In case of error
*/
int ft_set_tbl_option(ft_table_t *table, uint32_t option, int value);
int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value);
/**
@@ -790,7 +790,7 @@ int ft_set_tbl_option(ft_table_t *table, uint32_t option, int value);
* @param hor_span
* Column span.
* @return
* - 0: Success; default table option was changed.
* - 0: Success; cell span was changed.
* - (<0): In case of error
*/
int ft_set_cell_span(ft_table_t *table, size_t row, size_t col, size_t hor_span);

View File

@@ -42,7 +42,7 @@ SOFTWARE.
namespace fort
{
enum class CellOption {
enum class CellProperty {
MinWidth,
TextAlign,
TopPadding,
@@ -53,7 +53,7 @@ enum class CellOption {
RowType
};
enum class TableOption {
enum class TableProperty {
LeftMargin,
TopMargin,
RightMargin,
@@ -241,7 +241,7 @@ public:
Table &operator<<(const TableManipulator &arg)
{
if (arg.value == header.value)
ft_set_cell_option(table, FT_CUR_ROW, FT_ANY_ROW, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
ft_set_cell_prop(table, FT_CUR_ROW, FT_ANY_ROW, FT_CPROP_ROW_TYPE, FT_ROW_HEADER);
else if (arg.value == endr.value)
ft_ln(table);
else if (arg.value == separator.value)
@@ -402,12 +402,12 @@ public:
* @param value
* Value of the min width.
* @return
* - 0: Success; cell option was changed.
* - 0: Success; cell property was changed.
* - (<0): In case of error
*/
bool set_cell_min_width(size_t row, size_t col, unsigned value)
{
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_MIN_WIDTH, value));
return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_MIN_WIDTH, value));
}
/**
@@ -420,12 +420,12 @@ public:
* @param value
* Value of the text alignment.
* @return
* - 0: Success; cell option was changed.
* - 0: Success; cell property was changed.
* - (<0): In case of error
*/
bool set_cell_text_align(size_t row, size_t col, enum TextAlign value)
{
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_TEXT_ALIGN, static_cast<int>(value)));
return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_TEXT_ALIGN, static_cast<int>(value)));
}
/**
@@ -438,12 +438,12 @@ public:
* @param value
* Value of the top padding.
* @return
* - 0: Success; cell option was changed.
* - 0: Success; cell property was changed.
* - (<0): In case of error
*/
bool set_cell_top_padding(size_t row, size_t col, unsigned value)
{
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_TOP_PADDING, value));
return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_TOP_PADDING, value));
}
/**
@@ -456,12 +456,12 @@ public:
* @param value
* Value of the bottom padding.
* @return
* - 0: Success; cell option was changed.
* - 0: Success; cell property was changed.
* - (<0): In case of error
*/
bool set_cell_bottom_padding(size_t row, size_t col, unsigned value)
{
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_BOTTOM_PADDING, value));
return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_BOTTOM_PADDING, value));
}
/**
@@ -474,12 +474,12 @@ public:
* @param value
* Value of the left padding.
* @return
* - 0: Success; cell option was changed.
* - 0: Success; cell property was changed.
* - (<0): In case of error
*/
bool set_cell_left_padding(size_t row, size_t col, unsigned value)
{
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_LEFT_PADDING, value));
return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_LEFT_PADDING, value));
}
/**
@@ -492,12 +492,12 @@ public:
* @param value
* Value of the left padding.
* @return
* - 0: Success; cell option was changed.
* - 0: Success; cell property was changed.
* - (<0): In case of error
*/
bool set_cell_right_padding(size_t row, size_t col, unsigned value)
{
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_RIGHT_PADDING, value));
return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_RIGHT_PADDING, value));
}
/**
@@ -510,12 +510,12 @@ public:
* @param value
* Value of the empty string height.
* @return
* - 0: Success; cell option was changed.
* - 0: Success; cell property was changed.
* - (<0): In case of error
*/
bool set_cell_empty_str_height(size_t row, size_t col, unsigned value)
{
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_EMPTY_STR_HEIGHT, value));
return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_EMPTY_STR_HEIGHT, value));
}
/**
@@ -528,25 +528,25 @@ public:
* @param value
* Value of the row type.
* @return
* - 0: Success; cell option was changed.
* - 0: Success; cell property was changed.
* - (<0): In case of error
*/
bool set_cell_row_type(size_t row, size_t col, enum RowType value)
{
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_ROW_TYPE, static_cast<int>(value)));
return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, FT_CPROP_ROW_TYPE, static_cast<int>(value)));
}
template <CellOption option>
bool set_option(size_t row, size_t col, unsigned value);
template <CellProperty property>
bool set_property(size_t row, size_t col, unsigned value);
template <CellOption option>
bool set_option(size_t row, size_t col, enum TextAlign align);
template <CellProperty property>
bool set_property(size_t row, size_t col, enum TextAlign align);
template <CellOption option>
bool set_option(size_t row, size_t col, enum RowType rowType);
template <CellProperty property>
bool set_property(size_t row, size_t col, enum RowType rowType);
template <TableOption option>
bool set_option(unsigned value);
template <TableProperty property>
bool set_property(unsigned value);
/**
* Set border style for the table.
@@ -646,49 +646,49 @@ bool set_default_border_style(struct ft_border_style *style)
/*
* Declare specializations for set_option functions
* Declare specializations for set_property functions
*/
#define DECLARE_SPECS_FOR_CELL_OPTIONS_X \
SET_CELL_OPTION_SPEC(CellOption::MinWidth, FT_COPT_MIN_WIDTH, unsigned) \
SET_CELL_OPTION_SPEC(CellOption::TextAlign, FT_COPT_TEXT_ALIGN, TextAlign) \
SET_CELL_OPTION_SPEC(CellOption::TopPadding, FT_COPT_TOP_PADDING, unsigned) \
SET_CELL_OPTION_SPEC(CellOption::BottomPadding, FT_COPT_BOTTOM_PADDING, unsigned) \
SET_CELL_OPTION_SPEC(CellOption::LeftPadding, FT_COPT_LEFT_PADDING, unsigned) \
SET_CELL_OPTION_SPEC(CellOption::RightPading, FT_COPT_RIGHT_PADDING, unsigned) \
SET_CELL_OPTION_SPEC(CellOption::EmptyStrHeight, FT_COPT_EMPTY_STR_HEIGHT, unsigned) \
SET_CELL_OPTION_SPEC(CellOption::RowType, FT_COPT_ROW_TYPE, RowType)
#define DECLARE_SPECS_FOR_CELL_PROPS_X \
SET_CELL_PROP_SPEC(CellProperty::MinWidth, FT_CPROP_MIN_WIDTH, unsigned) \
SET_CELL_PROP_SPEC(CellProperty::TextAlign, FT_CPROP_TEXT_ALIGN, TextAlign) \
SET_CELL_PROP_SPEC(CellProperty::TopPadding, FT_CPROP_TOP_PADDING, unsigned) \
SET_CELL_PROP_SPEC(CellProperty::BottomPadding, FT_CPROP_BOTTOM_PADDING, unsigned) \
SET_CELL_PROP_SPEC(CellProperty::LeftPadding, FT_CPROP_LEFT_PADDING, unsigned) \
SET_CELL_PROP_SPEC(CellProperty::RightPading, FT_CPROP_RIGHT_PADDING, unsigned) \
SET_CELL_PROP_SPEC(CellProperty::EmptyStrHeight, FT_CPROP_EMPTY_STR_HEIGHT, unsigned) \
SET_CELL_PROP_SPEC(CellProperty::RowType, FT_CPROP_ROW_TYPE, RowType)
#define SET_CELL_OPTION_SPEC(CELL_OPTION, C_OPTION, VALUE_TYPE) \
#define SET_CELL_PROP_SPEC(CELL_OPTION, C_OPTION, VALUE_TYPE) \
template <> \
bool Table::set_option<CELL_OPTION>(size_t row, size_t col, VALUE_TYPE value) \
bool Table::set_property<CELL_OPTION>(size_t row, size_t col, VALUE_TYPE value) \
{ \
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, C_OPTION, static_cast<int>(value))); \
return FT_IS_SUCCESS(ft_set_cell_prop(table, row, col, C_OPTION, static_cast<int>(value))); \
}
DECLARE_SPECS_FOR_CELL_OPTIONS_X
DECLARE_SPECS_FOR_CELL_PROPS_X
#undef SET_TABLE_OPTION_SPEC
#undef DECLARE_SPECS_FOR_CELL_OPTIONS_X
#undef SET_TABLE_PROP_SPEC
#undef DECLARE_SPECS_FOR_PROPS_X
#define DECLARE_SPECS_FOR_TABLE_OPTIONS_X \
SET_TABLE_OPTION_SPEC(TableOption::LeftMargin, FT_TOPT_LEFT_MARGIN) \
SET_TABLE_OPTION_SPEC(TableOption::TopMargin, FT_TOPT_TOP_MARGIN) \
SET_TABLE_OPTION_SPEC(TableOption::RightMargin, FT_TOPT_RIGHT_MARGIN) \
SET_TABLE_OPTION_SPEC(TableOption::BottomMargin, FT_TOPT_BOTTOM_MARGIN)
#define DECLARE_SPECS_FOR_TABLE_PROPS_X \
SET_TABLE_PROP_SPEC(TableProperty::LeftMargin, FT_TPROP_LEFT_MARGIN) \
SET_TABLE_PROP_SPEC(TableProperty::TopMargin, FT_TPROP_TOP_MARGIN) \
SET_TABLE_PROP_SPEC(TableProperty::RightMargin, FT_TPROP_RIGHT_MARGIN) \
SET_TABLE_PROP_SPEC(TableProperty::BottomMargin, FT_TPROP_BOTTOM_MARGIN)
#define SET_TABLE_OPTION_SPEC(TABLE_OPTION, TBL_OPTION) \
#define SET_TABLE_PROP_SPEC(TABLE_OPTION, TBL_OPTION) \
template <> \
bool Table::set_option<TABLE_OPTION>(unsigned value) \
bool Table::set_property<TABLE_OPTION>(unsigned value) \
{ \
return FT_IS_SUCCESS(ft_set_tbl_option(table, TBL_OPTION, static_cast<int>(value))); \
return FT_IS_SUCCESS(ft_set_tbl_prop(table, TBL_OPTION, static_cast<int>(value))); \
}
DECLARE_SPECS_FOR_TABLE_OPTIONS_X
DECLARE_SPECS_FOR_TABLE_PROPS_X
#undef SET_TABLE_OPTION_SPEC
#undef DECLARE_SPECS_FOR_TABLE_OPTIONS_X
#undef SET_TABLE_PROP_SPEC
#undef DECLARE_SPECS_FOR_TABLE_PROPS_X