libfort
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
fort::table< TT > Class Template Reference

#include <fort.hpp>

Inheritance diagram for fort::table< TT >:
Inheritance graph
[legend]
Collaboration diagram for fort::table< TT >:
Collaboration graph
[legend]

Classes

class  cell_range
 
class  default_properties
 
class  table_cell
 
class  table_column
 
class  table_row
 

Public Member Functions

 table ()
 
 ~table ()
 
 table (const table &tbl)
 
 table (table &&tbl)
 
tableoperator= (const table &tbl)
 
tableoperator= (table &&tbl)
 
std::string to_string () const
 
const char * c_str () const
 
template<typename T >
tableoperator<< (const T &arg)
 
tableoperator<< (const table_manipulator &arg)
 
bool write (const char *str)
 
bool write_ln (const char *str)
 
bool write (const std::string &str)
 
bool write_ln (const std::string &str)
 
template<typename T_0 , typename T_1 >
bool write (const T_0 &arg_0, const T_1 &arg_1)
 
template<typename T_0 , typename T_1 , typename T_2 >
bool write (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 >
bool write (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 , typename T_4 >
bool write (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 , typename T_4 , typename T_5 >
bool write (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 , typename T_4 , typename T_5 , typename T_6 >
bool write (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5, const T_6 &arg_6)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 , typename T_4 , typename T_5 , typename T_6 , typename T_7 >
bool write (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5, const T_6 &arg_6, const T_7 &arg_7)
 
template<typename T_0 , typename T_1 >
bool write_ln (const T_0 &arg_0, const T_1 &arg_1)
 
template<typename T_0 , typename T_1 , typename T_2 >
bool write_ln (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 >
bool write_ln (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 , typename T_4 >
bool write_ln (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 , typename T_4 , typename T_5 >
bool write_ln (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 , typename T_4 , typename T_5 , typename T_6 >
bool write_ln (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5, const T_6 &arg_6)
 
template<typename T_0 , typename T_1 , typename T_2 , typename T_3 , typename T_4 , typename T_5 , typename T_6 , typename T_7 >
bool write_ln (const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5, const T_6 &arg_6, const T_7 &arg_7)
 
template<typename InputIt >
bool range_write (InputIt first, InputIt last)
 
template<typename InputIt >
bool range_write_ln (InputIt first, InputIt last)
 
bool set_border_style (const struct ft_border_style *style)
 
void set_cur_cell (size_t row_i, size_t col_i)
 
bool set_left_margin (unsigned value)
 
bool set_top_margin (unsigned value)
 
bool set_right_margin (unsigned value)
 
bool set_bottom_margin (unsigned value)
 
bool set_adding_strategy (fort::add_strategy value)
 
class table_row operator[] (std::size_t row_idx)
 
class table_cell cell (std::size_t row_idx, std::size_t col_idx)
 
size_t cur_col () const noexcept
 
size_t cur_row () const noexcept
 
bool is_empty () const noexcept
 
std::size_t row_count () const noexcept
 
class table_cell cur_cell ()
 
class table_row row (std::size_t row_idx)
 
class table_column column (std::size_t col_idx)
 
class cell_range range (std::size_t top_left_row, std::size_t top_left_col, std::size_t bottom_right_row, std::size_t bottom_right_col)
 
- Public Member Functions inherited from fort::property_owner< table< TT > >
 property_owner (std::size_t row_idx, std::size_t coll_idx, table< TT > *tbl, bool def=false)
 
bool set_cell_min_width (unsigned value)
 
bool set_cell_text_align (fort::text_align value)
 
bool set_cell_top_padding (unsigned value)
 
bool set_cell_bottom_padding (unsigned value)
 
bool set_cell_left_padding (unsigned value)
 
bool set_cell_right_padding (unsigned value)
 
bool set_cell_row_type (fort::row_type value)
 
bool set_cell_empty_str_height (unsigned value)
 
bool set_cell_content_fg_color (fort::color value)
 
bool set_cell_bg_color (fort::color value)
 
bool set_cell_content_bg_color (fort::color value)
 
bool set_cell_text_style (fort::text_style value)
 
bool set_cell_content_text_style (fort::text_style value)
 

Static Public Member Functions

static class default_properties default_props ()
 

Friends

class property_owner< table >
 

Additional Inherited Members

- Protected Member Functions inherited from fort::property_owner< table< TT > >
bool set_property (uint32_t property, int value)
 
- Protected Attributes inherited from fort::property_owner< table< TT > >
std::size_t ps_row_idx_
 
std::size_t ps_coll_idx_
 
table< TT > * ps_table_
 
bool set_default_properties_
 

Detailed Description

template<table_type TT = table_type::character>
class fort::table< TT >

Formatted table.

Table template class is a C++ wrapper around struct ft_table. Template parameter is table_type. Useful instantiations of table template class are char_table and utf8_table.

Constructor & Destructor Documentation

template<table_type TT = table_type::character>
fort::table< TT >::table ( )
inline

Default constructor.

template<table_type TT = table_type::character>
fort::table< TT >::~table ( )
inline

Destructor.

template<table_type TT = table_type::character>
fort::table< TT >::table ( const table< TT > &  tbl)
inline

Copy contstructor.

template<table_type TT = table_type::character>
fort::table< TT >::table ( table< TT > &&  tbl)
inline

Move contstructor.

Member Function Documentation

template<table_type TT = table_type::character>
const char* fort::table< TT >::c_str ( ) const
inline

Convert table to string representation.

Table object has ownership of the returned pointer. So there is no need to free it. To take ownership user should explicitly copy the returned string with strdup or similar functions.

Returned pointer may be later invalidated by:

  • Calling destroying the table;
  • Other invocations of c_str or to_string.
Returns
  • The pointer to the string representation of formatted table, on success.
  • NULL on error.
template<table_type TT = table_type::character>
class table_cell fort::table< TT >::cell ( std::size_t  row_idx,
std::size_t  col_idx 
)
inline

Get cell.

Parameters
row_idxRow index.
col_idxColumn index.
Returns
table_cell object.
template<table_type TT = table_type::character>
class table_column fort::table< TT >::column ( std::size_t  col_idx)
inline

Get column.

Parameters
col_idxColumn index.
Returns
table_column object.
template<table_type TT = table_type::character>
class table_cell fort::table< TT >::cur_cell ( )
inline

Get current cell.

Returns
Current cell.
template<table_type TT = table_type::character>
size_t fort::table< TT >::cur_col ( ) const
inlinenoexcept

Get column number of the current cell.

Returns
Column number of the current cell.
template<table_type TT = table_type::character>
size_t fort::table< TT >::cur_row ( ) const
inlinenoexcept

Get row number of the current cell.

Returns
Row number of the current cell.
template<table_type TT = table_type::character>
bool fort::table< TT >::is_empty ( ) const
inlinenoexcept

Check if table is empty.

Returns
true - table is empty false - some data has been inserted
template<table_type TT = table_type::character>
template<typename T >
table& fort::table< TT >::operator<< ( const T &  arg)
inline

Write provided object to the table.

To convert object to the string representation conversion for std::ostream is used.

Parameters
argObect that would be inserted in the current cell.
Returns
  • Reference to the current table.
template<table_type TT = table_type::character>
table& fort::table< TT >::operator<< ( const table_manipulator arg)
inline

< Current row

< Any row (can be used to refer to all cells in a column)

< Row type

template<table_type TT = table_type::character>
table& fort::table< TT >::operator= ( const table< TT > &  tbl)
inline

Copy assignment operator.

template<table_type TT = table_type::character>
table& fort::table< TT >::operator= ( table< TT > &&  tbl)
inline

Move assignment operator.

template<table_type TT = table_type::character>
class cell_range fort::table< TT >::range ( std::size_t  top_left_row,
std::size_t  top_left_col,
std::size_t  bottom_right_row,
std::size_t  bottom_right_col 
)
inline

Get range of cells.

Parameters
col_idxColumn index.
Returns
table_column object.
template<table_type TT = table_type::character>
template<typename InputIt >
bool fort::table< TT >::range_write ( InputIt  first,
InputIt  last 
)
inline

Write elements from range to the table.

Write objects from range to consecutive cells in the current row.

Parameters
first,lastRange of elements.
Returns
  • 0: Success; data were written
  • (<0): In case of error
template<table_type TT = table_type::character>
template<typename InputIt >
bool fort::table< TT >::range_write_ln ( InputIt  first,
InputIt  last 
)
inline

Write elements from range to the table and go to the next line.

Write objects from range to consecutive cells in the current row and move current position to the first cell of the next line(row).

Parameters
first,lastRange of elements.
Returns
  • 0: Success; data were written
  • (<0): In case of error
template<table_type TT = table_type::character>
class table_row fort::table< TT >::row ( std::size_t  row_idx)
inline

Get row.

Parameters
row_idxRow index.
Returns
table_row object.
template<table_type TT = table_type::character>
std::size_t fort::table< TT >::row_count ( ) const
inlinenoexcept

Get number of rows in the table.

Returns
Number of rows in the table.
template<table_type TT = table_type::character>
bool fort::table< TT >::set_adding_strategy ( fort::add_strategy  value)
inline

Set table adding strategy.

Parameters
valueAdding strategy.
Returns
  • true: Success; table property was changed.
  • false: In case of error.
template<table_type TT = table_type::character>
bool fort::table< TT >::set_border_style ( const struct ft_border_style style)
inline

Set border style for the table.

Parameters
stylePointer to border style.
Returns
  • True: Success; table border style was changed.
  • False: Error
template<table_type TT = table_type::character>
bool fort::table< TT >::set_bottom_margin ( unsigned  value)
inline

Set table bottom margin.

Parameters
valueBottom margin.
Returns
  • true: Success; table property was changed.
  • false: In case of error.
template<table_type TT = table_type::character>
void fort::table< TT >::set_cur_cell ( size_t  row_i,
size_t  col_i 
)
inline

Set current cell position.

Current cell - cell that will be edited with all modifiing functions.

Parameters
row_iNew row number for the current cell.
col_iNew row number for the current cell.
template<table_type TT = table_type::character>
bool fort::table< TT >::set_left_margin ( unsigned  value)
inline

Set table left margin.

Parameters
valueLeft margin.
Returns
  • true: Success; table property was changed.
  • false: In case of error.
template<table_type TT = table_type::character>
bool fort::table< TT >::set_right_margin ( unsigned  value)
inline

Set table right margin.

Parameters
valueRight margin.
Returns
  • true: Success; table property was changed.
  • false: In case of error.
template<table_type TT = table_type::character>
bool fort::table< TT >::set_top_margin ( unsigned  value)
inline

Set table top margin.

Parameters
valueTop margin.
Returns
  • true: Success; table property was changed.
  • false: In case of error.
template<table_type TT = table_type::character>
std::string fort::table< TT >::to_string ( ) const
inline

Convert table to string representation.

Returns
  • String representation of formatted table, on success.
  • In case of error std::runtime_error is thrown.
template<table_type TT = table_type::character>
bool fort::table< TT >::write ( const char *  str)
inline

Write string to the the table.

Write specified string to the current cell.

Parameters
strString to write.
Returns
  • 0: Success; data were written
  • (<0): In case of error
template<table_type TT = table_type::character>
bool fort::table< TT >::write ( const std::string &  str)
inline

Write string to the the table.

Write specified string to the current cell.

Parameters
strString to write.
Returns
  • 0: Success; data were written
  • (<0): In case of error
template<table_type TT = table_type::character>
bool fort::table< TT >::write_ln ( const char *  str)
inline

Write string to the the table and go to the next line.

Write specified string to the current cell and move current position to the first cell of the next line(row).

Parameters
strString to write.
Returns
  • 0: Success; data were written
  • (<0): In case of error
template<table_type TT = table_type::character>
bool fort::table< TT >::write_ln ( const std::string &  str)
inline

Write string to the the table and go to the next line.

Write specified string to the current cell and move current position to the first cell of the next line(row).

Parameters
strString to write.
Returns
  • 0: Success; data were written
  • (<0): In case of error

The documentation for this class was generated from the following file: