1
0
Fork 0

[A] Added more examples

This commit is contained in:
seleznevae 2019-09-22 10:18:15 +03:00
parent 3ae900ca2c
commit b4a8ffda0b
4 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,16 @@
#include <iostream>
#include "fort.hpp"
int main()
{
fort::table table;
table << fort::header
<< "N" << "Driver" << "Time" << "Avg Speed" << fort::endr
<< "1" << "Ricciardo" << "1:25.945" << "47.362" << fort::endr
<< "2" << "Hamilton" << "1:26.373" << "35.02" << fort::endr
<< "3" << "Verstappen" << "1:26.469" << "29.78" << fort::endr;
std::cout << table.to_string() << std::endl;
}

View File

@ -0,0 +1,28 @@
#include <iostream>
#include "fort.hpp"
int main()
{
fort::table table;
/* Set table border style */
table.set_border_style(FT_NICE_STYLE);
// Fill table with data
table << fort::header
<< "Rank" << "Title" << "Year" << "Rating" << fort::endr
<< "1" << "The Shawshank Redemption" << "1994" << "9.5" << fort::endr
<< "2" << "12 Angry Men" << "1957" << "8.8" << fort::endr
<< "3" << "It's a Wonderful Life" << "1946" << "8.6" << fort::endr
<< fort::separator
<< "4" << "2001: A Space Odyssey" << "1968" << "8.5" << fort::endr
<< "5" << "Blade Runner" << "1982" << "8.1" << fort::endr
<< fort::endr;
table.column(0).set_cell_text_align(fort::text_align::center);
table.column(1).set_cell_text_align(fort::text_align::left);
table.column(3).set_cell_text_align(fort::text_align::center);
std::cout << table.to_string() << std::endl;
}

View File

@ -0,0 +1,35 @@
#include <iostream>
#include "fort.hpp"
int main()
{
fort::table table;
/* Set table border style */
table.set_border_style(FT_DOUBLE2_STYLE);
// Fill table with data
table << fort::header
<< "Sed" << "Aenean" << "Text" << fort::endr;
table << "Duis" << "Aliquam"
<< "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n"
"In accumsan felis eros, nec malesuada sapien bibendum eget."
<< fort::endr;
table << "Mauris" << "Curabitur"
<< "Proin condimentum eros viverra nunc ultricies, at fringilla \n"
"quam pellentesque."
<< fort::endr;
table << "Summary" << ""
<< "Sed tempor est eget odio varius dignissim."
<< fort::endr;
table[0][2].set_cell_text_align(fort::text_align::center);
table[3][0].set_cell_text_align(fort::text_align::center);
table[3][0].set_cell_span(2);
std::cout << table.to_string() << std::endl;
}

View File

@ -47,6 +47,21 @@ target_link_libraries(${PROJECT_NAME}_non_ascii_table
add_executable(${PROJECT_NAME}_simple_table_cpp
1-simple_table.cpp)
target_link_libraries(${PROJECT_NAME}_simple_table_cpp
fort)
add_executable(${PROJECT_NAME}_custom_table_cpp
2-custom_table.cpp)
target_link_libraries(${PROJECT_NAME}_custom_table_cpp
fort)
add_executable(${PROJECT_NAME}_complex_layout_cpp
3-complex_layout.cpp)
target_link_libraries(${PROJECT_NAME}_complex_layout_cpp
fort)
add_executable(${PROJECT_NAME}_ex_cpp
main.cpp)
target_link_libraries(${PROJECT_NAME}_ex_cpp
@ -62,7 +77,10 @@ set(${PROJECT_NAME}_examples
${PROJECT_NAME}_beautiful_table
${PROJECT_NAME}_complex_layout
${PROJECT_NAME}_non_ascii_table
${PROJECT_NAME}_ex_cpp
${PROJECT_NAME}_simple_table_cpp
${PROJECT_NAME}_custom_table_cpp
PARENT_SCOPE)
if(DEFINED FORT_LINK_LIBRARIES)