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"
88 template<
typename ... Args >
89 void addRow( Args
const & ... args );
112 { m_errors->clear(); }
147 {
return *m_errors; }
154 {
return *m_errors; }
161 std::unique_ptr< geos::TableErrorListing > m_errors;
195 template<
typename T >
208 bool columnMajorValues );
225 bool columnMajorValues,
246 m_columnValues.clear();
252 std::map< RowType, std::map< ColumnType, string > > m_data;
254 std::set< real64 > m_columnValues;
256 std::unique_ptr< geos::TableErrorListing > m_errors = std::make_unique< geos::TableErrorListing >();
263 template<
typename T >
266 template<
typename ... Args >
271 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" );
272 if constexpr (std::is_same_v< Args, CellType >) {
273 cells.push_back( { args,
string() } );
275 else if constexpr (std::is_floating_point_v< std::decay_t< decltype(args) > >) {
276 if( !
getErrorsList().hasErrors() && (std::isnan( args ) || std::isinf( args )))
278 m_errors->addError(
"Warning : Invalid values detected (nan/inf)." );
280 cells.push_back( {CellType::Value, GEOS_FMT(
"{}", args )} );
284 cells.push_back( {CellType::Value, GEOS_FMT(
"{}", args )} );
290 template<
typename T >
293 static_assert( has_formatter_v< decltype(value) >,
"Argument passed in addCell cannot be converted to string" );
294 m_columnValues.insert( columnValue );
295 m_data[rowValue][columnValue] = GEOS_FMT(
"{}", value );
Enumerates the Units that are in use in GEOS and regroups useful conversion and formatting functions.
Class for managing 2D table m_data.
real64 RowType
Type real64 for a row.
void collectTableValues(arrayView1d< real64 const > dim0AxisCoordinates, arrayView1d< real64 const > dim1AxisCoordinates, arrayView1d< real64 const > values, bool columnMajorValues)
Collects all the values needed to build the table.
void clear()
Clear all data stored in TableData.
void addCell(RowType rowValue, ColumnType columnValue, T const &value)
Add a cell to the table. If necessary, create automatically the containing column & row.
TableData2D::TableDataHolder convertTable2D(arrayView1d< real64 const > coordX, arrayView1d< real64 const > coordY, string_view rowAxisDescription, string_view columnAxisDescription, arrayView1d< real64 const > const values, bool columnMajorValues, string_view valueDescription)
Convert from 2D axis/values a structure the information needed to build a TableFormatter.
TableDataHolder buildTableData(string_view dataDescription, string_view rowFmt="{}", string_view columnFmt="{}") const
real64 ColumnType
Type real64 for a column.
Class for managing table data.
DataRows const & getCellsData() const
stdVector< string > const & getErrorMsgs() const
Get all error messages.
void clear()
Reset data in the table.
void addRow(stdVector< CellData > const &row)
Add a row to the table.
void clearErrors()
Remove all errors.
bool operator==(TableData const &comparingTable) const
Comparison operator for data rows.
TableErrorListing & getErrorsList()
Get all error messages.
void addRow(Args const &... args)
Add a row to the table. The values passed to addRow (can be any type).
bool operator<(TableData const &other) const
Lexicographic sorting.
void addSeparator()
Add a line separator to the table You must have filled values in TableData before using it.
stdVector< stdVector< CellData > > DataRows
Alias for table data rows with cells values.
TableErrorListing const & getErrorsList() const
Get all error messages.
stdVector< stdVector< CellData > > const & getTableDataRows() const
Class for retrieving errors in the table classes.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
std::string string
String type.
double real64
64-bit floating point type.
constexpr bool isCellType
Trait to check is the args is a special type of cell.
CellType
The different type a cell can handle.
std::string_view string_view
String type.
internal::StdVectorWrapper< T, Allocator, USE_STD_CONTAINER_BOUNDS_CHECKING > stdVector
Struct containing conversion informations.
stdVector< string > headerNames
TableData tableData
TableData to be built.
Representing a data in TableData.
string value
The cell value.
CellType type
The cell type.