![]() |
Lumiera 0.pre.04
»edit your freedom«
|
#include "lib/stat/data.hpp"
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.
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.
| TAB | a 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. |
Static Public Attributes | |
| static constexpr size_t | columnCnt = std::tuple_size_v<decltype(std::declval<TAB>().allColumns())> |
Public Member Functions | |
| DataTable (fs::path csvFile="") | |
| DataTable (CSVData const &csv) | |
| bool | empty () const |
| size_t | size () const |
| CSVData | renderCSV () const |
| void | newRow () |
| void | dupRow () |
| void | dropLastRow () |
| void | reserve (size_t expectedCapacity) |
| void | clear () |
| void | appendFrom (CSVData const &csv) |
| 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()) |
Private Member Functions | |
| template<class OP > | |
| void | forAllColumns (OP &&doIt) const |
| apply a generic Lambda to all columns | |
| void | loadData () |
| void | saveData (std::ofstream &csvFile, size_t lineLimit) |
| void | verifyHeaderSpec (string headerLine) |
| CSVLine | generateHeaderSpec () const |
| void | appendRowFromCSV (string line) |
| CSVLine | formatCSVRow (size_t rownum) const |
Private Member Functions inherited from MoveOnly | |
| ~MoveOnly ()=default | |
| MoveOnly ()=default | |
| MoveOnly (MoveOnly &&)=default | |
| MoveOnly (MoveOnly const &)=delete | |
| MoveOnly & | operator= (MoveOnly &&)=delete |
| MoveOnly & | operator= (MoveOnly const &)=delete |
Private Attributes | |
| fs::path | filename_ |
|
inline |
Definition at line 192 of file data.hpp.
References DataTable< TAB >::loadData().
Here is the call graph for this function:Definition at line 198 of file data.hpp.
References DataTable< TAB >::appendFrom().
Here is the call graph for this function:
|
inline |
Definition at line 210 of file data.hpp.
References DataTable< TAB >::size().
Referenced by DataTable< TAB >::dropLastRow(), DataTable< TAB >::dupRow(), and DataTable< TAB >::saveData().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 216 of file data.hpp.
References DataTable< TAB >::forAllColumns().
Referenced by DataTable< TAB >::empty(), DataTable< TAB >::newRow(), DataTable< TAB >::renderCSV(), and DataTable< TAB >::saveData().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 229 of file data.hpp.
References DataTable< TAB >::formatCSVRow(), DataTable< TAB >::generateHeaderSpec(), and DataTable< TAB >::size().
Here is the call graph for this function:
|
inline |
Definition at line 246 of file data.hpp.
References DataTable< TAB >::forAllColumns(), and DataTable< TAB >::size().
Referenced by DataTable< TAB >::dupRow().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 257 of file data.hpp.
References DataTable< TAB >::empty(), DataTable< TAB >::forAllColumns(), and DataTable< TAB >::newRow().
Here is the call graph for this function:
|
inline |
Definition at line 270 of file data.hpp.
References DataTable< TAB >::empty(), and DataTable< TAB >::forAllColumns().
Here is the call graph for this function:
|
inline |
Definition at line 282 of file data.hpp.
References DataTable< TAB >::forAllColumns().
Referenced by DataTable< TAB >::loadData().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 292 of file data.hpp.
References DataTable< TAB >::forAllColumns().
Here is the call graph for this function:
|
inline |
Definition at line 302 of file data.hpp.
References DataTable< TAB >::appendRowFromCSV(), and DataTable< TAB >::verifyHeaderSpec().
Referenced by DataTable< TAB >::DataTable().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
| lineLimit | number of rows to retain, back from the newest |
Definition at line 315 of file data.hpp.
References std::filesystem::consolidated(), DataTable< TAB >::filename_, and DataTable< TAB >::saveData().
Referenced by DataTable< TAB >::saveAs().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 343 of file data.hpp.
References std::filesystem::consolidated(), DataTable< TAB >::filename_, and DataTable< TAB >::save().
Here is the call graph for this function:
|
inlineprivate |
apply a generic Lambda to all columns
Definition at line 364 of file data.hpp.
References lib::meta::forEach().
Referenced by DataTable< TAB >::clear(), DataTable< TAB >::dropLastRow(), DataTable< TAB >::dupRow(), DataTable< TAB >::newRow(), DataTable< TAB >::reserve(), DataTable< TAB >::size(), and DataTable< TAB >::verifyHeaderSpec().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
Definition at line 371 of file data.hpp.
References DataTable< TAB >::appendRowFromCSV(), DataTable< TAB >::filename_, DataTable< TAB >::reserve(), and DataTable< TAB >::verifyHeaderSpec().
Referenced by DataTable< TAB >::DataTable().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
Definition at line 402 of file data.hpp.
References DataTable< TAB >::empty(), DataTable< TAB >::formatCSVRow(), DataTable< TAB >::generateHeaderSpec(), and DataTable< TAB >::size().
Referenced by DataTable< TAB >::save().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
Definition at line 415 of file data.hpp.
References DataTable< TAB >::filename_, and DataTable< TAB >::forAllColumns().
Referenced by DataTable< TAB >::appendFrom(), and DataTable< TAB >::loadData().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
Definition at line 430 of file data.hpp.
Referenced by DataTable< TAB >::renderCSV(), and DataTable< TAB >::saveData().
Here is the caller graph for this function:
|
inlineprivate |
Definition at line 443 of file data.hpp.
Referenced by DataTable< TAB >::appendFrom(), and DataTable< TAB >::loadData().
Here is the caller graph for this function:
|
inlineprivate |
Definition at line 470 of file data.hpp.
Referenced by DataTable< TAB >::renderCSV(), and DataTable< TAB >::saveData().
Here is the caller graph for this function:
|
private |
Definition at line 189 of file data.hpp.
Referenced by DataTable< TAB >::loadData(), DataTable< TAB >::save(), DataTable< TAB >::saveAs(), and DataTable< TAB >::verifyHeaderSpec().
|
staticconstexpr |
Inheritance diagram for DataTable< TAB >:
Collaboration diagram for DataTable< TAB >: