Lumiera  0.pre.03
»edit your freedom«
DataTable< TAB > Class Template Reference

#include "lib/stat/data.hpp"

Description

template<class TAB>
class lib::stat::DataTable< TAB >

Table with data values, stored persistently as CSV file.

Each row within the table represents a data record, holding a sequence of values. Values are statically typed per column, i.e. one column may hold strings, while the next column holds doubles. For actual usage it is thus necessary to define the column layout, through a sequence of column Descriptors.

Usage

Actually those Column objects serve as descriptors, but also as accessors — and they hold the actual data storage for each column, which is a std::vector<VAL> of value type VAL. There is always a current record — corresponding to the actual data value and the newest data row. For persistent storage, the sequence of rows is reversed, so the newest data appears at the top of the CSV file.

Template Parameters
TABa struct comprised of several Column objects, which hold the data and provide access to values of this specific column. Moreover, this type must define a function allColumns() to return a tuple with references to these column fields; the order of fields within this tuple also defines the order of columns within the table and persistent CSV storage.

Definition at line 194 of file data.hpp.

Public Member Functions

 DataTable (fs::path csvFile="")
 
 DataTable (CSVData const &csv)
 
void appendFrom (CSVData const &csv)
 
void clear ()
 
void dropLastRow ()
 
void dupRow ()
 
bool empty () const
 
void newRow ()
 
CSVData renderCSV () const
 
void reserve (size_t expectedCapacity)
 
void save (size_t lineLimit=std::numeric_limits< size_t >::max(), bool backupOld=false)
 
void saveAs (fs::path newStorage, size_t lineLimit=std::numeric_limits< size_t >::max())
 
size_t size () const
 

Static Public Attributes

static constexpr size_t columnCnt = std::tuple_size_v<decltype(std::declval<TAB>().allColumns())>
 

Private Member Functions

void appendRowFromCSV (string line)
 
template<class OP >
void forAllColumns (OP &&doIt) const
 apply a generic Lambda to all columns
 
CSVLine formatCSVRow (size_t rownum) const
 
CSVLine generateHeaderSpec () const
 
void loadData ()
 
void saveData (std::ofstream &csvFile, size_t lineLimit)
 
void verifyHeaderSpec (string headerLine)
 
- Private Member Functions inherited from MoveOnly
 MoveOnly (MoveOnly &&)=default
 
 MoveOnly (MoveOnly const &)=delete
 
MoveOnlyoperator= (MoveOnly &&)=delete
 
MoveOnlyoperator= (MoveOnly const &)=delete
 

Private Attributes

fs::path filename_
 

Member Function Documentation

◆ save()

void save ( size_t  lineLimit = std::numeric_limits<size_t>::max(),
bool  backupOld = false 
)
inline
Parameters
lineLimitnumber of rows to retain, back from the newest

Definition at line 323 of file data.hpp.

+ Inheritance diagram for DataTable< TAB >:
+ Collaboration diagram for DataTable< TAB >:

The documentation for this class was generated from the following file: