20 #ifndef GEOS_COMMON_FORMAT_TABLE_TABLEDATA_HPP
21 #define GEOS_COMMON_FORMAT_TABLE_TABLEDATA_HPP
25 #include "common/format/Format.hpp"
26 #include "TableTypes.hpp"
54 template<
typename ... Args >
55 void addRow( Args
const & ... args );
61 void addRow( std::vector< CellData >
const & row );
88 std::vector< std::vector< CellData > > m_rows;
121 template<
typename T >
162 std::map< RowType, std::map< ColumnType, string > > m_data;
165 std::set< real64 > m_columnValues;
172 template<
typename T >
175 template<
typename ... Args >
178 std::vector< CellData > cells;
180 static_assert( has_formatter_v< decltype(args) > ||
isCellType< std::decay_t< decltype(args) > >,
"Argument passed in addRow cannot be converted to string nor a CellType" );
181 if constexpr (std::is_same_v< Args, CellType >) {
182 if( args == CellType::Separator )
184 cells.push_back( {CellType::Separator} );
188 cells.push_back( {CellType::MergeNext} );
193 cells.push_back( {CellType::Value, GEOS_FMT(
"{}", args )} );
199 template<
typename T >
202 static_assert( has_formatter_v< decltype(value) >,
"Argument passed in addCell cannot be converted to string" );
203 m_columnValues.insert( columnValue );
204 m_data[rowValue][columnValue] = GEOS_FMT(
"{}", value );
Enumerates the Units that are in use in GEOS and regroups useful conversion and formatting functions.
Unit
Enumerator of available unit types. Units are in SI by default.
Class for managing 2D table m_data.
real64 RowType
Type real64 for a row.
TableData2D::TableDataHolder convertTable2D(arrayView1d< real64 const > const values, units::Unit const valueUnit, ArrayOfArraysView< real64 const > const coordinates, string_view rowAxisDescription, string_view columnAxisDescription)
void addCell(RowType rowValue, ColumnType columnValue, T const &value)
Add a cell to the table. If necessary, create automatically the containing column & row.
void collectTableValues(arraySlice1d< real64 const > rowAxisValues, arraySlice1d< real64 const > columnAxisValues, arrayView1d< real64 const > values)
Collects all the values needed to build the table.
TableDataHolder buildTableData(string_view dataDescription, string_view rowFmt="{}", string_view columnFmt="{}") const
real64 ColumnType
Type real64 for a column.
Class for managing table data.
void clear()
Reset data in the table.
std::vector< std::vector< CellData > > const & getTableDataRows() const
void addRow(Args const &... args)
Add a row to the table. The values passed to addRow (can be any type).
std::vector< string > const & getErrorMsgs() const
Get all error messages.
void addSeparator()
Add a line separator to the table You must have filled values in TableData before using it.
void addRow(std::vector< CellData > const &row)
Add a row to the table.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
double real64
64-bit floating point type.
constexpr bool isCellType
Trait to check is the args is a special type of cell.
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
CellType
The different type a cell can handle.
std::string_view string_view
String type.
Struct containing conversion informations.
TableData tableData
TableData to be built.
std::vector< string > headerNames
Representing a data in TableData.
string value
The cell value.
CellType type
The cell type.