ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
Acts::Table Class Reference

A utility class for creating formatted markdown tables with automatic column sizing and alignment. More...

#include <Acts/Utilities/Table.hpp>

Classes

struct  Column

Public Types

enum class  Alignment { Left , Right , Center }
 Text alignment options for table columns. More...

Public Member Functions

void addColumn (const std::string &header, const std::string &format, Alignment alignment=Alignment::Left)
 Add a column with header, format string, and alignment.
void addColumn (const std::string &header, const std::string &format, const std::string &alignment="left")
 Add a column with header, format string, and alignment as string.
template<typename... Args>
void addRow (Args &&... args)
 Add a row with variable arguments matching the number of columns.
void setMarkdownMode (bool includeMarkers)
 Set whether to include markdown alignment markers in output.
std::string toString () const
 Generate the formatted table as a markdown string.

Detailed Description

A utility class for creating formatted markdown tables with automatic column sizing and alignment.

Usage:

Table table;
table.addColumn("Name", "{}", "left"); // String alignment
table.addColumn("Value", "{:.2f}", "right"); // or "r" for short
table.addColumn("Count", "{}", Table::Alignment::Center); // Enum also
supported table.addRow("Item1", 1.23, 42); table.addRow("Item2", 4.56, 7);
std::cout << table.toString();
A utility class for creating formatted markdown tables with automatic column sizing and alignment.
Definition Table.hpp:33
@ Center
Definition Table.hpp:36
void addRow(Args &&... args)
Add a row with variable arguments matching the number of columns.
Definition Table.hpp:77
std::string toString() const
Generate the formatted table as a markdown string.
Definition Table.hpp:104
void addColumn(const std::string &header, const std::string &format, Alignment alignment=Alignment::Left)
Add a column with header, format string, and alignment.
Definition Table.hpp:49

Member Enumeration Documentation

◆ Alignment

enum class Acts::Table::Alignment
strong

Text alignment options for table columns.

Enumerator
Left 
Right 
Center 

Member Function Documentation

◆ addColumn() [1/2]

void Acts::Table::addColumn ( const std::string & header,
const std::string & format,
Alignment alignment = Alignment::Left )

Add a column with header, format string, and alignment.

Parameters
headerColumn header text
formatFormat string for the column values
alignmentColumn alignment (default: Left)

◆ addColumn() [2/2]

void Acts::Table::addColumn ( const std::string & header,
const std::string & format,
const std::string & alignment = "left" )

Add a column with header, format string, and alignment as string.

Parameters
headerColumn header text
formatFormat string for the column values
alignmentString alignment: "left"/"l", "right"/"r", "center"/"c" (case insensitive)
Exceptions
std::invalid_argumentif alignment string is not recognized

◆ addRow()

template<typename... Args>
void Acts::Table::addRow ( Args &&... args)

Add a row with variable arguments matching the number of columns.

Parameters
argsArguments to add as row values
Exceptions
std::runtime_errorif argument count doesn't match column count

◆ setMarkdownMode()

void Acts::Table::setMarkdownMode ( bool includeMarkers)

Set whether to include markdown alignment markers in output.

Parameters
includeMarkersIf true (default), includes markdown alignment markers

◆ toString()

std::string Acts::Table::toString ( ) const

Generate the formatted table as a markdown string.

Returns
Markdown formatted string representation of the table