cphot 0.1
A C++ tool for computing photometry from spectra.
rapidcsv::Document Class Reference

Class representing a CSV document. More...

#include <rapidcsv.hpp>

Public Member Functions

 Document (const std::string &pPath=std::string(), const LabelParams &pLabelParams=LabelParams(), const SeparatorParams &pSeparatorParams=SeparatorParams(), const ConverterParams &pConverterParams=ConverterParams(), const LineReaderParams &pLineReaderParams=LineReaderParams())
 Constructor. More...
 
 Document (std::istream &pStream, const LabelParams &pLabelParams=LabelParams(), const SeparatorParams &pSeparatorParams=SeparatorParams(), const ConverterParams &pConverterParams=ConverterParams(), const LineReaderParams &pLineReaderParams=LineReaderParams())
 Constructor. More...
 
void Load (const std::string &pPath, const LabelParams &pLabelParams=LabelParams(), const SeparatorParams &pSeparatorParams=SeparatorParams(), const ConverterParams &pConverterParams=ConverterParams(), const LineReaderParams &pLineReaderParams=LineReaderParams())
 Read Document data from file. More...
 
void Load (std::istream &pStream, const LabelParams &pLabelParams=LabelParams(), const SeparatorParams &pSeparatorParams=SeparatorParams(), const ConverterParams &pConverterParams=ConverterParams(), const LineReaderParams &pLineReaderParams=LineReaderParams())
 Read Document data from stream. More...
 
void Save (const std::string &pPath=std::string())
 Write Document data to file. More...
 
void Save (std::ostream &pStream)
 Write Document data to stream. More...
 
void Clear ()
 Clears loaded Document data. More...
 
ssize_t GetColumnIdx (const std::string &pColumnName) const
 Get column index by name. More...
 
template<typename T >
std::vector< T > GetColumn (const size_t pColumnIdx) const
 Get column by index. More...
 
template<typename T >
std::vector< T > GetColumn (const size_t pColumnIdx, ConvFunc< T > pToVal) const
 Get column by index. More...
 
template<typename T >
std::vector< T > GetColumn (const std::string &pColumnName) const
 Get column by name. More...
 
template<typename T >
std::vector< T > GetColumn (const std::string &pColumnName, ConvFunc< T > pToVal) const
 Get column by name. More...
 
template<typename T >
void SetColumn (const size_t pColumnIdx, const std::vector< T > &pColumn)
 Set column by index. More...
 
template<typename T >
void SetColumn (const std::string &pColumnName, const std::vector< T > &pColumn)
 Set column by name. More...
 
void RemoveColumn (const size_t pColumnIdx)
 Remove column by index. More...
 
void RemoveColumn (const std::string &pColumnName)
 Remove column by name. More...
 
template<typename T >
void InsertColumn (const size_t pColumnIdx, const std::vector< T > &pColumn=std::vector< T >(), const std::string &pColumnName=std::string())
 Insert column at specified index. More...
 
size_t GetColumnCount () const
 Get number of data columns (excluding label columns). More...
 
ssize_t GetRowIdx (const std::string &pRowName) const
 Get row index by name. More...
 
template<typename T >
std::vector< T > GetRow (const size_t pRowIdx) const
 Get row by index. More...
 
template<typename T >
std::vector< T > GetRow (const size_t pRowIdx, ConvFunc< T > pToVal) const
 Get row by index. More...
 
template<typename T >
std::vector< T > GetRow (const std::string &pRowName) const
 Get row by name. More...
 
template<typename T >
std::vector< T > GetRow (const std::string &pRowName, ConvFunc< T > pToVal) const
 Get row by name. More...
 
template<typename T >
void SetRow (const size_t pRowIdx, const std::vector< T > &pRow)
 Set row by index. More...
 
template<typename T >
void SetRow (const std::string &pRowName, const std::vector< T > &pRow)
 Set row by name. More...
 
void RemoveRow (const size_t pRowIdx)
 Remove row by index. More...
 
void RemoveRow (const std::string &pRowName)
 Remove row by name. More...
 
template<typename T >
void InsertRow (const size_t pRowIdx, const std::vector< T > &pRow=std::vector< T >(), const std::string &pRowName=std::string())
 Insert row at specified index. More...
 
size_t GetRowCount () const
 Get number of data rows (excluding label rows). More...
 
template<typename T >
GetCell (const size_t pColumnIdx, const size_t pRowIdx) const
 Get cell by index. More...
 
template<typename T >
GetCell (const size_t pColumnIdx, const size_t pRowIdx, ConvFunc< T > pToVal) const
 Get cell by index. More...
 
template<typename T >
GetCell (const std::string &pColumnName, const std::string &pRowName) const
 Get cell by name. More...
 
template<typename T >
GetCell (const std::string &pColumnName, const std::string &pRowName, ConvFunc< T > pToVal) const
 Get cell by name. More...
 
template<typename T >
GetCell (const std::string &pColumnName, const size_t pRowIdx) const
 Get cell by column name and row index. More...
 
template<typename T >
GetCell (const std::string &pColumnName, const size_t pRowIdx, ConvFunc< T > pToVal) const
 Get cell by column name and row index. More...
 
template<typename T >
GetCell (const size_t pColumnIdx, const std::string &pRowName) const
 Get cell by column index and row name. More...
 
template<typename T >
GetCell (const size_t pColumnIdx, const std::string &pRowName, ConvFunc< T > pToVal) const
 Get cell by column index and row name. More...
 
template<typename T >
void SetCell (const size_t pColumnIdx, const size_t pRowIdx, const T &pCell)
 Set cell by index. More...
 
template<typename T >
void SetCell (const std::string &pColumnName, const std::string &pRowName, const T &pCell)
 Set cell by name. More...
 
std::string GetColumnName (const ssize_t pColumnIdx)
 Get column name. More...
 
void SetColumnName (size_t pColumnIdx, const std::string &pColumnName)
 Set column name. More...
 
std::vector< std::string > GetColumnNames ()
 Get column names. More...
 
std::string GetRowName (const ssize_t pRowIdx)
 Get row name. More...
 
void SetRowName (size_t pRowIdx, const std::string &pRowName)
 Set row name. More...
 
std::vector< std::string > GetRowNames ()
 Get row names. More...
 

Detailed Description

Class representing a CSV document.

Definition at line 400 of file rapidcsv.hpp.

Constructor & Destructor Documentation

◆ Document() [1/2]

rapidcsv::Document::Document ( const std::string &  pPath = std::string(),
const LabelParams pLabelParams = LabelParams(),
const SeparatorParams pSeparatorParams = SeparatorParams(),
const ConverterParams pConverterParams = ConverterParams(),
const LineReaderParams pLineReaderParams = LineReaderParams() 
)
inlineexplicit

Constructor.

Parameters
pPathspecifies the path of an existing CSV-file to populate the Document data with.
pLabelParamsspecifies which row and column should be treated as labels.
pSeparatorParamsspecifies which field and row separators should be used.
pConverterParamsspecifies how invalid numbers (including empty strings) should be handled.
pLineReaderParamsspecifies how special line formats should be treated.

Definition at line 413 of file rapidcsv.hpp.

◆ Document() [2/2]

rapidcsv::Document::Document ( std::istream &  pStream,
const LabelParams pLabelParams = LabelParams(),
const SeparatorParams pSeparatorParams = SeparatorParams(),
const ConverterParams pConverterParams = ConverterParams(),
const LineReaderParams pLineReaderParams = LineReaderParams() 
)
inlineexplicit

Constructor.

Parameters
pStreamspecifies an input stream to read CSV data from.
pLabelParamsspecifies which row and column should be treated as labels.
pSeparatorParamsspecifies which field and row separators should be used.
pConverterParamsspecifies how invalid numbers (including empty strings) should be handled.
pLineReaderParamsspecifies how special line formats should be treated.

Definition at line 439 of file rapidcsv.hpp.

Member Function Documentation

◆ Clear()

void rapidcsv::Document::Clear ( )
inline

Clears loaded Document data.

Definition at line 528 of file rapidcsv.hpp.

◆ GetCell() [1/8]

template<typename T >
T rapidcsv::Document::GetCell ( const size_t  pColumnIdx,
const size_t  pRowIdx 
) const
inline

Get cell by index.

Parameters
pColumnIdxzero-based column index.
pRowIdxzero-based row index.
Returns
cell data.

Definition at line 1021 of file rapidcsv.hpp.

◆ GetCell() [2/8]

template<typename T >
T rapidcsv::Document::GetCell ( const size_t  pColumnIdx,
const size_t  pRowIdx,
ConvFunc< T >  pToVal 
) const
inline

Get cell by index.

Parameters
pColumnIdxzero-based column index.
pRowIdxzero-based row index.
pToValconversion function.
Returns
cell data.

Definition at line 1040 of file rapidcsv.hpp.

◆ GetCell() [3/8]

template<typename T >
T rapidcsv::Document::GetCell ( const size_t  pColumnIdx,
const std::string &  pRowName 
) const
inline

Get cell by column index and row name.

Parameters
pColumnIdxzero-based column index.
pRowNamerow label name.
Returns
cell data.

Definition at line 1143 of file rapidcsv.hpp.

◆ GetCell() [4/8]

template<typename T >
T rapidcsv::Document::GetCell ( const size_t  pColumnIdx,
const std::string &  pRowName,
ConvFunc< T >  pToVal 
) const
inline

Get cell by column index and row name.

Parameters
pColumnIdxzero-based column index.
pRowNamerow label name.
pToValconversion function.
Returns
cell data.

Definition at line 1162 of file rapidcsv.hpp.

◆ GetCell() [5/8]

template<typename T >
T rapidcsv::Document::GetCell ( const std::string &  pColumnName,
const size_t  pRowIdx 
) const
inline

Get cell by column name and row index.

Parameters
pColumnNamecolumn label name.
pRowIdxzero-based row index.
Returns
cell data.

Definition at line 1106 of file rapidcsv.hpp.

◆ GetCell() [6/8]

template<typename T >
T rapidcsv::Document::GetCell ( const std::string &  pColumnName,
const size_t  pRowIdx,
ConvFunc< T >  pToVal 
) const
inline

Get cell by column name and row index.

Parameters
pColumnNamecolumn label name.
pRowIdxzero-based row index.
pToValconversion function.
Returns
cell data.

Definition at line 1125 of file rapidcsv.hpp.

◆ GetCell() [7/8]

template<typename T >
T rapidcsv::Document::GetCell ( const std::string &  pColumnName,
const std::string &  pRowName 
) const
inline

Get cell by name.

Parameters
pColumnNamecolumn label name.
pRowNamerow label name.
Returns
cell data.

Definition at line 1057 of file rapidcsv.hpp.

◆ GetCell() [8/8]

template<typename T >
T rapidcsv::Document::GetCell ( const std::string &  pColumnName,
const std::string &  pRowName,
ConvFunc< T >  pToVal 
) const
inline

Get cell by name.

Parameters
pColumnNamecolumn label name.
pRowNamerow label name.
pToValconversion function.
Returns
cell data.

Definition at line 1082 of file rapidcsv.hpp.

◆ GetColumn() [1/4]

template<typename T >
std::vector<T> rapidcsv::Document::GetColumn ( const size_t  pColumnIdx) const
inline

Get column by index.

Parameters
pColumnIdxzero-based column index.
Returns
vector of column data.

Definition at line 562 of file rapidcsv.hpp.

◆ GetColumn() [2/4]

template<typename T >
std::vector<T> rapidcsv::Document::GetColumn ( const size_t  pColumnIdx,
ConvFunc< T >  pToVal 
) const
inline

Get column by index.

Parameters
pColumnIdxzero-based column index.
pToValconversion function.
Returns
vector of column data.

Definition at line 599 of file rapidcsv.hpp.

◆ GetColumn() [3/4]

template<typename T >
std::vector<T> rapidcsv::Document::GetColumn ( const std::string &  pColumnName) const
inline

Get column by name.

Parameters
pColumnNamecolumn label name.
Returns
vector of column data.

Definition at line 621 of file rapidcsv.hpp.

◆ GetColumn() [4/4]

template<typename T >
std::vector<T> rapidcsv::Document::GetColumn ( const std::string &  pColumnName,
ConvFunc< T >  pToVal 
) const
inline

Get column by name.

Parameters
pColumnNamecolumn label name.
pToValconversion function.
Returns
vector of column data.

Definition at line 638 of file rapidcsv.hpp.

◆ GetColumnCount()

size_t rapidcsv::Document::GetColumnCount ( ) const
inline

Get number of data columns (excluding label columns).

Returns
column count.

Definition at line 781 of file rapidcsv.hpp.

◆ GetColumnIdx()

ssize_t rapidcsv::Document::GetColumnIdx ( const std::string &  pColumnName) const
inline

Get column index by name.

Parameters
pColumnNamecolumn label name.
Returns
zero-based column index.

Definition at line 544 of file rapidcsv.hpp.

◆ GetColumnName()

std::string rapidcsv::Document::GetColumnName ( const ssize_t  pColumnIdx)
inline

Get column name.

Parameters
pColumnIdxzero-based column index.
Returns
column name.

Definition at line 1235 of file rapidcsv.hpp.

◆ GetColumnNames()

std::vector<std::string> rapidcsv::Document::GetColumnNames ( )
inline

Get column names.

Returns
vector of column names.

Definition at line 1279 of file rapidcsv.hpp.

◆ GetRow() [1/4]

template<typename T >
std::vector<T> rapidcsv::Document::GetRow ( const size_t  pRowIdx) const
inline

Get row by index.

Parameters
pRowIdxzero-based row index.
Returns
vector of row data.

Definition at line 811 of file rapidcsv.hpp.

◆ GetRow() [2/4]

template<typename T >
std::vector<T> rapidcsv::Document::GetRow ( const size_t  pRowIdx,
ConvFunc< T >  pToVal 
) const
inline

Get row by index.

Parameters
pRowIdxzero-based row index.
pToValconversion function.
Returns
vector of row data.

Definition at line 835 of file rapidcsv.hpp.

◆ GetRow() [3/4]

template<typename T >
std::vector<T> rapidcsv::Document::GetRow ( const std::string &  pRowName) const
inline

Get row by name.

Parameters
pRowNamerow label name.
Returns
vector of row data.

Definition at line 858 of file rapidcsv.hpp.

◆ GetRow() [4/4]

template<typename T >
std::vector<T> rapidcsv::Document::GetRow ( const std::string &  pRowName,
ConvFunc< T >  pToVal 
) const
inline

Get row by name.

Parameters
pRowNamerow label name.
pToValconversion function.
Returns
vector of row data.

Definition at line 875 of file rapidcsv.hpp.

◆ GetRowCount()

size_t rapidcsv::Document::GetRowCount ( ) const
inline

Get number of data rows (excluding label rows).

Returns
row count.

Definition at line 1008 of file rapidcsv.hpp.

◆ GetRowIdx()

ssize_t rapidcsv::Document::GetRowIdx ( const std::string &  pRowName) const
inline

Get row index by name.

Parameters
pRowNamerow label name.
Returns
zero-based row index.

Definition at line 793 of file rapidcsv.hpp.

◆ GetRowName()

std::string rapidcsv::Document::GetRowName ( const ssize_t  pRowIdx)
inline

Get row name.

Parameters
pRowIdxzero-based column index.
Returns
row name.

Definition at line 1296 of file rapidcsv.hpp.

◆ GetRowNames()

std::vector<std::string> rapidcsv::Document::GetRowNames ( )
inline

Get row names.

Returns
vector of row names.

Definition at line 1339 of file rapidcsv.hpp.

◆ InsertColumn()

template<typename T >
void rapidcsv::Document::InsertColumn ( const size_t  pColumnIdx,
const std::vector< T > &  pColumn = std::vector<T>(),
const std::string &  pColumnName = std::string() 
)
inline

Insert column at specified index.

Parameters
pColumnIdxzero-based column index.
pColumnvector of column data (optional argument).
pColumnNamecolumn label name (optional argument).

Definition at line 733 of file rapidcsv.hpp.

◆ InsertRow()

template<typename T >
void rapidcsv::Document::InsertRow ( const size_t  pRowIdx,
const std::vector< T > &  pRow = std::vector<T>(),
const std::string &  pRowName = std::string() 
)
inline

Insert row at specified index.

Parameters
pRowIdxzero-based row index.
pRowvector of row data (optional argument).
pRowNamerow label name (optional argument).

Definition at line 967 of file rapidcsv.hpp.

◆ Load() [1/2]

void rapidcsv::Document::Load ( const std::string &  pPath,
const LabelParams pLabelParams = LabelParams(),
const SeparatorParams pSeparatorParams = SeparatorParams(),
const ConverterParams pConverterParams = ConverterParams(),
const LineReaderParams pLineReaderParams = LineReaderParams() 
)
inline

Read Document data from file.

Parameters
pPathspecifies the path of an existing CSV-file to populate the Document data with.
pLabelParamsspecifies which row and column should be treated as labels.
pSeparatorParamsspecifies which field and row separators should be used.
pConverterParamsspecifies how invalid numbers (including empty strings) should be handled.
pLineReaderParamsspecifies how special line formats should be treated.

Definition at line 463 of file rapidcsv.hpp.

◆ Load() [2/2]

void rapidcsv::Document::Load ( std::istream &  pStream,
const LabelParams pLabelParams = LabelParams(),
const SeparatorParams pSeparatorParams = SeparatorParams(),
const ConverterParams pConverterParams = ConverterParams(),
const LineReaderParams pLineReaderParams = LineReaderParams() 
)
inline

Read Document data from stream.

Parameters
pStreamspecifies an input stream to read CSV data from.
pLabelParamsspecifies which row and column should be treated as labels.
pSeparatorParamsspecifies which field and row separators should be used.
pConverterParamsspecifies how invalid numbers (including empty strings) should be handled.
pLineReaderParamsspecifies how special line formats should be treated.

Definition at line 486 of file rapidcsv.hpp.

◆ RemoveColumn() [1/2]

void rapidcsv::Document::RemoveColumn ( const size_t  pColumnIdx)
inline

Remove column by index.

Parameters
pColumnIdxzero-based column index.

Definition at line 702 of file rapidcsv.hpp.

◆ RemoveColumn() [2/2]

void rapidcsv::Document::RemoveColumn ( const std::string &  pColumnName)
inline

Remove column by name.

Parameters
pColumnNamecolumn label name.

Definition at line 715 of file rapidcsv.hpp.

◆ RemoveRow() [1/2]

void rapidcsv::Document::RemoveRow ( const size_t  pRowIdx)
inline

Remove row by index.

Parameters
pRowIdxzero-based row index.

Definition at line 939 of file rapidcsv.hpp.

◆ RemoveRow() [2/2]

void rapidcsv::Document::RemoveRow ( const std::string &  pRowName)
inline

Remove row by name.

Parameters
pRowNamerow label name.

Definition at line 949 of file rapidcsv.hpp.

◆ Save() [1/2]

void rapidcsv::Document::Save ( const std::string &  pPath = std::string())
inline

Write Document data to file.

Parameters
pPathoptionally specifies the path where the CSV-file will be created (if not specified, the original path provided when creating or loading the Document data will be used).

Definition at line 506 of file rapidcsv.hpp.

◆ Save() [2/2]

void rapidcsv::Document::Save ( std::ostream &  pStream)
inline

Write Document data to stream.

Parameters
pStreamspecifies an output stream to write the data to.

Definition at line 519 of file rapidcsv.hpp.

◆ SetCell() [1/2]

template<typename T >
void rapidcsv::Document::SetCell ( const size_t  pColumnIdx,
const size_t  pRowIdx,
const T &  pCell 
)
inline

Set cell by index.

Parameters
pRowIdxzero-based row index.
pColumnIdxzero-based column index.
pCellcell data.

Definition at line 1180 of file rapidcsv.hpp.

◆ SetCell() [2/2]

template<typename T >
void rapidcsv::Document::SetCell ( const std::string &  pColumnName,
const std::string &  pRowName,
const T &  pCell 
)
inline

Set cell by name.

Parameters
pColumnNamecolumn label name.
pRowNamerow label name.
pCellcell data.

Definition at line 1213 of file rapidcsv.hpp.

◆ SetColumn() [1/2]

template<typename T >
void rapidcsv::Document::SetColumn ( const size_t  pColumnIdx,
const std::vector< T > &  pColumn 
)
inline

Set column by index.

Parameters
pColumnIdxzero-based column index.
pColumnvector of column data.

Definition at line 654 of file rapidcsv.hpp.

◆ SetColumn() [2/2]

template<typename T >
void rapidcsv::Document::SetColumn ( const std::string &  pColumnName,
const std::vector< T > &  pColumn 
)
inline

Set column by name.

Parameters
pColumnNamecolumn label name.
pColumnvector of column data.

Definition at line 688 of file rapidcsv.hpp.

◆ SetColumnName()

void rapidcsv::Document::SetColumnName ( size_t  pColumnIdx,
const std::string &  pColumnName 
)
inline

Set column name.

Parameters
pColumnIdxzero-based column index.
pColumnNamecolumn name.

Definition at line 1251 of file rapidcsv.hpp.

◆ SetRow() [1/2]

template<typename T >
void rapidcsv::Document::SetRow ( const size_t  pRowIdx,
const std::vector< T > &  pRow 
)
inline

Set row by index.

Parameters
pRowIdxzero-based row index.
pRowvector of row data.

Definition at line 891 of file rapidcsv.hpp.

◆ SetRow() [2/2]

template<typename T >
void rapidcsv::Document::SetRow ( const std::string &  pRowName,
const std::vector< T > &  pRow 
)
inline

Set row by name.

Parameters
pRowNamerow label name.
pRowvector of row data.

Definition at line 925 of file rapidcsv.hpp.

◆ SetRowName()

void rapidcsv::Document::SetRowName ( size_t  pRowIdx,
const std::string &  pRowName 
)
inline

Set row name.

Parameters
pRowIdxzero-based row index.
pRowNamerow name.

Definition at line 1312 of file rapidcsv.hpp.


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