rapidcsv::Document

Search for usage in LXR

rapidcsv::Document Class Reference

#include <rapidcsv.h>

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())
 
 Document (std::istream &pStream, const LabelParams &pLabelParams=LabelParams(), const SeparatorParams &pSeparatorParams=SeparatorParams(), const ConverterParams &pConverterParams=ConverterParams(), const LineReaderParams &pLineReaderParams=LineReaderParams())
 
void Clear ()
 
template<typename T >
GetCell (const size_t pColumnIdx, const size_t pRowIdx) const
 
template<typename T >
GetCell (const size_t pColumnIdx, const size_t pRowIdx, ConvFunc< T > pToVal) const
 
template<typename T >
GetCell (const size_t pColumnIdx, const std::string &pRowName) const
 
template<typename T >
GetCell (const size_t pColumnIdx, const std::string &pRowName, ConvFunc< T > pToVal) const
 
template<typename T >
GetCell (const std::string &pColumnName, const size_t pRowIdx) const
 
template<typename T >
GetCell (const std::string &pColumnName, const size_t pRowIdx, ConvFunc< T > pToVal) const
 
template<typename T >
GetCell (const std::string &pColumnName, const std::string &pRowName) const
 
template<typename T >
GetCell (const std::string &pColumnName, const std::string &pRowName, ConvFunc< T > pToVal) const
 
template<typename T >
std::vector< T > GetColumn (const size_t pColumnIdx) const
 
template<typename T >
std::vector< T > GetColumn (const size_t pColumnIdx, ConvFunc< T > pToVal) const
 
template<typename T >
std::vector< T > GetColumn (const std::string &pColumnName) const
 
template<typename T >
std::vector< T > GetColumn (const std::string &pColumnName, ConvFunc< T > pToVal) const
 
size_t GetColumnCount () const
 
ssize_t GetColumnIdx (const std::string &pColumnName) const
 
std::string GetColumnName (const ssize_t pColumnIdx)
 
std::vector< std::string > GetColumnNames ()
 
template<typename T >
std::vector< T > GetRow (const size_t pRowIdx) const
 
template<typename T >
std::vector< T > GetRow (const size_t pRowIdx, ConvFunc< T > pToVal) const
 
template<typename T >
std::vector< T > GetRow (const std::string &pRowName) const
 
template<typename T >
std::vector< T > GetRow (const std::string &pRowName, ConvFunc< T > pToVal) const
 
size_t GetRowCount () const
 
ssize_t GetRowIdx (const std::string &pRowName) const
 
std::string GetRowName (const ssize_t pRowIdx)
 
std::vector< std::string > GetRowNames ()
 
template<typename T >
void InsertColumn (const size_t pColumnIdx, const std::vector< T > &pColumn=std::vector< T >(), const std::string &pColumnName=std::string())
 
template<typename T >
void InsertRow (const size_t pRowIdx, const std::vector< T > &pRow=std::vector< T >(), const std::string &pRowName=std::string())
 
void Load (const std::string &pPath, const LabelParams &pLabelParams=LabelParams(), const SeparatorParams &pSeparatorParams=SeparatorParams(), const ConverterParams &pConverterParams=ConverterParams(), const LineReaderParams &pLineReaderParams=LineReaderParams())
 
void Load (std::istream &pStream, const LabelParams &pLabelParams=LabelParams(), const SeparatorParams &pSeparatorParams=SeparatorParams(), const ConverterParams &pConverterParams=ConverterParams(), const LineReaderParams &pLineReaderParams=LineReaderParams())
 
void RemoveColumn (const size_t pColumnIdx)
 
void RemoveColumn (const std::string &pColumnName)
 
void RemoveRow (const size_t pRowIdx)
 
void RemoveRow (const std::string &pRowName)
 
void Save (const std::string &pPath=std::string())
 
void Save (std::ostream &pStream)
 
template<typename T >
void SetCell (const size_t pColumnIdx, const size_t pRowIdx, const T &pCell)
 
template<typename T >
void SetCell (const std::string &pColumnName, const std::string &pRowName, const T &pCell)
 
template<typename T >
void SetColumn (const size_t pColumnIdx, const std::vector< T > &pColumn)
 
template<typename T >
void SetColumn (const std::string &pColumnName, const std::vector< T > &pColumn)
 
void SetColumnName (size_t pColumnIdx, const std::string &pColumnName)
 
template<typename T >
void SetRow (const size_t pRowIdx, const std::vector< T > &pRow)
 
template<typename T >
void SetRow (const std::string &pRowName, const std::vector< T > &pRow)
 
void SetRowName (size_t pRowIdx, const std::string &pRowName)
 

Detailed Description

Class representing a CSV document.

Definition at line 382 of file rapidcsv.h.

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 395 of file rapidcsv.h.

◆ 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 418 of file rapidcsv.h.

Member Function Documentation

◆ Clear()

void rapidcsv::Document::Clear ( )
inline

Clears loaded Document data.

Definition at line 499 of file rapidcsv.h.

◆ 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 991 of file rapidcsv.h.

◆ 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 1010 of file rapidcsv.h.

◆ 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 1115 of file rapidcsv.h.

◆ 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 1134 of file rapidcsv.h.

◆ 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 1077 of file rapidcsv.h.

◆ 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 1096 of file rapidcsv.h.

◆ 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 1027 of file rapidcsv.h.

◆ 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 1052 of file rapidcsv.h.

◆ 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 533 of file rapidcsv.h.

◆ 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 557 of file rapidcsv.h.

◆ 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 579 of file rapidcsv.h.

◆ 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 596 of file rapidcsv.h.

◆ GetColumnCount()

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

Get number of data columns (excluding label columns).

Returns
column count.

Definition at line 745 of file rapidcsv.h.

◆ 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 515 of file rapidcsv.h.

◆ 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 1209 of file rapidcsv.h.

◆ GetColumnNames()

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

Get column names.

Returns
vector of column names.

Definition at line 1255 of file rapidcsv.h.

◆ 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 776 of file rapidcsv.h.

◆ 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 801 of file rapidcsv.h.

◆ 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 825 of file rapidcsv.h.

◆ 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 842 of file rapidcsv.h.

◆ GetRowCount()

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

Get number of data rows (excluding label rows).

Returns
row count.

Definition at line 977 of file rapidcsv.h.

◆ 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 758 of file rapidcsv.h.

◆ 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 1273 of file rapidcsv.h.

◆ GetRowNames()

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

Get row names.

Returns
vector of row names.

Definition at line 1318 of file rapidcsv.h.

◆ 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 694 of file rapidcsv.h.

◆ 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 935 of file rapidcsv.h.

◆ 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 439 of file rapidcsv.h.

◆ 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 461 of file rapidcsv.h.

◆ RemoveColumn() [1/2]

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

Remove column by index.

Parameters
pColumnIdxzero-based column index.

Definition at line 663 of file rapidcsv.h.

◆ RemoveColumn() [2/2]

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

Remove column by name.

Parameters
pColumnNamecolumn label name.

Definition at line 676 of file rapidcsv.h.

◆ RemoveRow() [1/2]

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

Remove row by index.

Parameters
pRowIdxzero-based row index.

Definition at line 907 of file rapidcsv.h.

◆ RemoveRow() [2/2]

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

Remove row by name.

Parameters
pRowNamerow label name.

Definition at line 917 of file rapidcsv.h.

◆ 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 480 of file rapidcsv.h.

◆ 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 493 of file rapidcsv.h.

◆ 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 1153 of file rapidcsv.h.

◆ 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 1186 of file rapidcsv.h.

◆ 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 612 of file rapidcsv.h.

◆ 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 649 of file rapidcsv.h.

◆ 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 1226 of file rapidcsv.h.

◆ 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 858 of file rapidcsv.h.

◆ 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 893 of file rapidcsv.h.

◆ 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 1290 of file rapidcsv.h.


The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:15:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.