20 #ifndef GEOS_COMMON_FORMAT_TABLE_TABLELAYOUT_HPP
21 #define GEOS_COMMON_FORMAT_TABLE_TABLELAYOUT_HPP
24 #include "TableTypes.hpp"
136 { m_parent = parent; }
150 { m_next = nextCell; }
205 {
return m_headerMergeCount; }
212 { m_headerMergeCount+= value;}
218 { m_headerMergeCount--; }
225 {
return !this->m_subColumn.empty(); }
232 {
return this->m_parent !=
nullptr; }
240 size_t m_headerMergeCount = 0;
259 m_currentColumn( columnPtr ), m_currentLayer( idxLayer )
269 this->m_currentColumn= columnPtr;
290 {
return *m_currentColumn; }
297 {
return m_currentColumn; }
306 {
return a.m_currentColumn == b.m_currentColumn; };
314 {
return a.m_currentColumn != b.m_currentColumn; };
321 {
return m_currentLayer; }
334 size_t m_currentLayer;
355 using TableLayoutArgs = std::initializer_list< std::variant< string_view, TableLayout::Column > >;
365 std::vector< TableLayout::Column >
const & columns )
369 for(
auto const & column :columns )
385 processArguments( args );
396 processArguments( args );
405 std::vector< string >
const & args )
422 {
return m_tableColumnsData; }
428 {
return m_tableColumnsData; }
434 {
return m_tableTitle; }
467 {
return m_borderMargin; }
474 {
return m_columnMargin; }
480 {
return m_marginValue; }
486 {
return m_titleMargin; }
493 {
return m_sublineHeaderCounts; }
500 {
return m_sublineDataCounts; }
516 for(
auto const & arg : args )
518 std::visit( [
this](
auto const & value ) {
530 template<
typename ... Ts >
531 void processArguments( Ts &... args )
540 void addToColumns( std::vector< string >
const & columnNames );
547 void addToColumns( TableLayout::Column
const & column );
550 std::vector< Column > m_tableColumnsData;
552 std::vector< size_t > m_sublineHeaderCounts;
554 std::vector< size_t > m_sublineDataCounts;
555 bool m_wrapLine =
true;
Class representing a column in a table layout.
size_t getNumberCellMerge()
TableLayout::Column & addSubColumns(string const &subColName)
Adds a single sub-column to the column.
std::vector< Column > m_subColumn
A vector containing all sub-columns in the column.
Column * getParent()
Get the parent column.
Column * getNextCell()
GGet the next column in the layout.
Column()
Default constructor. Initializes a column with default values.
Column(TableLayout::CellLayout cellLayout)
Constructor to initialize a column with a specific CellLayout.
ColumnAlignement m_alignment
struct containing m_alignment for the column (header and values)
void decrementMergeHeaderCount()
Decremente number of times we will divide the current cell.
TableLayout::Column & addSubColumns(std::initializer_list< string > subColName)
Adds multiple sub-columns to the column.
TableLayout::Column & setValuesAlignment(Alignment valueAlignment)
Sets the values alignment for the column.
CellLayout m_header
The header cell layout.
void setParent(Column *parent)
Set the parent column.
void incrementMergeHeaderCount(size_t value)
Increment number of times we will divide the current cell.
TableLayout::Column & setHeaderAlignment(Alignment headerAlignment)
Sets the header alignment for the column.
Column & setVisibility(CellType celltype)
Set the column visibility.
Column & setName(string_view name)
Sets the name of the column.
bool hasChild() const
Checks if the column has any child columns.
TableLayout::Column & addSubColumns(std::initializer_list< TableLayout::Column > subCol)
Adds multiple sub-columns to the column.
bool hasParent() const
Checks if the column has a parent column.
void setNextCell(Column *nextCell)
Set the next column in the layout.
Iterator to loop over all columns, starting by the deepest sub columns, then to their parents,...
DeepFirstIterator(ColumnType *columnPtr, size_t idxLayer)
Construct a new Leaf Iterator object.
friend bool operator==(DeepFirstIterator const &a, DeepFirstIterator const &b)
Equality comparison operator.
ColumnType * operator->()
Arrow operator.
DeepFirstIterator operator++(int)
Postfix ++ overload.
friend bool operator!=(DeepFirstIterator const &a, DeepFirstIterator const &b)
Inequality comparison operator.
DeepFirstIterator & operator++()
Prefix ++ overload.
ColumnType & operator*()
Dereference operator.
DeepFirstIterator & operator=(Column *columnPtr)
Copy assignment operator.
bool isLastColumn()
Check if the current cell belong the last column.
size_t getCurrentLayer() const
Gets the current layer (depth) of the iterator.
Class for setup the table layout.
bool isLineBreakEnabled() const
TableLayout(string_view title, std::vector< string > const &args)
Construct a new Table Layout object.
integer const & getMarginTitle() const
integer const & getMarginValue() const
std::vector< size_t > & getNbSubDataLines()
Get the Nb Rows object.
TableLayout(string_view title, TableLayoutArgs args)
Construct a new Table Layout object.
integer const & getColumnMargin() const
std::initializer_list< std::variant< string_view, TableLayout::Column > > TableLayoutArgs
Alias for an initializer list of variants that can contain either a string or a layout column.
TableLayout(string_view title, std::vector< TableLayout::Column > const &columns)
Construct a new Table Layout object.
Alignment
Type of aligment for a column.
DeepFirstIterator endDeepFirst()
TableLayout & setMargin(MarginValue marginValue)
Set the minimal margin width between cell content and borders.
std::vector< size_t > & getSublineInHeaderCounts()
Get the Nb Rows object.
integer const & getBorderMargin() const
TableLayout(TableLayoutArgs args)
Construct a new Table Layout object.
string_view getTitle() const
void addToColumns(string_view m_header)
Create and add a column to the columns vector given a string.
TableLayout & setTitle(string_view title)
std::vector< Column > const & getColumns() const
Section
Enumeration for table sections.
std::vector< Column > & getColumns()
MarginValue
Space to apply between all data and border.
size_t getMaxDepth() const
Get the max depth of a column.
TableLayout & enableLineBreak(bool value)
Remove the return line at the end & begenning of the table.
DeepFirstIterator beginDeepFirst()
std::int32_t integer
Signed integer type.
CellType
The different type a cell can handle.
std::string_view string_view
String type.
Structure grouping the cell information to display it in a table (content, type, alignment,...
size_t m_cellWidth
Maximum length of the data in the cell.
CellType m_cellType
The type of the cell (Header,Value, Merge, ...).
CellLayout(CellType cellType, string const &value, TableLayout::Alignment alignment)
Constructor to initialize a cell given celltype, value and alignment.
CellLayout()
Constructor to initialize a Cell with a default settings.
std::vector< string > m_lines
vector containing each cell content, separated by lines.
Alignment m_alignment
The alignment of the cell (left, center, right).
Structure to set up values m_alignment for each colum.
Alignment headerAlignment
Alignment for column name. By default aligned to center.
Alignment valueAlignment
Alignment for column values. By default aligned to right side.