GEOS
TableLayout.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_COMMON_FORMAT_TABLE_TABLELAYOUT_HPP
21 #define GEOS_COMMON_FORMAT_TABLE_TABLELAYOUT_HPP
22 
23 #include "common/DataTypes.hpp"
24 
25 namespace geos
26 {
27 
32 {
33 
34 public:
35 
37  enum Alignment { right, left, center };
38 
41  {
42  tiny = 0,
43  small = 1,
44  medium = 2,
45  large = 3
46  };
47 
51  enum Section { header, values };
52 
56  struct ColumnParam
57  {
59  string columnName;
61  Alignment alignment = Alignment::right;
63  bool enabled = true;
65  std::vector< string > splitColumnNameLines;
66 
72  ColumnParam( std::string const & name, Alignment align )
73  : columnName( name ), alignment( align )
74  {}
75 
82  ColumnParam( std::string const & name, Alignment align, bool display )
83  : columnName( name ), alignment( align ), enabled( display )
84  {}
85  };
86 
90  struct Column
91  {
95  std::vector< string > m_columnValues;
98  };
99 
100  TableLayout() = default;
101 
107  TableLayout( std::vector< string > const & columnNames, string const & title = "" );
108 
115  TableLayout( std::vector< ColumnParam > const & columnParameters, string const & title = "" );
116 
120  std::vector< Column > const & getColumns() const;
121 
126 
130  integer const & getBorderMargin() const;
131 
135  integer const & getColumnMargin() const;
136 
140  integer const & getMarginTitle() const;
141 
146  void setMargin( MarginValue marginValue );
147 
148 private:
149 
150  std::vector< Column > m_columns;
151  string m_tableTitle;
152  integer m_borderMargin;
153  integer m_columnMargin;
154  integer m_titleMargin = 2;
155 
156 };
157 }
158 
159 #endif /* GEOS_COMMON_FORMAT_TABLE_TABLELAYOUT_HPP */
Class for setup the table layout.
Definition: TableLayout.hpp:32
integer const & getMarginTitle() const
integer const & getColumnMargin() const
Alignment
Type of aligment for a column.
Definition: TableLayout.hpp:37
integer const & getBorderMargin() const
TableLayout(std::vector< string > const &columnNames, string const &title="")
Construct a new Table object, all values in the table are centered by default.
string_view getTitle() const
void setMargin(MarginValue marginValue)
Set the minimal margin width between cell content and borders.
std::vector< Column > const & getColumns() const
Section
Enumeration for table sections.
Definition: TableLayout.hpp:51
MarginValue
Space to apply between all data and border.
Definition: TableLayout.hpp:41
TableLayout(std::vector< ColumnParam > const &columnParameters, string const &title="")
Construct a new Table object by specifying value alignment and optionally their displays based to log...
std::string string
String type.
Definition: DataTypes.hpp:91
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
std::string_view string_view
String type.
Definition: DataTypes.hpp:94
Struct for a column.
Definition: TableLayout.hpp:91
string m_maxStringSize
The largest string in the column.
Definition: TableLayout.hpp:97
ColumnParam m_parameter
Structure who contains parameters for a column.
Definition: TableLayout.hpp:93
std::vector< string > m_columnValues
A vector containing all column values.
Definition: TableLayout.hpp:95
Structure to set up each colum parameters.
Definition: TableLayout.hpp:57
bool enabled
A boolean to display a colummn.
Definition: TableLayout.hpp:63
string columnName
Name for a column.
Definition: TableLayout.hpp:59
std::vector< string > splitColumnNameLines
Vector containing substring column name delimited by "\n".
Definition: TableLayout.hpp:65
Alignment alignment
Alignment for a column. By default aligned to the right side.
Definition: TableLayout.hpp:61
ColumnParam(std::string const &name, Alignment align, bool display)
Construct a ColumnParam object with the specified name, alignment, and display flag.
Definition: TableLayout.hpp:82
ColumnParam(std::string const &name, Alignment align)
Construct a ColumnParam object with the specified name and alignment.
Definition: TableLayout.hpp:72