EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple > Class Template Reference

#include <acts/blob/sPHENIX/thirdparty/dfelibs/dfe/dfe_io_dsv.hpp>

+ Collaboration diagram for dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >:

Public Member Functions

 NamedTupleDsvReader ()=delete
 
 NamedTupleDsvReader (const NamedTupleDsvReader &)=delete
 
 NamedTupleDsvReader (NamedTupleDsvReader &&)=default
 
 ~NamedTupleDsvReader ()=default
 
NamedTupleDsvReaderoperator= (const NamedTupleDsvReader &)=delete
 
NamedTupleDsvReaderoperator= (NamedTupleDsvReader &&)=default
 
 NamedTupleDsvReader (const std::string &path, const std::vector< std::string > &optional_columns={}, bool verify_header=true)
 
bool read (NamedTuple &record)
 
template<typename T >
bool read (NamedTuple &record, std::vector< T > &extra)
 
std::size_t num_extra_columns () const
 Return the number of additional columns that are not part of the tuple.
 
std::size_t num_records () const
 Return the number of records read so far.
 

Private Types

using Tuple = typename NamedTuple::Tuple
 

Private Member Functions

void use_default_columns ()
 
void parse_header (const std::vector< std::string > &optional_columns)
 
template<std::size_t... I>
void parse_record (NamedTuple &record, std::index_sequence< I...>) const
 
template<std::size_t I>
void parse_element (NamedTuple &record) const
 

Private Attributes

DsvReader< Delimiter > m_reader
 
std::vector< std::string > m_columns
 
std::size_t m_num_columns = SIZE_MAX
 
std::array< std::size_t,
std::tuple_size< Tuple >
::value
m_tuple_column_map
 
std::vector< std::size_t > m_extra_columns
 

Detailed Description

template<char Delimiter, typename NamedTuple>
class dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >

Read records as delimiter-separated values from a text file.

The reader is strict about its input format to avoid ambiguities. If header verification is disabled, the first line will be skipped and each line must contain exactly as many columns as there are tuple members in exactly the same order. If header verification is enabled, the first line is interpreted as the header. Names in the header must match exactly to the tuple members but can be in arbitrary order. The file can contain extra columns that are not tuple members. Each following row must have exactly the same number of columns as the header.

Definition at line 183 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 183 of file dfe_io_dsv.hpp

Member Typedef Documentation

template<char Delimiter, typename NamedTuple>
using dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::Tuple = typename NamedTuple::Tuple
private

Definition at line 229 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 229 of file dfe_io_dsv.hpp

Constructor & Destructor Documentation

template<char Delimiter, typename NamedTuple>
dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::NamedTupleDsvReader ( )
delete
template<char Delimiter, typename NamedTuple>
dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::NamedTupleDsvReader ( const NamedTupleDsvReader< Delimiter, NamedTuple > &  )
delete
template<char Delimiter, typename NamedTuple>
dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::NamedTupleDsvReader ( NamedTupleDsvReader< Delimiter, NamedTuple > &&  )
default
template<char Delimiter, typename NamedTuple>
dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::~NamedTupleDsvReader ( )
default
template<char Delimiter, typename NamedTuple >
dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::NamedTupleDsvReader ( const std::string &  path,
const std::vector< std::string > &  optional_columns = {},
bool  verify_header = true 
)
inline

Open a file at the given path.

Parameters
pathPath to the input file
optional_columnsRecord columns that can be missing in the file
verify_headertrue to check header column names, false to skip

The set of optional columns must match names in the record. When allowing optional columns, header verification must be set to true.

Definition at line 387 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 387 of file dfe_io_dsv.hpp

References dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_columns, dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_reader, dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::parse_header(), and dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::use_default_columns().

+ Here is the call graph for this function:

Member Function Documentation

template<char Delimiter, typename NamedTuple>
std::size_t dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::num_extra_columns ( ) const
inline

Return the number of additional columns that are not part of the tuple.

Definition at line 223 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 223 of file dfe_io_dsv.hpp

References dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_extra_columns.

template<char Delimiter, typename NamedTuple>
std::size_t dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::num_records ( ) const
inline

Return the number of records read so far.

Definition at line 225 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 225 of file dfe_io_dsv.hpp

References dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_reader, and Acts::UnitConstants::u.

template<char Delimiter, typename NamedTuple>
NamedTupleDsvReader& dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::operator= ( const NamedTupleDsvReader< Delimiter, NamedTuple > &  )
delete
template<char Delimiter, typename NamedTuple>
NamedTupleDsvReader& dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::operator= ( NamedTupleDsvReader< Delimiter, NamedTuple > &&  )
default
template<char Delimiter, typename NamedTuple>
template<std::size_t I>
void dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::parse_element ( NamedTuple &  record) const
inlineprivate

Definition at line 250 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 250 of file dfe_io_dsv.hpp

References nlohmann::detail::get(), I, dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_columns, dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_tuple_column_map, and dfe::io_dsv_impl::parse().

+ Here is the call graph for this function:

template<char Delimiter, typename NamedTuple >
void dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::parse_header ( const std::vector< std::string > &  optional_columns)
inlineprivate

Definition at line 459 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 459 of file dfe_io_dsv.hpp

References c, it, name, and eicpy.verify::names.

Referenced by dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::NamedTupleDsvReader().

+ Here is the caller graph for this function:

template<char Delimiter, typename NamedTuple>
template<std::size_t... I>
void dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::parse_record ( NamedTuple &  record,
std::index_sequence< I...>   
) const
inlineprivate

Definition at line 243 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 243 of file dfe_io_dsv.hpp

References nlohmann::detail::void().

+ Here is the call graph for this function:

template<char Delimiter, typename NamedTuple >
bool dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::read ( NamedTuple &  record)
inline

Read the next record from the file.

Extra columns in the file will be ignored. Elements of the record that correspond to missing, optional columns will not be set and retain their value.

Returns
true if a record was successfully read
false if no more records are available

Definition at line 409 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 409 of file dfe_io_dsv.hpp

References nlohmann::to_string(), and value.

+ Here is the call graph for this function:

template<char Delimiter, typename NamedTuple >
template<typename T >
bool dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::read ( NamedTuple &  record,
std::vector< T > &  extra 
)
inline

Read the next record and any extra columns from the file.

Returns
true if a record was successfully read
false if no more records are available

Definition at line 431 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 431 of file dfe_io_dsv.hpp

References dfe::io_dsv_impl::parse(), and read().

+ Here is the call graph for this function:

template<char Delimiter, typename NamedTuple >
void dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::use_default_columns ( )
inlineprivate

Definition at line 447 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 447 of file dfe_io_dsv.hpp

References value.

Referenced by dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::NamedTupleDsvReader().

+ Here is the caller graph for this function:

Member Data Documentation

template<char Delimiter, typename NamedTuple>
std::vector<std::string> dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_columns
private
template<char Delimiter, typename NamedTuple>
std::vector<std::size_t> dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_extra_columns
private

Definition at line 238 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 238 of file dfe_io_dsv.hpp

Referenced by dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::num_extra_columns().

template<char Delimiter, typename NamedTuple>
std::size_t dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_num_columns = SIZE_MAX
private

Definition at line 234 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 234 of file dfe_io_dsv.hpp

template<char Delimiter, typename NamedTuple>
DsvReader<Delimiter> dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_reader
private
template<char Delimiter, typename NamedTuple>
std::array<std::size_t, std::tuple_size<Tuple>::value> dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::m_tuple_column_map
private

Definition at line 236 of file dfe_io_dsv.hpp.

View newest version in sPHENIX GitHub at line 236 of file dfe_io_dsv.hpp

Referenced by dfe::io_dsv_impl::NamedTupleDsvReader< Delimiter, NamedTuple >::parse_element().


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