NEML2 1.4.0
Loading...
Searching...
No Matches
Sequence< T > Class Template Reference

A lazily parsed sequence of data. More...

Detailed Description

template<typename T>
class neml2::Sequence< T >

A lazily parsed sequence of data.

This class is primarily designed to help parse CSV files, similar to neml2::CrossRef. Upon constuction, this object holds a single string without any further parser. The string can be parsed in one of two ways:

  1. As a space delimited vector of data of type
    Template Parameters
    T.In this mode, the string is simply parsed using utils::parse<std::vector<T>>.
  2. As a column in a csv file. In this mode, the string must conform to the schema "path/to/filename.csv:<column-name|[column-index]>", where the part before the colon represents the CSV file path, and the part after the colon represents the column identifier. The column identifier can either be the column name or the column index. The column index should be enclosed by square brackets.

One apparent caveat is that if the underlying string is not space delimited and has the pattern "*.csv:*", it cannot be parsed into a std::vector<std::string>.

Template Parameters
T

#include <Sequence.h>

Public Member Functions

 Sequence ()=default
 
Sequence< T > & operator= (const std::string &other)
 Assignment operator.
 
 operator std::vector< T > () const
 Implicit conversion operator.
 
std::vector< T > vec () const
 Convert to a vector.
 
bool operator== (const Sequence< T > &other) const
 Test equality.
 
const std::string & raw () const
 Get the raw string literal.
 

Friends

std::stringstream & operator>> (std::stringstream &in, Sequence< T > &)
 

Constructor & Destructor Documentation

◆ Sequence()

template<typename T >
Sequence ( )
default

Member Function Documentation

◆ operator std::vector< T >()

template<typename T >
operator std::vector< T > ( ) const

Implicit conversion operator.

◆ operator=()

template<typename T >
Sequence< T > & operator= ( const std::string & other)

Assignment operator.

This simply assigns the string without further parsing

◆ operator==()

template<typename T >
bool operator== ( const Sequence< T > & other) const
inline

Test equality.

◆ raw()

template<typename T >
const std::string & raw ( ) const
inline

Get the raw string literal.

◆ vec()

template<typename T >
std::vector< T > vec ( ) const

Convert to a vector.

Friends And Related Symbol Documentation

◆ operator>>

template<typename T >
std::stringstream & operator>> ( std::stringstream & in,
Sequence< T > & seq )
friend