From f450ba0fd3abd553b702c6e22543bd97fc4e4240 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Sat, 22 Dec 2018 11:06:10 +0300 Subject: [PATCH] [C] Improved documentation --- docs/index.md | 17 ++++++++++++ lib/fort.hpp | 77 ++++++++++++++++++++++++++------------------------- 2 files changed, 56 insertions(+), 38 deletions(-) diff --git a/docs/index.md b/docs/index.md index d90dfd4..d8f3e2e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -40,6 +40,23 @@ These pages contain the API documentation of **libfort** - simple library to cre - @link ft_text_alignment ft_text_alignment @endlink -- alignment of cell content - @link ft_row_type ft_row_type @endlink -- alignment of cell content +- @link fort.hpp `libfort C++ API` @endlink + - @link fort::table @endlink -- basic table class + - Table navigation + - @link fort::table::set_cur_cell set_cur_cell @endlink -- set border style + + - String conversions + - @link fort::table::to_string to_string @endlink -- convert table to string representation + - @link fort::table::c_str c_str @endlink -- convert table to string representation + + - Modify appearance of the table + - @link fort::table::set_border_style set_border_style @endlink -- set border style + - @link fort::table::set_left_margin set_left_margin @endlink -- set table left margin + - @link fort::table::set_top_margin set_top_margin @endlink -- set table top margin + - @link fort::table::set_bottom_margin set_bottom_margin @endlink -- set table bottom margin + - @link fort::table::set_right_margin set_right_margin @endlink -- set table right margin + + List of libfort builtin border styles: diff --git a/lib/fort.hpp b/lib/fort.hpp index 1ea0402..84d07ca 100644 --- a/lib/fort.hpp +++ b/lib/fort.hpp @@ -325,22 +325,6 @@ public: return set_property(FT_CPROP_CONT_TEXT_STYLE, static_cast(value)); } - /** - * Set column span for the specified cell of the table. - * - * @param hor_span - * Column span. - * @return - * - true: Success; cell span was changed. - * - false: In case of error. - */ - bool set_cell_span(size_t hor_span) - { - if (set_default_properties_) - return false; - - return FT_IS_SUCCESS(ft_set_cell_span(ps_table_->table_, ps_row_idx_, ps_coll_idx_, hor_span)); - } protected: std::size_t ps_row_idx_; std::size_t ps_coll_idx_; @@ -866,42 +850,59 @@ public: /* Iterators */ /* todo: implement chains like table[0][0] = table [0][1] = "somethings" */ - class table_cell_iterator: public property_owner + class table_cell: public property_owner
{ public: - table_cell_iterator(std::size_t row_idx, std::size_t coll_idx, table &tbl) + table_cell(std::size_t row_idx, std::size_t coll_idx, table &tbl) :property_owner(row_idx, coll_idx, &tbl) {} - table_cell_iterator& operator=(const char *str) + table_cell& operator=(const char *str) { ft_set_cur_cell(ps_table_->table_, ps_row_idx_, ps_coll_idx_); ps_table_->write(str); return *this; } - table_cell_iterator& operator=(const std::string &str) + table_cell& operator=(const std::string &str) { return operator=(str.c_str()); } - }; - class table_row_iterator: public property_owner
- { - public: - table_row_iterator(std::size_t row_idx, table &tbl) - :property_owner(row_idx, FT_ANY_COLUMN, &tbl) {} - - class table_cell_iterator - operator[](std::size_t coll_idx) + /** + * Set column span for the specified cell of the table. + * + * @param hor_span + * Column span. + * @return + * - true: Success; cell span was changed. + * - false: In case of error. + */ + bool set_cell_span(size_t hor_span) { - return table_cell_iterator(ps_row_idx_, coll_idx, *ps_table_); + if (set_default_properties_) + return false; + + return FT_IS_SUCCESS(ft_set_cell_span(ps_table_->table_, ps_row_idx_, ps_coll_idx_, hor_span)); } }; - class table_column_iterator: public property_owner
+ class table_row: public property_owner
{ public: - table_column_iterator(std::size_t col_idx, table &tbl) + table_row(std::size_t row_idx, table &tbl) + :property_owner(row_idx, FT_ANY_COLUMN, &tbl) {} + + class table_cell + operator[](std::size_t coll_idx) + { + return table_cell(ps_row_idx_, coll_idx, *ps_table_); + } + }; + + class table_column: public property_owner
+ { + public: + table_column(std::size_t col_idx, table &tbl) :property_owner(FT_ANY_ROW, col_idx, &tbl) {} }; @@ -912,22 +913,22 @@ public: :property_owner(FT_ANY_ROW, FT_ANY_COLUMN, tbl, true) {} }; - class table_row_iterator + class table_row operator[](std::size_t row_idx) { - return table_row_iterator(row_idx, *this); + return table_row(row_idx, *this); } - class table_row_iterator + class table_row row(std::size_t row_idx) { - return table_row_iterator(row_idx, *this); + return table_row(row_idx, *this); } - class table_column_iterator + class table_column column(std::size_t col_idx) { - return table_column_iterator(col_idx, *this); + return table_column(col_idx, *this); } static class default_properties