[F] Moved to c++11

This commit is contained in:
seleznevae 2018-07-29 09:59:40 +03:00
parent cfdf971d72
commit 199e123383
3 changed files with 123 additions and 8 deletions

View File

@ -49,7 +49,7 @@ if("${FORT_COMPILER}" STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W4") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W4")
else("${FORT_COMPILER}" STREQUAL "MSVC") else("${FORT_COMPILER}" STREQUAL "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Wextra -std=c99 -Wpedantic") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Wextra -std=c99 -Wpedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -Wextra") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -Wextra -std=c++11")
endif("${FORT_COMPILER}" STREQUAL "MSVC") endif("${FORT_COMPILER}" STREQUAL "MSVC")

View File

@ -16,6 +16,13 @@ int main()
<< "4" << "2001: A Space Odyssey" << "1968" << "8.5" << fort::endr << "4" << "2001: A Space Odyssey" << "1968" << "8.5" << fort::endr
<< "5" << "Blade Runner" << "1982" << "8.1" << fort::endr << "5" << "Blade Runner" << "1982" << "8.1" << fort::endr
<< fort::endr; << fort::endr;
using fort::CellOption;
using fort::TableOption;
table.set_option<CellOption::MinWidth>(0, 0, 20);
table.set_option<CellOption::TextAlign>(0, 0, fort::TextAlign::Left);
table.set_option<CellOption::RowType>(2, FT_ANY_COLUMN, fort::RowType::Header);
std::cout << table.to_string() << std::endl; std::cout << table.to_string() << std::endl;
} }
@ -33,9 +40,9 @@ int main()
using fort::CellOption; using fort::CellOption;
using fort::TableOption; using fort::TableOption;
table.set_option<CellOption::MinWidth>(0, 0, 20); table.set_cell_min_width(0, 0, 20);
table.set_option<CellOption::TextAlign>(0, 0, fort::TextAlign::Left); table.set_cell_text_align(0, 0, fort::TextAlign::Left);
table.set_option<CellOption::RowType>(2, FT_ANY_COLUMN, fort::RowType::Header); table.set_cell_row_type(2, FT_ANY_COLUMN, fort::RowType::Header);
table.set_option<TableOption::LeftMargin>(4); table.set_option<TableOption::LeftMargin>(4);

View File

@ -61,13 +61,13 @@ enum class TableOption {
}; };
enum class TextAlign { enum class TextAlign {
Left, Left = 0,
Center, Center,
Right Right
}; };
enum class RowType { enum class RowType {
Common, Common = 0,
Header Header
}; };
@ -315,6 +315,42 @@ public:
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_MIN_WIDTH, value)); return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_MIN_WIDTH, value));
} }
/**
* Set text alignment for the specified cell of the table.
*
* @param row
* Cell row.
* @param col
* Cell column.
* @param value
* Value of the text alignment.
* @return
* - 0: Success; cell option 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)));
}
/**
* Set top padding for the specified cell of the table.
*
* @param row
* Cell row.
* @param col
* Cell column.
* @param value
* Value of the top padding.
* @return
* - 0: Success; cell option 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));
}
/** /**
* Set bottom padding for the specified cell of the table. * Set bottom padding for the specified cell of the table.
* *
@ -333,14 +369,86 @@ public:
return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_BOTTOM_PADDING, value)); return FT_IS_SUCCESS(ft_set_cell_option(table, row, col, FT_COPT_BOTTOM_PADDING, value));
} }
/**
* Set left padding for the specified cell of the table.
*
* @param row
* Cell row.
* @param col
* Cell column.
* @param value
* Value of the left padding.
* @return
* - 0: Success; cell option 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));
}
/**
* Set right padding for the specified cell of the table.
*
* @param row
* Cell row.
* @param col
* Cell column.
* @param value
* Value of the left padding.
* @return
* - 0: Success; cell option 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));
}
/**
* Set empty string height for the specified cell of the table.
*
* @param row
* Cell row.
* @param col
* Cell column.
* @param value
* Value of the empty string height.
* @return
* - 0: Success; cell option 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));
}
/**
* Set row type for the specified cell of the table.
*
* @param row
* Cell row.
* @param col
* Cell column.
* @param value
* Value of the row type.
* @return
* - 0: Success; cell option 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)));
}
template <CellOption option> template <CellOption option>
bool set_option(size_t row, size_t col, unsigned value); bool set_option(size_t row, size_t col, unsigned value);
template <CellOption option> template <CellOption option>
bool set_option(size_t row, size_t col, TextAlign align); bool set_option(size_t row, size_t col, enum TextAlign align);
template <CellOption option> template <CellOption option>
bool set_option(size_t row, size_t col, RowType rowType); bool set_option(size_t row, size_t col, enum RowType rowType);
template <TableOption option> template <TableOption option>
bool set_option(unsigned value); bool set_option(unsigned value);